From 50ffe587e08aebe69879f2e5b67ba1304ff781b3 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 6 Sep 2015 18:46:46 +0000 Subject: [PATCH] Import libc++ 3.7.0 release (r246257). --- .arcconfig | 4 + .gitignore | 54 + CMakeLists.txt | 345 + CREDITS.TXT | 11 + LICENSE.TXT | 2 +- Makefile | 56 + TODO.TXT | 49 + cmake/Modules/CodeCoverage.cmake | 36 + cmake/Modules/HandleLibCXXABI.cmake | 103 + .../Modules/MacroEnsureOutOfSourceBuild.cmake | 18 + cmake/config-ix.cmake | 35 + include/CMakeLists.txt | 24 + include/__bit_reference | 1 - include/__config | 143 +- include/__debug | 2 +- include/__functional_03 | 86 +- include/__functional_base | 24 +- include/__functional_base_03 | 57 + include/__hash_table | 140 +- include/__locale | 40 +- include/__refstring | 4 +- include/__split_buffer | 21 +- include/__sso_allocator | 2 + include/__tree | 124 +- include/__tuple | 90 +- include/__undef___deallocate | 18 + include/algorithm | 174 +- include/array | 11 - include/atomic | 55 +- include/cctype | 1 + include/cinttypes | 2 + include/clocale | 2 + include/cmath | 18 +- include/cstdio | 59 +- include/cstdlib | 8 + include/cstring | 2 + include/ctime | 2 + include/cwchar | 20 +- include/deque | 146 +- include/exception | 6 +- include/experimental/__config | 8 + include/experimental/algorithm | 114 + include/experimental/chrono | 59 + include/experimental/dynarray | 2 + include/experimental/ratio | 77 + include/experimental/string_view | 9 +- include/experimental/system_error | 63 + include/experimental/tuple | 81 + include/experimental/type_traits | 8 +- include/experimental/utility | 7 +- include/ext/hash_map | 31 +- include/forward_list | 66 +- include/fstream | 32 +- include/functional | 118 +- include/future | 28 +- include/iosfwd | 5 + include/iostream | 10 +- include/iterator | 36 +- include/list | 65 +- include/locale | 65 +- include/map | 231 +- include/memory | 227 +- include/module.modulemap | 1 + include/mutex | 57 +- include/new | 12 + include/ostream | 4 +- include/queue | 4 +- include/random | 8 +- include/ratio | 35 +- include/regex | 24 +- include/scoped_allocator | 22 + include/set | 2 + include/shared_mutex | 112 +- include/stack | 4 +- include/stdexcept | 2 +- include/streambuf | 21 +- include/string | 79 +- include/support/android/locale_bionic.h | 31 + include/support/ibm/limits.h | 99 + include/support/ibm/support.h | 54 + include/support/ibm/xlocale.h | 326 + include/support/newlib/xlocale.h | 63 + include/support/solaris/floatingpoint.h | 14 + include/support/solaris/wchar.h | 47 + include/support/solaris/xlocale.h | 67 + include/support/win32/limits_win32.h | 79 + include/support/win32/locale_win32.h | 129 + include/support/win32/math_win32.h | 117 + include/support/win32/support.h | 206 + include/support/xlocale/xlocale.h | 194 + include/tuple | 20 +- include/type_traits | 163 +- include/unordered_map | 215 +- include/unordered_set | 18 +- include/utility | 23 +- include/valarray | 1 + include/vector | 185 +- lib/CMakeLists.txt | 131 + lib/buildit | 179 + lib/libc++abi.exp | 159 + lib/libc++abi2.exp | 310 + lib/libc++sjlj-abi.exp | 159 + lib/libc++unexp.exp | 19 + lib/notweak.exp | 5 + lib/weak.exp | 16 + src/chrono.cpp | 66 +- src/config_elast.h | 36 + src/debug.cpp | 2 +- src/exception.cpp | 32 +- src/future.cpp | 5 - src/ios.cpp | 14 +- src/iostream.cpp | 74 +- src/locale.cpp | 206 +- src/memory.cpp | 17 +- src/mutex.cpp | 10 +- src/new.cpp | 16 +- src/random.cpp | 112 +- src/shared_mutex.cpp | 25 +- src/string.cpp | 2 +- src/support/atomic_support.h | 142 + src/support/solaris/README | 4 + src/support/solaris/mbsnrtowcs.inc | 76 + src/support/solaris/wcsnrtombs.inc | 93 + src/support/solaris/xlocale.c | 66 + src/support/win32/locale_win32.cpp | 105 + src/support/win32/support.cpp | 166 + src/system_error.cpp | 9 +- src/thread.cpp | 4 +- test/CMakeLists.txt | 89 + test/libcxx/__init__.py | 0 test/libcxx/compiler.py | 152 + .../unord/unord.set/insert_dup_alloc.pass.cpp | 48 + test/libcxx/double_include.sh.cpp | 114 + .../header.algorithm.synop/includes.pass.cpp | 20 + .../experimental/algorithms/version.pass.cpp | 20 + .../dynarray/dynarray.cons/alloc.pass.cpp | 86 + .../dynarray/dynarray.cons/default.pass.cpp | 95 + .../dynarray/dynarray.data/default.pass.cpp | 67 + .../dynarray/dynarray.mutate/default.pass.cpp | 48 + .../dynarray/dynarray.overview/at.pass.cpp | 94 + .../dynarray.overview/begin_end.pass.cpp | 108 + .../dynarray.overview/capacity.pass.cpp | 57 + .../dynarray.overview/front_back.pass.cpp | 68 + .../dynarray.overview/indexing.pass.cpp | 71 + .../dynarray/dynarray.traits/default.pass.cpp | 32 +- .../dynarray/dynarray.zero/default.pass.cpp | 50 + .../sequences/dynarray/nothing_to_do.pass.cpp | 12 + .../header.ratio.synop/includes.pass.cpp | 24 + .../utilities/ratio/version.pass.cpp | 20 + .../includes.pass.cpp | 22 + .../utilities/syserror/version.pass.cpp | 20 + .../header.chrono.synop/includes.pass.cpp | 22 + .../utilities/time/version.pass.cpp | 20 + .../header.tuple.synop/includes.pass.cpp | 21 + .../utilities/tuple/version.pass.cpp | 20 + test/libcxx/selftest/not_test.sh.cpp | 17 + test/libcxx/selftest/test.fail.cpp | 11 + test/libcxx/selftest/test.pass.cpp | 13 + test/libcxx/selftest/test.sh.cpp | 16 + test/libcxx/selftest/test_macros.pass.cpp | 58 + test/libcxx/test/__init__.py | 0 test/libcxx/test/config.py | 709 + test/libcxx/test/executor.py | 191 + test/libcxx/test/format.py | 163 + test/libcxx/test/target_info.py | 55 + test/libcxx/test/tracing.py | 34 + .../type_traits/convert_to_integral.pass.cpp | 94 + test/libcxx/util.py | 46 + .../util.smartptr/race_condition.pass.cpp | 94 + test/lit.cfg | 51 + test/lit.site.cfg.in | 30 + test/nothing_to_do.pass.cpp | 13 + .../alg.c.library/tested_elsewhere.pass.cpp | 12 + .../alg.copy/copy.pass.cpp | 73 + .../alg.copy/copy_backward.pass.cpp | 51 + .../alg.copy/copy_if.pass.cpp | 80 + .../alg.copy/copy_n.pass.cpp | 76 + .../alg.fill/fill.pass.cpp | 59 + .../alg.fill/fill_n.pass.cpp | 156 + .../alg.generate/generate.pass.cpp | 47 + .../alg.generate/generate_n.pass.cpp | 50 + .../alg.move/move.pass.cpp | 134 + .../alg.move/move_backward.pass.cpp | 88 + .../alg.partitions/is_partitioned.pass.cpp | 77 + .../alg.partitions/partition.pass.cpp | 104 + .../alg.partitions/partition_copy.pass.cpp | 50 + .../alg.partitions/partition_point.pass.cpp | 76 + .../alg.partitions/stable_partition.pass.cpp | 314 + .../random_shuffle.pass.cpp | 30 + .../random_shuffle_rand.pass.cpp | 37 + .../random_shuffle_urng.pass.cpp | 31 + .../alg.remove/remove.pass.cpp | 83 + .../alg.remove/remove_copy.pass.cpp | 70 + .../alg.remove/remove_copy_if.pass.cpp | 73 + .../alg.remove/remove_if.pass.cpp | 98 + .../alg.replace/replace.pass.cpp | 44 + .../alg.replace/replace_copy.pass.cpp | 72 + .../alg.replace/replace_copy_if.pass.cpp | 74 + .../alg.replace/replace_if.pass.cpp | 45 + .../alg.reverse/reverse.pass.cpp | 60 + .../alg.reverse/reverse_copy.pass.cpp | 81 + .../alg.rotate/rotate.pass.cpp | 439 + .../alg.rotate/rotate_copy.pass.cpp | 134 + .../alg.swap/iter_swap.pass.cpp | 27 + .../alg.swap/swap_ranges.pass.cpp | 159 + .../alg.transform/binary_transform.pass.cpp | 217 + .../alg.transform/unary_transform.pass.cpp | 77 + .../alg.unique/unique.pass.cpp | 189 + .../alg.unique/unique_copy.pass.cpp | 125 + .../alg.unique/unique_copy_pred.pass.cpp | 152 + .../alg.unique/unique_pred.pass.cpp | 231 + .../nothing_to_do.pass.cpp | 12 + .../alg.adjacent.find/adjacent_find.pass.cpp | 35 + .../adjacent_find_pred.pass.cpp | 39 + .../alg.all_of/all_of.pass.cpp | 47 + .../alg.any_of/any_of.pass.cpp | 55 + .../alg.nonmodifying/alg.count/count.pass.cpp | 32 + .../alg.count/count_if.pass.cpp | 36 + .../alg.nonmodifying/alg.equal/equal.pass.cpp | 66 + .../alg.equal/equal_pred.pass.cpp | 87 + .../alg.find.end/find_end.pass.cpp | 57 + .../alg.find.end/find_end_pred.pass.cpp | 86 + .../alg.find.first.of/find_first_of.pass.cpp | 49 + .../find_first_of_pred.pass.cpp | 55 + .../alg.nonmodifying/alg.find/find.pass.cpp | 31 + .../alg.find/find_if.pass.cpp | 35 + .../alg.find/find_if_not.pass.cpp | 35 + .../alg.foreach/test.pass.cpp | 39 + .../is_permutation.pass.cpp | 605 + .../is_permutation_pred.pass.cpp | 729 + .../alg.none_of/none_of.pass.cpp | 55 + .../alg.search/search.pass.cpp | 72 + .../alg.search/search_n.pass.cpp | 77 + .../alg.search/search_n_pred.pass.cpp | 154 + .../alg.search/search_pred.pass.cpp | 111 + .../mismatch/mismatch.pass.cpp | 53 + .../mismatch/mismatch_pred.pass.cpp | 71 + .../alg.nonmodifying/nothing_to_do.pass.cpp | 12 + .../binary.search/binary_search.pass.cpp | 63 + .../binary.search/binary_search_comp.pass.cpp | 64 + .../equal.range/equal_range.pass.cpp | 69 + .../equal.range/equal_range_comp.pass.cpp | 70 + .../lower.bound/lower_bound.pass.cpp | 64 + .../lower.bound/lower_bound_comp.pass.cpp | 65 + .../alg.binary.search/nothing_to_do.pass.cpp | 12 + .../upper.bound/upper_bound.pass.cpp | 64 + .../upper.bound/upper_bound_comp.pass.cpp | 65 + .../is.heap/is_heap.pass.cpp | 521 + .../is.heap/is_heap_comp.pass.cpp | 522 + .../is.heap/is_heap_until.pass.cpp | 521 + .../is.heap/is_heap_until_comp.pass.cpp | 522 + .../make.heap/make_heap.pass.cpp | 39 + .../make.heap/make_heap_comp.pass.cpp | 101 + .../nothing_to_do.pass.cpp | 12 + .../pop.heap/pop_heap.pass.cpp | 39 + .../pop.heap/pop_heap_comp.pass.cpp | 68 + .../push.heap/push_heap.pass.cpp | 38 + .../push.heap/push_heap_comp.pass.cpp | 66 + .../sort.heap/sort_heap.pass.cpp | 40 + .../sort.heap/sort_heap_comp.pass.cpp | 66 + .../lexicographical_compare.pass.cpp | 69 + .../lexicographical_compare_comp.pass.cpp | 73 + .../alg.merge/inplace_merge.pass.cpp | 108 + .../alg.merge/inplace_merge_comp.pass.cpp | 146 + .../alg.sorting/alg.merge/merge.pass.cpp | 224 + .../alg.sorting/alg.merge/merge_comp.pass.cpp | 234 + .../alg.sorting/alg.min.max/max.pass.cpp | 54 + .../alg.sorting/alg.min.max/max_comp.pass.cpp | 56 + .../alg.min.max/max_element.pass.cpp | 80 + .../alg.min.max/max_element_comp.pass.cpp | 100 + .../alg.min.max/max_init_list.pass.cpp | 42 + .../alg.min.max/max_init_list_comp.pass.cpp | 43 + .../alg.sorting/alg.min.max/min.pass.cpp | 54 + .../alg.sorting/alg.min.max/min_comp.pass.cpp | 56 + .../alg.min.max/min_element.pass.cpp | 80 + .../alg.min.max/min_element_comp.pass.cpp | 100 + .../alg.min.max/min_init_list.pass.cpp | 42 + .../alg.min.max/min_init_list_comp.pass.cpp | 43 + .../alg.sorting/alg.min.max/minmax.pass.cpp | 62 + .../alg.min.max/minmax_comp.pass.cpp | 65 + .../alg.min.max/minmax_element.pass.cpp | 98 + .../alg.min.max/minmax_element_comp.pass.cpp | 104 + .../alg.min.max/minmax_init_list.pass.cpp | 39 + .../minmax_init_list_comp.pass.cpp | 77 + .../alg.nth.element/nth_element.pass.cpp | 63 + .../alg.nth.element/nth_element_comp.pass.cpp | 86 + .../next_permutation.pass.cpp | 66 + .../next_permutation_comp.pass.cpp | 68 + .../prev_permutation.pass.cpp | 66 + .../prev_permutation_comp.pass.cpp | 68 + .../includes/includes.pass.cpp | 84 + .../includes/includes_comp.pass.cpp | 85 + .../alg.set.operations/nothing_to_do.pass.cpp | 12 + .../set.difference/set_difference.pass.cpp | 200 + .../set_difference_comp.pass.cpp | 202 + .../set_intersection.pass.cpp | 198 + .../set_intersection_comp.pass.cpp | 200 + .../set_symmetric_difference.pass.cpp | 199 + .../set_symmetric_difference_comp.pass.cpp | 203 + .../set.union/set_union.pass.cpp | 198 + .../set.union/set_union_comp.pass.cpp | 200 + .../alg.sort/is.sorted/is_sorted.pass.cpp | 183 + .../is.sorted/is_sorted_comp.pass.cpp | 184 + .../is.sorted/is_sorted_until.pass.cpp | 183 + .../is.sorted/is_sorted_until_comp.pass.cpp | 184 + .../alg.sort/nothing_to_do.pass.cpp | 12 + .../partial_sort_copy.pass.cpp | 86 + .../partial_sort_copy_comp.pass.cpp | 90 + .../partial.sort/partial_sort.pass.cpp | 63 + .../partial.sort/partial_sort_comp.pass.cpp | 87 + .../alg.sorting/alg.sort/sort/sort.pass.cpp | 150 + .../alg.sort/sort/sort_comp.pass.cpp | 57 + .../alg.sort/stable.sort/stable_sort.pass.cpp | 150 + .../stable.sort/stable_sort_comp.pass.cpp | 83 + .../alg.sorting/nothing_to_do.pass.cpp | 12 + .../algorithms.general/nothing_to_do.pass.cpp | 12 + test/std/algorithms/version.pass.cpp | 20 + .../atomic_signal_fence.pass.cpp | 21 + .../atomic_thread_fence.pass.cpp | 21 + .../atomics.flag/atomic_flag_clear.pass.cpp | 36 + .../atomic_flag_clear_explicit.pass.cpp | 60 + .../atomic_flag_test_and_set.pass.cpp | 36 + ...atomic_flag_test_and_set_explicit.pass.cpp | 96 + test/std/atomics/atomics.flag/clear.pass.cpp | 72 + .../atomics/atomics.flag/copy_assign.fail.cpp | 24 + .../atomics/atomics.flag/copy_ctor.fail.cpp | 23 + .../copy_volatile_assign.fail.cpp | 24 + .../std/atomics/atomics.flag/default.pass.cpp | 33 + test/std/atomics/atomics.flag/init.pass.cpp | 25 + .../atomics.flag/test_and_set.pass.cpp | 108 + .../atomics.general/nothing_to_do.pass.cpp | 13 + .../replace_failure_order.pass.cpp | 43 + .../atomics.lockfree/lockfree.pass.cpp | 52 + .../atomics.order/kill_dependency.pass.cpp | 23 + .../atomics.order/memory_order.pass.cpp | 33 + .../atomics.syn/nothing_to_do.pass.cpp | 13 + .../atomics.types.generic/address.pass.cpp | 140 + .../atomics.types.generic/bool.pass.cpp | 237 + .../cstdint_typedefs.pass.cpp | 69 + .../atomics.types.generic/integral.pass.cpp | 203 + .../integral_typedefs.pass.cpp | 50 + .../trivially_copyable.fail.cpp | 70 + .../trivially_copyable.pass.cpp | 77 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../atomic_compare_exchange_strong.pass.cpp | 88 + ..._compare_exchange_strong_explicit.pass.cpp | 95 + .../atomic_compare_exchange_weak.pass.cpp | 90 + ...ic_compare_exchange_weak_explicit.pass.cpp | 97 + .../atomic_exchange.pass.cpp | 73 + .../atomic_exchange_explicit.pass.cpp | 75 + .../atomic_fetch_add.pass.cpp | 111 + .../atomic_fetch_add_explicit.pass.cpp | 115 + .../atomic_fetch_and.pass.cpp | 64 + .../atomic_fetch_and_explicit.pass.cpp | 66 + .../atomic_fetch_or.pass.cpp | 64 + .../atomic_fetch_or_explicit.pass.cpp | 66 + .../atomic_fetch_sub.pass.cpp | 111 + .../atomic_fetch_sub_explicit.pass.cpp | 116 + .../atomic_fetch_xor.pass.cpp | 64 + .../atomic_fetch_xor_explicit.pass.cpp | 66 + .../atomic_init.pass.cpp | 71 + .../atomic_is_lock_free.pass.cpp | 61 + .../atomic_load.pass.cpp | 71 + .../atomic_load_explicit.pass.cpp | 71 + .../atomic_store.pass.cpp | 71 + .../atomic_store_explicit.pass.cpp | 71 + .../atomic_var_init.pass.cpp | 24 + .../ctor.pass.cpp | 56 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../atomics/libcpp-has-no-threads.fail.cpp | 23 + .../atomics/libcpp-has-no-threads.pass.cpp | 18 + test/std/atomics/version.pass.cpp | 22 + test/std/containers/Copyable.h | 18 + test/std/containers/Emplaceable.h | 54 + test/std/containers/NotConstructible.h | 39 + .../associative/map/compare.pass.cpp | 32 + .../associative/map/map.access/at.pass.cpp | 154 + .../associative/map/map.access/empty.pass.cpp | 43 + .../map/map.access/index_key.pass.cpp | 105 + .../map/map.access/index_rv_key.pass.cpp | 58 + .../map/map.access/index_tuple.pass.cpp | 33 + .../map/map.access/iterator.pass.cpp | 227 + .../map/map.access/max_size.pass.cpp | 35 + .../associative/map/map.access/size.pass.cpp | 59 + .../associative/map/map.cons/alloc.pass.cpp | 42 + .../map.cons/assign_initializer_list.pass.cpp | 75 + .../associative/map/map.cons/compare.pass.cpp | 40 + .../map/map.cons/compare_alloc.pass.cpp | 45 + .../associative/map/map.cons/copy.pass.cpp | 131 + .../map/map.cons/copy_alloc.pass.cpp | 95 + .../map/map.cons/copy_assign.pass.cpp | 182 + .../associative/map/map.cons/default.pass.cpp | 40 + .../map/map.cons/default_noexcept.pass.cpp | 53 + .../map/map.cons/default_recursive.pass.cpp | 29 + .../map/map.cons/dtor_noexcept.pass.cpp | 51 + .../map/map.cons/initializer_list.pass.cpp | 67 + .../initializer_list_compare.pass.cpp | 69 + .../initializer_list_compare_alloc.pass.cpp | 100 + .../map/map.cons/iter_iter.pass.cpp | 68 + .../map/map.cons/iter_iter_comp.pass.cpp | 73 + .../map.cons/iter_iter_comp_alloc.pass.cpp | 108 + .../associative/map/map.cons/move.pass.cpp | 120 + .../map/map.cons/move_alloc.pass.cpp | 234 + .../map/map.cons/move_assign.pass.cpp | 190 + .../map.cons/move_assign_noexcept.pass.cpp | 53 + .../map/map.cons/move_noexcept.pass.cpp | 51 + .../map/map.modifiers/clear.pass.cpp | 63 + .../map/map.modifiers/emplace.pass.cpp | 165 + .../map/map.modifiers/emplace_hint.pass.cpp | 160 + .../map/map.modifiers/erase_iter.pass.cpp | 259 + .../map.modifiers/erase_iter_iter.pass.cpp | 157 + .../map/map.modifiers/erase_key.pass.cpp | 275 + .../map/map.modifiers/insert_cv.pass.cpp | 89 + .../insert_initializer_list.pass.cpp | 71 + .../map/map.modifiers/insert_iter_cv.pass.cpp | 81 + .../map.modifiers/insert_iter_iter.pass.cpp | 77 + .../map/map.modifiers/insert_iter_rv.pass.cpp | 87 + .../map.modifiers/insert_or_assign.pass.cpp | 192 + .../map/map.modifiers/insert_rv.pass.cpp | 93 + .../map/map.modifiers/try.emplace.pass.cpp | 189 + .../associative/map/map.ops/count.pass.cpp | 193 + .../associative/map/map.ops/count0.pass.cpp | 34 + .../associative/map/map.ops/count1.fail.cpp | 39 + .../associative/map/map.ops/count2.fail.cpp | 39 + .../associative/map/map.ops/count3.fail.cpp | 39 + .../map/map.ops/equal_range.pass.cpp | 490 + .../map/map.ops/equal_range0.pass.cpp | 34 + .../map/map.ops/equal_range1.fail.cpp | 39 + .../map/map.ops/equal_range2.fail.cpp | 39 + .../map/map.ops/equal_range3.fail.cpp | 39 + .../associative/map/map.ops/find.pass.cpp | 260 + .../associative/map/map.ops/find0.pass.cpp | 34 + .../associative/map/map.ops/find1.fail.cpp | 39 + .../associative/map/map.ops/find2.fail.cpp | 39 + .../associative/map/map.ops/find3.fail.cpp | 39 + .../map/map.ops/lower_bound.pass.cpp | 372 + .../map/map.ops/lower_bound0.pass.cpp | 34 + .../map/map.ops/lower_bound1.fail.cpp | 39 + .../map/map.ops/lower_bound2.fail.cpp | 39 + .../map/map.ops/lower_bound3.fail.cpp | 39 + .../map/map.ops/upper_bound.pass.cpp | 335 + .../map/map.ops/upper_bound0.pass.cpp | 34 + .../map/map.ops/upper_bound1.fail.cpp | 39 + .../map/map.ops/upper_bound2.fail.cpp | 39 + .../map/map.ops/upper_bound3.fail.cpp | 39 + .../map/map.special/member_swap.pass.cpp | 176 + .../map/map.special/non_member_swap.pass.cpp | 281 + .../map/map.special/swap_noexcept.pass.cpp | 148 + .../containers/associative/map/types.pass.cpp | 70 + .../associative/map/version.pass.cpp | 20 + .../associative/multimap/empty.pass.cpp | 43 + .../associative/multimap/iterator.pass.cpp | 231 + .../associative/multimap/max_size.pass.cpp | 35 + .../multimap/multimap.cons/alloc.pass.cpp | 42 + .../assign_initializer_list.pass.cpp | 85 + .../multimap/multimap.cons/compare.pass.cpp | 40 + .../multimap.cons/compare_alloc.pass.cpp | 45 + .../multimap/multimap.cons/copy.pass.cpp | 104 + .../multimap.cons/copy_alloc.pass.cpp | 77 + .../multimap.cons/copy_assign.pass.cpp | 125 + .../multimap/multimap.cons/default.pass.cpp | 40 + .../multimap.cons/default_noexcept.pass.cpp | 53 + .../multimap.cons/default_recursive.pass.cpp | 29 + .../multimap.cons/dtor_noexcept.pass.cpp | 51 + .../multimap.cons/initializer_list.pass.cpp | 83 + .../initializer_list_compare.pass.cpp | 91 + .../initializer_list_compare_alloc.pass.cpp | 129 + .../multimap/multimap.cons/iter_iter.pass.cpp | 112 + .../multimap.cons/iter_iter_comp.pass.cpp | 86 + .../iter_iter_comp_alloc.pass.cpp | 91 + .../multimap/multimap.cons/move.pass.cpp | 132 + .../multimap.cons/move_alloc.pass.cpp | 234 + .../multimap.cons/move_assign.pass.cpp | 190 + .../move_assign_noexcept.pass.cpp | 53 + .../multimap.cons/move_noexcept.pass.cpp | 51 + .../multimap.modifiers/clear.pass.cpp | 63 + .../multimap.modifiers/emplace.pass.cpp | 150 + .../multimap.modifiers/emplace_hint.pass.cpp | 160 + .../multimap.modifiers/erase_iter.pass.cpp | 301 + .../erase_iter_iter.pass.cpp | 157 + .../multimap.modifiers/erase_key.pass.cpp | 153 + .../multimap.modifiers/insert_cv.pass.cpp | 81 + .../insert_initializer_list.pass.cpp | 91 + .../insert_iter_cv.pass.cpp | 81 + .../insert_iter_iter.pass.cpp | 101 + .../insert_iter_rv.pass.cpp | 87 + .../multimap.modifiers/insert_rv.pass.cpp | 85 + .../multimap/multimap.ops/count.pass.cpp | 175 + .../multimap/multimap.ops/count0.pass.cpp | 34 + .../multimap/multimap.ops/count1.fail.cpp | 37 + .../multimap/multimap.ops/count2.fail.cpp | 37 + .../multimap/multimap.ops/count3.fail.cpp | 37 + .../multimap.ops/equal_range.pass.cpp | 287 + .../multimap.ops/equal_range0.pass.cpp | 34 + .../multimap.ops/equal_range1.fail.cpp | 37 + .../multimap.ops/equal_range2.fail.cpp | 39 + .../multimap.ops/equal_range3.fail.cpp | 39 + .../multimap/multimap.ops/find.pass.cpp | 223 + .../multimap/multimap.ops/find0.pass.cpp | 34 + .../multimap/multimap.ops/find1.fail.cpp | 39 + .../multimap/multimap.ops/find2.fail.cpp | 39 + .../multimap/multimap.ops/find3.fail.cpp | 39 + .../multimap.ops/lower_bound.pass.cpp | 237 + .../multimap.ops/lower_bound0.pass.cpp | 34 + .../multimap.ops/lower_bound1.fail.cpp | 39 + .../multimap.ops/lower_bound2.fail.cpp | 39 + .../multimap.ops/lower_bound3.fail.cpp | 39 + .../multimap.ops/upper_bound.pass.cpp | 236 + .../multimap.ops/upper_bound0.pass.cpp | 34 + .../multimap.ops/upper_bound1.fail.cpp | 39 + .../multimap.ops/upper_bound2.fail.cpp | 39 + .../multimap.ops/upper_bound3.fail.cpp | 39 + .../multimap.special/member_swap.pass.cpp | 176 + .../multimap.special/non_member_swap.pass.cpp | 281 + .../multimap.special/swap_noexcept.pass.cpp | 148 + .../associative/multimap/scary.pass.cpp | 24 + .../associative/multimap/size.pass.cpp | 59 + .../associative/multimap/types.pass.cpp | 70 + .../associative/multiset/clear.pass.cpp | 63 + .../associative/multiset/count.pass.cpp | 160 + .../associative/multiset/emplace.pass.cpp | 83 + .../multiset/emplace_hint.pass.cpp | 83 + .../associative/multiset/empty.pass.cpp | 43 + .../associative/multiset/equal_range.pass.cpp | 263 + .../associative/multiset/erase_iter.pass.cpp | 203 + .../multiset/erase_iter_iter.pass.cpp | 141 + .../associative/multiset/erase_key.pass.cpp | 129 + .../associative/multiset/find.pass.cpp | 240 + .../associative/multiset/insert_cv.pass.cpp | 73 + .../multiset/insert_initializer_list.pass.cpp | 61 + .../multiset/insert_iter_cv.pass.cpp | 73 + .../multiset/insert_iter_iter.pass.cpp | 85 + .../multiset/insert_iter_rv.pass.cpp | 76 + .../associative/multiset/insert_rv.pass.cpp | 76 + .../associative/multiset/iterator.pass.cpp | 215 + .../associative/multiset/lower_bound.pass.cpp | 223 + .../associative/multiset/max_size.pass.cpp | 35 + .../multiset/multiset.cons/alloc.pass.cpp | 29 + .../assign_initializer_list.pass.cpp | 57 + .../multiset/multiset.cons/compare.pass.cpp | 28 + .../multiset.cons/compare_alloc.pass.cpp | 31 + .../multiset/multiset.cons/copy.pass.cpp | 118 + .../multiset.cons/copy_alloc.pass.cpp | 68 + .../multiset.cons/copy_assign.pass.cpp | 138 + .../multiset/multiset.cons/default.pass.cpp | 40 + .../multiset.cons/default_noexcept.pass.cpp | 53 + .../multiset.cons/dtor_noexcept.pass.cpp | 51 + .../multiset.cons/initializer_list.pass.cpp | 73 + .../initializer_list_compare.pass.cpp | 38 + .../initializer_list_compare_alloc.pass.cpp | 41 + .../multiset/multiset.cons/iter_iter.pass.cpp | 83 + .../multiset.cons/iter_iter_alloc.pass.cpp | 92 + .../multiset.cons/iter_iter_comp.pass.cpp | 53 + .../multiset/multiset.cons/move.pass.cpp | 119 + .../multiset.cons/move_alloc.pass.cpp | 187 + .../multiset.cons/move_assign.pass.cpp | 186 + .../move_assign_noexcept.pass.cpp | 53 + .../multiset.cons/move_noexcept.pass.cpp | 51 + .../multiset.special/member_swap.pass.cpp | 177 + .../multiset.special/non_member_swap.pass.cpp | 165 + .../multiset.special/swap_noexcept.pass.cpp | 148 + .../associative/multiset/scary.pass.cpp | 24 + .../associative/multiset/size.pass.cpp | 59 + .../associative/multiset/types.pass.cpp | 70 + .../associative/multiset/upper_bound.pass.cpp | 222 + .../containers/associative/set/clear.pass.cpp | 63 + .../containers/associative/set/count.pass.cpp | 168 + .../associative/set/emplace.pass.cpp | 90 + .../associative/set/emplace_hint.pass.cpp | 83 + .../containers/associative/set/empty.pass.cpp | 43 + .../associative/set/equal_range.pass.cpp | 370 + .../associative/set/erase_iter.pass.cpp | 203 + .../associative/set/erase_iter_iter.pass.cpp | 141 + .../associative/set/erase_key.pass.cpp | 203 + .../containers/associative/set/find.pass.cpp | 240 + .../associative/set/insert_cv.pass.cpp | 81 + .../set/insert_initializer_list.pass.cpp | 61 + .../associative/set/insert_iter_cv.pass.cpp | 73 + .../associative/set/insert_iter_iter.pass.cpp | 73 + .../associative/set/insert_iter_rv.pass.cpp | 76 + .../associative/set/insert_rv.pass.cpp | 84 + .../associative/set/iterator.pass.cpp | 211 + .../associative/set/lower_bound.pass.cpp | 337 + .../associative/set/max_size.pass.cpp | 35 + .../associative/set/set.cons/alloc.pass.cpp | 29 + .../set.cons/assign_initializer_list.pass.cpp | 57 + .../associative/set/set.cons/compare.pass.cpp | 28 + .../set/set.cons/compare_alloc.pass.cpp | 31 + .../associative/set/set.cons/copy.pass.cpp | 94 + .../set/set.cons/copy_alloc.pass.cpp | 56 + .../set/set.cons/copy_assign.pass.cpp | 109 + .../associative/set/set.cons/default.pass.cpp | 40 + .../set/set.cons/default_noexcept.pass.cpp | 53 + .../set/set.cons/dtor_noexcept.pass.cpp | 51 + .../set/set.cons/initializer_list.pass.cpp | 55 + .../initializer_list_compare.pass.cpp | 38 + .../initializer_list_compare_alloc.pass.cpp | 63 + .../set/set.cons/iter_iter.pass.cpp | 71 + .../set/set.cons/iter_iter_alloc.pass.cpp | 84 + .../set/set.cons/iter_iter_comp.pass.cpp | 47 + .../associative/set/set.cons/move.pass.cpp | 107 + .../set/set.cons/move_alloc.pass.cpp | 188 + .../set/set.cons/move_assign.pass.cpp | 186 + .../set.cons/move_assign_noexcept.pass.cpp | 53 + .../set/set.cons/move_noexcept.pass.cpp | 51 + .../set/set.special/member_swap.pass.cpp | 177 + .../set/set.special/non_member_swap.pass.cpp | 165 + .../set/set.special/swap_noexcept.pass.cpp | 148 + .../containers/associative/set/size.pass.cpp | 59 + .../containers/associative/set/types.pass.cpp | 70 + .../associative/set/upper_bound.pass.cpp | 336 + .../associative/set/version.pass.cpp | 20 + .../tree_balance_after_insert.pass.cpp | 1616 + .../associative/tree_left_rotate.pass.cpp | 98 + .../associative/tree_remove.pass.cpp | 1648 + .../associative/tree_right_rotate.pass.cpp | 98 + .../container.adaptors/nothing_to_do.pass.cpp | 12 + .../priqueue.cons.alloc/ctor_alloc.pass.cpp | 48 + .../ctor_comp_alloc.pass.cpp | 48 + .../ctor_comp_cont_alloc.pass.cpp | 62 + .../ctor_comp_rcont_alloc.pass.cpp | 61 + .../ctor_copy_alloc.pass.cpp | 58 + .../ctor_move_alloc.pass.cpp | 68 + .../priqueue.cons/assign_copy.pass.cpp | 36 + .../priqueue.cons/assign_move.pass.cpp | 42 + .../priqueue.cons/ctor_comp.pass.cpp | 27 + .../ctor_comp_container.pass.cpp | 34 + .../ctor_comp_rcontainer.pass.cpp | 40 + .../priqueue.cons/ctor_copy.pass.cpp | 35 + .../priqueue.cons/ctor_default.pass.cpp | 27 + .../priqueue.cons/ctor_iter_iter.pass.cpp | 25 + .../ctor_iter_iter_comp.pass.cpp | 27 + .../ctor_iter_iter_comp_cont.pass.cpp | 27 + .../ctor_iter_iter_comp_rcont.pass.cpp | 32 + .../priqueue.cons/ctor_move.pass.cpp | 41 + .../priqueue.cons/default_noexcept.pass.cpp | 31 + .../priqueue.cons/dtor_noexcept.pass.cpp | 27 + .../move_assign_noexcept.pass.cpp | 31 + .../priqueue.cons/move_noexcept.pass.cpp | 31 + .../priqueue.members/emplace.pass.cpp | 32 + .../priqueue.members/empty.pass.cpp | 27 + .../priqueue.members/pop.pass.cpp | 34 + .../priqueue.members/push.pass.cpp | 28 + .../priqueue.members/push_rvalue.pass.cpp | 32 + .../priqueue.members/size.pass.cpp | 27 + .../priqueue.members/swap.pass.cpp | 30 + .../priqueue.members/top.pass.cpp | 28 + .../priqueue.special/swap.pass.cpp | 32 + .../priqueue.special/swap_noexcept.pass.cpp | 32 + .../priority.queue/types.pass.cpp | 60 + .../queue.cons.alloc/ctor_alloc.pass.cpp | 38 + .../ctor_container_alloc.pass.cpp | 57 + .../ctor_queue_alloc.pass.cpp | 52 + .../ctor_rcontainer_alloc.pass.cpp | 59 + .../ctor_rqueue_alloc.pass.cpp | 60 + .../queue/queue.cons/ctor_container.pass.cpp | 37 + .../queue/queue.cons/ctor_copy.pass.cpp | 32 + .../queue/queue.cons/ctor_default.pass.cpp | 28 + .../queue/queue.cons/ctor_move.pass.cpp | 41 + .../queue/queue.cons/ctor_rcontainer.pass.cpp | 39 + .../queue.cons/default_noexcept.pass.cpp | 30 + .../queue/queue.cons/dtor_noexcept.pass.cpp | 27 + .../queue.cons/move_assign_noexcept.pass.cpp | 30 + .../queue/queue.cons/move_noexcept.pass.cpp | 30 + .../queue/queue.defn/assign_copy.pass.cpp | 33 + .../queue/queue.defn/assign_move.pass.cpp | 42 + .../queue/queue.defn/back.pass.cpp | 26 + .../queue/queue.defn/back_const.pass.cpp | 27 + .../queue/queue.defn/emplace.pass.cpp | 30 + .../queue/queue.defn/empty.pass.cpp | 25 + .../queue/queue.defn/front.pass.cpp | 26 + .../queue/queue.defn/front_const.pass.cpp | 27 + .../queue/queue.defn/pop.pass.cpp | 37 + .../queue/queue.defn/push.pass.cpp | 32 + .../queue/queue.defn/push_rv.pass.cpp | 36 + .../queue/queue.defn/size.pass.cpp | 23 + .../queue/queue.defn/swap.pass.cpp | 36 + .../queue/queue.defn/types.pass.cpp | 58 + .../queue/queue.ops/eq.pass.cpp | 40 + .../queue/queue.ops/lt.pass.cpp | 45 + .../queue/queue.special/swap.pass.cpp | 37 + .../queue.special/swap_noexcept.pass.cpp | 31 + .../container.adaptors/queue/version.pass.cpp | 20 + .../stack.cons.alloc/ctor_alloc.pass.cpp | 38 + .../ctor_container_alloc.pass.cpp | 57 + .../stack.cons.alloc/ctor_copy_alloc.pass.cpp | 52 + .../ctor_rcontainer_alloc.pass.cpp | 59 + .../ctor_rqueue_alloc.pass.cpp | 60 + .../stack/stack.cons/ctor_container.pass.cpp | 37 + .../stack/stack.cons/ctor_copy.pass.cpp | 32 + .../stack/stack.cons/ctor_default.pass.cpp | 28 + .../stack/stack.cons/ctor_move.pass.cpp | 41 + .../stack/stack.cons/ctor_rcontainer.pass.cpp | 39 + .../stack.cons/default_noexcept.pass.cpp | 30 + .../stack/stack.cons/dtor_noexcept.pass.cpp | 27 + .../stack.cons/move_assign_noexcept.pass.cpp | 30 + .../stack/stack.cons/move_noexcept.pass.cpp | 30 + .../stack/stack.defn/assign_copy.pass.cpp | 33 + .../stack/stack.defn/assign_move.pass.cpp | 42 + .../stack/stack.defn/emplace.pass.cpp | 29 + .../stack/stack.defn/empty.pass.cpp | 25 + .../stack/stack.defn/pop.pass.cpp | 34 + .../stack/stack.defn/push.pass.cpp | 29 + .../stack/stack.defn/push_rv.pass.cpp | 33 + .../stack/stack.defn/size.pass.cpp | 23 + .../stack/stack.defn/swap.pass.cpp | 36 + .../stack/stack.defn/top.pass.cpp | 26 + .../stack/stack.defn/top_const.pass.cpp | 27 + .../stack/stack.defn/types.pass.cpp | 59 + .../stack/stack.ops/eq.pass.cpp | 40 + .../stack/stack.ops/lt.pass.cpp | 45 + .../stack/stack.special/swap.pass.cpp | 37 + .../stack.special/swap_noexcept.pass.cpp | 31 + .../container.adaptors/stack/version.pass.cpp | 20 + .../nothing_to_do.pass.cpp | 12 + .../associative.reqmts/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../sequence.reqmts/nothing_to_do.pass.cpp | 12 + .../unord.req/nothing_to_do.pass.cpp | 12 + .../unord.req.except/nothing_to_do.pass.cpp | 12 + .../containers.general/nothing_to_do.pass.cpp | 12 + test/std/containers/nothing_to_do.pass.cpp | 12 + .../array/array.cons/default.pass.cpp | 31 + .../array.cons/initializer_list.pass.cpp | 34 + .../sequences/array/array.data/data.pass.cpp | 35 + .../array/array.data/data_const.pass.cpp | 35 + .../sequences/array/array.fill/fill.pass.cpp | 36 + .../sequences/array/array.size/size.pass.cpp | 53 + .../array/array.special/swap.pass.cpp | 43 + .../sequences/array/array.swap/swap.pass.cpp | 43 + .../sequences/array/array.tuple/get.fail.cpp | 25 + .../sequences/array/array.tuple/get.pass.cpp | 52 + .../array/array.tuple/get_const.pass.cpp | 37 + .../array/array.tuple/get_rv.pass.cpp | 30 + .../array/array.tuple/tuple_element.pass.cpp | 54 + .../array/array.tuple/tuple_size.pass.cpp | 42 + .../array.zero/tested_elsewhere.pass.cpp | 18 + .../containers/sequences/array/at.pass.cpp | 67 + .../containers/sequences/array/begin.pass.cpp | 32 + .../sequences/array/contiguous.pass.cpp | 31 + .../sequences/array/front_back.pass.cpp | 62 + .../sequences/array/indexing.pass.cpp | 60 + .../sequences/array/iterators.pass.cpp | 110 + .../containers/sequences/array/types.pass.cpp | 62 + .../sequences/array/version.pass.cpp | 20 + .../deque/deque.capacity/access.pass.cpp | 91 + .../deque/deque.capacity/resize_size.pass.cpp | 86 + .../deque.capacity/resize_size_value.pass.cpp | 86 + .../deque.capacity/shrink_to_fit.pass.cpp | 77 + .../sequences/deque/deque.cons/alloc.pass.cpp | 38 + .../assign_initializer_list.pass.cpp | 43 + .../deque.cons/assign_iter_iter.pass.cpp | 109 + .../deque.cons/assign_size_value.pass.cpp | 85 + .../sequences/deque/deque.cons/copy.pass.cpp | 61 + .../deque/deque.cons/copy_alloc.pass.cpp | 51 + .../deque/deque.cons/default.pass.cpp | 41 + .../deque.cons/default_noexcept.pass.cpp | 50 + .../deque/deque.cons/dtor_noexcept.pass.cpp | 52 + .../deque.cons/initializer_list.pass.cpp | 41 + .../initializer_list_alloc.pass.cpp | 44 + .../deque/deque.cons/iter_iter.pass.cpp | 62 + .../deque/deque.cons/iter_iter_alloc.pass.cpp | 51 + .../sequences/deque/deque.cons/move.pass.cpp | 72 + .../deque/deque.cons/move_alloc.pass.cpp | 87 + .../deque/deque.cons/move_assign.pass.cpp | 91 + .../deque.cons/move_assign_noexcept.pass.cpp | 52 + .../deque/deque.cons/move_noexcept.pass.cpp | 50 + .../deque/deque.cons/op_equal.pass.cpp | 63 + .../op_equal_initializer_list.pass.cpp | 43 + .../sequences/deque/deque.cons/size.pass.cpp | 113 + .../deque/deque.cons/size_value.pass.cpp | 51 + .../deque.cons/size_value_alloc.pass.cpp | 67 + .../deque/deque.modifiers/emplace.pass.cpp | 112 + .../deque.modifiers/emplace_back.pass.cpp | 87 + .../deque.modifiers/emplace_front.pass.cpp | 87 + .../erase_iter.invalidation.pass.cpp | 70 + .../deque/deque.modifiers/erase_iter.pass.cpp | 90 + .../erase_iter_iter.invalidation.pass.cpp | 78 + .../deque.modifiers/erase_iter_iter.pass.cpp | 96 + .../insert_iter_initializer_list.pass.cpp | 63 + .../deque.modifiers/insert_iter_iter.pass.cpp | 295 + .../deque.modifiers/insert_rvalue.pass.cpp | 118 + .../insert_size_value.pass.cpp | 159 + .../deque.modifiers/insert_value.pass.cpp | 139 + .../pop_back.invalidation.pass.cpp | 49 + .../deque/deque.modifiers/pop_back.pass.cpp | 84 + .../pop_front.invalidation.pass.cpp | 49 + .../deque/deque.modifiers/pop_front.pass.cpp | 84 + .../deque/deque.modifiers/push_back.pass.cpp | 73 + .../push_back_exception_safety.pass.cpp | 101 + .../deque.modifiers/push_back_rvalue.pass.cpp | 80 + .../deque/deque.modifiers/push_front.pass.cpp | 83 + .../push_front_exception_safety.pass.cpp | 101 + .../push_front_rvalue.pass.cpp | 90 + .../deque/deque.special/copy.pass.cpp | 88 + .../deque.special/copy_backward.pass.cpp | 87 + .../deque/deque.special/move.pass.cpp | 87 + .../deque.special/move_backward.pass.cpp | 87 + .../deque/deque.special/swap.pass.cpp | 110 + .../deque.special/swap_noexcept.pass.cpp | 90 + .../sequences/deque/iterators.pass.cpp | 79 + .../containers/sequences/deque/types.pass.cpp | 90 + .../sequences/deque/version.pass.cpp | 20 + .../forwardlist.access/front.pass.cpp | 61 + .../forwardlist.cons/alloc.fail.cpp | 30 + .../forwardlist.cons/alloc.pass.cpp | 41 + .../forwardlist.cons/assign_copy.pass.cpp | 146 + .../forwardlist.cons/assign_init.pass.cpp | 70 + .../forwardlist.cons/assign_move.pass.cpp | 199 + .../forwardlist.cons/assign_op_init.pass.cpp | 70 + .../forwardlist.cons/assign_range.pass.cpp | 78 + .../assign_size_value.pass.cpp | 68 + .../forwardlist.cons/copy.pass.cpp | 69 + .../forwardlist.cons/copy_alloc.pass.cpp | 67 + .../forwardlist.cons/default.pass.cpp | 41 + .../default_noexcept.pass.cpp | 50 + .../default_recursive.pass.cpp | 25 + .../forwardlist.cons/dtor_noexcept.pass.cpp | 52 + .../forwardlist.cons/init.pass.cpp | 43 + .../forwardlist.cons/init_alloc.pass.cpp | 48 + .../forwardlist.cons/move.pass.cpp | 73 + .../forwardlist.cons/move_alloc.pass.cpp | 73 + .../move_assign_noexcept.pass.cpp | 52 + .../forwardlist.cons/move_noexcept.pass.cpp | 50 + .../forwardlist.cons/range.pass.cpp | 48 + .../forwardlist.cons/range_alloc.pass.cpp | 54 + .../forwardlist.cons/size.fail.cpp | 35 + .../forwardlist.cons/size.pass.cpp | 66 + .../forwardlist.cons/size_value.pass.cpp | 45 + .../size_value_alloc.pass.cpp | 50 + .../forwardlist.iter/before_begin.pass.cpp | 104 + .../forwardlist.iter/iterators.pass.cpp | 145 + .../forwardlist.modifiers/clear.pass.cpp | 62 + .../emplace_after.pass.cpp | 89 + .../emplace_front.pass.cpp | 50 + .../erase_after_many.pass.cpp | 155 + .../erase_after_one.pass.cpp | 97 + .../insert_after_const.pass.cpp | 87 + .../insert_after_init.pass.cpp | 75 + .../insert_after_range.pass.cpp | 80 + .../insert_after_rv.pass.cpp | 90 + .../insert_after_size_value.pass.cpp | 73 + .../forwardlist.modifiers/pop_front.pass.cpp | 78 + .../push_front_const.pass.cpp | 47 + .../push_front_exception_safety.pass.cpp | 73 + .../push_front_rv.pass.cpp | 50 + .../resize_size.pass.cpp | 114 + .../resize_size_value.pass.cpp | 84 + .../forwardlist.ops/merge.pass.cpp | 48 + .../forwardlist.ops/merge_pred.pass.cpp | 49 + .../forwardlist.ops/remove.pass.cpp | 155 + .../forwardlist.ops/remove_if.pass.cpp | 155 + .../forwardlist.ops/reverse.pass.cpp | 42 + .../forwardlist/forwardlist.ops/sort.pass.cpp | 47 + .../forwardlist.ops/sort_pred.pass.cpp | 48 + .../splice_after_flist.pass.cpp | 75 + .../forwardlist.ops/splice_after_one.pass.cpp | 140 + .../splice_after_range.pass.cpp | 169 + .../forwardlist.ops/unique.pass.cpp | 120 + .../forwardlist.ops/unique_pred.pass.cpp | 125 + .../forwardlist.spec/equal.pass.cpp | 60 + .../forwardlist.spec/member_swap.pass.cpp | 259 + .../forwardlist.spec/non_member_swap.pass.cpp | 260 + .../forwardlist.spec/relational.pass.cpp | 65 + .../forwardlist.spec/swap_noexcept.pass.cpp | 90 + .../sequences/forwardlist/max_size.pass.cpp | 35 + .../sequences/forwardlist/types.pass.cpp | 62 + .../sequences/forwardlist/version.pass.cpp | 20 + .../sequences/list/db_back.pass.cpp | 56 + .../sequences/list/db_cback.pass.cpp | 52 + .../sequences/list/db_cfront.pass.cpp | 52 + .../sequences/list/db_front.pass.cpp | 56 + .../sequences/list/db_iterators_6.pass.cpp | 58 + .../sequences/list/db_iterators_7.pass.cpp | 58 + .../sequences/list/db_iterators_8.pass.cpp | 54 + .../sequences/list/db_iterators_9.pass.cpp | 67 + .../sequences/list/iterators.pass.cpp | 159 + .../list/list.capacity/resize_size.pass.cpp | 81 + .../list.capacity/resize_size_value.pass.cpp | 53 + .../list/list.cons/assign_copy.pass.cpp | 44 + .../assign_initializer_list.pass.cpp | 45 + .../list/list.cons/assign_move.pass.cpp | 82 + .../sequences/list/list.cons/copy.pass.cpp | 54 + .../list/list.cons/copy_alloc.pass.cpp | 42 + .../sequences/list/list.cons/default.pass.cpp | 58 + .../list/list.cons/default_noexcept.pass.cpp | 50 + .../list.cons/default_stack_alloc.pass.cpp | 48 + .../list/list.cons/dtor_noexcept.pass.cpp | 52 + .../list/list.cons/initializer_list.pass.cpp | 43 + .../list.cons/initializer_list_alloc.pass.cpp | 46 + .../list/list.cons/input_iterator.pass.cpp | 77 + .../sequences/list/list.cons/move.pass.cpp | 74 + .../list/list.cons/move_alloc.pass.cpp | 78 + .../list.cons/move_assign_noexcept.pass.cpp | 52 + .../list/list.cons/move_noexcept.pass.cpp | 50 + .../op_equal_initializer_list.pass.cpp | 44 + .../list/list.cons/size_type.pass.cpp | 103 + .../list/list.cons/size_value_alloc.pass.cpp | 79 + .../list/list.modifiers/clear.pass.cpp | 35 + .../list/list.modifiers/emplace.pass.cpp | 88 + .../list/list.modifiers/emplace_back.pass.cpp | 66 + .../list.modifiers/emplace_front.pass.cpp | 66 + .../list/list.modifiers/erase_iter.pass.cpp | 65 + .../list.modifiers/erase_iter_db1.pass.cpp | 51 + .../list.modifiers/erase_iter_db2.pass.cpp | 53 + .../list.modifiers/erase_iter_iter.pass.cpp | 84 + .../erase_iter_iter_db1.pass.cpp | 51 + .../erase_iter_iter_db2.pass.cpp | 51 + .../erase_iter_iter_db3.pass.cpp | 51 + .../erase_iter_iter_db4.pass.cpp | 49 + .../insert_iter_initializer_list.pass.cpp | 67 + .../insert_iter_iter_iter.pass.cpp | 185 + .../insert_iter_rvalue.pass.cpp | 68 + .../insert_iter_size_value.pass.cpp | 106 + .../list.modifiers/insert_iter_value.pass.cpp | 112 + .../list/list.modifiers/pop_back.pass.cpp | 55 + .../list/list.modifiers/pop_front.pass.cpp | 43 + .../list/list.modifiers/push_back.pass.cpp | 37 + .../push_back_exception_safety.pass.cpp | 73 + .../list.modifiers/push_back_rvalue.pass.cpp | 46 + .../list/list.modifiers/push_front.pass.cpp | 37 + .../push_front_exception_safety.pass.cpp | 73 + .../list.modifiers/push_front_rvalue.pass.cpp | 46 + .../sequences/list/list.ops/merge.pass.cpp | 41 + .../list/list.ops/merge_comp.pass.cpp | 42 + .../sequences/list/list.ops/remove.pass.cpp | 69 + .../list/list.ops/remove_if.pass.cpp | 64 + .../sequences/list/list.ops/reverse.pass.cpp | 37 + .../sequences/list/list.ops/sort.pass.cpp | 37 + .../list/list.ops/sort_comp.pass.cpp | 38 + .../list/list.ops/splice_pos_list.pass.cpp | 803 + .../list.ops/splice_pos_list_iter.pass.cpp | 357 + .../splice_pos_list_iter_iter.pass.cpp | 237 + .../sequences/list/list.ops/unique.pass.cpp | 37 + .../list/list.ops/unique_pred.pass.cpp | 42 + .../list/list.special/db_swap_1.pass.cpp | 59 + .../sequences/list/list.special/swap.pass.cpp | 146 + .../list/list.special/swap_noexcept.pass.cpp | 90 + .../containers/sequences/list/types.pass.cpp | 48 + .../sequences/list/version.pass.cpp | 20 + .../sequences/nothing_to_do.pass.cpp | 12 + .../vector.bool/assign_copy.pass.cpp | 44 + .../assign_initializer_list.pass.cpp | 43 + .../vector.bool/assign_move.pass.cpp | 81 + .../sequences/vector.bool/capacity.pass.cpp | 44 + .../vector.bool/construct_default.pass.cpp | 70 + .../vector.bool/construct_iter_iter.pass.cpp | 48 + .../construct_iter_iter_alloc.pass.cpp | 55 + .../vector.bool/construct_size.pass.cpp | 64 + .../vector.bool/construct_size_value.pass.cpp | 37 + .../construct_size_value_alloc.pass.cpp | 39 + .../sequences/vector.bool/copy.pass.cpp | 65 + .../sequences/vector.bool/copy_alloc.pass.cpp | 62 + .../vector.bool/default_noexcept.pass.cpp | 49 + .../vector.bool/dtor_noexcept.pass.cpp | 51 + .../sequences/vector.bool/emplace.pass.cpp | 68 + .../vector.bool/emplace_back.pass.cpp | 57 + .../sequences/vector.bool/erase_iter.pass.cpp | 65 + .../vector.bool/erase_iter_iter.pass.cpp | 85 + .../sequences/vector.bool/find.pass.cpp | 40 + .../vector.bool/initializer_list.pass.cpp | 41 + .../initializer_list_alloc.pass.cpp | 44 + .../insert_iter_initializer_list.pass.cpp | 65 + .../insert_iter_iter_iter.pass.cpp | 126 + .../insert_iter_size_value.pass.cpp | 81 + .../vector.bool/insert_iter_value.pass.cpp | 77 + .../sequences/vector.bool/iterators.pass.cpp | 123 + .../sequences/vector.bool/move.pass.cpp | 64 + .../sequences/vector.bool/move_alloc.pass.cpp | 77 + .../vector.bool/move_assign_noexcept.pass.cpp | 51 + .../vector.bool/move_noexcept.pass.cpp | 54 + .../op_equal_initializer_list.pass.cpp | 43 + .../sequences/vector.bool/push_back.pass.cpp | 48 + .../sequences/vector.bool/reserve.pass.cpp | 54 + .../vector.bool/resize_size.pass.cpp | 50 + .../vector.bool/resize_size_value.pass.cpp | 52 + .../vector.bool/shrink_to_fit.pass.cpp | 38 + .../sequences/vector.bool/swap.pass.cpp | 98 + .../vector.bool/swap_noexcept.pass.cpp | 90 + .../sequences/vector.bool/types.pass.cpp | 72 + .../vector.bool/vector_bool.pass.cpp | 52 + .../containers/sequences/vector/asan.pass.cpp | 52 + .../sequences/vector/asan_throw.pass.cpp | 232 + .../vector/const_value_type.pass.cpp | 22 + .../sequences/vector/contiguous.pass.cpp | 52 + .../sequences/vector/db_back.pass.cpp | 56 + .../sequences/vector/db_cback.pass.cpp | 52 + .../sequences/vector/db_cfront.pass.cpp | 52 + .../sequences/vector/db_cindex.pass.cpp | 54 + .../sequences/vector/db_front.pass.cpp | 56 + .../sequences/vector/db_index.pass.cpp | 56 + .../sequences/vector/db_iterators_2.pass.cpp | 54 + .../sequences/vector/db_iterators_3.pass.cpp | 54 + .../sequences/vector/db_iterators_4.pass.cpp | 56 + .../sequences/vector/db_iterators_5.pass.cpp | 60 + .../sequences/vector/db_iterators_6.pass.cpp | 58 + .../sequences/vector/db_iterators_7.pass.cpp | 58 + .../sequences/vector/db_iterators_8.pass.cpp | 54 + .../sequences/vector/iterators.pass.cpp | 165 + .../sequences/vector/types.pass.cpp | 86 + .../vector/vector.capacity/capacity.pass.cpp | 48 + .../vector/vector.capacity/reserve.pass.cpp | 69 + .../vector.capacity/resize_size.pass.cpp | 83 + .../resize_size_value.pass.cpp | 76 + .../vector.capacity/shrink_to_fit.pass.cpp | 62 + .../vector/vector.capacity/swap.pass.cpp | 50 + .../vector/vector.cons/assign_copy.pass.cpp | 44 + .../assign_initializer_list.pass.cpp | 55 + .../vector/vector.cons/assign_move.pass.cpp | 101 + .../vector.cons/assign_size_value.pass.cpp | 54 + .../vector.cons/construct_default.pass.cpp | 90 + .../vector.cons/construct_iter_iter.pass.cpp | 56 + .../construct_iter_iter_alloc.pass.cpp | 71 + .../vector.cons/construct_size.pass.cpp | 73 + .../vector.cons/construct_size_value.pass.cpp | 40 + .../construct_size_value_alloc.pass.cpp | 39 + .../vector/vector.cons/copy.pass.cpp | 78 + .../vector/vector.cons/copy_alloc.pass.cpp | 64 + .../vector.cons/default.recursive.pass.cpp | 23 + .../vector.cons/default_noexcept.pass.cpp | 51 + .../vector/vector.cons/dtor_noexcept.pass.cpp | 52 + .../vector.cons/initializer_list.pass.cpp | 43 + .../initializer_list_alloc.pass.cpp | 47 + .../vector/vector.cons/move.pass.cpp | 103 + .../vector/vector.cons/move_alloc.pass.cpp | 99 + .../vector.cons/move_assign_noexcept.pass.cpp | 52 + .../vector/vector.cons/move_noexcept.pass.cpp | 55 + .../op_equal_initializer_list.pass.cpp | 46 + .../vector/vector.data/data.pass.cpp | 44 + .../vector/vector.data/data_const.pass.cpp | 44 + .../vector/vector.modifiers/emplace.pass.cpp | 160 + .../vector.modifiers/emplace_back.pass.cpp | 107 + .../vector.modifiers/emplace_extra.pass.cpp | 62 + .../vector.modifiers/erase_iter.pass.cpp | 75 + .../vector.modifiers/erase_iter_db1.pass.cpp | 51 + .../vector.modifiers/erase_iter_db2.pass.cpp | 53 + .../vector.modifiers/erase_iter_iter.pass.cpp | 128 + .../erase_iter_iter_db1.pass.cpp | 51 + .../erase_iter_iter_db2.pass.cpp | 51 + .../erase_iter_iter_db3.pass.cpp | 51 + .../erase_iter_iter_db4.pass.cpp | 49 + .../insert_iter_initializer_list.pass.cpp | 68 + .../insert_iter_iter_iter.pass.cpp | 190 + .../insert_iter_rvalue.pass.cpp | 86 + .../insert_iter_size_value.pass.cpp | 132 + .../insert_iter_value.pass.cpp | 116 + .../vector/vector.modifiers/pop_back.pass.cpp | 55 + .../vector.modifiers/push_back.pass.cpp | 108 + .../push_back_exception_safety.pass.cpp | 86 + .../push_back_rvalue.pass.cpp | 111 + .../vector/vector.special/db_swap_1.pass.cpp | 56 + .../vector/vector.special/swap.pass.cpp | 188 + .../vector.special/swap_noexcept.pass.cpp | 91 + .../sequences/vector/version.pass.cpp | 20 + test/std/containers/stack_allocator.h | 66 + test/std/containers/test_compare.h | 36 + test/std/containers/test_hash.h | 32 + test/std/containers/unord/next_prime.pass.cpp | 51 + .../unord/unord.map/bucket.pass.cpp | 77 + .../unord/unord.map/bucket_count.pass.cpp | 80 + .../unord/unord.map/bucket_size.pass.cpp | 81 + .../unord/unord.map/compare.pass.cpp | 42 + .../containers/unord/unord.map/count.pass.cpp | 65 + .../unord/unord.map/db_iterators_7.pass.cpp | 60 + .../unord/unord.map/db_iterators_8.pass.cpp | 56 + .../unord.map/db_local_iterators_7.pass.cpp | 57 + .../unord.map/db_local_iterators_8.pass.cpp | 54 + .../containers/unord/unord.map/eq.pass.cpp | 163 + .../unord.map/equal_range_const.pass.cpp | 75 + .../unord.map/equal_range_non_const.pass.cpp | 75 + .../unord/unord.map/find_const.pass.cpp | 71 + .../unord/unord.map/find_non_const.pass.cpp | 71 + .../unord/unord.map/iterators.pass.cpp | 128 + .../unord/unord.map/load_factor.pass.cpp | 77 + .../unord/unord.map/local_iterators.pass.cpp | 421 + .../unord/unord.map/max_bucket_count.pass.cpp | 43 + .../unord/unord.map/max_load_factor.pass.cpp | 71 + .../unord/unord.map/max_size.pass.cpp | 36 + .../unord/unord.map/rehash.pass.cpp | 91 + .../unord/unord.map/reserve.pass.cpp | 91 + .../unord/unord.map/swap_member.pass.cpp | 572 + .../containers/unord/unord.map/types.pass.cpp | 72 + .../unord.map.cnstr/allocator.pass.cpp | 111 + .../unord.map.cnstr/assign_copy.pass.cpp | 185 + .../unord.map.cnstr/assign_init.pass.cpp | 97 + .../unord.map.cnstr/assign_move.pass.cpp | 229 + .../unord.map/unord.map.cnstr/copy.pass.cpp | 151 + .../unord.map.cnstr/copy_alloc.pass.cpp | 110 + .../unord.map.cnstr/default.pass.cpp | 78 + .../unord.map.cnstr/default_noexcept.pass.cpp | 70 + .../unord.map.cnstr/dtor_noexcept.pass.cpp | 67 + .../unord.map/unord.map.cnstr/init.pass.cpp | 162 + .../unord.map.cnstr/init_size.pass.cpp | 100 + .../unord.map.cnstr/init_size_hash.pass.cpp | 102 + .../init_size_hash_equal.pass.cpp | 105 + .../init_size_hash_equal_allocator.pass.cpp | 107 + .../unord.map/unord.map.cnstr/move.pass.cpp | 199 + .../unord.map.cnstr/move_alloc.pass.cpp | 157 + .../move_assign_noexcept.pass.cpp | 69 + .../unord.map.cnstr/move_noexcept.pass.cpp | 66 + .../unord.map/unord.map.cnstr/range.pass.cpp | 170 + .../unord.map.cnstr/range_size.pass.cpp | 105 + .../unord.map.cnstr/range_size_hash.pass.cpp | 108 + .../range_size_hash_equal.pass.cpp | 110 + .../range_size_hash_equal_allocator.pass.cpp | 113 + .../unord.map/unord.map.cnstr/size.fail.cpp | 69 + .../unord.map/unord.map.cnstr/size.pass.cpp | 69 + .../unord.map.cnstr/size_hash.pass.cpp | 73 + .../unord.map.cnstr/size_hash_equal.pass.cpp | 75 + .../size_hash_equal_allocator.pass.cpp | 77 + .../unord.map/unord.map.elem/at.pass.cpp | 134 + .../unord.map/unord.map.elem/index.pass.cpp | 115 + .../unord.map.elem/index_tuple.pass.cpp | 41 + .../unord.map.swap/db_swap_1.pass.cpp | 44 + .../unord.map.swap/swap_noexcept.pass.cpp | 199 + .../unord.map.swap/swap_non_member.pass.cpp | 572 + .../unorder.map.modifiers/clear.pass.cpp | 61 + .../unorder.map.modifiers/emplace.pass.cpp | 80 + .../emplace_hint.pass.cpp | 93 + .../erase_const_iter.pass.cpp | 92 + .../erase_iter_db1.pass.cpp | 39 + .../erase_iter_db2.pass.cpp | 42 + .../erase_iter_iter_db1.pass.cpp | 41 + .../erase_iter_iter_db2.pass.cpp | 41 + .../erase_iter_iter_db3.pass.cpp | 41 + .../erase_iter_iter_db4.pass.cpp | 40 + .../unorder.map.modifiers/erase_key.pass.cpp | 177 + .../erase_range.pass.cpp | 99 + .../insert_const_lvalue.pass.cpp | 86 + .../insert_hint_const_lvalue.pass.cpp | 97 + .../insert_hint_rvalue.pass.cpp | 156 + .../insert_init.pass.cpp | 72 + .../insert_or_assign.pass.cpp | 198 + .../insert_range.pass.cpp | 71 + .../insert_rvalue.pass.cpp | 152 + .../try.emplace.pass.cpp | 195 + .../unord/unord.map/version.pass.cpp | 20 + .../unord/unord.multimap/bucket.pass.cpp | 77 + .../unord.multimap/bucket_count.pass.cpp | 49 + .../unord/unord.multimap/bucket_size.pass.cpp | 85 + .../unord/unord.multimap/count.pass.cpp | 71 + .../unord.multimap/db_iterators_7.pass.cpp | 60 + .../unord.multimap/db_iterators_8.pass.cpp | 56 + .../db_local_iterators_7.pass.cpp | 57 + .../db_local_iterators_8.pass.cpp | 54 + .../unord/unord.multimap/eq.pass.cpp | 181 + .../unord.multimap/equal_range_const.pass.cpp | 97 + .../equal_range_non_const.pass.cpp | 97 + .../unord/unord.multimap/find_const.pass.cpp | 71 + .../unord.multimap/find_non_const.pass.cpp | 71 + .../unord/unord.multimap/iterators.fail.cpp | 69 + .../unord/unord.multimap/iterators.pass.cpp | 134 + .../unord/unord.multimap/load_factor.pass.cpp | 77 + .../unord.multimap/local_iterators.fail.cpp | 286 + .../unord.multimap/local_iterators.pass.cpp | 549 + .../unord.multimap/max_bucket_count.pass.cpp | 43 + .../unord.multimap/max_load_factor.pass.cpp | 71 + .../unord/unord.multimap/max_size.pass.cpp | 36 + .../unord/unord.multimap/rehash.pass.cpp | 119 + .../unord/unord.multimap/reserve.pass.cpp | 93 + .../unord/unord.multimap/scary.pass.cpp | 24 + .../unord/unord.multimap/swap_member.pass.cpp | 585 + .../unord/unord.multimap/types.pass.cpp | 72 + .../unord.multimap.cnstr/allocator.pass.cpp | 111 + .../unord.multimap.cnstr/assign_copy.pass.cpp | 227 + .../unord.multimap.cnstr/assign_init.pass.cpp | 146 + .../unord.multimap.cnstr/assign_move.pass.cpp | 306 + .../unord.multimap.cnstr/copy.pass.cpp | 193 + .../unord.multimap.cnstr/copy_alloc.pass.cpp | 138 + .../unord.multimap.cnstr/default.pass.cpp | 78 + .../default_noexcept.pass.cpp | 70 + .../dtor_noexcept.pass.cpp | 67 + .../unord.multimap.cnstr/init.pass.cpp | 254 + .../unord.multimap.cnstr/init_size.pass.cpp | 144 + .../init_size_hash.pass.cpp | 146 + .../init_size_hash_equal.pass.cpp | 149 + .../init_size_hash_equal_allocator.pass.cpp | 151 + .../unord.multimap.cnstr/move.pass.cpp | 243 + .../unord.multimap.cnstr/move_alloc.pass.cpp | 228 + .../move_assign_noexcept.pass.cpp | 69 + .../move_noexcept.pass.cpp | 66 + .../unord.multimap.cnstr/range.pass.cpp | 263 + .../unord.multimap.cnstr/range_size.pass.cpp | 149 + .../range_size_hash.pass.cpp | 152 + .../range_size_hash_equal.pass.cpp | 154 + .../range_size_hash_equal_allocator.pass.cpp | 157 + .../unord.multimap.cnstr/size.fail.cpp | 69 + .../unord.multimap.cnstr/size.pass.cpp | 69 + .../unord.multimap.cnstr/size_hash.pass.cpp | 73 + .../size_hash_equal.pass.cpp | 75 + .../size_hash_equal_allocator.pass.cpp | 77 + .../unord.multimap.modifiers/clear.pass.cpp | 61 + .../unord.multimap.modifiers/emplace.pass.cpp | 74 + .../emplace_hint.pass.cpp | 109 + .../erase_const_iter.pass.cpp | 140 + .../erase_iter_db1.pass.cpp | 39 + .../erase_iter_db2.pass.cpp | 42 + .../erase_iter_iter_db1.pass.cpp | 41 + .../erase_iter_iter_db2.pass.cpp | 41 + .../erase_iter_iter_db3.pass.cpp | 41 + .../erase_iter_iter_db4.pass.cpp | 40 + .../erase_key.pass.cpp | 388 + .../erase_range.pass.cpp | 179 + .../insert_const_lvalue.pass.cpp | 78 + .../insert_hint_const_lvalue.pass.cpp | 97 + .../insert_hint_rvalue.pass.cpp | 156 + .../insert_init.pass.cpp | 122 + .../insert_range.pass.cpp | 121 + .../insert_rvalue.pass.cpp | 136 + .../unord.multimap.swap/db_swap_1.pass.cpp | 44 + .../swap_noexcept.pass.cpp | 198 + .../swap_non_member.pass.cpp | 584 + .../unord/unord.multiset/bucket.pass.cpp | 76 + .../unord.multiset/bucket_count.pass.cpp | 79 + .../unord/unord.multiset/bucket_size.pass.cpp | 84 + .../unord/unord.multiset/clear.pass.cpp | 60 + .../unord/unord.multiset/count.pass.cpp | 70 + .../unord.multiset/db_iterators_7.pass.cpp | 58 + .../unord.multiset/db_iterators_8.pass.cpp | 54 + .../db_local_iterators_7.pass.cpp | 57 + .../db_local_iterators_8.pass.cpp | 54 + .../unord/unord.multiset/emplace.pass.cpp | 64 + .../unord.multiset/emplace_hint.pass.cpp | 80 + .../unord/unord.multiset/eq.pass.cpp | 180 + .../unord.multiset/equal_range_const.pass.cpp | 90 + .../equal_range_non_const.pass.cpp | 90 + .../unord.multiset/erase_const_iter.pass.cpp | 93 + .../unord.multiset/erase_iter_db1.pass.cpp | 38 + .../unord.multiset/erase_iter_db2.pass.cpp | 41 + .../erase_iter_iter_db1.pass.cpp | 40 + .../erase_iter_iter_db2.pass.cpp | 40 + .../erase_iter_iter_db3.pass.cpp | 40 + .../erase_iter_iter_db4.pass.cpp | 39 + .../unord/unord.multiset/erase_key.pass.cpp | 176 + .../unord/unord.multiset/erase_range.pass.cpp | 94 + .../unord/unord.multiset/find_const.pass.cpp | 68 + .../unord.multiset/find_non_const.pass.cpp | 68 + .../insert_const_lvalue.pass.cpp | 70 + .../insert_hint_const_lvalue.pass.cpp | 89 + .../insert_hint_rvalue.pass.cpp | 138 + .../unord/unord.multiset/insert_init.pass.cpp | 71 + .../unord.multiset/insert_range.pass.cpp | 70 + .../unord.multiset/insert_rvalue.pass.cpp | 118 + .../unord/unord.multiset/iterators.fail.cpp | 67 + .../unord/unord.multiset/iterators.pass.cpp | 127 + .../unord/unord.multiset/load_factor.pass.cpp | 76 + .../unord.multiset/local_iterators.fail.cpp | 261 + .../unord.multiset/local_iterators.pass.cpp | 500 + .../unord.multiset/max_bucket_count.pass.cpp | 38 + .../unord.multiset/max_load_factor.pass.cpp | 70 + .../unord/unord.multiset/max_size.pass.cpp | 36 + .../unord/unord.multiset/rehash.pass.cpp | 90 + .../unord/unord.multiset/reserve.pass.cpp | 90 + .../unord/unord.multiset/scary.pass.cpp | 24 + .../unord/unord.multiset/swap_member.pass.cpp | 571 + .../unord/unord.multiset/types.pass.cpp | 69 + .../unord.multiset.cnstr/allocator.pass.cpp | 109 + .../unord.multiset.cnstr/assign_copy.pass.cpp | 209 + .../unord.multiset.cnstr/assign_init.pass.cpp | 97 + .../unord.multiset.cnstr/assign_move.pass.cpp | 286 + .../unord.multiset.cnstr/copy.pass.cpp | 171 + .../unord.multiset.cnstr/copy_alloc.pass.cpp | 123 + .../unord.multiset.cnstr/default.pass.cpp | 74 + .../default_noexcept.pass.cpp | 70 + .../dtor_noexcept.pass.cpp | 67 + .../unord.multiset.cnstr/init.pass.cpp | 163 + .../unord.multiset.cnstr/init_size.pass.cpp | 97 + .../init_size_hash.pass.cpp | 100 + .../init_size_hash_equal.pass.cpp | 102 + .../init_size_hash_equal_allocator.pass.cpp | 104 + .../unord.multiset.cnstr/move.pass.cpp | 194 + .../unord.multiset.cnstr/move_alloc.pass.cpp | 213 + .../move_assign_noexcept.pass.cpp | 69 + .../move_noexcept.pass.cpp | 66 + .../unord.multiset.cnstr/range.pass.cpp | 167 + .../unord.multiset.cnstr/range_size.pass.cpp | 101 + .../range_size_hash.pass.cpp | 104 + .../range_size_hash_equal.pass.cpp | 106 + .../range_size_hash_equal_allocator.pass.cpp | 109 + .../unord.multiset.cnstr/size.fail.cpp | 65 + .../unord.multiset.cnstr/size.pass.cpp | 65 + .../unord.multiset.cnstr/size_hash.pass.cpp | 69 + .../size_hash_equal.pass.cpp | 71 + .../size_hash_equal_allocator.pass.cpp | 73 + .../unord.multiset.swap/db_swap_1.pass.cpp | 43 + .../swap_noexcept.pass.cpp | 198 + .../swap_non_member.pass.cpp | 571 + .../unord/unord.set/bucket.pass.cpp | 75 + .../unord/unord.set/bucket_count.pass.cpp | 77 + .../unord/unord.set/bucket_size.pass.cpp | 79 + .../containers/unord/unord.set/clear.pass.cpp | 59 + .../containers/unord/unord.set/count.pass.cpp | 69 + .../unord/unord.set/db_iterators_7.pass.cpp | 58 + .../unord/unord.set/db_iterators_8.pass.cpp | 54 + .../unord.set/db_local_iterators_7.pass.cpp | 57 + .../unord.set/db_local_iterators_8.pass.cpp | 54 + .../unord/unord.set/emplace.pass.cpp | 70 + .../unord/unord.set/emplace_hint.pass.cpp | 80 + .../containers/unord/unord.set/eq.pass.cpp | 159 + .../unord.set/equal_range_const.pass.cpp | 81 + .../unord.set/equal_range_non_const.pass.cpp | 81 + .../unord/unord.set/erase_const_iter.pass.cpp | 90 + .../unord/unord.set/erase_iter_db1.pass.cpp | 38 + .../unord/unord.set/erase_iter_db2.pass.cpp | 41 + .../unord.set/erase_iter_iter_db1.pass.cpp | 40 + .../unord.set/erase_iter_iter_db2.pass.cpp | 40 + .../unord.set/erase_iter_iter_db3.pass.cpp | 40 + .../unord.set/erase_iter_iter_db4.pass.cpp | 39 + .../unord/unord.set/erase_key.pass.cpp | 175 + .../unord/unord.set/erase_range.pass.cpp | 93 + .../unord/unord.set/find_const.pass.cpp | 67 + .../unord/unord.set/find_non_const.pass.cpp | 67 + .../unord.set/insert_const_lvalue.pass.cpp | 78 + .../insert_hint_const_lvalue.pass.cpp | 89 + .../unord.set/insert_hint_rvalue.pass.cpp | 138 + .../unord/unord.set/insert_init.pass.cpp | 71 + .../unord/unord.set/insert_range.pass.cpp | 70 + .../unord/unord.set/insert_rvalue.pass.cpp | 134 + .../unord/unord.set/iterators.fail.cpp | 67 + .../unord/unord.set/iterators.pass.cpp | 127 + .../unord/unord.set/load_factor.pass.cpp | 76 + .../unord/unord.set/local_iterators.fail.cpp | 261 + .../unord/unord.set/local_iterators.pass.cpp | 388 + .../unord/unord.set/max_bucket_count.pass.cpp | 38 + .../unord/unord.set/max_load_factor.pass.cpp | 70 + .../unord/unord.set/max_size.pass.cpp | 36 + .../unord/unord.set/rehash.pass.cpp | 90 + .../unord/unord.set/reserve.pass.cpp | 90 + .../unord/unord.set/swap_member.pass.cpp | 571 + .../containers/unord/unord.set/types.pass.cpp | 69 + .../unord.set.cnstr/allocator.pass.cpp | 109 + .../unord.set.cnstr/assign_copy.pass.cpp | 184 + .../unord.set.cnstr/assign_init.pass.cpp | 97 + .../unord.set.cnstr/assign_move.pass.cpp | 225 + .../unord.set/unord.set.cnstr/copy.pass.cpp | 147 + .../unord.set.cnstr/copy_alloc.pass.cpp | 107 + .../unord.set.cnstr/default.pass.cpp | 74 + .../unord.set.cnstr/default_noexcept.pass.cpp | 70 + .../unord.set.cnstr/dtor_noexcept.pass.cpp | 67 + .../unord.set/unord.set.cnstr/init.pass.cpp | 163 + .../unord.set.cnstr/init_size.pass.cpp | 97 + .../unord.set.cnstr/init_size_hash.pass.cpp | 100 + .../init_size_hash_equal.pass.cpp | 102 + .../init_size_hash_equal_allocator.pass.cpp | 104 + .../unord.set/unord.set.cnstr/move.pass.cpp | 194 + .../unord.set.cnstr/move_alloc.pass.cpp | 156 + .../move_assign_noexcept.pass.cpp | 69 + .../unord.set.cnstr/move_noexcept.pass.cpp | 66 + .../unord.set/unord.set.cnstr/range.pass.cpp | 168 + .../unord.set.cnstr/range_size.pass.cpp | 101 + .../unord.set.cnstr/range_size_hash.pass.cpp | 104 + .../range_size_hash_equal.pass.cpp | 106 + .../range_size_hash_equal_allocator.pass.cpp | 109 + .../unord.set/unord.set.cnstr/size.fail.cpp | 45 + .../unord.set/unord.set.cnstr/size.pass.cpp | 65 + .../unord.set.cnstr/size_hash.pass.cpp | 69 + .../unord.set.cnstr/size_hash_equal.pass.cpp | 71 + .../size_hash_equal_allocator.pass.cpp | 73 + .../unord.set.swap/db_swap_1.pass.cpp | 43 + .../unord.set.swap/swap_noexcept.pass.cpp | 198 + .../unord.set.swap/swap_non_member.pass.cpp | 571 + .../unord/unord.set/version.pass.cpp | 20 + test/std/depr/depr.auto.ptr/auto.ptr/A.h | 30 + test/std/depr/depr.auto.ptr/auto.ptr/AB.h | 41 + .../auto.ptr.cons/assignment.fail.cpp | 44 + .../auto.ptr.cons/assignment.pass.cpp | 44 + .../auto.ptr/auto.ptr.cons/convert.fail.cpp | 40 + .../auto.ptr/auto.ptr.cons/convert.pass.cpp | 40 + .../auto.ptr.cons/convert_assignment.fail.cpp | 47 + .../auto.ptr.cons/convert_assignment.pass.cpp | 47 + .../auto.ptr/auto.ptr.cons/copy.fail.cpp | 38 + .../auto.ptr/auto.ptr.cons/copy.pass.cpp | 38 + .../auto.ptr/auto.ptr.cons/explicit.fail.cpp | 40 + .../auto.ptr/auto.ptr.cons/pointer.pass.cpp | 40 + .../assign_from_auto_ptr_ref.pass.cpp | 40 + .../convert_from_auto_ptr_ref.pass.cpp | 39 + .../convert_to_auto_ptr.pass.cpp | 36 + .../convert_to_auto_ptr_ref.pass.cpp | 33 + .../auto.ptr/auto.ptr.members/arrow.pass.cpp | 37 + .../auto.ptr/auto.ptr.members/deref.pass.cpp | 37 + .../auto.ptr.members/release.pass.cpp | 38 + .../auto.ptr/auto.ptr.members/reset.pass.cpp | 54 + .../auto.ptr/element_type.pass.cpp | 36 + .../depr/depr.auto.ptr/nothing_to_do.pass.cpp | 12 + .../std/depr/depr.c.headers/assert_h.pass.cpp | 20 + test/std/depr/depr.c.headers/ciso646.pass.cpp | 20 + .../depr/depr.c.headers/complex.h.pass.cpp | 21 + test/std/depr/depr.c.headers/ctype_h.pass.cpp | 103 + test/std/depr/depr.c.headers/errno_h.pass.cpp | 33 + test/std/depr/depr.c.headers/fenv_h.pass.cpp | 76 + test/std/depr/depr.c.headers/float_h.pass.cpp | 140 + .../depr/depr.c.headers/inttypes_h.pass.cpp | 643 + .../std/depr/depr.c.headers/iso646_h.pass.cpp | 17 + .../std/depr/depr.c.headers/limits_h.pass.cpp | 92 + .../std/depr/depr.c.headers/locale_h.pass.cpp | 48 + test/std/depr/depr.c.headers/math_h.pass.cpp | 683 + .../std/depr/depr.c.headers/setjmp_h.pass.cpp | 20 + .../std/depr/depr.c.headers/signal_h.pass.cpp | 57 + .../std/depr/depr.c.headers/stdarg_h.pass.cpp | 35 + .../depr/depr.c.headers/stdbool_h.pass.cpp | 32 + .../std/depr/depr.c.headers/stddef_h.pass.cpp | 37 + .../std/depr/depr.c.headers/stdint_h.pass.cpp | 291 + test/std/depr/depr.c.headers/stdio_h.pass.cpp | 138 + .../std/depr/depr.c.headers/stdlib_h.pass.cpp | 84 + .../std/depr/depr.c.headers/string_h.pass.cpp | 50 + .../std/depr/depr.c.headers/tgmath_h.pass.cpp | 23 + test/std/depr/depr.c.headers/time_h.pass.cpp | 40 + test/std/depr/depr.c.headers/uchar_h.pass.cpp | 19 + test/std/depr/depr.c.headers/wchar_h.pass.cpp | 104 + .../std/depr/depr.c.headers/wctype_h.pass.cpp | 114 + .../pointer_to_binary_function.pass.cpp | 26 + .../pointer_to_unary_function.pass.cpp | 26 + .../ptr_fun1.pass.cpp | 25 + .../ptr_fun2.pass.cpp | 25 + .../const_mem_fun.pass.cpp | 31 + .../const_mem_fun1.pass.cpp | 31 + .../const_mem_fun1_ref_t.pass.cpp | 33 + .../const_mem_fun1_t.pass.cpp | 33 + .../const_mem_fun_ref.pass.cpp | 31 + .../const_mem_fun_ref1.pass.cpp | 31 + .../const_mem_fun_ref_t.pass.cpp | 33 + .../const_mem_fun_t.pass.cpp | 33 + .../mem_fun.pass.cpp | 31 + .../mem_fun1.pass.cpp | 31 + .../mem_fun1_ref_t.pass.cpp | 33 + .../mem_fun1_t.pass.cpp | 33 + .../mem_fun_ref.pass.cpp | 31 + .../mem_fun_ref1.pass.cpp | 31 + .../mem_fun_ref_t.pass.cpp | 33 + .../mem_fun_t.pass.cpp | 33 + .../depr.adaptors/nothing_to_do.pass.cpp | 12 + .../depr.base/binary_function.pass.cpp | 28 + .../depr.base/unary_function.pass.cpp | 26 + .../nothing_to_do.pass.cpp | 12 + .../depr/depr.ios.members/io_state.pass.cpp | 25 + .../depr/depr.ios.members/open_mode.pass.cpp | 25 + .../depr/depr.ios.members/seek_dir.pass.cpp | 25 + .../depr/depr.ios.members/streamoff.pass.cpp | 25 + .../depr/depr.ios.members/streampos.pass.cpp | 24 + .../depr.lib.bind.1st/bind1st.pass.cpp | 24 + .../depr.lib.bind.2nd/bind2nd.pass.cpp | 24 + .../depr.lib.binder.1st/binder1st.pass.cpp | 58 + .../depr.lib.binder.2nd/binder2nd.pass.cpp | 58 + .../depr.lib.binders/nothing_to_do.pass.cpp | 12 + test/std/depr/depr.lib.binders/test_func.h | 33 + .../depr.istrstream.cons/ccp.pass.cpp | 43 + .../depr.istrstream.cons/ccp_size.pass.cpp | 43 + .../depr.istrstream.cons/cp.pass.cpp | 43 + .../depr.istrstream.cons/cp_size.pass.cpp | 43 + .../depr.istrstream.members/rdbuf.pass.cpp | 27 + .../depr.istrstream.members/str.pass.cpp | 26 + .../depr.istrstream/types.pass.cpp | 23 + .../cp_size_mode.pass.cpp | 41 + .../depr.ostrstream.cons/default.pass.cpp | 28 + .../depr.ostrstream.members/freeze.pass.cpp | 34 + .../depr.ostrstream.members/pcount.pass.cpp | 27 + .../depr.ostrstream.members/rdbuf.pass.cpp | 28 + .../depr.ostrstream.members/str.pass.cpp | 27 + .../depr.ostrstream/types.pass.cpp | 23 + .../depr.strstream.cons/cp_size_mode.pass.cpp | 59 + .../depr.strstream.cons/default.pass.cpp | 35 + .../depr.strstream.dest/rdbuf.pass.cpp | 28 + .../depr.strstream.oper/freeze.pass.cpp | 34 + .../depr.strstream.oper/pcount.pass.cpp | 27 + .../depr.strstream.oper/str.pass.cpp | 27 + .../depr.strstream/types.pass.cpp | 32 + .../depr.strstreambuf.cons/ccp_size.pass.cpp | 40 + .../cp_size_cp.pass.cpp | 96 + .../depr.strstreambuf.cons/cscp_size.pass.cpp | 40 + .../depr.strstreambuf.cons/cucp_size.pass.cpp | 40 + .../custom_alloc.pass.cpp | 51 + .../depr.strstreambuf.cons/default.pass.cpp | 31 + .../scp_size_scp.pass.cpp | 96 + .../ucp_size_ucp.pass.cpp | 96 + .../depr.strstreambuf.members/freeze.pass.cpp | 28 + .../depr.strstreambuf.members/pcount.pass.cpp | 32 + .../depr.strstreambuf.members/str.pass.cpp | 28 + .../overflow.pass.cpp | 47 + .../pbackfail.pass.cpp | 62 + .../seekoff.pass.cpp | 57 + .../seekpos.pass.cpp | 39 + .../setbuf.pass.cpp | 27 + .../underflow.pass.cpp | 51 + .../depr.strstreambuf/types.pass.cpp | 21 + .../depr/depr.str.strstreams/version.pass.cpp | 20 + .../nothing_to_do.pass.cpp | 12 + .../set.unexpected/get_unexpected.pass.cpp | 39 + .../set.unexpected/set_unexpected.pass.cpp | 35 + .../unexpected_handler.pass.cpp | 19 + .../unexpected/unexpected.pass.cpp | 26 + test/std/depr/nothing_to_do.pass.cpp | 12 + .../diagnostics/assertions/cassert.pass.cpp | 24 + .../nothing_to_do.pass.cpp | 12 + test/std/diagnostics/errno/cerrno.pass.cpp | 349 + test/std/diagnostics/nothing_to_do.pass.cpp | 12 + .../domain.error/domain_error.pass.cpp | 42 + .../invalid_argument.pass.cpp | 42 + .../length.error/length_error.pass.cpp | 42 + .../logic.error/logic_error.pass.cpp | 42 + .../out.of.range/out_of_range.pass.cpp | 42 + .../overflow.error/overflow_error.pass.cpp | 42 + .../range.error/range_error.pass.cpp | 42 + .../runtime.error/runtime_error.pass.cpp | 42 + .../underflow.error/underflow_error.pass.cpp | 42 + .../std.exceptions/version.pass.cpp | 20 + test/std/diagnostics/syserr/errc.pass.cpp | 104 + .../eq_error_code_error_code.pass.cpp | 106 + .../syserr.errcat/nothing_to_do.pass.cpp | 12 + .../syserr.errcat.derived/message.pass.cpp | 34 + .../default_ctor.pass.cpp | 40 + .../syserr.errcat.nonvirtuals/eq.pass.cpp | 26 + .../syserr.errcat.nonvirtuals/lt.pass.cpp | 26 + .../syserr.errcat.nonvirtuals/neq.pass.cpp | 26 + .../generic_category.pass.cpp | 25 + .../system_category.pass.cpp | 29 + .../error_category.pass.cpp | 19 + .../default_error_condition.pass.cpp | 25 + .../equivalent_error_code_int.pass.cpp | 24 + .../equivalent_int_error_condition.pass.cpp | 25 + .../syserr.errcode/nothing_to_do.pass.cpp | 12 + .../ErrorCodeEnum.pass.cpp | 44 + .../default.pass.cpp | 24 + .../int_error_category.pass.cpp | 31 + .../ErrorCodeEnum.pass.cpp | 45 + .../syserr.errcode.modifiers/assign.pass.cpp | 33 + .../syserr.errcode.modifiers/clear.pass.cpp | 30 + .../syserr.errcode.nonmembers/lt.pass.cpp | 27 + .../make_error_code.pass.cpp | 26 + .../stream_inserter.pass.cpp | 27 + .../syserr.errcode.observers/bool.pass.cpp | 30 + .../category.pass.cpp | 23 + .../default_error_condition.pass.cpp | 31 + .../syserr.errcode.observers/message.pass.cpp | 24 + .../syserr.errcode.observers/value.pass.cpp | 23 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../ErrorConditionEnum.pass.cpp | 26 + .../default.pass.cpp | 24 + .../int_error_category.pass.cpp | 31 + .../ErrorConditionEnum.pass.cpp | 27 + .../assign.pass.cpp | 33 + .../clear.pass.cpp | 30 + .../lt.pass.cpp | 27 + .../make_error_condition.pass.cpp | 26 + .../bool.pass.cpp | 30 + .../category.pass.cpp | 23 + .../message.pass.cpp | 24 + .../value.pass.cpp | 23 + .../nothing_to_do.pass.cpp | 12 + .../syserr/syserr.hash/error_code.pass.cpp | 42 + .../syserr.syserr/nothing_to_do.pass.cpp | 12 + .../ctor_error_code.pass.cpp | 29 + ...tor_error_code_const_char_pointer.pass.cpp | 30 + .../ctor_error_code_string.pass.cpp | 30 + .../ctor_int_error_category.pass.cpp | 29 + ...error_category_const_char_pointer.pass.cpp | 31 + .../ctor_int_error_category_string.pass.cpp | 31 + .../nothing_to_do.pass.cpp | 12 + test/std/diagnostics/syserr/version.pass.cpp | 20 + .../alg.random.sample/sample.fail.cpp | 36 + .../alg.random.sample/sample.pass.cpp | 146 + .../alg.random.sample/sample.stable.pass.cpp | 53 + test/std/experimental/nothing_to_do.pass.cpp | 12 + .../default.pass.cpp | 23 + .../derive.pass.cpp | 25 + .../optional.comp_with_t/equal.pass.cpp | 58 + .../optional.comp_with_t/greater.pass.cpp | 61 + .../greater_equal.pass.cpp | 61 + .../optional.comp_with_t/less_equal.pass.cpp | 61 + .../optional.comp_with_t/less_than.pass.cpp | 61 + .../optional.comp_with_t/not_equal.pass.cpp | 58 + .../optional.defs/tested_elsewhere.pass.cpp | 12 + .../optional.general/nothing_to_do.pass.cpp | 12 + .../optional/optional.hash/hash.pass.cpp | 47 + .../optional.inplace/in_place_t.pass.cpp | 42 + .../optional/optional.nullops/equal.pass.cpp | 41 + .../optional.nullops/greater.pass.cpp | 41 + .../optional.nullops/greater_equal.pass.cpp | 41 + .../optional.nullops/less_equal.pass.cpp | 41 + .../optional.nullops/less_than.pass.cpp | 41 + .../optional.nullops/not_equal.pass.cpp | 41 + .../optional.nullopt/nullopt_t.pass.cpp | 43 + .../assign_value.pass.cpp | 72 + .../optional.object.assign/copy.pass.cpp | 90 + .../optional.object.assign/emplace.pass.cpp | 148 + .../emplace_initializer_list.pass.cpp | 116 + .../optional.object.assign/move.pass.cpp | 103 + .../optional.object.assign/nullopt_t.pass.cpp | 67 + .../optional.object.ctor/const_T.pass.cpp | 117 + .../optional.object.ctor/copy.pass.cpp | 124 + .../optional.object.ctor/default.pass.cpp | 67 + .../optional.object.ctor/in_place_t.pass.cpp | 145 + .../initializer_list.pass.cpp | 126 + .../optional.object.ctor/move.pass.cpp | 124 + .../optional.object.ctor/nullopt_t.pass.cpp | 68 + .../optional.object.ctor/rvalue_T.pass.cpp | 110 + .../optional.object.dtor/dtor.pass.cpp | 59 + .../optional.object.observe/bool.pass.cpp | 32 + .../dereference.pass.cpp | 49 + .../dereference_const.pass.cpp | 57 + .../optional.object.observe/op_arrow.pass.cpp | 48 + .../op_arrow_const.pass.cpp | 67 + .../optional.object.observe/value.pass.cpp | 53 + .../value_const.fail.cpp | 40 + .../value_const.pass.cpp | 58 + .../optional.object.observe/value_or.pass.cpp | 71 + .../value_or_const.pass.cpp | 82 + .../optional.object.swap/swap.pass.cpp | 306 + .../optional_const_void.fail.cpp | 25 + .../optional_not_destructible.fail.cpp | 35 + ...ptional_not_noexcept_destructible.fail.cpp | 34 + .../optional.object/optional_void.fail.cpp | 25 + .../optional/optional.object/types.pass.cpp | 43 + .../optional/optional.relops/equal.pass.cpp | 79 + .../optional.relops/greater_equal.pass.cpp | 75 + .../optional.relops/greater_than.pass.cpp | 75 + .../optional.relops/less_equal.pass.cpp | 75 + .../optional.relops/less_than.pass.cpp | 75 + .../optional.relops/not_equal.pass.cpp | 79 + .../optional.specalg/make_optional.pass.cpp | 50 + .../optional/optional.specalg/swap.pass.cpp | 305 + .../optional_const_in_place_t.fail.cpp | 28 + .../optional_const_lvalue_ref.fail.cpp | 26 + .../optional_const_nullopt_t.fail.cpp | 28 + .../optional.syn/optional_in_place_t.fail.cpp | 28 + ...ptional_includes_initializer_list.pass.cpp | 23 + .../optional.syn/optional_lvalue_ref.fail.cpp | 26 + .../optional.syn/optional_nullopt_t.fail.cpp | 28 + .../optional.syn/optional_rvalue_ref.fail.cpp | 26 + .../experimental/optional/version.pass.cpp | 20 + .../string.view/nothing_to_do.pass.cpp | 12 + .../string.view.access/at.pass.cpp | 57 + .../string.view.access/back.pass.cpp | 48 + .../string.view.access/data.pass.cpp | 48 + .../string.view.access/front.pass.cpp | 48 + .../string.view.access/index.pass.cpp | 51 + .../string.view.capacity/capacity.pass.cpp | 87 + .../opeq.string_view.pointer.pass.cpp | 68 + .../opeq.string_view.string.pass.cpp | 54 + .../opeq.string_view.string_view.pass.cpp | 61 + .../opge.string_view.pointer.pass.cpp | 71 + .../opge.string_view.string.pass.cpp | 50 + .../opge.string_view.string_view.pass.cpp | 64 + .../opgt.string_view.pointer.pass.cpp | 71 + .../opgt.string_view.string.pass.cpp | 50 + .../opgt.string_view.string_view.pass.cpp | 64 + .../ople.string_view.pointer.pass.cpp | 71 + .../ople.string_view.string.pass.cpp | 50 + .../ople.string_view.string_view.pass.cpp | 64 + .../oplt.string_view.pointer.pass.cpp | 71 + .../oplt.string_view.string.pass.cpp | 50 + .../oplt.string_view.string_view.pass.cpp | 64 + .../opne.string_view.pointer.pass.cpp | 69 + .../opne.string_view.string.pass.cpp | 49 + .../opne.string_view.string_view.pass.cpp | 61 + .../string.view.cons/default.pass.cpp | 46 + .../string.view.cons/from_literal.pass.cpp | 64 + .../string.view.cons/from_ptr_len.pass.cpp | 81 + .../string.view.cons/from_string.pass.cpp | 54 + .../string.view.cons/from_string1.fail.cpp | 32 + .../string.view.cons/from_string2.fail.cpp | 32 + .../string.view.find/find_char_size.pass.cpp | 84 + .../find_first_not_of_char_size.pass.cpp | 84 + .../find_first_not_of_pointer_size.pass.cpp | 165 + ...nd_first_not_of_pointer_size_size.pass.cpp | 392 + ...ind_first_not_of_string_view_size.pass.cpp | 148 + .../find_first_of_char_size.pass.cpp | 82 + .../find_first_of_pointer_size.pass.cpp | 165 + .../find_first_of_pointer_size_size.pass.cpp | 392 + .../find_first_of_string_view_size.pass.cpp | 148 + .../find_last_not_of_char_size.pass.cpp | 82 + .../find_last_not_of_pointer_size.pass.cpp | 165 + ...ind_last_not_of_pointer_size_size.pass.cpp | 392 + ...find_last_not_of_string_view_size.pass.cpp | 148 + .../find_last_of_char_size.pass.cpp | 82 + .../find_last_of_pointer_size.pass.cpp | 165 + .../find_last_of_pointer_size_size.pass.cpp | 392 + .../find_last_of_string_view_size.pass.cpp | 148 + .../find_pointer_size.pass.cpp | 171 + .../find_pointer_size_size.pass.cpp | 393 + .../find_string_view_size.pass.cpp | 164 + .../string.view.find/rfind_char_size.pass.cpp | 83 + .../rfind_pointer_size.pass.cpp | 171 + .../rfind_pointer_size_size.pass.cpp | 392 + .../rfind_string_view_size.pass.cpp | 164 + .../string.view.hash/string_view.pass.cpp | 55 + .../string.view.io/stream_insert.pass.cpp | 58 + .../string.view.iterators/begin.pass.cpp | 77 + .../string.view.iterators/end.pass.cpp | 85 + .../string.view.iterators/rbegin.pass.cpp | 59 + .../string.view.iterators/rend.pass.cpp | 66 + .../string.view.modifiers/clear.pass.cpp | 65 + .../remove_prefix.pass.cpp | 76 + .../remove_suffix.pass.cpp | 76 + .../string.view.modifiers/swap.pass.cpp | 74 + .../string.view.nonmem/quoted.pass.cpp | 212 + .../string.view.ops/basic_string.pass.cpp | 63 + .../string.view.ops/compare.pointer.pass.cpp | 126 + .../compare.pointer_size.pass.cpp | 444 + .../compare.size_size_sv.pass.cpp | 397 + ...compare.size_size_sv_pointer_size.pass.cpp | 1349 + .../compare.size_size_sv_size_size.pass.cpp | 5843 ++++ .../string.view.ops/compare.sv.pass.cpp | 121 + .../string.view/string.view.ops/copy.pass.cpp | 92 + .../string.view.ops/substr.pass.cpp | 107 + .../string.view.ops/to_string.pass.cpp | 76 + .../string.view.synop/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../meta/meta.type.synop/includes.pass.cpp | 22 + .../meta/meta.type.synop/meta.rel.pass.cpp | 65 + .../meta.type.synop/meta.unary.cat.pass.cpp | 181 + .../meta.type.synop/meta.unary.comp.pass.cpp | 102 + .../meta.type.synop/meta.unary.prop.pass.cpp | 489 + .../meta.unary.prop.query.pass.cpp | 66 + .../utilities/meta/version.pass.cpp | 20 + .../utilities/nothing_to_do.pass.cpp | 13 + .../header.ratio.synop/includes.pass.cpp | 21 + .../header.ratio.synop/ratio_equal_v.pass.cpp | 47 + .../ratio_greater_equal_v.pass.cpp | 61 + .../ratio_greater_v.pass.cpp | 57 + .../ratio_less_equal_v.pass.cpp | 57 + .../header.ratio.synop/ratio_less_v.pass.cpp | 57 + .../ratio_not_equal_v.pass.cpp | 47 + .../utilities/ratio/nothing_to_do.pass.cpp | 13 + .../includes.pass.cpp | 21 + .../is_error_code_enum_v.pass.cpp | 37 + .../is_error_condition_enum.pass.cpp | 38 + .../header.chrono.synop/includes.pass.cpp | 19 + .../treat_as_floating_point_v.pass.cpp | 49 + .../header.tuple.synop/includes.pass.cpp | 19 + .../tuple/tuple.apply/arg_type.pass.cpp | 182 + .../tuple.apply/constexpr_types.pass.cpp | 123 + .../tuple/tuple.apply/extended_types.pass.cpp | 423 + .../tuple/tuple.apply/large_arity.pass.cpp | 146 + .../tuple/tuple.apply/ref_qualifiers.pass.cpp | 53 + .../tuple/tuple.apply/return_type.pass.cpp | 76 + .../tuple/tuple.apply/types.pass.cpp | 427 + .../utilities/tuple/tuple_size_v.fail.cpp | 25 + .../utilities/tuple/tuple_size_v.pass.cpp | 45 + .../utilities/tuple/tuple_size_v_2.fail.cpp | 25 + .../utilities/tuple/tuple_size_v_3.fail.cpp | 25 + .../utility.erased.type/erased_type.pass.cpp | 17 + .../utility/utility.synop/includes.pass.cpp | 20 + .../utilities/utility/version.pass.cpp | 20 + .../extensions/hash/specializations.fail.cpp | 17 + .../extensions/hash/specializations.pass.cpp | 31 + .../hash_map/const_iterator.fail.cpp | 18 + test/std/extensions/nothing_to_do.pass.cpp | 12 + .../file.streams/c.files/cinttypes.pass.cpp | 929 + .../file.streams/c.files/cstdio.pass.cpp | 148 + .../file.streams/c.files/gets.fail.cpp | 23 + .../fopen.fail.cpp | 15 + .../lit.local.cfg | 2 + .../rename.fail.cpp | 15 + .../c.files/version_ccstdio.pass.cpp | 20 + .../c.files/version_cinttypes.pass.cpp | 20 + .../filebuf.assign/member_swap.pass.cpp | 54 + .../filebuf.assign/move_assign.pass.cpp | 56 + .../filebuf.assign/nonmember_swap.pass.cpp | 56 + .../fstreams/filebuf.cons/default.pass.cpp | 30 + .../fstreams/filebuf.cons/move.pass.cpp | 54 + .../filebuf.members/open_pointer.pass.cpp | 51 + .../filebuf.virtuals/overflow.pass.cpp | 142 + .../filebuf.virtuals/pbackfail.pass.cpp | 56 + .../filebuf.virtuals/seekoff.pass.cpp | 66 + .../fstreams/filebuf.virtuals/underflow.dat | 1 + .../filebuf.virtuals/underflow.pass.cpp | 121 + .../filebuf.virtuals/underflow_utf8.dat | 1 + .../fstreams/filebuf/types.pass.cpp | 34 + .../fstream.assign/member_swap.pass.cpp | 71 + .../fstream.assign/move_assign.pass.cpp | 50 + .../fstream.assign/nonmember_swap.pass.cpp | 72 + .../fstreams/fstream.cons/default.pass.cpp | 28 + .../fstreams/fstream.cons/move.pass.cpp | 48 + .../fstreams/fstream.cons/pointer.pass.cpp | 44 + .../fstreams/fstream.cons/string.pass.cpp | 46 + .../fstreams/fstream.members/close.pass.cpp | 42 + .../fstream.members/open_pointer.pass.cpp | 50 + .../fstream.members/open_string.pass.cpp | 50 + .../fstreams/fstream.members/rdbuf.pass.cpp | 30 + .../fstreams/fstream/types.pass.cpp | 34 + .../ifstream.assign/member_swap.pass.cpp | 42 + .../ifstream.assign/move_assign.pass.cpp | 40 + .../ifstream.assign/nonmember_swap.pass.cpp | 43 + .../fstreams/ifstream.assign/test.dat | 1 + .../fstreams/ifstream.assign/test2.dat | 1 + .../fstreams/ifstream.cons/default.pass.cpp | 28 + .../fstreams/ifstream.cons/move.pass.cpp | 38 + .../fstreams/ifstream.cons/pointer.pass.cpp | 46 + .../fstreams/ifstream.cons/string.pass.cpp | 46 + .../fstreams/ifstream.cons/test.dat | 1 + .../fstreams/ifstream.members/close.pass.cpp | 38 + .../ifstream.members/open_pointer.pass.cpp | 46 + .../ifstream.members/open_string.pass.cpp | 46 + .../fstreams/ifstream.members/rdbuf.pass.cpp | 32 + .../fstreams/ifstream.members/test.dat | 1 + .../fstreams/ifstream/types.pass.cpp | 34 + .../file.streams/fstreams/lit.local.cfg | 2 + .../ofstream.assign/member_swap.pass.cpp | 79 + .../ofstream.assign/move_assign.pass.cpp | 52 + .../ofstream.assign/nonmember_swap.pass.cpp | 80 + .../fstreams/ofstream.cons/default.pass.cpp | 28 + .../fstreams/ofstream.cons/move.pass.cpp | 50 + .../fstreams/ofstream.cons/pointer.pass.cpp | 46 + .../fstreams/ofstream.cons/string.pass.cpp | 46 + .../fstreams/ofstream.members/close.pass.cpp | 42 + .../ofstream.members/open_pointer.pass.cpp | 58 + .../ofstream.members/open_string.pass.cpp | 58 + .../fstreams/ofstream.members/rdbuf.pass.cpp | 36 + .../fstreams/ofstream/types.pass.cpp | 34 + .../file.streams/fstreams/version.pass.cpp | 20 + .../file.streams/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../ext.manip/get_money.pass.cpp | 75 + .../ext.manip/get_time.pass.cpp | 73 + .../ext.manip/put_money.pass.cpp | 91 + .../ext.manip/put_time.pass.cpp | 84 + .../iostream.assign/member_swap.pass.cpp | 85 + .../iostream.assign/move_assign.pass.cpp | 92 + .../iostreamclass/iostream.cons/move.pass.cpp | 78 + .../iostream.cons/streambuf.pass.cpp | 55 + .../iostream.dest/nothing_to_do.pass.cpp | 12 + .../iostreamclass/types.pass.cpp | 37 + .../bool.pass.cpp | 79 + .../double.pass.cpp | 79 + .../float.pass.cpp | 79 + .../istream.formatted.arithmetic/int.pass.cpp | 79 + .../long.pass.cpp | 79 + .../long_double.pass.cpp | 79 + .../long_long.pass.cpp | 79 + .../pointer.pass.cpp | 97 + .../short.pass.cpp | 79 + .../unsigned_int.pass.cpp | 79 + .../unsigned_long.pass.cpp | 79 + .../unsigned_long_long.pass.cpp | 79 + .../unsigned_short.pass.cpp | 79 + .../tested_elsewhere.pass.cpp | 12 + .../istream_extractors/basic_ios.pass.cpp | 38 + .../istream_extractors/chart.pass.cpp | 87 + .../istream_extractors/ios_base.pass.cpp | 36 + .../istream_extractors/istream.pass.cpp | 38 + .../istream_extractors/signed_char.pass.cpp | 70 + .../signed_char_pointer.pass.cpp | 85 + .../istream_extractors/streambuf.pass.cpp | 69 + .../istream_extractors/unsigned_char.pass.cpp | 70 + .../unsigned_char_pointer.pass.cpp | 85 + .../wchar_t_pointer.pass.cpp | 85 + .../istream.formatted/nothing_to_do.pass.cpp | 12 + .../input.streams/istream.manip/ws.pass.cpp | 79 + .../istream.rvalue/rvalue.pass.cpp | 63 + .../istream.unformatted/get.pass.cpp | 100 + .../istream.unformatted/get_chart.pass.cpp | 103 + .../get_pointer_size.pass.cpp | 99 + .../get_pointer_size_chart.pass.cpp | 99 + .../get_streambuf.pass.cpp | 88 + .../get_streambuf_chart.pass.cpp | 89 + .../getline_pointer_size.pass.cpp | 83 + .../getline_pointer_size_chart.pass.cpp | 83 + .../istream.unformatted/ignore.pass.cpp | 76 + .../istream.unformatted/ignore_0xff.pass.cpp | 34 + .../istream.unformatted/peek.pass.cpp | 69 + .../istream.unformatted/putback.pass.cpp | 89 + .../istream.unformatted/read.pass.cpp | 81 + .../istream.unformatted/readsome.pass.cpp | 85 + .../istream.unformatted/seekg.pass.cpp | 66 + .../istream.unformatted/seekg_off.pass.cpp | 74 + .../istream.unformatted/sync.pass.cpp | 64 + .../istream.unformatted/tellg.pass.cpp | 63 + .../istream.unformatted/unget.pass.cpp | 81 + .../istream.assign/member_swap.pass.cpp | 85 + .../istream.assign/move_assign.pass.cpp | 92 + .../istream/istream.cons/move.pass.cpp | 78 + .../istream/istream.cons/streambuf.pass.cpp | 55 + .../istream/istream_sentry/ctor.pass.cpp | 128 + .../input.streams/istream/types.pass.cpp | 35 + .../input.streams/version.pass.cpp | 20 + .../iostream.format/nothing_to_do.pass.cpp | 12 + .../ostream.assign/member_swap.pass.cpp | 85 + .../ostream.assign/move_assign.pass.cpp | 92 + .../output.streams/ostream.cons/move.pass.cpp | 74 + .../ostream.cons/streambuf.pass.cpp | 53 + .../ostream.formatted/nothing_to_do.pass.cpp | 12 + .../tested_elsewhere.pass.cpp | 12 + .../bool.pass.cpp | 91 + .../double.pass.cpp | 83 + .../float.pass.cpp | 83 + .../ostream.inserters.arithmetic/int.pass.cpp | 83 + .../long.pass.cpp | 83 + .../long_double.pass.cpp | 83 + .../long_long.pass.cpp | 83 + .../ostream.inserters.arithmetic/minus1.pass | 84 + .../pointer.pass.cpp | 91 + .../short.pass.cpp | 83 + .../unsigned_int.pass.cpp | 83 + .../unsigned_long.pass.cpp | 83 + .../unsigned_long_long.pass.cpp | 83 + .../unsigned_short.pass.cpp | 83 + .../CharT.pass.cpp | 88 + .../CharT_pointer.pass.cpp | 88 + .../ostream.inserters.character/char.pass.cpp | 88 + .../char_pointer.pass.cpp | 88 + .../char_to_wide.pass.cpp | 88 + .../char_to_wide_pointer.pass.cpp | 88 + .../signed_char.pass.cpp | 88 + .../signed_char_pointer.pass.cpp | 88 + .../unsigned_char.pass.cpp | 88 + .../unsigned_char_pointer.pass.cpp | 88 + .../ostream.inserters/basic_ios.pass.cpp | 70 + .../ostream.inserters/ios_base.pass.cpp | 61 + .../ostream.inserters/ostream.pass.cpp | 69 + .../ostream.inserters/streambuf.pass.cpp | 69 + .../ostream.manip/endl.pass.cpp | 80 + .../ostream.manip/ends.pass.cpp | 71 + .../ostream.manip/flush.pass.cpp | 58 + .../ostream.rvalue/CharT_pointer.pass.cpp | 72 + .../ostream.seeks/seekp.pass.cpp | 68 + .../ostream.seeks/seekp2.pass.cpp | 70 + .../ostream.seeks/tellp.pass.cpp | 54 + .../ostream.unformatted/flush.pass.cpp | 54 + .../ostream.unformatted/put.pass.cpp | 76 + .../ostream.unformatted/write.pass.cpp | 76 + .../output.streams/ostream/types.pass.cpp | 35 + .../ostream_sentry/construct.pass.cpp | 61 + .../ostream_sentry/destruct.pass.cpp | 75 + .../output.streams/version.pass.cpp | 20 + .../quoted.manip/quoted.pass.cpp | 219 + .../quoted.manip/quoted_char.fail.cpp | 36 + .../quoted.manip/quoted_traits.fail.cpp | 42 + .../std.manip/resetiosflags.pass.cpp | 54 + .../std.manip/setbase.pass.cpp | 74 + .../std.manip/setfill.pass.cpp | 38 + .../std.manip/setiosflags.pass.cpp | 54 + .../std.manip/setprecision.pass.cpp | 50 + .../iostream.format/std.manip/setw.pass.cpp | 50 + .../std.manip/version.pass.cpp | 20 + .../iostream.forward/iosfwd.pass.cpp | 142 + .../iostream.forward/version.pass.cpp | 20 + .../narrow.stream.objects/cerr.pass.cpp | 29 + .../narrow.stream.objects/cin.pass.cpp | 34 + .../narrow.stream.objects/clog.pass.cpp | 23 + .../narrow.stream.objects/cout.pass.cpp | 29 + .../iostream.objects/version.pass.cpp | 20 + .../wide.stream.objects/wcerr.pass.cpp | 29 + .../wide.stream.objects/wcin.pass.cpp | 34 + .../wide.stream.objects/wclog.pass.cpp | 23 + .../wide.stream.objects/wcout.pass.cpp | 25 + .../fpos/fpos.members/state.pass.cpp | 24 + .../fpos/fpos.operations/addition.pass.cpp | 28 + .../fpos/fpos.operations/ctor_int.pass.cpp | 24 + .../fpos/fpos.operations/difference.pass.cpp | 26 + .../fpos/fpos.operations/eq_int.pass.cpp | 26 + .../fpos/fpos.operations/offset.pass.cpp | 25 + .../fpos/fpos.operations/streamsize.pass.cpp | 24 + .../fpos/fpos.operations/subtraction.pass.cpp | 28 + .../fpos/nothing_to_do.pass.cpp | 12 + .../ios.base/fmtflags.state/flags.pass.cpp | 33 + .../fmtflags.state/flags_fmtflags.pass.cpp | 36 + .../fmtflags.state/precision.pass.cpp | 33 + .../precision_streamsize.pass.cpp | 36 + .../fmtflags.state/setf_fmtflags.pass.cpp | 36 + .../setf_fmtflags_mask.pass.cpp | 36 + .../fmtflags.state/unsetf_mask.pass.cpp | 35 + .../ios.base/fmtflags.state/width.pass.cpp | 33 + .../fmtflags.state/width_streamsize.pass.cpp | 36 + .../register_callback.pass.cpp | 54 + .../ios.base/ios.base.cons/dtor.pass.cpp | 86 + .../ios.base/ios.base.locales/getloc.pass.cpp | 34 + .../ios.base/ios.base.locales/imbue.pass.cpp | 89 + .../ios.base/ios.base.storage/iword.pass.cpp | 42 + .../ios.base/ios.base.storage/pword.pass.cpp | 43 + .../ios.base/ios.base.storage/xalloc.pass.cpp | 26 + .../sync_with_stdio.pass.cpp | 27 + .../ios_Init/tested_elsewhere.pass.cpp | 12 + .../ctor_char_pointer_error_code.pass.cpp | 39 + .../ctor_string_error_code.pass.cpp | 39 + .../ios.types/ios_fmtflags/fmtflags.pass.cpp | 81 + .../ios.types/ios_iostate/iostate.pass.cpp | 36 + .../ios.types/ios_openmode/openmode.pass.cpp | 42 + .../ios.types/ios_seekdir/seekdir.pass.cpp | 26 + .../ios.base/ios.types/nothing_to_do.pass.cpp | 12 + .../ios.base/nothing_to_do.pass.cpp | 16 + .../basic.ios.cons/ctor_streambuf.pass.cpp | 48 + .../ios/basic.ios.members/copyfmt.pass.cpp | 190 + .../ios/basic.ios.members/fill.pass.cpp | 23 + .../basic.ios.members/fill_char_type.pass.cpp | 26 + .../ios/basic.ios.members/imbue.pass.cpp | 101 + .../ios/basic.ios.members/move.pass.cpp | 140 + .../ios/basic.ios.members/narow.pass.cpp | 24 + .../ios/basic.ios.members/rdbuf.pass.cpp | 31 + .../rdbuf_streambuf.pass.cpp | 34 + .../ios/basic.ios.members/set_rdbuf.pass.cpp | 57 + .../ios/basic.ios.members/swap.pass.cpp | 168 + .../ios/basic.ios.members/tie.pass.cpp | 23 + .../basic.ios.members/tie_ostream.pass.cpp | 26 + .../ios/basic.ios.members/widen.pass.cpp | 23 + .../ios/iostate.flags/bad.pass.cpp | 41 + .../ios/iostate.flags/bool.pass.cpp | 25 + .../ios/iostate.flags/clear.pass.cpp | 65 + .../ios/iostate.flags/eof.pass.cpp | 37 + .../ios/iostate.flags/exceptions.pass.cpp | 33 + .../iostate.flags/exceptions_iostate.pass.cpp | 48 + .../ios/iostate.flags/fail.pass.cpp | 41 + .../ios/iostate.flags/good.pass.cpp | 35 + .../ios/iostate.flags/not.pass.cpp | 25 + .../ios/iostate.flags/rdstate.pass.cpp | 25 + .../ios/iostate.flags/setstate.pass.cpp | 64 + .../iostreams.base/ios/types.pass.cpp | 33 + .../adjustfield.manip/internal.pass.cpp | 29 + .../adjustfield.manip/left.pass.cpp | 29 + .../adjustfield.manip/right.pass.cpp | 29 + .../basefield.manip/dec.pass.cpp | 29 + .../basefield.manip/hex.pass.cpp | 29 + .../basefield.manip/oct.pass.cpp | 29 + .../iostream_category.pass.cpp | 23 + .../error.reporting/make_error_code.pass.cpp | 24 + .../make_error_condition.pass.cpp | 24 + .../floatfield.manip/defaultfloat.pass.cpp | 30 + .../floatfield.manip/fixed.pass.cpp | 29 + .../floatfield.manip/hexfloat.pass.cpp | 30 + .../floatfield.manip/scientific.pass.cpp | 29 + .../fmtflags.manip/boolalpha.pass.cpp | 29 + .../fmtflags.manip/noboolalpha.pass.cpp | 30 + .../fmtflags.manip/noshowbase.pass.cpp | 30 + .../fmtflags.manip/noshowpoint.pass.cpp | 30 + .../fmtflags.manip/noshowpos.pass.cpp | 30 + .../fmtflags.manip/noskipws.pass.cpp | 30 + .../fmtflags.manip/nounitbuf.pass.cpp | 30 + .../fmtflags.manip/nouppercase.pass.cpp | 30 + .../fmtflags.manip/showbase.pass.cpp | 29 + .../fmtflags.manip/showpoint.pass.cpp | 29 + .../fmtflags.manip/showpos.pass.cpp | 29 + .../fmtflags.manip/skipws.pass.cpp | 29 + .../fmtflags.manip/unitbuf.pass.cpp | 29 + .../fmtflags.manip/uppercase.pass.cpp | 29 + .../std.ios.manip/nothing_to_do.pass.cpp | 12 + .../stream.types/streamoff.pass.cpp | 21 + .../stream.types/streamsize.pass.cpp | 21 + .../iostreams.base/version.pass.cpp | 20 + .../tested_elsewhere.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + test/std/input.output/nothing_to_do.pass.cpp | 12 + .../streambuf.reqts/tested_elsewhere.pass.cpp | 12 + .../streambuf/streambuf.cons/copy.fail.cpp | 25 + .../streambuf/streambuf.cons/copy.pass.cpp | 84 + .../streambuf/streambuf.cons/default.fail.cpp | 22 + .../streambuf/streambuf.cons/default.pass.cpp | 56 + .../streambuf.members/nothing_to_do.pass.cpp | 12 + .../streambuf.buffer/pubseekoff.pass.cpp | 35 + .../streambuf.buffer/pubseekpos.pass.cpp | 34 + .../streambuf.buffer/pubsetbuf.pass.cpp | 33 + .../streambuf.buffer/pubsync.pass.cpp | 33 + .../streambuf.locales/locales.pass.cpp | 52 + .../streambuf.pub.get/in_avail.pass.cpp | 52 + .../streambuf.pub.get/sbumpc.pass.cpp | 56 + .../streambuf.pub.get/sgetc.pass.cpp | 56 + .../streambuf.pub.get/sgetn.pass.cpp | 41 + .../streambuf.pub.get/snextc.pass.cpp | 56 + .../streambuf.pub.pback/sputbackc.pass.cpp | 56 + .../streambuf.pub.pback/sungetc.pass.cpp | 56 + .../streambuf.pub.put/sputc.pass.cpp | 63 + .../streambuf.pub.put/sputn.pass.cpp | 41 + .../nothing_to_do.pass.cpp | 12 + .../streambuf.assign/assign.pass.cpp | 91 + .../streambuf.assign/swap.pass.cpp | 101 + .../streambuf.get.area/gbump.pass.cpp | 59 + .../streambuf.get.area/setg.pass.cpp | 49 + .../streambuf.put.area/pbump.pass.cpp | 61 + .../streambuf.put.area/setp.pass.cpp | 49 + .../streambuf.virtuals/nothing_to_do.pass.cpp | 12 + .../tested_elsewhere.pass.cpp | 12 + .../streambuf.virt.get/showmanyc.pass.cpp | 33 + .../streambuf.virt.get/uflow.pass.cpp | 33 + .../streambuf.virt.get/underflow.pass.cpp | 30 + .../streambuf.virt.get/xsgetn.pass.cpp | 41 + .../nothing_to_do.pass.cpp | 12 + .../streambuf.virt.pback/pbackfail.pass.cpp | 32 + .../streambuf.virt.put/overflow.pass.cpp | 30 + .../streambuf.virt.put/xsputn.pass.cpp | 44 + .../stream.buffers/streambuf/types.pass.cpp | 39 + .../stream.buffers/version.pass.cpp | 20 + .../istringstream.assign/member_swap.pass.cpp | 56 + .../istringstream.assign/move.pass.cpp | 86 + .../nonmember_swap.pass.cpp | 59 + .../istringstream.cons/default.pass.cpp | 46 + .../istringstream.cons/move.pass.cpp | 48 + .../istringstream.cons/string.pass.cpp | 67 + .../istringstream.members/str.pass.cpp | 56 + .../istringstream/types.pass.cpp | 36 + .../ostringstream.assign/member_swap.pass.cpp | 48 + .../ostringstream.assign/move.pass.cpp | 46 + .../nonmember_swap.pass.cpp | 48 + .../ostringstream.cons/default.pass.cpp | 46 + .../ostringstream.cons/move.pass.cpp | 44 + .../ostringstream.cons/string.pass.cpp | 59 + .../ostringstream.members/str.pass.cpp | 52 + .../ostringstream/types.pass.cpp | 36 + .../stringbuf.assign/member_swap.pass.cpp | 64 + .../stringbuf/stringbuf.assign/move.pass.cpp | 58 + .../stringbuf.assign/nonmember_swap.pass.cpp | 66 + .../stringbuf/stringbuf.cons/default.pass.cpp | 30 + .../stringbuf/stringbuf.cons/move.pass.cpp | 52 + .../stringbuf/stringbuf.cons/string.pass.cpp | 47 + .../stringbuf/stringbuf.members/str.pass.cpp | 34 + .../stringbuf.virtuals/overflow.pass.cpp | 97 + .../stringbuf.virtuals/pbackfail.pass.cpp | 92 + .../stringbuf.virtuals/seekoff.pass.cpp | 143 + .../stringbuf.virtuals/seekpos.pass.cpp | 77 + .../stringbuf.virtuals/setbuf.pass.cpp | 32 + .../stringbuf.virtuals/underflow.pass.cpp | 70 + .../string.streams/stringbuf/types.pass.cpp | 36 + .../stringstream.cons/default.pass.cpp | 46 + .../stringstream.cons/move.pass.cpp | 52 + .../stringstream.cons/move2.pass.cpp | 37 + .../stringstream.cons/string.pass.cpp | 49 + .../stringstream.assign/member_swap.pass.cpp | 56 + .../stringstream.assign/move.pass.cpp | 54 + .../nonmember_swap.pass.cpp | 59 + .../stringstream.members/str.pass.cpp | 62 + .../stringstream/types.pass.cpp | 36 + .../string.streams/version.pass.cpp | 20 + .../iterator.container/data.pass.cpp | 74 + .../iterator.container/empty.pass.cpp | 77 + .../iterator.container/size.pass.cpp | 76 + .../iterator.basic/iterator.pass.cpp | 82 + .../iterator.operations/advance.pass.cpp | 45 + .../iterator.operations/distance.pass.cpp | 40 + .../iterator.operations/next.pass.cpp | 46 + .../iterator.operations/prev.pass.cpp | 44 + .../iterator.traits/const_pointer.pass.cpp | 35 + .../iterator.traits/empty.pass.cpp | 38 + .../iterator.traits/iterator.pass.cpp | 43 + .../iterator.traits/pointer.pass.cpp | 35 + .../nothing_to_do.pass.cpp | 12 + .../bidirectional_iterator_tag.pass.cpp | 24 + .../forward_iterator_tag.pass.cpp | 24 + .../input_iterator_tag.pass.cpp | 22 + .../output_iterator_tag.pass.cpp | 22 + .../random_access_iterator_tag.pass.cpp | 24 + .../iterator.range/begin-end.pass.cpp | 146 + .../nothing_to_do.pass.cpp | 12 + .../forward.iterators/nothing_to_do.pass.cpp | 12 + .../input.iterators/nothing_to_do.pass.cpp | 12 + .../iterator.iterators/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../output.iterators/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../iterator.synopsis/nothing_to_do.pass.cpp | 12 + .../iterators.general/gcc_workaround.pass.cpp | 20 + .../iterators.general/nothing_to_do.pass.cpp | 12 + .../back.insert.iter.cons/container.fail.cpp | 24 + .../back.insert.iter.cons/container.pass.cpp | 31 + .../back.insert.iter.op++/post.pass.cpp | 36 + .../back.insert.iter.op++/pre.pass.cpp | 34 + .../back.insert.iter.op=/lv_value.pass.cpp | 46 + .../back.insert.iter.op=/rv_value.pass.cpp | 42 + .../back.insert.iter.op_astrk/test.pass.cpp | 34 + .../back.inserter/test.pass.cpp | 35 + .../nothing_to_do.pass.cpp | 12 + .../back.insert.iterator/types.pass.cpp | 59 + .../front.insert.iter.cons/container.fail.cpp | 24 + .../front.insert.iter.cons/container.pass.cpp | 31 + .../front.insert.iter.op++/post.pass.cpp | 36 + .../front.insert.iter.op++/pre.pass.cpp | 34 + .../front.insert.iter.op=/lv_value.pass.cpp | 47 + .../front.insert.iter.op=/rv_value.pass.cpp | 41 + .../front.insert.iter.op_astrk/test.pass.cpp | 34 + .../front.inserter/test.pass.cpp | 35 + .../nothing_to_do.pass.cpp | 12 + .../front.insert.iterator/types.pass.cpp | 60 + .../insert.iter.cons/test.pass.cpp | 31 + .../insert.iter.op++/post.pass.cpp | 36 + .../insert.iter.op++/pre.pass.cpp | 34 + .../insert.iter.op=/lv_value.pass.cpp | 85 + .../insert.iter.op=/rv_value.pass.cpp | 98 + .../insert.iter.op_astrk/test.pass.cpp | 34 + .../insert.iter.ops/inserter/test.pass.cpp | 35 + .../insert.iter.ops/nothing_to_do.pass.cpp | 12 + .../insert.iterator/types.pass.cpp | 64 + .../insert.iterators/nothing_to_do.pass.cpp | 12 + .../make_move_iterator.pass.cpp | 46 + .../move.iter.nonmember/minus.pass.cpp | 39 + .../move.iter.nonmember/plus.pass.cpp | 37 + .../move.iter.op.+/difference_type.pass.cpp | 36 + .../move.iter.op.+=/difference_type.pass.cpp | 37 + .../move.iter.op.-/difference_type.pass.cpp | 36 + .../move.iter.op.-=/difference_type.pass.cpp | 37 + .../move.iter.op.comp/op_eq.pass.cpp | 46 + .../move.iter.op.comp/op_gt.pass.cpp | 42 + .../move.iter.op.comp/op_gte.pass.cpp | 42 + .../move.iter.op.comp/op_lt.pass.cpp | 42 + .../move.iter.op.comp/op_lte.pass.cpp | 42 + .../move.iter.op.comp/op_neq.pass.cpp | 46 + .../move.iter.op.const/convert.fail.cpp | 38 + .../move.iter.op.const/convert.pass.cpp | 44 + .../move.iter.op.const/default.pass.cpp | 34 + .../move.iter.op.const/iter.fail.cpp | 31 + .../move.iter.op.const/iter.pass.cpp | 37 + .../tested_elsewhere.pass.cpp | 12 + .../move.iter.op.decr/post.pass.cpp | 37 + .../move.iter.op.decr/pre.pass.cpp | 37 + .../move.iter.op.incr/post.pass.cpp | 39 + .../move.iter.op.incr/pre.pass.cpp | 39 + .../difference_type.pass.cpp | 58 + .../move.iter.op.ref/op_arrow.pass.cpp | 31 + .../move.iter.op.star/op_star.pass.cpp | 61 + .../move.iter.op=/move_iterator.fail.cpp | 39 + .../move.iter.op=/move_iterator.pass.cpp | 47 + .../move.iter.ops/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../move.iterator/types.pass.cpp | 56 + .../move.iterators/nothing_to_do.pass.cpp | 12 + .../predef.iterators/nothing_to_do.pass.cpp | 12 + .../reverse.iterators/nothing_to_do.pass.cpp | 12 + .../reverse.iter.ops/nothing_to_do.pass.cpp | 12 + .../reverse.iter.cons/default.pass.cpp | 33 + .../reverse.iter.cons/iter.fail.cpp | 31 + .../reverse.iter.cons/iter.pass.cpp | 35 + .../reverse_iterator.fail.cpp | 38 + .../reverse_iterator.pass.cpp | 42 + .../tested_elsewhere.pass.cpp | 12 + .../make_reverse_iterator.pass.cpp | 42 + .../reverse.iter.op!=/test.pass.cpp | 42 + .../reverse.iter.op++/post.pass.cpp | 37 + .../reverse.iter.op++/pre.pass.cpp | 37 + .../reverse.iter.op+/difference_type.pass.cpp | 36 + .../difference_type.pass.cpp | 37 + .../reverse.iter.op--/post.pass.cpp | 37 + .../reverse.iter.op--/pre.pass.cpp | 37 + .../reverse.iter.op-/difference_type.pass.cpp | 36 + .../difference_type.pass.cpp | 37 + .../reverse.iter.op.star/op_star.pass.cpp | 47 + .../reverse_iterator.fail.cpp | 39 + .../reverse_iterator.pass.cpp | 45 + .../reverse.iter.op==/test.pass.cpp | 42 + .../reverse.iter.opdiff/test.pass.cpp | 43 + .../reverse.iter.opgt/test.pass.cpp | 42 + .../reverse.iter.opgt=/test.pass.cpp | 42 + .../difference_type.pass.cpp | 38 + .../reverse.iter.oplt/test.pass.cpp | 42 + .../reverse.iter.oplt=/test.pass.cpp | 42 + .../reverse.iter.opref/op_arrow.pass.cpp | 89 + .../difference_type.pass.cpp | 37 + .../nothing_to_do.pass.cpp | 12 + .../reverse.iterator/types.pass.cpp | 61 + .../istream.iterator.cons/copy.pass.cpp | 36 + .../istream.iterator.cons/default.fail.cpp | 30 + .../istream.iterator.cons/default.pass.cpp | 30 + .../istream.iterator.cons/istream.pass.cpp | 30 + .../istream.iterator.ops/arrow.pass.cpp | 37 + .../istream.iterator.ops/dereference.pass.cpp | 34 + .../istream.iterator.ops/equal.pass.cpp | 52 + .../post_increment.pass.cpp | 32 + .../pre_increment.pass.cpp | 29 + .../istream.iterator/types.pass.cpp | 56 + .../istreambuf.iterator.cons/default.pass.cpp | 41 + .../istreambuf.iterator.cons/istream.pass.cpp | 42 + .../istreambuf.iterator.cons/proxy.pass.cpp | 36 + .../streambuf.pass.cpp | 50 + .../istreambuf.iterator_equal/equal.pass.cpp | 78 + .../not_equal.pass.cpp | 80 + .../dereference.pass.cpp | 40 + .../istreambuf.iterator_op==/equal.pass.cpp | 80 + .../arrow.pass.cpp | 28 + .../post_increment.pass.cpp | 38 + .../pre_increment.pass.cpp | 39 + .../istreambuf.iterator_proxy/proxy.pass.cpp | 44 + .../istreambuf.iterator/types.pass.cpp | 60 + .../iterator.range/begin_array.pass.cpp | 24 + .../iterator.range/begin_const.pass.cpp | 23 + .../iterator.range/begin_non_const.pass.cpp | 25 + .../iterator.range/end_array.pass.cpp | 24 + .../iterator.range/end_const.pass.cpp | 23 + .../iterator.range/end_non_const.pass.cpp | 23 + .../stream.iterators/nothing_to_do.pass.cpp | 12 + .../ostream.iterator.cons.des/copy.pass.cpp | 26 + .../ostream.pass.cpp | 25 + .../ostream_delem.pass.cpp | 32 + .../ostream.iterator.ops/assign_t.pass.cpp | 46 + .../ostream.iterator.ops/dereference.pass.cpp | 26 + .../ostream.iterator.ops/increment.pass.cpp | 29 + .../ostream.iterator/types.pass.cpp | 40 + .../ostreambuf.iter.cons/ostream.pass.cpp | 32 + .../ostreambuf.iter.cons/streambuf.pass.cpp | 32 + .../ostreambuf.iter.ops/assign_c.pass.cpp | 39 + .../ostreambuf.iter.ops/deref.pass.cpp | 34 + .../ostreambuf.iter.ops/failed.pass.cpp | 30 + .../ostreambuf.iter.ops/increment.pass.cpp | 39 + .../ostreambuf.iterator/types.pass.cpp | 44 + test/std/iterators/version.pass.cpp | 20 + .../cstdint/cstdint.syn/cstdint.pass.cpp | 292 + .../language.support/cstdint/version.pass.cpp | 20 + .../language.support/nothing_to_do.pass.cpp | 12 + .../alloc.errors/bad.alloc/bad_alloc.pass.cpp | 27 + .../new.badlength/bad_array_length.pass.cpp | 29 + .../bad_array_new_length.pass.cpp | 27 + .../new.handler/new_handler.pass.cpp | 19 + .../alloc.errors/nothing_to_do.pass.cpp | 12 + .../set.new.handler/get_new_handler.pass.cpp | 25 + .../set.new.handler/set_new_handler.pass.cpp | 22 + .../new.delete.array/new_array.pass.cpp | 57 + .../new_array_nothrow.pass.cpp | 54 + .../new_array_nothrow_replace.pass.cpp | 51 + .../new_array_replace.pass.cpp | 51 + .../sized_delete_array11.pass.cpp | 68 + .../sized_delete_array14.pass.cpp | 73 + ..._array_calls_unsized_delete_array.pass.cpp | 56 + ...zed_delete_array_fsizeddeallocation.sh.cpp | 80 + .../not_testable.pass.cpp | 12 + .../new.delete.placement/new.pass.cpp | 30 + .../new.delete.placement/new_array.pass.cpp | 30 + .../new.delete/new.delete.single/new.pass.cpp | 57 + .../new.delete.single/new_nothrow.pass.cpp | 54 + .../new_nothrow_replace.pass.cpp | 51 + .../new.delete.single/new_replace.pass.cpp | 51 + .../new.delete.single/sized_delete11.pass.cpp | 56 + .../new.delete.single/sized_delete14.pass.cpp | 62 + ...sized_delete_calls_unsized_delete.pass.cpp | 45 + .../sized_delete_fsizeddeallocation.sh.cpp | 69 + .../new.delete/nothing_to_do.pass.cpp | 12 + .../support.dynamic/version.pass.cpp | 20 + .../bad.exception/bad_exception.pass.cpp | 27 + .../except.nested/assign.pass.cpp | 59 + .../except.nested/ctor_copy.pass.cpp | 57 + .../except.nested/ctor_default.pass.cpp | 55 + .../except.nested/rethrow_if_nested.pass.cpp | 89 + .../except.nested/rethrow_nested.pass.cpp | 70 + .../except.nested/throw_with_nested.pass.cpp | 119 + .../nothing_to_do.pass.cpp | 12 + .../set.terminate/get_terminate.pass.cpp | 25 + .../set.terminate/set_terminate.pass.cpp | 23 + .../terminate_handler.pass.cpp | 19 + .../terminate/terminate.pass.cpp | 26 + .../exception/exception.pass.cpp | 25 + .../propagation/current_exception.pass.cpp | 269 + .../propagation/exception_ptr.pass.cpp | 34 + .../propagation/make_exception_ptr.pass.cpp | 49 + .../propagation/rethrow_exception.pass.cpp | 57 + .../uncaught/uncaught_exception.pass.cpp | 45 + .../uncaught/uncaught_exceptions.pass.cpp | 45 + .../support.exception/version.pass.cpp | 20 + .../support.general/nothing_to_do.pass.cpp | 12 + .../support.initlist.access/access.pass.cpp | 62 + .../support.initlist.cons/default.pass.cpp | 29 + .../support.initlist.range/begin_end.pass.cpp | 59 + .../support.initlist/types.pass.cpp | 37 + .../support.initlist/version.pass.cpp | 20 + .../support.limits/c.limits/cfloat.pass.cpp | 140 + .../support.limits/c.limits/climits.pass.cpp | 92 + .../c.limits/version_cfloat.pass.cpp | 20 + .../c.limits/version_climits.pass.cpp | 20 + .../limits/denorm.style/check_values.pass.cpp | 38 + .../limits/is_specialized.pass.cpp | 71 + .../const_data_members.pass.cpp | 199 + .../denorm_min.pass.cpp | 53 + .../numeric.limits.members/digits.pass.cpp | 53 + .../numeric.limits.members/digits10.pass.cpp | 57 + .../numeric.limits.members/epsilon.pass.cpp | 54 + .../has_denorm.pass.cpp | 52 + .../has_denorm_loss.pass.cpp | 52 + .../has_infinity.pass.cpp | 52 + .../has_quiet_NaN.pass.cpp | 52 + .../has_signaling_NaN.pass.cpp | 52 + .../numeric.limits.members/infinity.pass.cpp | 58 + .../is_bounded.pass.cpp | 52 + .../numeric.limits.members/is_exact.pass.cpp | 52 + .../numeric.limits.members/is_iec559.pass.cpp | 56 + .../is_integer.pass.cpp | 52 + .../numeric.limits.members/is_modulo.pass.cpp | 52 + .../numeric.limits.members/is_signed.pass.cpp | 52 + .../numeric.limits.members/lowest.pass.cpp | 60 + .../numeric.limits.members/max.pass.cpp | 60 + .../max_digits10.pass.cpp | 53 + .../max_exponent.pass.cpp | 53 + .../max_exponent10.pass.cpp | 53 + .../numeric.limits.members/min.pass.cpp | 60 + .../min_exponent.pass.cpp | 53 + .../min_exponent10.pass.cpp | 53 + .../numeric.limits.members/quiet_NaN.pass.cpp | 73 + .../numeric.limits.members/radix.pass.cpp | 53 + .../round_error.pass.cpp | 54 + .../round_style.pass.cpp | 52 + .../signaling_NaN.pass.cpp | 73 + .../tinyness_before.pass.cpp | 52 + .../numeric.limits.members/traps.pass.cpp | 58 + .../limits/numeric.limits/default.pass.cpp | 83 + .../numeric.special/nothing_to_do.pass.cpp | 12 + .../limits/round.style/check_values.pass.cpp | 34 + .../support.limits/limits/version.pass.cpp | 20 + .../support.limits/nothing_to_do.pass.cpp | 12 + .../support.rtti/bad.cast/bad_cast.pass.cpp | 27 + .../bad.typeid/bad_typeid.pass.cpp | 27 + .../support.rtti/type.info/type_info.pass.cpp | 26 + .../type.info/type_info_hash.pass.cpp | 23 + .../support.rtti/version.pass.cpp | 20 + .../support.runtime/csetjmp.pass.cpp | 24 + .../support.runtime/csignal.pass.cpp | 57 + .../support.runtime/cstdarg.pass.cpp | 35 + .../support.runtime/cstdbool.pass.cpp | 32 + .../support.runtime/cstdlib.pass.cpp | 88 + .../support.runtime/ctime.pass.cpp | 42 + .../support.runtime/version_csetjmp.pass.cpp | 20 + .../support.runtime/version_csignal.pass.cpp | 20 + .../support.runtime/version_cstdarg.pass.cpp | 20 + .../support.runtime/version_cstdbool.pass.cpp | 20 + .../support.runtime/version_cstdlib.pass.cpp | 20 + .../support.runtime/version_ctime.pass.cpp | 20 + .../support.start.term/quick_exit.pass.cpp | 23 + .../quick_exit_check1.fail.cpp | 25 + .../quick_exit_check2.fail.cpp | 25 + .../support.types/max_align_t.pass.cpp | 34 + .../support.types/null.pass.cpp | 18 + .../support.types/nullptr_t.pass.cpp | 79 + .../nullptr_t_integral_cast.fail.cpp | 17 + .../nullptr_t_integral_cast.pass.cpp | 24 + .../support.types/offsetof.pass.cpp | 26 + .../support.types/ptrdiff_t.pass.cpp | 27 + .../support.types/size_t.pass.cpp | 27 + .../support.types/version.pass.cpp | 20 + .../localization/c.locales/clocale.pass.cpp | 54 + .../localization/c.locales/version.pass.cpp | 20 + .../locale.categories/__scan_keyword.pass.cpp | 118 + .../locale.collate.byname/compare.pass.cpp | 87 + .../locale.collate.byname/hash.pass.cpp | 41 + .../locale.collate.byname/transform.pass.cpp | 69 + .../locale.collate.byname/types.pass.cpp | 45 + .../locale.collate/ctor.pass.cpp | 67 + .../locale.collate.members/compare.pass.cpp | 49 + .../locale.collate.members/hash.pass.cpp | 39 + .../locale.collate.members/transform.pass.cpp | 33 + .../tested_elsewhere.pass.cpp | 12 + .../locale.collate/types.pass.cpp | 49 + .../category.collate/nothing_to_do.pass.cpp | 12 + .../category.ctype/ctype_base.pass.cpp | 78 + .../facet.ctype.char.dtor/dtor.pass.cpp | 40 + .../facet.ctype.char.members/ctor.pass.cpp | 50 + .../facet.ctype.char.members/is_1.pass.cpp | 59 + .../facet.ctype.char.members/is_many.pass.cpp | 118 + .../narrow_1.pass.cpp | 33 + .../narrow_many.pass.cpp | 38 + .../facet.ctype.char.members/scan_is.pass.cpp | 44 + .../scan_not.pass.cpp | 44 + .../facet.ctype.char.members/table.pass.cpp | 33 + .../tolower_1.pass.cpp | 33 + .../tolower_many.pass.cpp | 36 + .../toupper_1.pass.cpp | 33 + .../toupper_many.pass.cpp | 36 + .../facet.ctype.char.members/widen_1.pass.cpp | 33 + .../widen_many.pass.cpp | 38 + .../classic_table.pass.cpp | 59 + .../tested_elsewhere.pass.cpp | 12 + .../facet.ctype.special/types.pass.cpp | 38 + .../locale.codecvt.byname/ctor_char.pass.cpp | 70 + .../ctor_char16_t.pass.cpp | 70 + .../ctor_char32_t.pass.cpp | 70 + .../ctor_wchar_t.pass.cpp | 72 + .../locale.codecvt/codecvt_base.pass.cpp | 27 + .../locale.codecvt/ctor_char.pass.cpp | 52 + .../locale.codecvt/ctor_char16_t.pass.cpp | 58 + .../locale.codecvt/ctor_char32_t.pass.cpp | 58 + .../locale.codecvt/ctor_wchar_t.pass.cpp | 52 + .../char16_t_always_noconv.pass.cpp | 26 + .../char16_t_encoding.pass.cpp | 26 + .../char16_t_in.pass.cpp | 40 + .../char16_t_length.pass.cpp | 32 + .../char16_t_max_length.pass.cpp | 26 + .../char16_t_out.pass.cpp | 45 + .../char16_t_unshift.pass.cpp | 33 + .../char32_t_always_noconv.pass.cpp | 26 + .../char32_t_encoding.pass.cpp | 26 + .../char32_t_in.pass.cpp | 40 + .../char32_t_length.pass.cpp | 32 + .../char32_t_max_length.pass.cpp | 26 + .../char32_t_out.pass.cpp | 45 + .../char32_t_unshift.pass.cpp | 33 + .../char_always_noconv.pass.cpp | 26 + .../char_encoding.pass.cpp | 26 + .../locale.codecvt.members/char_in.pass.cpp | 38 + .../char_length.pass.cpp | 32 + .../char_max_length.pass.cpp | 26 + .../locale.codecvt.members/char_out.pass.cpp | 38 + .../char_unshift.pass.cpp | 33 + .../utf_sanity_check.pass.cpp | 127 + .../wchar_t_always_noconv.pass.cpp | 26 + .../wchar_t_encoding.pass.cpp | 26 + .../wchar_t_in.pass.cpp | 42 + .../wchar_t_length.pass.cpp | 32 + .../wchar_t_max_length.pass.cpp | 26 + .../wchar_t_out.pass.cpp | 69 + .../wchar_t_unshift.pass.cpp | 35 + .../tested_elsewhere.pass.cpp | 12 + .../locale.codecvt/types_char.pass.cpp | 40 + .../locale.codecvt/types_char16_t.pass.cpp | 42 + .../locale.codecvt/types_char32_t.pass.cpp | 42 + .../locale.codecvt/types_wchar_t.pass.cpp | 40 + .../locale.ctype.byname/is_1.pass.cpp | 112 + .../locale.ctype.byname/is_many.pass.cpp | 247 + .../locale.ctype.byname/mask.pass.cpp | 53 + .../locale.ctype.byname/narrow_1.pass.cpp | 56 + .../locale.ctype.byname/narrow_many.pass.cpp | 64 + .../locale.ctype.byname/scan_is.pass.cpp | 71 + .../locale.ctype.byname/scan_not.pass.cpp | 71 + .../locale.ctype.byname/tolower_1.pass.cpp | 91 + .../locale.ctype.byname/tolower_many.pass.cpp | 96 + .../locale.ctype.byname/toupper_1.pass.cpp | 91 + .../locale.ctype.byname/toupper_many.pass.cpp | 96 + .../locale.ctype.byname/types.pass.cpp | 71 + .../locale.ctype.byname/widen_1.pass.cpp | 58 + .../locale.ctype.byname/widen_many.pass.cpp | 65 + .../category.ctype/locale.ctype/ctor.pass.cpp | 51 + .../locale.ctype.members/is_1.pass.cpp | 59 + .../locale.ctype.members/is_many.pass.cpp | 118 + .../locale.ctype.members/narrow_1.pass.cpp | 33 + .../locale.ctype.members/narrow_many.pass.cpp | 38 + .../locale.ctype.members/scan_is.pass.cpp | 44 + .../locale.ctype.members/scan_not.pass.cpp | 44 + .../locale.ctype.members/tolower_1.pass.cpp | 33 + .../tolower_many.pass.cpp | 36 + .../locale.ctype.members/toupper_1.pass.cpp | 33 + .../toupper_many.pass.cpp | 36 + .../locale.ctype.members/widen_1.pass.cpp | 33 + .../locale.ctype.members/widen_many.pass.cpp | 38 + .../tested_elsewhere.pass.cpp | 12 + .../locale.ctype/types.pass.cpp | 38 + .../nothing_to_do.pass.cpp | 12 + .../locale.messages/ctor.pass.cpp | 52 + .../not_testable.pass.cpp | 34 + .../tested_elsewhere.pass.cpp | 12 + .../locale.messages/messages_base.pass.cpp | 24 + .../locale.messages/types.pass.cpp | 34 + .../category.messages/nothing_to_do.pass.cpp | 12 + .../locale.money.get/ctor.pass.cpp | 52 + .../get_long_double_en_US.pass.cpp | 723 + .../get_long_double_fr_FR.pass.cpp | 726 + .../get_long_double_ru_RU.pass.cpp | 735 + .../get_long_double_zh_CN.pass.cpp | 726 + .../get_string_en_US.pass.cpp | 731 + .../tested_elsewhere.pass.cpp | 12 + .../locale.money.get/types.pass.cpp | 34 + .../locale.money.put/ctor.pass.cpp | 52 + .../put_long_double_en_US.pass.cpp | 494 + .../put_long_double_fr_FR.pass.cpp | 495 + .../put_long_double_ru_RU.pass.cpp | 501 + .../put_long_double_zh_CN.pass.cpp | 496 + .../put_string_en_US.pass.cpp | 494 + .../tested_elsewhere.pass.cpp | 12 + .../locale.money.put/types.pass.cpp | 34 + .../curr_symbol.pass.cpp | 147 + .../decimal_point.pass.cpp | 148 + .../frac_digits.pass.cpp | 145 + .../grouping.pass.cpp | 150 + .../neg_format.pass.cpp | 227 + .../negative_sign.pass.cpp | 145 + .../pos_format.pass.cpp | 227 + .../positive_sign.pass.cpp | 145 + .../thousands_sep.pass.cpp | 151 + .../locale.moneypunct/ctor.pass.cpp | 52 + .../curr_symbol.pass.cpp | 75 + .../decimal_point.pass.cpp | 75 + .../frac_digits.pass.cpp | 75 + .../grouping.pass.cpp | 75 + .../neg_format.pass.cpp | 88 + .../negative_sign.pass.cpp | 76 + .../pos_format.pass.cpp | 88 + .../positive_sign.pass.cpp | 75 + .../thousands_sep.pass.cpp | 75 + .../tested_elsewhere.pass.cpp | 12 + .../locale.moneypunct/money_base.pass.cpp | 33 + .../locale.moneypunct/types.pass.cpp | 48 + .../category.monetary/nothing_to_do.pass.cpp | 12 + .../locale.nm.put/ctor.pass.cpp | 52 + .../facet.num.put.members/put_bool.pass.cpp | 100 + .../facet.num.put.members/put_double.pass.cpp | 17887 +++++++++++ .../facet.num.put.members/put_long.pass.cpp | 371 + .../put_long_double.pass.cpp | 26248 ++++++++++++++++ .../put_long_long.pass.cpp | 344 + .../put_pointer.pass.cpp | 43 + .../put_unsigned_long.pass.cpp | 374 + .../put_unsigned_long_long.pass.cpp | 344 + .../tested_elsewhere.pass.cpp | 12 + .../locale.nm.put/types.pass.cpp | 32 + .../locale.num.get/ctor.pass.cpp | 52 + .../facet.num.get.members/get_bool.pass.cpp | 230 + .../facet.num.get.members/get_double.pass.cpp | 256 + .../facet.num.get.members/get_float.pass.cpp | 171 + .../facet.num.get.members/get_long.pass.cpp | 519 + .../get_long_double.pass.cpp | 231 + .../get_long_long.pass.cpp | 105 + .../get_pointer.pass.cpp | 61 + .../get_unsigned_int.pass.cpp | 83 + .../get_unsigned_long.pass.cpp | 83 + .../get_unsigned_long_long.pass.cpp | 83 + .../get_unsigned_short.pass.cpp | 83 + .../test_min_max.pass.cpp | 62 + .../tested_elsewhere.pass.cpp | 12 + .../locale.num.get/types.pass.cpp | 32 + .../category.numeric/nothing_to_do.pass.cpp | 12 + .../date_order.pass.cpp | 55 + .../date_order_wide.pass.cpp | 55 + .../locale.time.get.byname/get_date.pass.cpp | 99 + .../get_date_wide.pass.cpp | 98 + .../get_monthname.pass.cpp | 92 + .../get_monthname_wide.pass.cpp | 101 + .../locale.time.get.byname/get_one.pass.cpp | 168 + .../get_one_wide.pass.cpp | 170 + .../locale.time.get.byname/get_time.pass.cpp | 94 + .../get_time_wide.pass.cpp | 94 + .../get_weekday.pass.cpp | 91 + .../get_weekday_wide.pass.cpp | 89 + .../locale.time.get.byname/get_year.pass.cpp | 85 + .../get_year_wide.pass.cpp | 85 + .../locale.time.get/ctor.pass.cpp | 52 + .../date_order.pass.cpp | 34 + .../locale.time.get.members/get_date.pass.cpp | 51 + .../get_date_wide.pass.cpp | 51 + .../locale.time.get.members/get_many.pass.cpp | 68 + .../get_monthname.pass.cpp | 265 + .../get_monthname_wide.pass.cpp | 265 + .../locale.time.get.members/get_one.pass.cpp | 305 + .../locale.time.get.members/get_time.pass.cpp | 117 + .../get_time_wide.pass.cpp | 117 + .../get_weekday.pass.cpp | 220 + .../get_weekday_wide.pass.cpp | 220 + .../locale.time.get.members/get_year.pass.cpp | 138 + .../tested_elsewhere.pass.cpp | 12 + .../locale.time.get/time_base.pass.cpp | 29 + .../locale.time.get/types.pass.cpp | 41 + .../locale.time.put.byname/put1.pass.cpp | 78 + .../locale.time.put/ctor.pass.cpp | 52 + .../locale.time.put.members/put1.pass.cpp | 61 + .../locale.time.put.members/put2.pass.cpp | 332 + .../tested_elsewhere.pass.cpp | 12 + .../locale.time.put/types.pass.cpp | 32 + .../category.time/nothing_to_do.pass.cpp | 12 + .../decimal_point.pass.cpp | 65 + .../locale.numpunct.byname/grouping.pass.cpp | 68 + .../thousands_sep.pass.cpp | 68 + .../locale.numpunct/ctor.pass.cpp | 66 + .../decimal_point.pass.cpp | 32 + .../facet.numpunct.members/falsename.pass.cpp | 32 + .../facet.numpunct.members/grouping.pass.cpp | 32 + .../thousands_sep.pass.cpp | 32 + .../facet.numpunct.members/truename.pass.cpp | 32 + .../tested_elsewhere.pass.cpp | 12 + .../locale.numpunct/types.pass.cpp | 48 + .../facet.numpunct/nothing_to_do.pass.cpp | 12 + .../facets.examples/nothing_to_do.pass.cpp | 12 + .../locale.stdcvt/codecvt_mode.pass.cpp | 29 + .../locale.stdcvt/codecvt_utf16.pass.cpp | 42 + .../codecvt_utf16_always_noconv.pass.cpp | 45 + .../codecvt_utf16_encoding.pass.cpp | 45 + .../locale.stdcvt/codecvt_utf16_in.pass.cpp | 739 + .../codecvt_utf16_length.pass.cpp | 449 + .../codecvt_utf16_max_length.pass.cpp | 63 + .../locale.stdcvt/codecvt_utf16_out.pass.cpp | 331 + .../codecvt_utf16_unshift.pass.cpp | 56 + .../locale.stdcvt/codecvt_utf8.pass.cpp | 42 + .../codecvt_utf8_always_noconv.pass.cpp | 45 + .../codecvt_utf8_encoding.pass.cpp | 45 + .../locale.stdcvt/codecvt_utf8_in.pass.cpp | 360 + .../codecvt_utf8_length.pass.cpp | 244 + .../codecvt_utf8_max_length.pass.cpp | 63 + .../locale.stdcvt/codecvt_utf8_out.pass.cpp | 456 + .../codecvt_utf8_unshift.pass.cpp | 56 + .../codecvt_utf8_utf16_always_noconv.pass.cpp | 45 + .../codecvt_utf8_utf16_encoding.pass.cpp | 45 + .../codecvt_utf8_utf16_in.pass.cpp | 372 + .../codecvt_utf8_utf16_length.pass.cpp | 235 + .../codecvt_utf8_utf16_max_length.pass.cpp | 63 + .../codecvt_utf8_utf16_out.pass.cpp | 415 + .../codecvt_utf8_utf16_unshift.pass.cpp | 56 + .../locale.stdcvt/version.pass.cpp | 20 + .../locale.syn/nothing_to_do.pass.cpp | 12 + .../classification/isalnum.pass.cpp | 31 + .../classification/isalpha.pass.cpp | 31 + .../classification/iscntrl.pass.cpp | 31 + .../classification/isdigit.pass.cpp | 31 + .../classification/isgraph.pass.cpp | 31 + .../classification/islower.pass.cpp | 31 + .../classification/isprint.pass.cpp | 31 + .../classification/ispunct.pass.cpp | 31 + .../classification/isspace.pass.cpp | 31 + .../classification/isupper.pass.cpp | 31 + .../classification/isxdigit.pass.cpp | 31 + .../conversions.buffer/ctor.pass.cpp | 58 + .../conversions.buffer/lit.local.cfg | 2 + .../conversions.buffer/overflow.pass.cpp | 100 + .../conversions.buffer/pbackfail.pass.cpp | 59 + .../conversions.buffer/rdbuf.pass.cpp | 31 + .../conversions.buffer/seekoff.pass.cpp | 58 + .../conversions.buffer/state.pass.cpp | 28 + .../conversions.buffer/test.pass.cpp | 36 + .../conversions.buffer/underflow.dat | 1 + .../conversions.buffer/underflow.pass.cpp | 84 + .../conversions.buffer/underflow_utf8.dat | 1 + .../conversions.character/tolower.pass.cpp | 31 + .../conversions.character/toupper.pass.cpp | 31 + .../conversions.string/converted.pass.cpp | 32 + .../conversions.string/ctor_codecvt.pass.cpp | 38 + .../ctor_codecvt_state.pass.cpp | 28 + .../ctor_err_string.pass.cpp | 68 + .../conversions.string/from_bytes.pass.cpp | 39 + .../conversions.string/state.pass.cpp | 25 + .../conversions.string/to_bytes.pass.cpp | 39 + .../conversions.string/types.pass.cpp | 35 + .../conversions/nothing_to_do.pass.cpp | 12 + .../locale.convenience/nothing_to_do.pass.cpp | 12 + .../has_facet.pass.cpp | 32 + .../use_facet.pass.cpp | 52 + .../locale/locale.cons/assign.pass.cpp | 83 + .../locale/locale.cons/char_pointer.pass.cpp | 104 + .../locales/locale/locale.cons/copy.pass.cpp | 82 + .../locale/locale.cons/default.pass.cpp | 75 + .../locale_char_pointer_cat.pass.cpp | 82 + .../locale.cons/locale_facetptr.pass.cpp | 106 + .../locale.cons/locale_locale_cat.pass.cpp | 82 + .../locale.cons/locale_string_cat.pass.cpp | 81 + .../locale/locale.cons/string.pass.cpp | 87 + .../locale/locale.members/combine.pass.cpp | 94 + .../locale/locale.members/name.pass.cpp | 29 + .../locale/locale.operators/compare.pass.cpp | 34 + .../locale/locale.operators/eq.pass.cpp | 84 + .../locale/locale.statics/classic.pass.cpp | 59 + .../locale/locale.statics/global.pass.cpp | 63 + .../locale.category/category.pass.cpp | 59 + .../locale.types/locale.facet/facet.pass.cpp | 53 + .../locale/locale.types/locale.id/id.pass.cpp | 50 + .../locale.types/nothing_to_do.pass.cpp | 12 + .../locales/locale/nothing_to_do.pass.cpp | 12 + .../locales/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + test/std/localization/version.pass.cpp | 20 + test/std/nothing_to_do.pass.cpp | 13 + test/std/numerics/c.math/cmath.pass.cpp | 1485 + test/std/numerics/c.math/cmath_isinf.pass.cpp | 30 + test/std/numerics/c.math/cmath_isnan.pass.cpp | 30 + test/std/numerics/c.math/ctgmath.pass.cpp | 22 + test/std/numerics/c.math/tgmath_h.pass.cpp | 20 + .../numerics/c.math/version_cmath.pass.cpp | 20 + .../numerics/cfenv/cfenv.syn/cfenv.pass.cpp | 76 + test/std/numerics/cfenv/version.pass.cpp | 22 + test/std/numerics/complex.number/cases.h | 230 + .../complex.number/ccmplx/ccomplex.pass.cpp | 21 + .../complex.number/cmplx.over/arg.pass.cpp | 55 + .../complex.number/cmplx.over/conj.pass.cpp | 66 + .../complex.number/cmplx.over/imag.pass.cpp | 67 + .../complex.number/cmplx.over/norm.pass.cpp | 55 + .../complex.number/cmplx.over/pow.pass.cpp | 104 + .../complex.number/cmplx.over/proj.pass.cpp | 66 + .../complex.number/cmplx.over/real.pass.cpp | 67 + .../complex.literals/literals.pass.cpp | 51 + .../complex.literals/literals1.fail.cpp | 20 + .../complex.literals/literals1.pass.cpp | 43 + .../complex.literals/literals2.pass.cpp | 43 + .../assignment_complex.pass.cpp | 48 + .../assignment_scalar.pass.cpp | 37 + .../divide_equal_complex.pass.cpp | 53 + .../divide_equal_scalar.pass.cpp | 44 + .../minus_equal_complex.pass.cpp | 52 + .../minus_equal_scalar.pass.cpp | 40 + .../plus_equal_complex.pass.cpp | 52 + .../plus_equal_scalar.pass.cpp | 40 + .../times_equal_complex.pass.cpp | 52 + .../times_equal_scalar.pass.cpp | 44 + .../complex.members/construct.pass.cpp | 70 + .../complex.members/real_imag.pass.cpp | 64 + .../complex_divide_complex.pass.cpp | 159 + .../complex_divide_scalar.pass.cpp | 41 + .../complex_equals_complex.pass.cpp | 60 + .../complex_equals_scalar.pass.cpp | 81 + .../complex_minus_complex.pass.cpp | 49 + .../complex.ops/complex_minus_scalar.pass.cpp | 49 + .../complex_not_equals_complex.pass.cpp | 62 + .../complex_not_equals_scalar.pass.cpp | 81 + .../complex.ops/complex_plus_complex.pass.cpp | 49 + .../complex.ops/complex_plus_scalar.pass.cpp | 49 + .../complex_times_complex.pass.cpp | 161 + .../complex.ops/complex_times_scalar.pass.cpp | 41 + .../scalar_divide_complex.pass.cpp | 41 + .../scalar_equals_complex.pass.cpp | 81 + .../complex.ops/scalar_minus_complex.pass.cpp | 49 + .../scalar_not_equals_complex.pass.cpp | 81 + .../complex.ops/scalar_plus_complex.pass.cpp | 49 + .../complex.ops/scalar_times_complex.pass.cpp | 41 + .../complex.ops/stream_input.pass.cpp | 99 + .../complex.ops/stream_output.pass.cpp | 26 + .../complex.ops/unary_minus.pass.cpp | 36 + .../complex.ops/unary_plus.pass.cpp | 36 + .../double_float_explicit.pass.cpp | 37 + .../double_float_implicit.pass.cpp | 37 + .../double_long_double_explicit.pass.cpp | 37 + .../double_long_double_implicit.fail.cpp | 27 + .../float_double_explicit.pass.cpp | 37 + .../float_double_implicit.fail.cpp | 27 + .../float_long_double_explicit.pass.cpp | 37 + .../float_long_double_implicit.fail.cpp | 27 + .../long_double_double_explicit.pass.cpp | 37 + .../long_double_double_implicit.pass.cpp | 37 + .../long_double_float_explicit.pass.cpp | 37 + .../long_double_float_implicit.pass.cpp | 37 + .../complex.synopsis/nothing_to_do.pass.cpp | 12 + .../complex.transcendentals/acos.pass.cpp | 140 + .../complex.transcendentals/acosh.pass.cpp | 142 + .../complex.transcendentals/asin.pass.cpp | 120 + .../complex.transcendentals/asinh.pass.cpp | 119 + .../complex.transcendentals/atan.pass.cpp | 68 + .../complex.transcendentals/atanh.pass.cpp | 132 + .../complex.transcendentals/cos.pass.cpp | 68 + .../complex.transcendentals/cosh.pass.cpp | 118 + .../complex.transcendentals/exp.pass.cpp | 114 + .../complex.transcendentals/log.pass.cpp | 131 + .../complex.transcendentals/log10.pass.cpp | 66 + .../pow_complex_complex.pass.cpp | 71 + .../pow_complex_scalar.pass.cpp | 69 + .../pow_scalar_complex.pass.cpp | 69 + .../complex.transcendentals/sin.pass.cpp | 69 + .../complex.transcendentals/sinh.pass.cpp | 119 + .../complex.transcendentals/sqrt.pass.cpp | 109 + .../complex.transcendentals/tan.pass.cpp | 70 + .../complex.transcendentals/tanh.pass.cpp | 101 + .../complex.value.ops/abs.pass.cpp | 63 + .../complex.value.ops/arg.pass.cpp | 135 + .../complex.value.ops/conj.pass.cpp | 41 + .../complex.value.ops/imag.pass.cpp | 32 + .../complex.value.ops/norm.pass.cpp | 63 + .../complex.value.ops/polar.pass.cpp | 112 + .../complex.value.ops/proj.pass.cpp | 71 + .../complex.value.ops/real.pass.cpp | 32 + .../complex.number/complex/types.pass.cpp | 36 + .../numerics/complex.number/layout.pass.cpp | 36 + .../numerics/complex.number/version.pass.cpp | 20 + test/std/numerics/nothing_to_do.pass.cpp | 12 + .../gslice.access/tested_elsewhere.pass.cpp | 12 + .../class.gslice/gslice.cons/default.pass.cpp | 25 + .../gslice.cons/start_size_stride.pass.cpp | 38 + .../class.gslice/nothing_to_do.pass.cpp | 12 + .../class.slice/cons.slice/default.pass.cpp | 25 + .../cons.slice/start_size_stride.pass.cpp | 25 + .../class.slice/nothing_to_do.pass.cpp | 12 + .../slice.access/tested_elsewhere.pass.cpp | 12 + .../template.gslice.array/default.fail.cpp | 22 + .../gslice.array.assign/gslice_array.pass.cpp | 81 + .../gslice.array.assign/valarray.pass.cpp | 77 + .../addition.pass.cpp | 77 + .../gslice.array.comp.assign/and.pass.cpp | 77 + .../gslice.array.comp.assign/divide.pass.cpp | 77 + .../gslice.array.comp.assign/modulo.pass.cpp | 77 + .../multiply.pass.cpp | 77 + .../gslice.array.comp.assign/or.pass.cpp | 77 + .../shift_left.pass.cpp | 77 + .../shift_right.pass.cpp | 77 + .../subtraction.pass.cpp | 77 + .../gslice.array.comp.assign/xor.pass.cpp | 77 + .../gslice.array.fill/assign_value.pass.cpp | 74 + .../template.gslice.array/types.pass.cpp | 24 + .../template.indirect.array/default.fail.cpp | 22 + .../indirect_array.pass.cpp | 80 + .../indirect.array.assign/valarray.pass.cpp | 77 + .../addition.pass.cpp | 77 + .../indirect.array.comp.assign/and.pass.cpp | 77 + .../divide.pass.cpp | 77 + .../modulo.pass.cpp | 77 + .../multiply.pass.cpp | 77 + .../indirect.array.comp.assign/or.pass.cpp | 77 + .../shift_left.pass.cpp | 77 + .../shift_right.pass.cpp | 77 + .../subtraction.pass.cpp | 77 + .../indirect.array.comp.assign/xor.pass.cpp | 77 + .../indirect.array.fill/assign_value.pass.cpp | 74 + .../template.indirect.array/types.pass.cpp | 24 + .../template.mask.array/default.fail.cpp | 22 + .../mask.array.assign/mask_array.pass.cpp | 66 + .../mask.array.assign/valarray.pass.cpp | 49 + .../mask.array.comp.assign/addition.pass.cpp | 49 + .../mask.array.comp.assign/and.pass.cpp | 49 + .../mask.array.comp.assign/divide.pass.cpp | 49 + .../mask.array.comp.assign/modulo.pass.cpp | 49 + .../mask.array.comp.assign/multiply.pass.cpp | 49 + .../mask.array.comp.assign/or.pass.cpp | 49 + .../shift_left.pass.cpp | 49 + .../shift_right.pass.cpp | 49 + .../subtraction.pass.cpp | 49 + .../mask.array.comp.assign/xor.pass.cpp | 49 + .../mask.array.fill/assign_value.pass.cpp | 45 + .../template.mask.array/types.pass.cpp | 24 + .../template.slice.array/default.fail.cpp | 22 + .../slice.arr.assign/slice_array.pass.cpp | 55 + .../slice.arr.assign/valarray.pass.cpp | 43 + .../slice.arr.comp.assign/addition.pass.cpp | 43 + .../slice.arr.comp.assign/and.pass.cpp | 43 + .../slice.arr.comp.assign/divide.pass.cpp | 43 + .../slice.arr.comp.assign/modulo.pass.cpp | 43 + .../slice.arr.comp.assign/multiply.pass.cpp | 43 + .../slice.arr.comp.assign/or.pass.cpp | 43 + .../slice.arr.comp.assign/shift_left.pass.cpp | 43 + .../shift_right.pass.cpp | 43 + .../subtraction.pass.cpp | 43 + .../slice.arr.comp.assign/xor.pass.cpp | 43 + .../slice.arr.fill/assign_value.pass.cpp | 41 + .../template.slice.array/types.pass.cpp | 24 + .../numarray/template.valarray/types.pass.cpp | 26 + .../valarray.access/access.pass.cpp | 33 + .../valarray.access/const_access.pass.cpp | 31 + .../valarray.assign/copy_assign.pass.cpp | 58 + .../gslice_array_assign.pass.cpp | 58 + .../indirect_array_assign.pass.cpp | 58 + .../initializer_list_assign.pass.cpp | 57 + .../mask_array_assign.pass.cpp | 35 + .../valarray.assign/move_assign.pass.cpp | 63 + .../slice_array_assign.pass.cpp | 31 + .../valarray.assign/value_assign.pass.cpp | 31 + .../valarray.cassign/and_valarray.pass.cpp | 36 + .../valarray.cassign/and_value.pass.cpp | 33 + .../valarray.cassign/divide_valarray.pass.cpp | 36 + .../valarray.cassign/divide_value.pass.cpp | 33 + .../valarray.cassign/minus_valarray.pass.cpp | 36 + .../valarray.cassign/minus_value.pass.cpp | 33 + .../valarray.cassign/modulo_valarray.pass.cpp | 36 + .../valarray.cassign/modulo_value.pass.cpp | 33 + .../valarray.cassign/or_valarray.pass.cpp | 36 + .../valarray.cassign/or_value.pass.cpp | 33 + .../valarray.cassign/plus_valarray.pass.cpp | 36 + .../valarray.cassign/plus_value.pass.cpp | 33 + .../shift_left_valarray.pass.cpp | 36 + .../shift_left_value.pass.cpp | 33 + .../shift_right_valarray.pass.cpp | 36 + .../shift_right_value.pass.cpp | 33 + .../valarray.cassign/times_valarray.pass.cpp | 36 + .../valarray.cassign/times_value.pass.cpp | 33 + .../valarray.cassign/xor_valarray.pass.cpp | 36 + .../valarray.cassign/xor_value.pass.cpp | 33 + .../valarray.cons/copy.pass.cpp | 55 + .../valarray.cons/default.pass.cpp | 37 + .../valarray.cons/gslice_array.pass.cpp | 57 + .../valarray.cons/indirect_array.pass.cpp | 57 + .../valarray.cons/initializer_list.pass.cpp | 41 + .../valarray.cons/mask_array.pass.cpp | 34 + .../valarray.cons/move.pass.cpp | 61 + .../valarray.cons/pointer_size.pass.cpp | 52 + .../valarray.cons/size.pass.cpp | 39 + .../valarray.cons/slice_array.pass.cpp | 30 + .../valarray.cons/value_size.pass.cpp | 39 + .../valarray.members/apply_cref.pass.cpp | 51 + .../valarray.members/apply_value.pass.cpp | 51 + .../valarray.members/cshift.pass.cpp | 127 + .../valarray.members/max.pass.cpp | 40 + .../valarray.members/min.pass.cpp | 40 + .../valarray.members/resize.pass.cpp | 41 + .../valarray.members/shift.pass.cpp | 127 + .../valarray.members/size.pass.cpp | 41 + .../valarray.members/sum.pass.cpp | 28 + .../valarray.members/swap.pass.cpp | 89 + .../valarray.sub/gslice_const.pass.cpp | 77 + .../valarray.sub/gslice_non_const.pass.cpp | 57 + .../indirect_array_const.pass.cpp | 57 + .../indirect_array_non_const.pass.cpp | 58 + .../valarray.sub/slice_const.pass.cpp | 30 + .../valarray.sub/slice_non_const.pass.cpp | 43 + .../valarray.sub/valarray_bool_const.pass.cpp | 34 + .../valarray_bool_non_const.pass.cpp | 35 + .../valarray.unary/bit_not.pass.cpp | 55 + .../valarray.unary/negate.pass.cpp | 65 + .../valarray.unary/not.pass.cpp | 41 + .../valarray.unary/plus.pass.cpp | 65 + .../nothing_to_do.pass.cpp | 12 + .../and_valarray_valarray.pass.cpp | 35 + .../and_valarray_value.pass.cpp | 32 + .../and_value_valarray.pass.cpp | 32 + .../divide_valarray_valarray.pass.cpp | 35 + .../divide_valarray_value.pass.cpp | 32 + .../divide_value_valarray.pass.cpp | 32 + .../minus_valarray_valarray.pass.cpp | 35 + .../minus_valarray_value.pass.cpp | 32 + .../minus_value_valarray.pass.cpp | 32 + .../modulo_valarray_valarray.pass.cpp | 35 + .../modulo_valarray_value.pass.cpp | 32 + .../modulo_value_valarray.pass.cpp | 32 + .../or_valarray_valarray.pass.cpp | 35 + .../or_valarray_value.pass.cpp | 32 + .../or_value_valarray.pass.cpp | 32 + .../plus_valarray_valarray.pass.cpp | 35 + .../plus_valarray_value.pass.cpp | 32 + .../plus_value_valarray.pass.cpp | 32 + .../shift_left_valarray_valarray.pass.cpp | 35 + .../shift_left_valarray_value.pass.cpp | 32 + .../shift_left_value_valarray.pass.cpp | 32 + .../shift_right_valarray_valarray.pass.cpp | 35 + .../shift_right_valarray_value.pass.cpp | 32 + .../shift_right_value_valarray.pass.cpp | 32 + .../times_valarray_valarray.pass.cpp | 35 + .../times_valarray_value.pass.cpp | 32 + .../times_value_valarray.pass.cpp | 32 + .../xor_valarray_valarray.pass.cpp | 35 + .../xor_valarray_value.pass.cpp | 32 + .../xor_value_valarray.pass.cpp | 32 + .../and_valarray_valarray.pass.cpp | 37 + .../and_valarray_value.pass.cpp | 45 + .../and_value_valarray.pass.cpp | 45 + .../equal_valarray_valarray.pass.cpp | 37 + .../equal_valarray_value.pass.cpp | 34 + .../equal_value_valarray.pass.cpp | 34 + .../greater_equal_valarray_valarray.pass.cpp | 37 + .../greater_equal_valarray_value.pass.cpp | 34 + .../greater_equal_value_valarray.pass.cpp | 34 + .../greater_valarray_valarray.pass.cpp | 37 + .../greater_valarray_value.pass.cpp | 34 + .../greater_value_valarray.pass.cpp | 34 + .../less_equal_valarray_valarray.pass.cpp | 37 + .../less_equal_valarray_value.pass.cpp | 34 + .../less_equal_value_valarray.pass.cpp | 34 + .../less_valarray_valarray.pass.cpp | 37 + .../less_valarray_value.pass.cpp | 34 + .../less_value_valarray.pass.cpp | 34 + .../not_equal_valarray_valarray.pass.cpp | 37 + .../not_equal_valarray_value.pass.cpp | 34 + .../not_equal_value_valarray.pass.cpp | 34 + .../or_valarray_valarray.pass.cpp | 37 + .../or_valarray_value.pass.cpp | 45 + .../or_value_valarray.pass.cpp | 45 + .../valarray.special/swap.pass.cpp | 91 + .../valarray.transcend/abs_valarray.pass.cpp | 34 + .../valarray.transcend/acos_valarray.pass.cpp | 51 + .../valarray.transcend/asin_valarray.pass.cpp | 51 + .../atan2_valarray_valarray.pass.cpp | 53 + .../atan2_valarray_value.pass.cpp | 51 + .../atan2_value_valarray.pass.cpp | 51 + .../valarray.transcend/atan_valarray.pass.cpp | 51 + .../valarray.transcend/cos_valarray.pass.cpp | 51 + .../valarray.transcend/cosh_valarray.pass.cpp | 51 + .../valarray.transcend/exp_valarray.pass.cpp | 51 + .../log10_valarray.pass.cpp | 51 + .../valarray.transcend/log_valarray.pass.cpp | 51 + .../pow_valarray_valarray.pass.cpp | 53 + .../pow_valarray_value.pass.cpp | 51 + .../pow_value_valarray.pass.cpp | 51 + .../valarray.transcend/sin_valarray.pass.cpp | 51 + .../valarray.transcend/sinh_valarray.pass.cpp | 51 + .../valarray.transcend/sqrt_valarray.pass.cpp | 51 + .../valarray.transcend/tan_valarray.pass.cpp | 51 + .../valarray.transcend/tanh_valarray.pass.cpp | 51 + .../valarray.range/begin_const.pass.cpp | 30 + .../valarray.range/begin_non_const.pass.cpp | 31 + .../valarray.range/end_const.pass.cpp | 31 + .../valarray.range/end_non_const.pass.cpp | 32 + .../valarray.syn/nothing_to_do.pass.cpp | 12 + test/std/numerics/numarray/version.pass.cpp | 20 + .../accumulate/accumulate.pass.cpp | 53 + .../accumulate/accumulate_op.pass.cpp | 55 + .../adjacent_difference.pass.cpp | 115 + .../adjacent_difference_op.pass.cpp | 118 + .../inner.product/inner_product.pass.cpp | 82 + .../inner.product/inner_product_comp.pass.cpp | 85 + .../numeric.ops/numeric.iota/iota.pass.cpp | 38 + .../partial.sum/partial_sum.pass.cpp | 70 + .../partial.sum/partial_sum_op.pass.cpp | 72 + .../std/numerics/numeric.ops/version.pass.cpp | 20 + .../nothing_to_do.pass.cpp | 12 + .../numerics.general/nothing_to_do.pass.cpp | 12 + test/std/numerics/rand/nothing_to_do.pass.cpp | 12 + .../rand/rand.adapt/nothing_to_do.pass.cpp | 12 + .../rand.adapt.disc/assign.pass.cpp | 56 + .../rand.adapt/rand.adapt.disc/copy.pass.cpp | 54 + .../rand.adapt.disc/ctor_engine_copy.pass.cpp | 29 + .../rand.adapt.disc/ctor_engine_move.pass.cpp | 30 + .../rand.adapt.disc/ctor_result_type.pass.cpp | 51 + .../rand.adapt.disc/ctor_sseq.pass.cpp | 55 + .../rand.adapt.disc/default.pass.cpp | 42 + .../rand.adapt.disc/discard.pass.cpp | 52 + .../rand.adapt/rand.adapt.disc/eval.pass.cpp | 42 + .../rand.adapt/rand.adapt.disc/io.pass.cpp | 63 + .../rand.adapt.disc/result_type.pass.cpp | 42 + .../rand.adapt.disc/seed_result_type.pass.cpp | 50 + .../rand.adapt.disc/seed_sseq.pass.cpp | 48 + .../rand.adapt.disc/values.pass.cpp | 60 + .../rand.adapt.ibits/assign.pass.cpp | 56 + .../rand.adapt/rand.adapt.ibits/copy.pass.cpp | 54 + .../ctor_engine_copy.pass.cpp | 29 + .../ctor_engine_move.pass.cpp | 30 + .../ctor_result_type.pass.cpp | 51 + .../rand.adapt.ibits/ctor_sseq.pass.cpp | 55 + .../rand.adapt.ibits/default.pass.cpp | 42 + .../rand.adapt.ibits/discard.pass.cpp | 52 + .../rand.adapt/rand.adapt.ibits/eval.pass.cpp | 141 + .../rand.adapt/rand.adapt.ibits/io.pass.cpp | 63 + .../rand.adapt.ibits/result_type.pass.cpp | 83 + .../seed_result_type.pass.cpp | 50 + .../rand.adapt.ibits/seed_sseq.pass.cpp | 48 + .../rand.adapt.ibits/values.pass.cpp | 47 + .../rand.adapt.shuf/assign.pass.cpp | 39 + .../rand.adapt/rand.adapt.shuf/copy.pass.cpp | 38 + .../rand.adapt.shuf/ctor_engine_copy.pass.cpp | 31 + .../rand.adapt.shuf/ctor_engine_move.pass.cpp | 32 + .../rand.adapt.shuf/ctor_result_type.pass.cpp | 76 + .../rand.adapt.shuf/ctor_sseq.pass.cpp | 79 + .../rand.adapt.shuf/default.pass.cpp | 32 + .../rand.adapt.shuf/discard.pass.cpp | 37 + .../rand.adapt/rand.adapt.shuf/eval.pass.cpp | 93 + .../rand.adapt/rand.adapt.shuf/io.pass.cpp | 48 + .../rand.adapt.shuf/result_type.pass.cpp | 83 + .../rand.adapt.shuf/seed_result_type.pass.cpp | 36 + .../rand.adapt.shuf/seed_sseq.pass.cpp | 35 + .../rand.adapt.shuf/values.pass.cpp | 44 + .../numerics/rand/rand.device/ctor.pass.cpp | 83 + .../rand/rand.device/entropy.pass.cpp | 23 + .../numerics/rand/rand.device/eval.pass.cpp | 35 + .../rand/rand.dis/nothing_to_do.pass.cpp | 12 + .../rand.dist.bern/nothing_to_do.pass.cpp | 12 + .../rand.dist.bern.bernoulli/assign.pass.cpp | 33 + .../rand.dist.bern.bernoulli/copy.pass.cpp | 31 + .../ctor_double.pass.cpp | 36 + .../ctor_param.pass.cpp | 28 + .../rand.dist.bern.bernoulli/eq.pass.cpp | 36 + .../rand.dist.bern.bernoulli/eval.pass.cpp | 103 + .../eval_param.pass.cpp | 107 + .../get_param.pass.cpp | 28 + .../rand.dist.bern.bernoulli/io.pass.cpp | 40 + .../rand.dist.bern.bernoulli/max.pass.cpp | 26 + .../rand.dist.bern.bernoulli/min.pass.cpp | 26 + .../param_assign.pass.cpp | 30 + .../param_copy.pass.cpp | 29 + .../param_ctor.pass.cpp | 34 + .../param_eq.pass.cpp | 36 + .../param_types.pass.cpp | 27 + .../set_param.pass.cpp | 29 + .../rand.dist.bern.bernoulli/types.pass.cpp | 26 + .../rand.dist.bern.bin/assign.pass.cpp | 34 + .../rand.dist.bern.bin/copy.pass.cpp | 32 + .../ctor_int_double.pass.cpp | 40 + .../rand.dist.bern.bin/ctor_param.pass.cpp | 30 + .../rand.dist.bern.bin/eq.pass.cpp | 43 + .../rand.dist.bern.bin/eval.pass.cpp | 475 + .../rand.dist.bern.bin/eval_param.pass.cpp | 160 + .../rand.dist.bern.bin/get_param.pass.cpp | 29 + .../rand.dist.bern.bin/io.pass.cpp | 41 + .../rand.dist.bern.bin/max.pass.cpp | 27 + .../rand.dist.bern.bin/min.pass.cpp | 27 + .../rand.dist.bern.bin/param_assign.pass.cpp | 32 + .../rand.dist.bern.bin/param_copy.pass.cpp | 31 + .../rand.dist.bern.bin/param_ctor.pass.cpp | 44 + .../rand.dist.bern.bin/param_eq.pass.cpp | 37 + .../rand.dist.bern.bin/param_types.pass.cpp | 28 + .../rand.dist.bern.bin/set_param.pass.cpp | 30 + .../rand.dist.bern.bin/types.pass.cpp | 32 + .../rand.dist.bern.geo/assign.pass.cpp | 34 + .../rand.dist.bern.geo/copy.pass.cpp | 32 + .../rand.dist.bern.geo/ctor_double.pass.cpp | 32 + .../rand.dist.bern.geo/ctor_param.pass.cpp | 29 + .../rand.dist.bern.geo/eq.pass.cpp | 37 + .../rand.dist.bern.geo/eval.pass.cpp | 274 + .../rand.dist.bern.geo/eval_param.pass.cpp | 160 + .../rand.dist.bern.geo/get_param.pass.cpp | 29 + .../rand.dist.bern.geo/io.pass.cpp | 41 + .../rand.dist.bern.geo/max.pass.cpp | 27 + .../rand.dist.bern.geo/min.pass.cpp | 27 + .../rand.dist.bern.geo/param_assign.pass.cpp | 31 + .../rand.dist.bern.geo/param_copy.pass.cpp | 30 + .../rand.dist.bern.geo/param_ctor.pass.cpp | 35 + .../rand.dist.bern.geo/param_eq.pass.cpp | 37 + .../rand.dist.bern.geo/param_types.pass.cpp | 28 + .../rand.dist.bern.geo/set_param.pass.cpp | 30 + .../rand.dist.bern.geo/types.pass.cpp | 32 + .../rand.dist.bern.negbin/assign.pass.cpp | 34 + .../rand.dist.bern.negbin/copy.pass.cpp | 32 + .../ctor_int_double.pass.cpp | 40 + .../rand.dist.bern.negbin/ctor_param.pass.cpp | 30 + .../rand.dist.bern.negbin/eq.pass.cpp | 43 + .../rand.dist.bern.negbin/eval.pass.cpp | 272 + .../rand.dist.bern.negbin/eval_param.pass.cpp | 160 + .../rand.dist.bern.negbin/get_param.pass.cpp | 29 + .../rand.dist.bern.negbin/io.pass.cpp | 41 + .../rand.dist.bern.negbin/max.pass.cpp | 27 + .../rand.dist.bern.negbin/min.pass.cpp | 27 + .../param_assign.pass.cpp | 32 + .../rand.dist.bern.negbin/param_copy.pass.cpp | 31 + .../rand.dist.bern.negbin/param_ctor.pass.cpp | 44 + .../rand.dist.bern.negbin/param_eq.pass.cpp | 37 + .../param_types.pass.cpp | 28 + .../rand.dist.bern.negbin/set_param.pass.cpp | 30 + .../rand.dist.bern.negbin/types.pass.cpp | 32 + .../rand.dist.norm/nothing_to_do.pass.cpp | 12 + .../rand.dist.norm.cauchy/assign.pass.cpp | 34 + .../rand.dist.norm.cauchy/copy.pass.cpp | 32 + .../ctor_double_double.pass.cpp | 40 + .../rand.dist.norm.cauchy/ctor_param.pass.cpp | 30 + .../rand.dist.norm.cauchy/eq.pass.cpp | 37 + .../rand.dist.norm.cauchy/eval.pass.cpp | 80 + .../rand.dist.norm.cauchy/eval_param.pass.cpp | 83 + .../rand.dist.norm.cauchy/get_param.pass.cpp | 29 + .../rand.dist.norm.cauchy/io.pass.cpp | 41 + .../rand.dist.norm.cauchy/max.pass.cpp | 28 + .../rand.dist.norm.cauchy/min.pass.cpp | 27 + .../param_assign.pass.cpp | 32 + .../rand.dist.norm.cauchy/param_copy.pass.cpp | 31 + .../rand.dist.norm.cauchy/param_ctor.pass.cpp | 44 + .../rand.dist.norm.cauchy/param_eq.pass.cpp | 37 + .../param_types.pass.cpp | 28 + .../rand.dist.norm.cauchy/set_param.pass.cpp | 30 + .../rand.dist.norm.cauchy/types.pass.cpp | 34 + .../rand.dist.norm.chisq/assign.pass.cpp | 34 + .../rand.dist.norm.chisq/copy.pass.cpp | 32 + .../rand.dist.norm.chisq/ctor_double.pass.cpp | 32 + .../rand.dist.norm.chisq/ctor_param.pass.cpp | 29 + .../rand.dist.norm.chisq/eq.pass.cpp | 37 + .../rand.dist.norm.chisq/eval.pass.cpp | 154 + .../rand.dist.norm.chisq/eval_param.pass.cpp | 157 + .../rand.dist.norm.chisq/get_param.pass.cpp | 29 + .../rand.dist.norm.chisq/io.pass.cpp | 41 + .../rand.dist.norm.chisq/max.pass.cpp | 28 + .../rand.dist.norm.chisq/min.pass.cpp | 27 + .../param_assign.pass.cpp | 31 + .../rand.dist.norm.chisq/param_copy.pass.cpp | 30 + .../rand.dist.norm.chisq/param_ctor.pass.cpp | 35 + .../rand.dist.norm.chisq/param_eq.pass.cpp | 37 + .../rand.dist.norm.chisq/param_types.pass.cpp | 28 + .../rand.dist.norm.chisq/set_param.pass.cpp | 30 + .../rand.dist.norm.chisq/types.pass.cpp | 34 + .../rand.dist.norm.f/assign.pass.cpp | 34 + .../rand.dist.norm.f/copy.pass.cpp | 32 + .../ctor_double_double.pass.cpp | 40 + .../rand.dist.norm.f/ctor_param.pass.cpp | 30 + .../rand.dist.norm.f/eq.pass.cpp | 37 + .../rand.dist.norm.f/eval.pass.cpp | 106 + .../rand.dist.norm.f/eval_param.pass.cpp | 109 + .../rand.dist.norm.f/get_param.pass.cpp | 29 + .../rand.dist.norm.f/io.pass.cpp | 41 + .../rand.dist.norm.f/max.pass.cpp | 28 + .../rand.dist.norm.f/min.pass.cpp | 27 + .../rand.dist.norm.f/param_assign.pass.cpp | 32 + .../rand.dist.norm.f/param_copy.pass.cpp | 31 + .../rand.dist.norm.f/param_ctor.pass.cpp | 44 + .../rand.dist.norm.f/param_eq.pass.cpp | 37 + .../rand.dist.norm.f/param_types.pass.cpp | 28 + .../rand.dist.norm.f/set_param.pass.cpp | 30 + .../rand.dist.norm.f/types.pass.cpp | 34 + .../rand.dist.norm.lognormal/assign.pass.cpp | 34 + .../rand.dist.norm.lognormal/copy.pass.cpp | 32 + .../ctor_double_double.pass.cpp | 40 + .../ctor_param.pass.cpp | 30 + .../rand.dist.norm.lognormal/eq.pass.cpp | 37 + .../rand.dist.norm.lognormal/eval.pass.cpp | 244 + .../eval_param.pass.cpp | 250 + .../get_param.pass.cpp | 29 + .../rand.dist.norm.lognormal/io.pass.cpp | 41 + .../rand.dist.norm.lognormal/max.pass.cpp | 28 + .../rand.dist.norm.lognormal/min.pass.cpp | 27 + .../param_assign.pass.cpp | 32 + .../param_copy.pass.cpp | 31 + .../param_ctor.pass.cpp | 44 + .../param_eq.pass.cpp | 37 + .../param_types.pass.cpp | 28 + .../set_param.pass.cpp | 30 + .../rand.dist.norm.lognormal/types.pass.cpp | 34 + .../rand.dist.norm.normal/assign.pass.cpp | 34 + .../rand.dist.norm.normal/copy.pass.cpp | 32 + .../ctor_double_double.pass.cpp | 40 + .../rand.dist.norm.normal/ctor_param.pass.cpp | 30 + .../rand.dist.norm.normal/eq.pass.cpp | 37 + .../rand.dist.norm.normal/eval.pass.cpp | 70 + .../rand.dist.norm.normal/eval_param.pass.cpp | 71 + .../rand.dist.norm.normal/get_param.pass.cpp | 29 + .../rand.dist.norm.normal/io.pass.cpp | 41 + .../rand.dist.norm.normal/max.pass.cpp | 28 + .../rand.dist.norm.normal/min.pass.cpp | 27 + .../param_assign.pass.cpp | 32 + .../rand.dist.norm.normal/param_copy.pass.cpp | 31 + .../rand.dist.norm.normal/param_ctor.pass.cpp | 44 + .../rand.dist.norm.normal/param_eq.pass.cpp | 37 + .../param_types.pass.cpp | 28 + .../rand.dist.norm.normal/set_param.pass.cpp | 30 + .../rand.dist.norm.normal/types.pass.cpp | 34 + .../rand.dist.norm.t/assign.pass.cpp | 34 + .../rand.dist.norm.t/copy.pass.cpp | 32 + .../rand.dist.norm.t/ctor_double.pass.cpp | 32 + .../rand.dist.norm.t/ctor_param.pass.cpp | 29 + .../rand.dist.norm.t/eq.pass.cpp | 37 + .../rand.dist.norm.t/eval.pass.cpp | 142 + .../rand.dist.norm.t/eval_param.pass.cpp | 145 + .../rand.dist.norm.t/get_param.pass.cpp | 29 + .../rand.dist.norm.t/io.pass.cpp | 41 + .../rand.dist.norm.t/max.pass.cpp | 28 + .../rand.dist.norm.t/min.pass.cpp | 27 + .../rand.dist.norm.t/param_assign.pass.cpp | 31 + .../rand.dist.norm.t/param_copy.pass.cpp | 30 + .../rand.dist.norm.t/param_ctor.pass.cpp | 35 + .../rand.dist.norm.t/param_eq.pass.cpp | 37 + .../rand.dist.norm.t/param_types.pass.cpp | 28 + .../rand.dist.norm.t/set_param.pass.cpp | 30 + .../rand.dist.norm.t/types.pass.cpp | 34 + .../rand.dist.pois/nothing_to_do.pass.cpp | 12 + .../rand.dist.pois.exp/assign.pass.cpp | 34 + .../rand.dist.pois.exp/copy.pass.cpp | 32 + .../rand.dist.pois.exp/ctor_double.pass.cpp | 32 + .../rand.dist.pois.exp/ctor_param.pass.cpp | 29 + .../rand.dist.pois.exp/eq.pass.cpp | 37 + .../rand.dist.pois.exp/eval.pass.cpp | 154 + .../rand.dist.pois.exp/eval_param.pass.cpp | 75 + .../rand.dist.pois.exp/get_param.pass.cpp | 29 + .../rand.dist.pois.exp/io.pass.cpp | 41 + .../rand.dist.pois.exp/max.pass.cpp | 28 + .../rand.dist.pois.exp/min.pass.cpp | 27 + .../rand.dist.pois.exp/param_assign.pass.cpp | 31 + .../rand.dist.pois.exp/param_copy.pass.cpp | 30 + .../rand.dist.pois.exp/param_ctor.pass.cpp | 35 + .../rand.dist.pois.exp/param_eq.pass.cpp | 37 + .../rand.dist.pois.exp/param_types.pass.cpp | 28 + .../rand.dist.pois.exp/set_param.pass.cpp | 30 + .../rand.dist.pois.exp/types.pass.cpp | 34 + .../rand.dist.pois.extreme/assign.pass.cpp | 34 + .../rand.dist.pois.extreme/copy.pass.cpp | 32 + .../ctor_double_double.pass.cpp | 40 + .../ctor_param.pass.cpp | 30 + .../rand.dist.pois.extreme/eq.pass.cpp | 37 + .../rand.dist.pois.extreme/eval.pass.cpp | 190 + .../eval_param.pass.cpp | 194 + .../rand.dist.pois.extreme/get_param.pass.cpp | 29 + .../rand.dist.pois.extreme/io.pass.cpp | 41 + .../rand.dist.pois.extreme/max.pass.cpp | 28 + .../rand.dist.pois.extreme/min.pass.cpp | 27 + .../param_assign.pass.cpp | 32 + .../param_copy.pass.cpp | 31 + .../param_ctor.pass.cpp | 44 + .../rand.dist.pois.extreme/param_eq.pass.cpp | 37 + .../param_types.pass.cpp | 28 + .../rand.dist.pois.extreme/set_param.pass.cpp | 30 + .../rand.dist.pois.extreme/types.pass.cpp | 34 + .../rand.dist.pois.gamma/assign.pass.cpp | 34 + .../rand.dist.pois.gamma/copy.pass.cpp | 32 + .../ctor_double_double.pass.cpp | 40 + .../rand.dist.pois.gamma/ctor_param.pass.cpp | 30 + .../rand.dist.pois.gamma/eq.pass.cpp | 37 + .../rand.dist.pois.gamma/eval.pass.cpp | 154 + .../rand.dist.pois.gamma/eval_param.pass.cpp | 157 + .../rand.dist.pois.gamma/get_param.pass.cpp | 29 + .../rand.dist.pois.gamma/io.pass.cpp | 41 + .../rand.dist.pois.gamma/max.pass.cpp | 28 + .../rand.dist.pois.gamma/min.pass.cpp | 27 + .../param_assign.pass.cpp | 32 + .../rand.dist.pois.gamma/param_copy.pass.cpp | 31 + .../rand.dist.pois.gamma/param_ctor.pass.cpp | 44 + .../rand.dist.pois.gamma/param_eq.pass.cpp | 37 + .../rand.dist.pois.gamma/param_types.pass.cpp | 28 + .../rand.dist.pois.gamma/set_param.pass.cpp | 30 + .../rand.dist.pois.gamma/types.pass.cpp | 34 + .../rand.dist.pois.poisson/assign.pass.cpp | 34 + .../rand.dist.pois.poisson/copy.pass.cpp | 32 + .../ctor_double.pass.cpp | 32 + .../ctor_param.pass.cpp | 29 + .../rand.dist.pois.poisson/eq.pass.cpp | 37 + .../rand.dist.pois.poisson/eval.pass.cpp | 151 + .../eval_param.pass.cpp | 157 + .../rand.dist.pois.poisson/get_param.pass.cpp | 29 + .../rand.dist.pois.poisson/io.pass.cpp | 41 + .../rand.dist.pois.poisson/max.pass.cpp | 28 + .../rand.dist.pois.poisson/min.pass.cpp | 27 + .../param_assign.pass.cpp | 31 + .../param_copy.pass.cpp | 30 + .../param_ctor.pass.cpp | 35 + .../rand.dist.pois.poisson/param_eq.pass.cpp | 37 + .../param_types.pass.cpp | 28 + .../rand.dist.pois.poisson/set_param.pass.cpp | 30 + .../rand.dist.pois.poisson/types.pass.cpp | 34 + .../rand.dist.pois.weibull/assign.pass.cpp | 34 + .../rand.dist.pois.weibull/copy.pass.cpp | 32 + .../ctor_double_double.pass.cpp | 40 + .../ctor_param.pass.cpp | 30 + .../rand.dist.pois.weibull/eq.pass.cpp | 37 + .../rand.dist.pois.weibull/eval.pass.cpp | 166 + .../eval_param.pass.cpp | 169 + .../rand.dist.pois.weibull/get_param.pass.cpp | 29 + .../rand.dist.pois.weibull/io.pass.cpp | 41 + .../rand.dist.pois.weibull/max.pass.cpp | 28 + .../rand.dist.pois.weibull/min.pass.cpp | 27 + .../param_assign.pass.cpp | 32 + .../param_copy.pass.cpp | 31 + .../param_ctor.pass.cpp | 44 + .../rand.dist.pois.weibull/param_eq.pass.cpp | 37 + .../param_types.pass.cpp | 28 + .../rand.dist.pois.weibull/set_param.pass.cpp | 30 + .../rand.dist.pois.weibull/types.pass.cpp | 34 + .../rand.dist.samp/nothing_to_do.pass.cpp | 12 + .../rand.dist.samp.discrete/assign.pass.cpp | 35 + .../rand.dist.samp.discrete/copy.pass.cpp | 33 + .../ctor_default.pass.cpp | 29 + .../ctor_func.pass.cpp | 60 + .../ctor_init.pass.cpp | 81 + .../ctor_iterator.pass.cpp | 87 + .../ctor_param.pass.cpp | 33 + .../rand.dist.samp.discrete/eq.pass.cpp | 45 + .../rand.dist.samp.discrete/eval.pass.cpp | 279 + .../eval_param.pass.cpp | 45 + .../get_param.pass.cpp | 30 + .../rand.dist.samp.discrete/io.pass.cpp | 42 + .../rand.dist.samp.discrete/max.pass.cpp | 34 + .../rand.dist.samp.discrete/min.pass.cpp | 28 + .../param_assign.pass.cpp | 32 + .../param_copy.pass.cpp | 31 + .../param_ctor_default.pass.cpp | 32 + .../param_ctor_func.pass.cpp | 64 + .../param_ctor_init.pass.cpp | 88 + .../param_ctor_iterator.pass.cpp | 94 + .../rand.dist.samp.discrete/param_eq.pass.cpp | 39 + .../param_types.pass.cpp | 28 + .../set_param.pass.cpp | 31 + .../rand.dist.samp.discrete/types.pass.cpp | 32 + .../rand.dist.samp.pconst/assign.pass.cpp | 36 + .../rand.dist.samp.pconst/copy.pass.cpp | 34 + .../ctor_default.pass.cpp | 35 + .../rand.dist.samp.pconst/ctor_func.pass.cpp | 64 + .../ctor_init_func.pass.cpp | 78 + .../ctor_iterator.pass.cpp | 96 + .../rand.dist.samp.pconst/ctor_param.pass.cpp | 41 + .../rand.dist.samp.pconst/eq.pass.cpp | 47 + .../rand.dist.samp.pconst/eval.pass.cpp | 695 + .../rand.dist.samp.pconst/eval_param.pass.cpp | 97 + .../rand.dist.samp.pconst/get_param.pass.cpp | 32 + .../rand.dist.samp.pconst/io.pass.cpp | 44 + .../rand.dist.samp.pconst/max.pass.cpp | 30 + .../rand.dist.samp.pconst/min.pass.cpp | 30 + .../param_assign.pass.cpp | 34 + .../rand.dist.samp.pconst/param_copy.pass.cpp | 33 + .../param_ctor_default.pass.cpp | 34 + .../param_ctor_func.pass.cpp | 67 + .../param_ctor_init_func.pass.cpp | 79 + .../param_ctor_iterator.pass.cpp | 100 + .../rand.dist.samp.pconst/param_eq.pass.cpp | 41 + .../param_types.pass.cpp | 28 + .../rand.dist.samp.pconst/set_param.pass.cpp | 32 + .../rand.dist.samp.pconst/types.pass.cpp | 32 + .../rand.dist.samp.plinear/assign.pass.cpp | 36 + .../rand.dist.samp.plinear/copy.pass.cpp | 34 + .../ctor_default.pass.cpp | 36 + .../rand.dist.samp.plinear/ctor_func.pass.cpp | 69 + .../ctor_init_func.pass.cpp | 82 + .../ctor_iterator.pass.cpp | 101 + .../ctor_param.pass.cpp | 42 + .../rand.dist.samp.plinear/eq.pass.cpp | 47 + .../rand.dist.samp.plinear/eval.pass.cpp | 343 + .../eval_param.pass.cpp | 92 + .../rand.dist.samp.plinear/get_param.pass.cpp | 32 + .../rand.dist.samp.plinear/io.pass.cpp | 44 + .../rand.dist.samp.plinear/max.pass.cpp | 30 + .../rand.dist.samp.plinear/min.pass.cpp | 30 + .../param_assign.pass.cpp | 34 + .../param_copy.pass.cpp | 33 + .../param_ctor_default.pass.cpp | 35 + .../param_ctor_func.pass.cpp | 70 + .../param_ctor_init_func.pass.cpp | 83 + .../param_ctor_iterator.pass.cpp | 105 + .../rand.dist.samp.plinear/param_eq.pass.cpp | 41 + .../param_types.pass.cpp | 28 + .../rand.dist.samp.plinear/set_param.pass.cpp | 32 + .../rand.dist.samp.plinear/types.pass.cpp | 32 + .../rand.dist.uni/nothing_to_do.pass.cpp | 12 + .../rand.dist.uni.int/assign.pass.cpp | 34 + .../rand.dist.uni.int/copy.pass.cpp | 32 + .../rand.dist.uni.int/ctor_int_int.pass.cpp | 41 + .../rand.dist.uni.int/ctor_param.pass.cpp | 30 + .../rand.dist.uni.int/eq.pass.cpp | 37 + .../rand.dist.uni.int/eval.pass.cpp | 455 + .../rand.dist.uni.int/eval_param.pass.cpp | 75 + .../rand.dist.uni.int/get_param.pass.cpp | 29 + .../rand.dist.uni.int/io.pass.cpp | 41 + .../rand.dist.uni.int/max.pass.cpp | 27 + .../rand.dist.uni.int/min.pass.cpp | 27 + .../rand.dist.uni.int/param_assign.pass.cpp | 32 + .../rand.dist.uni.int/param_copy.pass.cpp | 31 + .../rand.dist.uni.int/param_ctor.pass.cpp | 44 + .../rand.dist.uni.int/param_eq.pass.cpp | 37 + .../rand.dist.uni.int/param_types.pass.cpp | 28 + .../rand.dist.uni.int/set_param.pass.cpp | 30 + .../rand.dist.uni.int/types.pass.cpp | 27 + .../rand.dist.uni.real/assign.pass.cpp | 34 + .../rand.dist.uni.real/copy.pass.cpp | 32 + .../rand.dist.uni.real/ctor_int_int.pass.cpp | 41 + .../rand.dist.uni.real/ctor_param.pass.cpp | 30 + .../rand.dist.uni.real/eq.pass.cpp | 37 + .../rand.dist.uni.real/eval.pass.cpp | 474 + .../rand.dist.uni.real/eval_param.pass.cpp | 74 + .../rand.dist.uni.real/get_param.pass.cpp | 29 + .../rand.dist.uni.real/io.pass.cpp | 41 + .../rand.dist.uni.real/max.pass.cpp | 27 + .../rand.dist.uni.real/min.pass.cpp | 27 + .../rand.dist.uni.real/param_assign.pass.cpp | 32 + .../rand.dist.uni.real/param_copy.pass.cpp | 31 + .../rand.dist.uni.real/param_ctor.pass.cpp | 44 + .../rand.dist.uni.real/param_eq.pass.cpp | 37 + .../rand.dist.uni.real/param_types.pass.cpp | 28 + .../rand.dist.uni.real/set_param.pass.cpp | 30 + .../rand.dist.uni.real/types.pass.cpp | 27 + .../rand/rand.eng/nothing_to_do.pass.cpp | 12 + .../rand.eng/rand.eng.lcong/assign.pass.cpp | 58 + .../rand.eng/rand.eng.lcong/copy.pass.cpp | 58 + .../rand.eng.lcong/ctor_result_type.pass.cpp | 154 + .../rand.eng.lcong/ctor_sseq.pass.cpp | 29 + .../rand.eng/rand.eng.lcong/default.pass.cpp | 57 + .../rand.eng/rand.eng.lcong/discard.pass.cpp | 73 + .../rand.eng/rand.eng.lcong/eval.pass.cpp | 87 + .../rand/rand.eng/rand.eng.lcong/io.pass.cpp | 44 + .../rand.eng.lcong/result_type.pass.cpp | 37 + .../rand.eng.lcong/seed_result_type.pass.cpp | 40 + .../rand.eng.lcong/seed_sseq.pass.cpp | 39 + .../rand.eng/rand.eng.lcong/values.pass.cpp | 74 + .../rand.eng/rand.eng.mers/assign.pass.cpp | 58 + .../rand/rand.eng/rand.eng.mers/copy.pass.cpp | 56 + .../rand.eng.mers/ctor_result_type.pass.cpp | 245 + .../rand.eng/rand.eng.mers/ctor_sseq.pass.cpp | 309 + .../rand.eng/rand.eng.mers/default.pass.cpp | 45 + .../rand.eng/rand.eng.mers/discard.pass.cpp | 55 + .../rand/rand.eng/rand.eng.mers/eval.pass.cpp | 45 + .../rand/rand.eng/rand.eng.mers/io.pass.cpp | 69 + .../rand.eng.mers/result_type.pass.cpp | 44 + .../rand.eng.mers/seed_result_type.pass.cpp | 52 + .../rand.eng/rand.eng.mers/seed_sseq.pass.cpp | 50 + .../rand.eng/rand.eng.mers/values.pass.cpp | 122 + .../rand.eng/rand.eng.sub/assign.pass.cpp | 56 + .../rand/rand.eng/rand.eng.sub/copy.pass.cpp | 54 + .../rand.eng.sub/ctor_result_type.pass.cpp | 51 + .../rand.eng/rand.eng.sub/ctor_sseq.pass.cpp | 55 + .../rand.eng/rand.eng.sub/default.pass.cpp | 42 + .../rand.eng/rand.eng.sub/discard.pass.cpp | 52 + .../rand/rand.eng/rand.eng.sub/eval.pass.cpp | 42 + .../rand/rand.eng/rand.eng.sub/io.pass.cpp | 63 + .../rand.eng.sub/result_type.pass.cpp | 42 + .../rand.eng.sub/seed_result_type.pass.cpp | 50 + .../rand.eng/rand.eng.sub/seed_sseq.pass.cpp | 48 + .../rand.eng/rand.eng.sub/values.pass.cpp | 70 + .../default_random_engine.pass.cpp | 22 + .../rand/rand.predef/knuth_b.pass.cpp | 22 + .../rand/rand.predef/minstd_rand.pass.cpp | 23 + .../rand/rand.predef/minstd_rand0.pass.cpp | 23 + .../rand/rand.predef/mt19937.pass.cpp | 27 + .../rand/rand.predef/mt19937_64.pass.cpp | 27 + .../rand/rand.predef/ranlux24.pass.cpp | 22 + .../rand/rand.predef/ranlux24_base.pass.cpp | 22 + .../rand/rand.predef/ranlux48.pass.cpp | 22 + .../rand/rand.predef/ranlux48_base.pass.cpp | 22 + .../rand/rand.req/nothing_to_do.pass.cpp | 12 + .../rand.req.adapt/nothing_to_do.pass.cpp | 12 + .../rand.req.dst/nothing_to_do.pass.cpp | 12 + .../rand.req.eng/nothing_to_do.pass.cpp | 12 + .../rand.req.genl/nothing_to_do.pass.cpp | 12 + .../rand.req.seedseq/nothing_to_do.pass.cpp | 12 + .../rand.req.urng/nothing_to_do.pass.cpp | 12 + .../rand/rand.synopsis/version.pass.cpp | 20 + .../rand/rand.util/nothing_to_do.pass.cpp | 12 + .../generate_canonical.pass.cpp | 100 + .../rand.util.seedseq/assign.fail.cpp | 23 + .../rand.util/rand.util.seedseq/copy.fail.cpp | 22 + .../rand.util.seedseq/default.pass.cpp | 23 + .../rand.util.seedseq/generate.pass.cpp | 805 + .../initializer_list.pass.cpp | 33 + .../rand.util.seedseq/iterator.pass.cpp | 32 + .../rand.util.seedseq/types.pass.cpp | 24 + test/std/re/nothing_to_do.pass.cpp | 12 + test/std/re/re.alg/nothing_to_do.pass.cpp | 12 + test/std/re/re.alg/re.alg.match/awk.pass.cpp | 1390 + .../std/re/re.alg/re.alg.match/basic.fail.cpp | 36 + .../std/re/re.alg/re.alg.match/basic.pass.cpp | 1367 + test/std/re/re.alg/re.alg.match/ecma.pass.cpp | 1349 + .../std/re/re.alg/re.alg.match/egrep.pass.cpp | 81 + .../re/re.alg/re.alg.match/extended.pass.cpp | 1363 + test/std/re/re.alg/re.alg.match/grep.pass.cpp | 49 + .../re.alg.match/lookahead_capture.pass.cpp | 98 + .../parse_curly_brackets.pass.cpp | 72 + .../re/re.alg/re.alg.replace/test1.pass.cpp | 107 + .../re/re.alg/re.alg.replace/test2.pass.cpp | 107 + .../re/re.alg/re.alg.replace/test3.pass.cpp | 73 + .../re/re.alg/re.alg.replace/test4.pass.cpp | 72 + .../re/re.alg/re.alg.replace/test5.pass.cpp | 73 + .../re/re.alg/re.alg.replace/test6.pass.cpp | 73 + test/std/re/re.alg/re.alg.search/awk.pass.cpp | 1574 + .../re/re.alg/re.alg.search/backup.pass.cpp | 63 + .../re/re.alg/re.alg.search/basic.fail.cpp | 36 + .../re/re.alg/re.alg.search/basic.pass.cpp | 1547 + .../std/re/re.alg/re.alg.search/ecma.pass.cpp | 1589 + .../re/re.alg/re.alg.search/egrep.pass.cpp | 90 + .../re/re.alg/re.alg.search/extended.pass.cpp | 1543 + .../std/re/re.alg/re.alg.search/grep.pass.cpp | 58 + .../re.alg/re.alg.search/lookahead.pass.cpp | 28 + .../re.alg.search/no_update_pos.pass.cpp | 38 + .../re.alg/re.except/nothing_to_do.pass.cpp | 12 + test/std/re/re.badexp/regex_error.pass.cpp | 96 + test/std/re/re.const/nothing_to_do.pass.cpp | 13 + .../re/re.const/re.err/error_type.pass.cpp | 143 + .../re.matchflag/match_flag_type.pass.cpp | 128 + .../re.matchflag/match_not_bol.pass.cpp | 50 + .../re.matchflag/match_not_eol.pass.cpp | 50 + .../re.synopt/syntax_option_type.pass.cpp | 114 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + .../nothing_to_do.pass.cpp | 13 + test/std/re/re.def/nothing_to_do.pass.cpp | 13 + test/std/re/re.general/nothing_to_do.pass.cpp | 13 + test/std/re/re.grammar/nothing_to_do.pass.cpp | 12 + test/std/re/re.iter/nothing_to_do.pass.cpp | 12 + .../re.regiter.cnstr/cnstr.fail.cpp | 36 + .../re.regiter.cnstr/cnstr.pass.cpp | 44 + .../re.regiter.cnstr/default.pass.cpp | 32 + .../re.regiter.comp/tested_elsewhere.pass.cpp | 19 + .../re.regiter.deref/deref.pass.cpp | 42 + .../re.regiter/re.regiter.incr/post.pass.cpp | 97 + test/std/re/re.iter/re.regiter/types.pass.cpp | 45 + .../re.tokiter.cnstr/array.fail.cpp | 39 + .../re.tokiter.cnstr/array.pass.cpp | 64 + .../re.tokiter.cnstr/default.pass.cpp | 32 + .../re.tokiter/re.tokiter.cnstr/init.fail.cpp | 36 + .../re.tokiter/re.tokiter.cnstr/init.pass.cpp | 64 + .../re.tokiter/re.tokiter.cnstr/int.fail.cpp | 35 + .../re.tokiter/re.tokiter.cnstr/int.pass.cpp | 75 + .../re.tokiter.cnstr/vector.fail.cpp | 40 + .../re.tokiter.cnstr/vector.pass.cpp | 128 + .../re.tokiter/re.tokiter.comp/equal.pass.cpp | 36 + .../re.tokiter.deref/deref.pass.cpp | 72 + .../re.tokiter/re.tokiter.incr/post.pass.cpp | 135 + test/std/re/re.iter/re.tokiter/types.pass.cpp | 45 + .../re.regex.assign/assign.il.pass.cpp | 33 + .../re.regex/re.regex.assign/assign.pass.cpp | 35 + .../assign_iter_iter_flag.pass.cpp | 46 + .../re.regex.assign/assign_ptr_flag.pass.cpp | 29 + .../assign_ptr_size_flag.pass.cpp | 25 + .../assign_string_flag.pass.cpp | 31 + .../re/re.regex/re.regex.assign/copy.pass.cpp | 26 + .../re/re.regex/re.regex.assign/il.pass.cpp | 27 + .../re/re.regex/re.regex.assign/ptr.pass.cpp | 25 + .../re.regex/re.regex.assign/string.pass.cpp | 26 + .../re.regex.const/constants.pass.cpp | 65 + .../re.regex.construct/awk_oct.pass.cpp | 28 + .../re.regex.construct/bad_escape.pass.cpp | 45 + .../re.regex/re.regex.construct/copy.pass.cpp | 25 + .../re.regex.construct/default.pass.cpp | 32 + .../re.regex.construct/il_flg.pass.cpp | 70 + .../re.regex.construct/iter_iter.pass.cpp | 43 + .../re.regex.construct/iter_iter_flg.pass.cpp | 69 + .../re.regex/re.regex.construct/ptr.pass.cpp | 34 + .../re.regex.construct/ptr_flg.pass.cpp | 59 + .../re.regex.construct/ptr_size_flg.pass.cpp | 60 + .../re.regex.construct/string.pass.cpp | 35 + .../re.regex.construct/string_flg.pass.cpp | 61 + .../re.regex/re.regex.locale/imbue.pass.cpp | 31 + .../re.regex.nonmemb/nothing_to_do.pass.cpp | 12 + .../re.regex.nmswap/swap.pass.cpp | 29 + .../tested_elsewhere.pass.cpp | 12 + .../re/re.regex/re.regex.swap/swap.pass.cpp | 28 + test/std/re/re.regex/types.pass.cpp | 35 + test/std/re/re.req/nothing_to_do.pass.cpp | 13 + .../re.results.acc/begin_end.pass.cpp | 38 + .../re.results.acc/cbegin_cend.pass.cpp | 38 + .../re.results/re.results.acc/index.pass.cpp | 53 + .../re.results/re.results.acc/length.pass.cpp | 36 + .../re.results.acc/position.pass.cpp | 36 + .../re.results/re.results.acc/prefix.pass.cpp | 34 + .../re/re.results/re.results.acc/str.pass.cpp | 36 + .../re.results/re.results.acc/suffix.pass.cpp | 34 + .../re.results.all/get_allocator.pass.cpp | 35 + .../re.results.const/allocator.pass.cpp | 35 + .../re.results.const/default.pass.cpp | 33 + .../re.results/re.results.form/form1.pass.cpp | 103 + .../re.results/re.results.form/form2.pass.cpp | 102 + .../re.results/re.results.form/form3.pass.cpp | 85 + .../re.results/re.results.form/form4.pass.cpp | 80 + .../re.results.nonmember/equal.pass.cpp | 46 + .../re.results/re.results.size/empty.pass.cpp | 36 + .../re.results.size/max_size.pass.cpp | 31 + .../re.results.state/ready.pass.cpp | 43 + .../re.results.swap/member_swap.pass.cpp | 39 + .../re.results.swap/non_member_swap.pass.cpp | 41 + test/std/re/re.results/types.pass.cpp | 51 + .../compare_string_type.pass.cpp | 49 + .../compare_sub_match.pass.cpp | 53 + .../compare_value_type_ptr.pass.cpp | 47 + .../re.submatch.members/default.pass.cpp | 33 + .../re.submatch.members/length.pass.cpp | 43 + .../operator_string.pass.cpp | 47 + .../re.submatch.members/str.pass.cpp | 47 + .../re.submatch.op/compare.pass.cpp | 287 + .../re.submatch.op/stream.pass.cpp | 42 + test/std/re/re.submatch/types.pass.cpp | 64 + test/std/re/re.syn/cmatch.pass.cpp | 20 + test/std/re/re.syn/cregex_iterator.pass.cpp | 20 + .../re/re.syn/cregex_token_iterator.pass.cpp | 20 + test/std/re/re.syn/csub_match.pass.cpp | 20 + test/std/re/re.syn/regex.pass.cpp | 20 + test/std/re/re.syn/smatch.pass.cpp | 20 + test/std/re/re.syn/sregex_iterator.pass.cpp | 20 + .../re/re.syn/sregex_token_iterator.pass.cpp | 20 + test/std/re/re.syn/ssub_match.pass.cpp | 20 + test/std/re/re.syn/wcmatch.pass.cpp | 20 + test/std/re/re.syn/wcregex_iterator.pass.cpp | 20 + .../re/re.syn/wcregex_token_iterator.pass.cpp | 20 + test/std/re/re.syn/wcsub_match.pass.cpp | 20 + test/std/re/re.syn/wregex.pass.cpp | 20 + test/std/re/re.syn/wsmatch.pass.cpp | 20 + test/std/re/re.syn/wsregex_iterator.pass.cpp | 20 + .../re/re.syn/wsregex_token_iterator.pass.cpp | 20 + test/std/re/re.syn/wssub_match.pass.cpp | 20 + test/std/re/re.traits/default.pass.cpp | 37 + test/std/re/re.traits/getloc.pass.cpp | 36 + test/std/re/re.traits/imbue.pass.cpp | 30 + test/std/re/re.traits/isctype.pass.cpp | 279 + test/std/re/re.traits/length.pass.cpp | 31 + .../re/re.traits/lookup_classname.pass.cpp | 211 + .../re/re.traits/lookup_collatename.pass.cpp | 192 + test/std/re/re.traits/transform.pass.cpp | 46 + .../re/re.traits/transform_primary.pass.cpp | 51 + test/std/re/re.traits/translate.pass.cpp | 34 + .../re/re.traits/translate_nocase.pass.cpp | 72 + test/std/re/re.traits/types.pass.cpp | 32 + test/std/re/re.traits/value.pass.cpp | 125 + .../basic.string.hash/strings.pass.cpp | 48 + .../basic.string.literals/literal.pass.cpp | 47 + .../basic.string.literals/literal1.fail.cpp | 22 + .../basic.string.literals/literal1.pass.cpp | 20 + .../basic.string.literals/literal2.fail.cpp | 20 + .../basic.string.literals/literal2.pass.cpp | 20 + .../basic.string.literals/literal3.pass.cpp | 20 + .../std/strings/basic.string/input_iterator.h | 41 + .../basic.string/string.access/at.pass.cpp | 58 + .../basic.string/string.access/back.pass.cpp | 56 + .../string.access/db_back.pass.cpp | 54 + .../string.access/db_cback.pass.cpp | 50 + .../string.access/db_cfront.pass.cpp | 50 + .../string.access/db_cindex.pass.cpp | 52 + .../string.access/db_front.pass.cpp | 54 + .../string.access/db_index.pass.cpp | 52 + .../basic.string/string.access/front.pass.cpp | 56 + .../basic.string/string.access/index.pass.cpp | 63 + .../string.capacity/capacity.pass.cpp | 58 + .../string.capacity/clear.pass.cpp | 57 + .../string.capacity/empty.pass.cpp | 42 + .../string.capacity/length.pass.cpp | 42 + .../string.capacity/max_size.pass.cpp | 73 + .../string.capacity/over_max_size.pass.cpp | 47 + .../string.capacity/reserve.pass.cpp | 117 + .../string.capacity/resize_size.pass.cpp | 79 + .../string.capacity/resize_size_char.pass.cpp | 79 + .../string.capacity/shrink_to_fit.pass.cpp | 62 + .../string.capacity/size.pass.cpp | 42 + .../basic.string/string.cons/alloc.pass.cpp | 95 + .../string.cons/char_assignment.pass.cpp | 49 + .../basic.string/string.cons/copy.pass.cpp | 49 + .../string.cons/copy_alloc.pass.cpp | 49 + .../string.cons/copy_assignment.pass.cpp | 70 + .../string.cons/default_noexcept.pass.cpp | 46 + .../string.cons/dtor_noexcept.pass.cpp | 47 + .../string.cons/initializer_list.pass.cpp | 46 + .../initializer_list_assignment.pass.cpp | 36 + .../string.cons/iter_alloc.pass.cpp | 119 + .../basic.string/string.cons/move.pass.cpp | 57 + .../string.cons/move_alloc.pass.cpp | 89 + .../string.cons/move_assign_noexcept.pass.cpp | 47 + .../string.cons/move_assignment.pass.cpp | 79 + .../string.cons/move_noexcept.pass.cpp | 50 + .../string.cons/pointer_alloc.pass.cpp | 89 + .../string.cons/pointer_assignment.pass.cpp | 72 + .../string.cons/pointer_size_alloc.pass.cpp | 87 + .../string.cons/size_char_alloc.pass.cpp | 128 + .../basic.string/string.cons/substr.pass.cpp | 173 + .../string.iterators/begin.pass.cpp | 48 + .../string.iterators/cbegin.pass.cpp | 45 + .../string.iterators/cend.pass.cpp | 41 + .../string.iterators/crbegin.pass.cpp | 45 + .../string.iterators/crend.pass.cpp | 41 + .../string.iterators/db_iterators_2.pass.cpp | 52 + .../string.iterators/db_iterators_3.pass.cpp | 52 + .../string.iterators/db_iterators_4.pass.cpp | 54 + .../string.iterators/db_iterators_5.pass.cpp | 58 + .../string.iterators/db_iterators_6.pass.cpp | 56 + .../string.iterators/db_iterators_7.pass.cpp | 56 + .../string.iterators/db_iterators_8.pass.cpp | 52 + .../string.iterators/end.pass.cpp | 50 + .../string.iterators/iterators.pass.cpp | 73 + .../string.iterators/rbegin.pass.cpp | 48 + .../string.iterators/rend.pass.cpp | 50 + .../string.modifiers/nothing_to_do.pass.cpp | 12 + .../string_append/initializer_list.pass.cpp | 36 + .../string_append/iterator.pass.cpp | 150 + .../string_append/pointer.pass.cpp | 63 + .../string_append/pointer_size.pass.cpp | 72 + .../string_append/push_back.pass.cpp | 44 + .../string_append/size_char.pass.cpp | 63 + .../string_append/string.pass.cpp | 79 + .../string_append/string_size_size.pass.cpp | 118 + .../string_assign/initializer_list.pass.cpp | 36 + .../string_assign/iterator.pass.cpp | 150 + .../string_assign/pointer.pass.cpp | 63 + .../string_assign/pointer_size.pass.cpp | 72 + .../string_assign/rv_string.pass.cpp | 80 + .../string_assign/size_char.pass.cpp | 63 + .../string_assign/string.pass.cpp | 79 + .../string_assign/string_size_size.pass.cpp | 118 + .../string_copy/copy.pass.cpp | 170 + .../string_erase/erase_iter_db1.pass.cpp | 50 + .../string_erase/erase_iter_db2.pass.cpp | 52 + .../string_erase/erase_iter_iter_db1.pass.cpp | 50 + .../string_erase/erase_iter_iter_db2.pass.cpp | 50 + .../string_erase/erase_iter_iter_db3.pass.cpp | 50 + .../string_erase/erase_iter_iter_db4.pass.cpp | 48 + .../string_erase/iter.pass.cpp | 64 + .../string_erase/iter_iter.pass.cpp | 149 + .../string_erase/pop_back.pass.cpp | 55 + .../string_erase/size_size.pass.cpp | 280 + .../string_insert/iter_char.pass.cpp | 88 + .../iter_initializer_list.pass.cpp | 50 + .../string_insert/iter_iter_iter.pass.cpp | 140 + .../string_insert/iter_size_char.pass.cpp | 181 + .../string_insert/size_pointer.pass.cpp | 211 + .../string_insert/size_pointer_size.pass.cpp | 692 + .../string_insert/size_size_char.pass.cpp | 212 + .../string_insert/size_string.pass.cpp | 211 + .../size_string_size_size.pass.cpp | 1784 ++ .../string_op_plus_equal/char.pass.cpp | 46 + .../initializer_list.pass.cpp | 36 + .../string_op_plus_equal/pointer.pass.cpp | 78 + .../string_op_plus_equal/string.pass.cpp | 79 + .../iter_iter_initializer_list.pass.cpp | 36 + .../iter_iter_iter_iter.pass.cpp | 976 + .../string_replace/iter_iter_pointer.pass.cpp | 285 + .../iter_iter_pointer_size.pass.cpp | 976 + .../iter_iter_size_char.pass.cpp | 286 + .../string_replace/iter_iter_string.pass.cpp | 285 + .../string_replace/size_size_pointer.pass.cpp | 375 + .../size_size_pointer_size.pass.cpp | 1327 + .../size_size_size_char.pass.cpp | 374 + .../string_replace/size_size_string.pass.cpp | 372 + .../size_size_string_size_size.pass.cpp | 5966 ++++ .../string_swap/swap.pass.cpp | 76 + .../string.nonmembers/nothing_to_do.pass.cpp | 12 + .../string.io/get_line.pass.cpp | 81 + .../string.io/get_line_delim.pass.cpp | 93 + .../string.io/get_line_delim_rv.pass.cpp | 51 + .../string.io/get_line_rv.pass.cpp | 51 + .../string.io/stream_extract.pass.cpp | 117 + .../string.io/stream_insert.pass.cpp | 91 + .../string.special/swap.pass.cpp | 78 + .../string.special/swap_noexcept.pass.cpp | 85 + .../string_op!=/pointer_string.pass.cpp | 69 + .../string_op!=/string_pointer.pass.cpp | 69 + .../string_op!=/string_string.pass.cpp | 70 + .../string_op+/char_string.pass.cpp | 80 + .../string_op+/pointer_string.pass.cpp | 128 + .../string_op+/string_char.pass.cpp | 80 + .../string_op+/string_pointer.pass.cpp | 128 + .../string_op+/string_string.pass.cpp | 222 + .../string_operator==/pointer_string.pass.cpp | 69 + .../string_operator==/string_pointer.pass.cpp | 69 + .../string_operator==/string_string.pass.cpp | 70 + .../string_opgt/pointer_string.pass.cpp | 69 + .../string_opgt/string_pointer.pass.cpp | 69 + .../string_opgt/string_string.pass.cpp | 70 + .../string_opgt=/pointer_string.pass.cpp | 69 + .../string_opgt=/string_pointer.pass.cpp | 69 + .../string_opgt=/string_string.pass.cpp | 70 + .../string_oplt/pointer_string.pass.cpp | 69 + .../string_oplt/string_pointer.pass.cpp | 69 + .../string_oplt/string_string.pass.cpp | 70 + .../string_oplt=/pointer_string.pass.cpp | 69 + .../string_oplt=/string_pointer.pass.cpp | 69 + .../string_oplt=/string_string.pass.cpp | 70 + .../string.ops/nothing_to_do.pass.cpp | 12 + .../string.accessors/c_str.pass.cpp | 52 + .../string.ops/string.accessors/data.pass.cpp | 52 + .../string.accessors/get_allocator.pass.cpp | 47 + .../string_compare/pointer.pass.cpp | 77 + .../string_compare/size_size_pointer.pass.cpp | 372 + .../size_size_pointer_size.pass.cpp | 1323 + .../string_compare/size_size_string.pass.cpp | 372 + .../size_size_string_size_size.pass.cpp | 5948 ++++ .../string.ops/string_compare/string.pass.cpp | 77 + .../char_size.pass.cpp | 102 + .../pointer_size.pass.cpp | 158 + .../pointer_size_size.pass.cpp | 387 + .../string_size.pass.cpp | 157 + .../string_find.first.of/char_size.pass.cpp | 98 + .../pointer_size.pass.cpp | 158 + .../pointer_size_size.pass.cpp | 387 + .../string_find.first.of/string_size.pass.cpp | 157 + .../char_size.pass.cpp | 98 + .../pointer_size.pass.cpp | 158 + .../pointer_size_size.pass.cpp | 387 + .../string_size.pass.cpp | 157 + .../string_find.last.of/char_size.pass.cpp | 98 + .../string_find.last.of/pointer_size.pass.cpp | 158 + .../pointer_size_size.pass.cpp | 387 + .../string_find.last.of/string_size.pass.cpp | 157 + .../string.ops/string_find/char_size.pass.cpp | 98 + .../string_find/pointer_size.pass.cpp | 164 + .../string_find/pointer_size_size.pass.cpp | 387 + .../string_find/string_size.pass.cpp | 157 + .../string_rfind/char_size.pass.cpp | 98 + .../string_rfind/pointer_size.pass.cpp | 165 + .../string_rfind/pointer_size_size.pass.cpp | 387 + .../string_rfind/string_size.pass.cpp | 157 + .../string.ops/string_substr/substr.pass.cpp | 166 + .../string.require/contiguous.pass.cpp | 53 + test/std/strings/basic.string/test_traits.h | 19 + test/std/strings/basic.string/types.pass.cpp | 85 + test/std/strings/c.strings/cctype.pass.cpp | 103 + test/std/strings/c.strings/cstring.pass.cpp | 55 + test/std/strings/c.strings/cuchar.pass.cpp | 18 + test/std/strings/c.strings/cwchar.pass.cpp | 115 + test/std/strings/c.strings/cwctype.pass.cpp | 114 + .../strings/c.strings/version_cctype.pass.cpp | 20 + .../c.strings/version_cstring.pass.cpp | 20 + .../strings/c.strings/version_cuchar.pass.cpp | 22 + .../strings/c.strings/version_cwchar.pass.cpp | 20 + .../c.strings/version_cwctype.pass.cpp | 20 + .../nothing_to_do.pass.cpp | 12 + .../assign2.pass.cpp | 24 + .../assign3.pass.cpp | 28 + .../compare.pass.cpp | 41 + .../copy.pass.cpp | 29 + .../eof.pass.cpp | 22 + .../eq.pass.cpp | 24 + .../eq_int_type.pass.cpp | 26 + .../find.pass.cpp | 28 + .../length.pass.cpp | 26 + .../lt.pass.cpp | 28 + .../move.pass.cpp | 33 + .../not_eof.pass.cpp | 26 + .../to_char_type.pass.cpp | 24 + .../to_int_type.pass.cpp | 24 + .../types.pass.cpp | 30 + .../assign2.pass.cpp | 28 + .../assign3.pass.cpp | 30 + .../compare.pass.cpp | 45 + .../copy.pass.cpp | 31 + .../eof.pass.cpp | 24 + .../eq.pass.cpp | 28 + .../eq_int_type.pass.cpp | 30 + .../find.pass.cpp | 30 + .../length.pass.cpp | 30 + .../lt.pass.cpp | 28 + .../move.pass.cpp | 35 + .../not_eof.pass.cpp | 30 + .../to_char_type.pass.cpp | 28 + .../to_int_type.pass.cpp | 28 + .../types.pass.cpp | 33 + .../assign2.pass.cpp | 28 + .../assign3.pass.cpp | 30 + .../compare.pass.cpp | 45 + .../copy.pass.cpp | 31 + .../eof.pass.cpp | 24 + .../eq.pass.cpp | 28 + .../eq_int_type.pass.cpp | 30 + .../find.pass.cpp | 30 + .../length.pass.cpp | 30 + .../lt.pass.cpp | 28 + .../move.pass.cpp | 35 + .../not_eof.pass.cpp | 30 + .../to_char_type.pass.cpp | 28 + .../to_int_type.pass.cpp | 28 + .../types.pass.cpp | 33 + .../assign2.pass.cpp | 24 + .../assign3.pass.cpp | 28 + .../compare.pass.cpp | 41 + .../copy.pass.cpp | 29 + .../eof.pass.cpp | 22 + .../eq.pass.cpp | 24 + .../eq_int_type.pass.cpp | 26 + .../find.pass.cpp | 28 + .../length.pass.cpp | 26 + .../lt.pass.cpp | 24 + .../move.pass.cpp | 33 + .../not_eof.pass.cpp | 26 + .../to_char_type.pass.cpp | 24 + .../to_int_type.pass.cpp | 24 + .../types.pass.cpp | 30 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../char.traits/nothing_to_do.pass.cpp | 12 + .../strings/string.classes/typedefs.pass.cpp | 30 + .../strings/string.conversions/stod.pass.cpp | 166 + .../strings/string.conversions/stof.pass.cpp | 170 + .../strings/string.conversions/stoi.pass.cpp | 108 + .../strings/string.conversions/stol.pass.cpp | 111 + .../strings/string.conversions/stold.pass.cpp | 168 + .../strings/string.conversions/stoll.pass.cpp | 110 + .../strings/string.conversions/stoul.pass.cpp | 109 + .../string.conversions/stoull.pass.cpp | 110 + .../string.conversions/to_string.pass.cpp | 126 + .../string.conversions/to_wstring.pass.cpp | 126 + .../strings.general/nothing_to_do.pass.cpp | 13 + test/std/strings/version.pass.cpp | 20 + .../futures/futures.async/async.pass.cpp | 198 + .../futures/futures.async/async_race.pass.cpp | 67 + .../default_error_condition.pass.cpp | 27 + .../equivalent_error_code_int.pass.cpp | 26 + .../equivalent_int_error_condition.pass.cpp | 27 + .../futures.errors/future_category.pass.cpp | 24 + .../futures.errors/make_error_code.pass.cpp | 28 + .../make_error_condition.pass.cpp | 30 + .../futures.future_error/code.pass.cpp | 43 + .../futures.future_error/types.pass.cpp | 23 + .../futures.future_error/what.pass.cpp | 50 + .../futures.overview/future_errc.pass.cpp | 30 + .../futures.overview/future_status.pass.cpp | 28 + .../is_error_code_enum_future_errc.pass.cpp | 21 + .../futures/futures.overview/launch.pass.cpp | 45 + .../futures.promise/alloc_ctor.pass.cpp | 84 + .../futures.promise/copy_assign.fail.cpp | 87 + .../futures.promise/copy_ctor.fail.cpp | 81 + .../futures/futures.promise/default.pass.cpp | 38 + .../futures/futures.promise/dtor.pass.cpp | 116 + .../futures.promise/get_future.pass.cpp | 55 + .../futures.promise/move_assign.pass.cpp | 91 + .../futures.promise/move_ctor.pass.cpp | 85 + .../futures.promise/set_exception.pass.cpp | 47 + .../set_exception_at_thread_exit.pass.cpp | 44 + .../futures.promise/set_lvalue.pass.cpp | 43 + .../set_lvalue_at_thread_exit.pass.cpp | 38 + .../futures.promise/set_rvalue.pass.cpp | 69 + .../set_rvalue_at_thread_exit.pass.cpp | 41 + .../set_value_at_thread_exit_const.pass.cpp | 35 + .../set_value_at_thread_exit_void.pass.cpp | 39 + .../futures.promise/set_value_const.pass.cpp | 63 + .../futures.promise/set_value_void.pass.cpp | 39 + .../futures/futures.promise/swap.pass.cpp | 84 + .../futures.promise/uses_allocator.pass.cpp | 28 + .../copy_assign.pass.cpp | 76 + .../futures.shared_future/copy_ctor.pass.cpp | 68 + .../ctor_future.pass.cpp | 68 + .../futures.shared_future/default.pass.cpp | 35 + .../futures.shared_future/dtor.pass.cpp | 68 + .../futures.shared_future/get.pass.cpp | 145 + .../move_assign.pass.cpp | 76 + .../futures.shared_future/move_ctor.pass.cpp | 68 + .../futures.shared_future/wait.pass.cpp | 88 + .../futures.shared_future/wait_for.pass.cpp | 97 + .../futures.shared_future/wait_until.pass.cpp | 129 + .../futures.state/nothing_to_do.pass.cpp | 13 + .../futures.task.members/assign_copy.fail.cpp | 48 + .../futures.task.members/assign_move.pass.cpp | 50 + .../futures.task.members/ctor1.fail.cpp | 29 + .../futures.task.members/ctor2.fail.cpp | 30 + .../futures.task.members/ctor_copy.fail.cpp | 46 + .../ctor_default.pass.cpp | 27 + .../futures.task.members/ctor_func.pass.cpp | 79 + .../ctor_func_alloc.pass.cpp | 124 + .../futures.task.members/ctor_move.pass.cpp | 48 + .../futures.task.members/dtor.pass.cpp | 62 + .../futures.task.members/get_future.pass.cpp | 64 + .../make_ready_at_thread_exit.pass.cpp | 106 + .../futures.task.members/operator.pass.cpp | 107 + .../futures.task.members/reset.pass.cpp | 60 + .../futures.task.members/swap.pass.cpp | 50 + .../futures.task.nonmembers/swap.pass.cpp | 52 + .../uses_allocator.pass.cpp | 26 + .../thread/futures/futures.tas/types.pass.cpp | 28 + .../copy_assign.fail.cpp | 74 + .../futures.unique_future/copy_ctor.fail.cpp | 66 + .../futures.unique_future/default.pass.cpp | 35 + .../futures.unique_future/dtor.pass.cpp | 68 + .../futures.unique_future/get.pass.cpp | 145 + .../move_assign.pass.cpp | 76 + .../futures.unique_future/move_ctor.pass.cpp | 70 + .../futures.unique_future/share.pass.cpp | 68 + .../futures.unique_future/wait.pass.cpp | 88 + .../futures.unique_future/wait_for.pass.cpp | 97 + .../futures.unique_future/wait_until.pass.cpp | 129 + test/std/thread/futures/test_allocator.h | 158 + test/std/thread/futures/version.pass.cpp | 22 + test/std/thread/macro.pass.cpp | 23 + .../thread.condition/cv_status.pass.cpp | 23 + .../notify_all_at_thread_exit.pass.cpp | 44 + .../thread.condition.condvar/assign.fail.cpp | 24 + .../thread.condition.condvar/copy.fail.cpp | 23 + .../thread.condition.condvar/default.pass.cpp | 24 + .../destructor.pass.cpp | 58 + .../native_handle.pass.cpp | 29 + .../notify_all.pass.cpp | 69 + .../notify_one.pass.cpp | 94 + .../thread.condition.condvar/wait.pass.cpp | 52 + .../wait_for.pass.cpp | 87 + .../wait_for_pred.pass.cpp | 95 + .../wait_pred.pass.cpp | 62 + .../wait_until.pass.cpp | 102 + .../wait_until_pred.pass.cpp | 113 + .../assign.fail.cpp | 24 + .../thread.condition.condvarany/copy.fail.cpp | 23 + .../default.pass.cpp | 24 + .../destructor.pass.cpp | 59 + .../notify_all.pass.cpp | 73 + .../notify_one.pass.cpp | 98 + .../wait.exception.pass.cpp | 63 + .../thread.condition.condvarany/wait.pass.cpp | 57 + .../wait_for.exception.pass.cpp | 63 + .../wait_for.pass.cpp | 90 + .../wait_for_pred.pass.cpp | 98 + .../wait_pred.pass.cpp | 66 + .../wait_until.pass.cpp | 105 + .../wait_until_pred.pass.cpp | 117 + .../thread/thread.condition/version.pass.cpp | 22 + .../thread.general/nothing_to_do.pass.cpp | 12 + .../thread.lock.algorithm/lock.pass.cpp | 507 + .../thread.lock.algorithm/try_lock.pass.cpp | 516 + .../thread.lock.guard/adopt_lock.pass.cpp | 51 + .../thread.lock.guard/assign.fail.cpp | 25 + .../thread.lock.guard/copy.fail.cpp | 23 + .../thread.lock.guard/mutex.fail.cpp | 48 + .../thread.lock.guard/mutex.pass.cpp | 50 + .../thread.lock.guard/types.pass.cpp | 29 + .../copy_assign.fail.cpp | 34 + .../copy_ctor.fail.cpp | 30 + .../thread.lock.shared.cons/default.pass.cpp | 28 + .../move_assign.pass.cpp | 39 + .../move_ctor.pass.cpp | 35 + .../thread.lock.shared.cons/mutex.pass.cpp | 81 + .../mutex_adopt_lock.pass.cpp | 30 + .../mutex_defer_lock.pass.cpp | 29 + .../mutex_duration.pass.cpp | 81 + .../mutex_time_point.pass.cpp | 81 + .../mutex_try_to_lock.pass.cpp | 74 + .../thread.lock.shared.locking/lock.pass.cpp | 79 + .../try_lock.pass.cpp | 70 + .../try_lock_for.pass.cpp | 75 + .../try_lock_until.pass.cpp | 75 + .../unlock.pass.cpp | 62 + .../member_swap.pass.cpp | 45 + .../nonmember_swap.pass.cpp | 46 + .../thread.lock.shared.mod/release.pass.cpp | 53 + .../thread.lock.shared.obs/mutex.pass.cpp | 38 + .../thread.lock.shared.obs/op_bool.pass.cpp | 38 + .../thread.lock.shared.obs/owns_lock.pass.cpp | 38 + .../thread.lock.shared/types.pass.cpp | 31 + .../copy_assign.fail.cpp | 31 + .../copy_ctor.fail.cpp | 29 + .../thread.lock.unique.cons/default.pass.cpp | 26 + .../move_assign.pass.cpp | 35 + .../move_ctor.pass.cpp | 33 + .../thread.lock.unique.cons/mutex.pass.cpp | 50 + .../mutex_adopt_lock.pass.cpp | 28 + .../mutex_defer_lock.pass.cpp | 27 + .../mutex_duration.pass.cpp | 68 + .../mutex_time_point.pass.cpp | 68 + .../mutex_try_to_lock.pass.cpp | 64 + .../thread.lock.unique.locking/lock.pass.cpp | 69 + .../try_lock.pass.cpp | 64 + .../try_lock_for.pass.cpp | 69 + .../try_lock_until.pass.cpp | 69 + .../unlock.pass.cpp | 56 + .../member_swap.pass.cpp | 38 + .../nonmember_swap.pass.cpp | 39 + .../thread.lock.unique.mod/release.pass.cpp | 46 + .../thread.lock.unique.obs/mutex.pass.cpp | 31 + .../thread.lock.unique.obs/op_bool.pass.cpp | 31 + .../thread.lock.unique.obs/owns_lock.pass.cpp | 31 + .../thread.lock.unique/types.pass.cpp | 29 + .../thread.mutex/thread.lock/types.pass.cpp | 34 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../thread.mutex.class/assign.fail.cpp | 23 + .../thread.mutex.class/copy.fail.cpp | 22 + .../thread.mutex.class/default.pass.cpp | 23 + .../thread.mutex.class/lock.pass.cpp | 50 + .../thread.mutex.class/native_handle.pass.cpp | 27 + .../thread.mutex.class/try_lock.pass.cpp | 52 + .../thread.mutex.recursive/assign.fail.cpp | 23 + .../thread.mutex.recursive/copy.fail.cpp | 22 + .../thread.mutex.recursive/default.pass.cpp | 23 + .../thread.mutex.recursive/lock.pass.cpp | 52 + .../native_handle.pass.cpp | 27 + .../thread.mutex.recursive/try_lock.pass.cpp | 54 + .../nothing_to_do.pass.cpp | 12 + .../thread.shared_mutex.class/assign.fail.cpp | 29 + .../thread.shared_mutex.class/copy.fail.cpp | 28 + .../default.pass.cpp | 24 + .../thread.shared_mutex.class/lock.pass.cpp | 50 + .../lock_shared.pass.cpp | 73 + .../try_lock.pass.cpp | 53 + .../try_lock_shared.pass.cpp | 58 + .../nothing_to_do.pass.cpp | 12 + .../assign.fail.cpp | 27 + .../copy.fail.cpp | 26 + .../default.pass.cpp | 24 + .../lock.pass.cpp | 49 + .../lock_shared.pass.cpp | 73 + .../try_lock.pass.cpp | 53 + .../try_lock_for.pass.cpp | 68 + .../try_lock_shared.pass.cpp | 57 + .../try_lock_shared_for.pass.cpp | 75 + .../try_lock_shared_until.pass.cpp | 75 + .../try_lock_until.pass.cpp | 70 + .../try_lock_until_deadlock_bug.pass.cpp | 70 + .../nothing_to_do.pass.cpp | 12 + .../thread.timedmutex.class/assign.fail.cpp | 23 + .../thread.timedmutex.class/copy.fail.cpp | 22 + .../thread.timedmutex.class/default.pass.cpp | 23 + .../thread.timedmutex.class/lock.pass.cpp | 50 + .../thread.timedmutex.class/try_lock.pass.cpp | 52 + .../try_lock_for.pass.cpp | 67 + .../try_lock_until.pass.cpp | 67 + .../assign.fail.cpp | 23 + .../thread.timedmutex.recursive/copy.fail.cpp | 22 + .../default.pass.cpp | 23 + .../thread.timedmutex.recursive/lock.pass.cpp | 52 + .../try_lock.pass.cpp | 54 + .../try_lock_for.pass.cpp | 69 + .../try_lock_until.pass.cpp | 69 + .../thread.once/nothing_to_do.pass.cpp | 12 + .../thread.once.callonce/call_once.pass.cpp | 254 + .../thread.once.onceflag/assign.fail.cpp | 23 + .../thread.once.onceflag/copy.fail.cpp | 22 + .../thread.once.onceflag/default.pass.cpp | 28 + test/std/thread/thread.mutex/version.pass.cpp | 20 + .../thread/thread.req/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../thread.req.native/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../thread.req.timing/nothing_to_do.pass.cpp | 12 + .../thread.thread.algorithm/swap.pass.cpp | 58 + .../thread.thread.assign/copy.fail.cpp | 51 + .../thread.thread.assign/move.pass.cpp | 65 + .../thread.thread.assign/move2.pass.cpp | 77 + .../thread.thread.constr/F.pass.cpp | 154 + .../thread.thread.constr/constr.fail.cpp | 26 + .../thread.thread.constr/copy.fail.cpp | 66 + .../thread.thread.constr/default.pass.cpp | 25 + .../thread.thread.constr/move.pass.cpp | 72 + .../thread.thread.destr/dtor.pass.cpp | 66 + .../thread.thread.id/assign.pass.cpp | 29 + .../thread.thread.id/copy.pass.cpp | 26 + .../thread.thread.id/default.pass.cpp | 25 + .../thread.thread.id/eq.pass.cpp | 32 + .../thread.thread.id/lt.pass.cpp | 43 + .../thread.thread.id/stream.pass.cpp | 29 + .../thread.thread.id/thread_id.pass.cpp | 35 + .../thread.thread.member/detach.pass.cpp | 73 + .../thread.thread.member/get_id.pass.cpp | 57 + .../thread.thread.member/join.pass.cpp | 54 + .../thread.thread.member/joinable.pass.cpp | 54 + .../native_handle.pass.cpp | 54 + .../thread.thread.member/swap.pass.cpp | 58 + .../hardware_concurrency.pass.cpp | 24 + .../thread.thread.class/types.pass.cpp | 27 + .../thread.thread.this/get_id.pass.cpp | 23 + .../thread.thread.this/sleep_for.pass.cpp | 57 + .../thread.thread.this/sleep_until.pass.cpp | 34 + .../thread.thread.this/yield.pass.cpp | 22 + .../thread/thread.threads/version.pass.cpp | 22 + .../allocator.adaptor.cnstr/allocs.pass.cpp | 112 + .../converting_copy.pass.cpp | 69 + .../converting_move.pass.cpp | 75 + .../allocator.adaptor.cnstr/copy.pass.cpp | 70 + .../allocator.adaptor.cnstr/default.pass.cpp | 58 + .../allocate_size.pass.cpp | 49 + .../allocate_size_hint.pass.cpp | 70 + .../construct.pass.cpp | 193 + .../deallocate.pass.cpp | 46 + .../destroy.pass.cpp | 70 + .../inner_allocator.pass.cpp | 45 + .../max_size.pass.cpp | 43 + .../outer_allocator.pass.cpp | 44 + ...ct_on_container_copy_construction.pass.cpp | 55 + .../allocator_pointers.pass.cpp | 117 + .../inner_allocator_type.pass.cpp | 39 + .../is_always_equal.pass.cpp | 75 + ...gate_on_container_copy_assignment.pass.cpp | 39 + ...gate_on_container_move_assignment.pass.cpp | 39 + .../propagate_on_container_swap.pass.cpp | 39 + .../scoped.adaptor.operators/eq.pass.cpp | 64 + .../allocator.adaptor/types.pass.cpp | 102 + .../date.time/asctime.thread-unsafe.fail.cpp | 18 + .../date.time/ctime.thread-unsafe.fail.cpp | 18 + .../date.time/gmtime.thread-unsafe.fail.cpp | 18 + .../localtime.thread-unsafe.fail.cpp | 18 + .../date.time/tested_elsewhere.pass.cpp | 38 + .../arithmetic.operations/divides.pass.cpp | 39 + .../arithmetic.operations/minus.pass.cpp | 39 + .../arithmetic.operations/modulus.pass.cpp | 39 + .../arithmetic.operations/multiplies.pass.cpp | 39 + .../arithmetic.operations/negate.pass.cpp | 38 + .../arithmetic.operations/plus.pass.cpp | 39 + .../transparent.pass.cpp | 61 + .../func.bind/func.bind.bind/copy.pass.cpp | 35 + .../invoke_function_object.pass.cpp | 49 + .../func.bind.bind/invoke_int_0.pass.cpp | 53 + .../func.bind.bind/invoke_lvalue.pass.cpp | 287 + .../func.bind.bind/invoke_rvalue.pass.cpp | 266 + .../func.bind.bind/invoke_void_0.pass.cpp | 72 + .../func.bind/func.bind.bind/nested.pass.cpp | 51 + .../is_bind_expression.pass.cpp | 32 + .../func.bind.isbind/is_placeholder.pass.cpp | 41 + .../func.bind.place/placeholders.pass.cpp | 43 + .../bind/func.bind/nothing_to_do.pass.cpp | 12 + .../bind/nothing_to_do.pass.cpp | 12 + .../bitwise.operations/bit_and.pass.cpp | 59 + .../bitwise.operations/bit_not.pass.cpp | 47 + .../bitwise.operations/bit_or.pass.cpp | 59 + .../bitwise.operations/bit_xor.pass.cpp | 63 + .../bitwise.operations/transparent.pass.cpp | 51 + .../comparisons/equal_to.pass.cpp | 41 + .../comparisons/greater.pass.cpp | 45 + .../comparisons/greater_equal.pass.cpp | 45 + .../comparisons/less.pass.cpp | 45 + .../comparisons/less_equal.pass.cpp | 45 + .../comparisons/not_equal_to.pass.cpp | 43 + .../comparisons/transparent.pass.cpp | 61 + .../func.def/nothing_to_do.pass.cpp | 12 + .../func.invoke/invoke.pass.cpp | 268 + .../func.memfn/member_data.fail.cpp | 42 + .../func.memfn/member_data.pass.cpp | 43 + .../func.memfn/member_function.pass.cpp | 72 + .../func.memfn/member_function_const.pass.cpp | 78 + .../member_function_const_volatile.pass.cpp | 78 + .../member_function_volatile.pass.cpp | 78 + .../func.require/binary_function.pass.cpp | 23 + .../func.require/invoke.pass.cpp | 50 + .../func.require/unary_function.pass.cpp | 22 + .../bad_function_call.pass.cpp | 26 + .../bad_function_call_ctor.pass.cpp | 20 + .../func.wrap.func.alg/swap.pass.cpp | 123 + .../func.wrap.func.cap/operator_bool.pass.cpp | 29 + .../func.wrap.func.con/F.pass.cpp | 90 + .../func.wrap.func.con/F_assign.pass.cpp | 98 + .../func.wrap.func.con/F_incomplete.pass.cpp | 29 + .../func.wrap.func.con/alloc.pass.cpp | 27 + .../func.wrap.func.con/alloc_F.pass.cpp | 106 + .../alloc_function.pass.cpp | 124 + .../func.wrap.func.con/alloc_nullptr.pass.cpp | 25 + .../alloc_rfunction.pass.cpp | 68 + .../func.wrap.func.con/copy.pass.cpp | 118 + .../func.wrap.func.con/copy_assign.pass.cpp | 109 + .../func.wrap.func.con/default.pass.cpp | 23 + .../func.wrap.func.con/no-variadics.pass.cpp | 24 + .../func.wrap.func.con/nullptr_t.pass.cpp | 23 + .../nullptr_t_assign.pass.cpp | 72 + .../func.wrap.func.inv/invoke.fail.cpp | 46 + .../func.wrap.func.inv/invoke.pass.cpp | 335 + .../func.wrap.func.inv/invoke_int_0.pass.cpp | 58 + .../invoke_no_variadics.pass.cpp | 60 + .../func.wrap.func.inv/invoke_void_0.pass.cpp | 67 + .../assign_F_alloc.pass.cpp | 60 + .../func.wrap.func.mod/swap.pass.cpp | 120 + .../operator_==.pass.cpp | 41 + .../func.wrap.func.targ/target.pass.cpp | 89 + .../func.wrap.func.targ/target_type.pass.cpp | 61 + .../func.wrap/func.wrap.func/function_types.h | 57 + .../func.wrap/func.wrap.func/types.pass.cpp | 108 + .../func.wrap/nothing_to_do.pass.cpp | 12 + .../logical.operations/logical_and.pass.cpp | 50 + .../logical.operations/logical_not.pass.cpp | 40 + .../logical.operations/logical_or.pass.cpp | 49 + .../logical.operations/transparent.pass.cpp | 46 + .../negators/binary_negate.pass.cpp | 29 + .../function.objects/negators/not1.pass.cpp | 22 + .../function.objects/negators/not2.pass.cpp | 24 + .../negators/unary_negate.pass.cpp | 26 + .../function.objects/refwrap/binary.pass.cpp | 80 + .../refwrap.access/conversion.pass.cpp | 46 + .../refwrap.assign/copy_assign.pass.cpp | 58 + .../refwrap/refwrap.const/copy_ctor.pass.cpp | 46 + .../refwrap/refwrap.const/type_ctor.fail.cpp | 22 + .../refwrap/refwrap.const/type_ctor.pass.cpp | 45 + .../refwrap/refwrap.helpers/cref_1.pass.cpp | 24 + .../refwrap/refwrap.helpers/cref_2.pass.cpp | 25 + .../refwrap/refwrap.helpers/ref_1.fail.cpp | 27 + .../refwrap/refwrap.helpers/ref_1.pass.cpp | 24 + .../refwrap/refwrap.helpers/ref_2.pass.cpp | 43 + .../refwrap/refwrap.invoke/invoke.fail.cpp | 52 + .../refwrap/refwrap.invoke/invoke.pass.cpp | 329 + .../refwrap.invoke/invoke_int_0.pass.cpp | 76 + .../refwrap.invoke/invoke_void_0.pass.cpp | 68 + .../function.objects/refwrap/type.pass.cpp | 37 + .../refwrap/type_properties.pass.cpp | 58 + .../function.objects/refwrap/unary.pass.cpp | 78 + .../refwrap/weak_result.pass.cpp | 82 + .../function.objects/unord.hash/enum.fail.cpp | 24 + .../function.objects/unord.hash/enum.pass.cpp | 62 + .../unord.hash/floating.pass.cpp | 70 + .../unord.hash/integral.pass.cpp | 60 + .../unord.hash/pointer.pass.cpp | 44 + .../function.objects/version.pass.cpp | 20 + .../intseq.general/integer_seq.pass.cpp | 86 + .../intseq/intseq.intseq/integer_seq.fail.cpp | 38 + .../intseq/intseq.intseq/integer_seq.pass.cpp | 48 + .../intseq.make/make_integer_seq.fail.cpp | 30 + .../intseq.make/make_integer_seq.pass.cpp | 34 + .../utilities/intseq/nothing_to_do.pass.cpp | 12 + .../allocator.tag/allocator_arg.pass.cpp | 22 + .../allocate.pass.cpp | 38 + .../allocate_hint.pass.cpp | 60 + .../construct.pass.cpp | 143 + .../deallocate.pass.cpp | 42 + .../allocator.traits.members/destroy.pass.cpp | 80 + .../max_size.pass.cpp | 70 + ...ct_on_container_copy_construction.pass.cpp | 68 + .../const_pointer.pass.cpp | 55 + .../const_void_pointer.pass.cpp | 55 + .../difference_type.pass.cpp | 62 + .../is_always_equal.pass.cpp | 52 + .../allocator.traits.types/pointer.pass.cpp | 42 + ...gate_on_container_copy_assignment.pass.cpp | 40 + ...gate_on_container_move_assignment.pass.cpp | 40 + .../propagate_on_container_swap.pass.cpp | 40 + .../rebind_alloc.pass.cpp | 79 + .../allocator.traits.types/size_type.pass.cpp | 63 + .../void_pointer.pass.cpp | 55 + .../allocator.traits/allocator_type.pass.cpp | 31 + .../allocator.traits/rebind_traits.pass.cpp | 79 + .../allocator.traits/value_type.pass.cpp | 31 + .../tested_elsewhere.pass.cpp | 12 + .../uses_allocator.pass.cpp | 33 + .../allocator.uses/nothing_to_do.pass.cpp | 12 + .../memory/c.malloc/nothing_to_do.pass.cpp | 14 + .../allocator.globals/eq.pass.cpp | 31 + .../allocator.members/address.pass.cpp | 39 + .../allocator.members/allocate.pass.cpp | 52 + .../allocator.members/construct.pass.cpp | 142 + .../allocator.members/max_size.pass.cpp | 27 + .../allocator_pointers.pass.cpp | 116 + .../allocator_types.pass.cpp | 55 + .../default.allocator/allocator_void.pass.cpp | 36 + .../pointer.traits/difference_type.pass.cpp | 25 + .../pointer.traits/element_type.pass.cpp | 25 + .../memory/pointer.traits/pointer.pass.cpp | 32 + .../pointer_to.pass.cpp | 48 + .../difference_type.pass.cpp | 48 + .../element_type.pass.cpp | 49 + .../pointer.traits.types/rebind.pass.cpp | 69 + .../memory/pointer.traits/pointer_to.pass.cpp | 32 + .../memory/pointer.traits/rebind.pass.cpp | 29 + .../utilities/memory/ptr.align/align.pass.cpp | 84 + .../nothing_to_do.pass.cpp | 12 + .../specialized.addressof/addressof.pass.cpp | 51 + .../uninitialized_copy.pass.cpp | 75 + .../uninitialized_copy_n.pass.cpp | 74 + .../uninitialized_fill_n.pass.cpp | 75 + .../uninitialized_fill.pass.cpp | 72 + .../raw_storag_iterator.base.pass.cpp | 48 + .../raw_storag_iterator.pass.cpp | 44 + .../temporary_buffer.pass.cpp | 29 + .../std/utilities/memory/unique.ptr/deleter.h | 182 + .../memory/unique.ptr/nothing_to_do.pass.cpp | 12 + .../make_unique.array.pass.cpp | 45 + .../make_unique.array1.fail.cpp | 17 + .../make_unique.array2.fail.cpp | 17 + .../make_unique.array3.fail.cpp | 17 + .../make_unique.array4.fail.cpp | 17 + .../make_unique.single.pass.cpp | 33 + .../unique.ptr.dltr/nothing_to_do.pass.cpp | 12 + .../convert_ctor.pass.cpp | 48 + .../unique.ptr.dltr.dflt/default.pass.cpp | 34 + .../unique.ptr.dltr.dflt/incomplete.fail.cpp | 26 + .../unique.ptr.dltr.dflt/void.fail.cpp | 24 + .../convert_ctor.fail.cpp | 32 + .../unique.ptr.dltr.dflt1/default.pass.cpp | 36 + .../unique.ptr.dltr.dflt1/incomplete.fail.cpp | 26 + .../nothing_to_do.pass.cpp | 12 + .../unique.ptr.runtime/move01.fail.cpp | 39 + .../unique.ptr.runtime/move01.pass.cpp | 79 + .../unique.ptr.runtime/move02.fail.cpp | 39 + .../unique.ptr.runtime/move03.fail.cpp | 57 + .../unique.ptr.runtime/move04.fail.cpp | 57 + .../move_convert01.fail.cpp | 57 + .../move_convert02.fail.cpp | 61 + .../move_convert03.fail.cpp | 62 + .../move_convert04.fail.cpp | 57 + .../move_convert05.fail.cpp | 61 + .../move_convert06.fail.cpp | 62 + .../move_convert07.fail.cpp | 56 + .../move_convert08.fail.cpp | 60 + .../move_convert09.fail.cpp | 62 + .../unique.ptr.runtime/null_asgn.pass.cpp | 41 + .../unique.ptr.runtime/null_ctor.pass.cpp | 44 + .../unique.ptr.runtime/nullptr_asgn.pass.cpp | 41 + .../unique.ptr.runtime/pointer_type.pass.cpp | 34 + .../default01.fail.cpp | 38 + .../default01.pass.cpp | 47 + .../default02.fail.cpp | 30 + .../default02.pass.cpp | 87 + .../default03.fail.cpp | 23 + .../unique.ptr.runtime.ctor/move01.fail.cpp | 42 + .../unique.ptr.runtime.ctor/move01.pass.cpp | 86 + .../unique.ptr.runtime.ctor/move02.fail.cpp | 42 + .../unique.ptr.runtime.ctor/move02.pass.cpp | 87 + .../unique.ptr.runtime.ctor/move03.fail.cpp | 55 + .../unique.ptr.runtime.ctor/move04.fail.cpp | 55 + .../move_convert01.fail.cpp | 57 + .../move_convert02.fail.cpp | 61 + .../move_convert03.fail.cpp | 78 + .../move_convert04.fail.cpp | 57 + .../move_convert05.fail.cpp | 61 + .../move_convert06.fail.cpp | 78 + .../move_convert07.fail.cpp | 57 + .../move_convert08.fail.cpp | 61 + .../move_convert09.fail.cpp | 78 + .../move_convert10.fail.cpp | 57 + .../move_convert11.fail.cpp | 61 + .../move_convert12.fail.cpp | 78 + .../move_convert13.fail.cpp | 57 + .../move_convert14.fail.cpp | 61 + .../move_convert15.fail.cpp | 78 + .../move_convert16.fail.cpp | 57 + .../move_convert17.fail.cpp | 61 + .../move_convert18.fail.cpp | 78 + .../unique.ptr.runtime.ctor/nullptr.pass.cpp | 46 + .../pointer01.fail.cpp | 36 + .../pointer01.pass.cpp | 63 + .../pointer02.fail.cpp | 29 + .../pointer02.pass.cpp | 95 + .../pointer03.fail.cpp | 23 + .../pointer04.fail.cpp | 67 + .../pointer_deleter01.pass.cpp | 43 + .../pointer_deleter02.pass.cpp | 58 + .../pointer_deleter03.pass.cpp | 60 + .../pointer_deleter04.fail.cpp | 55 + .../pointer_deleter04.pass.cpp | 58 + .../pointer_deleter05.fail.cpp | 58 + .../release.pass.cpp | 27 + .../reset1.pass.cpp | 50 + .../reset2.fail.cpp | 64 + .../swap.pass.cpp | 56 + .../dereference.fail.cpp | 23 + .../explicit_bool.pass.cpp | 39 + .../unique.ptr.runtime.observers/get.pass.cpp | 24 + .../get_deleter.pass.cpp | 37 + .../index.pass.cpp | 47 + .../op_arrow.fail.cpp | 30 + .../unique.ptr.single/pointer_type.pass.cpp | 34 + .../unique.ptr.single.asgn/move01.fail.cpp | 38 + .../unique.ptr.single.asgn/move01.pass.cpp | 75 + .../unique.ptr.single.asgn/move02.fail.cpp | 38 + .../unique.ptr.single.asgn/move03.fail.cpp | 56 + .../unique.ptr.single.asgn/move04.fail.cpp | 56 + .../move_convert01.fail.cpp | 57 + .../move_convert01.pass.cpp | 56 + .../move_convert02.fail.cpp | 61 + .../move_convert02.pass.cpp | 60 + .../move_convert03.fail.cpp | 62 + .../move_convert03.pass.cpp | 63 + .../move_convert04.fail.cpp | 57 + .../move_convert05.fail.cpp | 61 + .../move_convert06.fail.cpp | 62 + .../move_convert13.fail.cpp | 36 + .../unique.ptr.single.asgn/null.pass.cpp | 41 + .../unique.ptr.single.asgn/nullptr.pass.cpp | 41 + .../auto_pointer.pass.cpp | 68 + .../auto_pointer01.fail.cpp | 67 + .../auto_pointer02.fail.cpp | 61 + .../unique.ptr.single.ctor/default01.fail.cpp | 35 + .../unique.ptr.single.ctor/default01.pass.cpp | 46 + .../unique.ptr.single.ctor/default02.fail.cpp | 29 + .../unique.ptr.single.ctor/default02.pass.cpp | 84 + .../unique.ptr.single.ctor/default03.fail.cpp | 23 + .../unique.ptr.single.ctor/move01.fail.cpp | 42 + .../unique.ptr.single.ctor/move01.pass.cpp | 142 + .../unique.ptr.single.ctor/move02.fail.cpp | 42 + .../unique.ptr.single.ctor/move02.pass.cpp | 143 + .../unique.ptr.single.ctor/move03.fail.cpp | 55 + .../unique.ptr.single.ctor/move04.fail.cpp | 55 + .../move_convert01.fail.cpp | 56 + .../move_convert01.pass.cpp | 58 + .../move_convert02.fail.cpp | 62 + .../move_convert02.pass.cpp | 62 + .../move_convert03.fail.cpp | 79 + .../move_convert03.pass.cpp | 79 + .../move_convert04.fail.cpp | 58 + .../move_convert04.pass.cpp | 58 + .../move_convert05.fail.cpp | 51 + .../move_convert05.pass.cpp | 62 + .../move_convert06.fail.cpp | 79 + .../move_convert06.pass.cpp | 79 + .../move_convert07.fail.cpp | 58 + .../move_convert07.pass.cpp | 63 + .../move_convert08.fail.cpp | 118 + .../move_convert09.fail.cpp | 79 + .../move_convert10.fail.cpp | 58 + .../move_convert11.fail.cpp | 118 + .../move_convert12.fail.cpp | 79 + .../move_convert13.fail.cpp | 35 + .../unique.ptr.single.ctor/nullptr.pass.cpp | 46 + .../unique.ptr.single.ctor/pointer01.fail.cpp | 35 + .../unique.ptr.single.ctor/pointer01.pass.cpp | 63 + .../unique.ptr.single.ctor/pointer02.fail.cpp | 29 + .../unique.ptr.single.ctor/pointer02.pass.cpp | 95 + .../unique.ptr.single.ctor/pointer03.fail.cpp | 23 + .../unique.ptr.single.ctor/pointer03.pass.cpp | 78 + .../pointer_deleter01.pass.cpp | 99 + .../pointer_deleter02.pass.cpp | 58 + .../pointer_deleter03.pass.cpp | 60 + .../pointer_deleter04.fail.cpp | 55 + .../pointer_deleter04.pass.cpp | 58 + .../pointer_deleter05.pass.cpp | 66 + .../pointer_deleter06.pass.cpp | 39 + .../unique.ptr.single.dtor/null.pass.cpp | 44 + .../release.pass.cpp | 27 + .../reset1.pass.cpp | 50 + .../reset2.pass.cpp | 66 + .../reset_self.pass.cpp | 29 + .../unique.ptr.single.modifiers/swap.pass.cpp | 59 + .../dereference.pass.cpp | 23 + .../explicit_bool.pass.cpp | 39 + .../unique.ptr.single.observers/get.pass.cpp | 24 + .../get_deleter.pass.cpp | 37 + .../index.fail.cpp | 47 + .../op_arrow.pass.cpp | 30 + .../unique.ptr.special/cmp_nullptr.pass.cpp | 69 + .../unique.ptr/unique.ptr.special/eq.pass.cpp | 86 + .../unique.ptr.special/rel.pass.cpp | 100 + .../unique.ptr.special/swap.pass.cpp | 77 + .../declare_no_pointers.pass.cpp | 23 + .../declare_reachable.pass.cpp | 24 + .../get_pointer_safety.pass.cpp | 23 + .../util.smartptr/nothing_to_do.pass.cpp | 12 + .../enable_shared_from_this.pass.cpp | 53 + .../hash_shared_ptr.pass.cpp | 30 + .../hash_unique_ptr.pass.cpp | 30 + .../atomic_compare_exchange_strong.pass.cpp | 53 + ..._compare_exchange_strong_explicit.pass.cpp | 58 + .../atomic_compare_exchange_weak.pass.cpp | 53 + ...ic_compare_exchange_weak_explicit.pass.cpp | 58 + .../atomic_exchange.pass.cpp | 39 + .../atomic_exchange_explicit.pass.cpp | 39 + .../atomic_is_lock_free.pass.cpp | 31 + .../atomic_load.pass.cpp | 37 + .../atomic_load_explicit.pass.cpp | 37 + .../atomic_store.pass.cpp | 38 + .../atomic_store_explicit.pass.cpp | 38 + .../util.smartptr.shared/test_deleter.h | 68 + .../util.smartptr.shared/types.pass.cpp | 26 + .../get_deleter.pass.cpp | 67 + .../auto_ptr_Y.pass.cpp | 113 + .../shared_ptr.pass.cpp | 121 + .../shared_ptr_Y.pass.cpp | 121 + .../shared_ptr_Y_rv.pass.cpp | 123 + .../shared_ptr_rv.pass.cpp | 123 + .../unique_ptr_Y.pass.cpp | 113 + .../const_pointer_cast.pass.cpp | 57 + .../dynamic_pointer_cast.pass.cpp | 57 + .../static_pointer_cast.pass.cpp | 69 + .../cmp_nullptr.pass.cpp | 69 + .../util.smartptr.shared.cmp/eq.pass.cpp | 31 + .../util.smartptr.shared.cmp/lt.pass.cpp | 30 + .../auto_ptr.pass.cpp | 104 + .../default.pass.cpp | 22 + .../nullptr_t.pass.cpp | 22 + .../nullptr_t_deleter.pass.cpp | 47 + .../nullptr_t_deleter_allocator.pass.cpp | 85 + ...nullptr_t_deleter_allocator_throw.pass.cpp | 46 + .../nullptr_t_deleter_throw.pass.cpp | 63 + .../pointer.pass.cpp | 46 + .../pointer_deleter.pass.cpp | 48 + .../pointer_deleter_allocator.pass.cpp | 89 + .../pointer_deleter_allocator_throw.pass.cpp | 47 + .../pointer_deleter_throw.pass.cpp | 64 + .../pointer_throw.pass.cpp | 62 + .../shared_ptr.pass.cpp | 62 + .../shared_ptr_Y.pass.cpp | 97 + .../shared_ptr_Y_rv.pass.cpp | 109 + .../shared_ptr_pointer.pass.cpp | 61 + .../shared_ptr_rv.pass.cpp | 73 + .../unique_ptr.pass.cpp | 115 + .../weak_ptr.pass.cpp | 79 + .../allocate_shared.pass.cpp | 78 + .../allocate_shared_no_variadics.pass.cpp | 118 + .../make_shared.pass.cpp | 80 + .../make_shared.volatile.pass.cpp | 61 + .../tested_elsewhere.pass.cpp | 12 + .../util.smartptr.shared.io/io.pass.cpp | 29 + .../util.smartptr.shared.mod/reset.pass.cpp | 62 + .../reset_pointer.pass.cpp | 64 + .../reset_pointer_deleter.pass.cpp | 79 + .../reset_pointer_deleter_allocator.pass.cpp | 88 + .../util.smartptr.shared.mod/swap.pass.cpp | 104 + .../util.smartptr.shared.obs/arrow.pass.cpp | 29 + .../dereference.pass.cpp | 25 + .../util.smartptr.shared.obs/op_bool.pass.cpp | 29 + .../owner_before_shared_ptr.pass.cpp | 28 + .../owner_before_weak_ptr.pass.cpp | 31 + .../util.smartptr.shared.obs/unique.pass.cpp | 28 + .../util.smartptr.shared.spec/swap.pass.cpp | 104 + .../util.smartptr.weak/types.pass.cpp | 26 + .../owner_less.pass.cpp | 82 + .../shared_ptr_Y.pass.cpp | 61 + .../weak_ptr.pass.cpp | 78 + .../weak_ptr_Y.pass.cpp | 78 + .../util.smartptr.weak.const/default.pass.cpp | 25 + .../shared_ptr_Y.pass.cpp | 95 + .../weak_ptr.pass.cpp | 114 + .../weak_ptr_Y.pass.cpp | 108 + .../tested_elsewhere.pass.cpp | 12 + .../util.smartptr.weak.mod/reset.pass.cpp | 41 + .../util.smartptr.weak.mod/swap.pass.cpp | 49 + .../util.smartptr.weak.obs/expired.pass.cpp | 46 + .../util.smartptr.weak.obs/lock.pass.cpp | 58 + .../not_less_than.fail.cpp | 27 + .../owner_before_shared_ptr.pass.cpp | 31 + .../owner_before_weak_ptr.pass.cpp | 31 + .../util.smartptr.weak.spec/swap.pass.cpp | 49 + .../bad_weak_ptr.pass.cpp | 31 + test/std/utilities/memory/version.pass.cpp | 20 + .../meta/meta.hel/bool_constant.pass.cpp | 32 + .../meta/meta.hel/integral_constant.pass.cpp | 49 + .../meta/meta.rel/is_base_of.pass.cpp | 49 + .../meta/meta.rel/is_convertible.pass.cpp | 195 + .../meta.rel/is_convertible_fallback.pass.cpp | 18 + .../utilities/meta/meta.rel/is_same.pass.cpp | 59 + .../meta/meta.rqmts/nothing_to_do.pass.cpp | 12 + .../remove_all_extents.pass.cpp | 41 + .../meta.trans.arr/remove_extent.pass.cpp | 42 + .../meta.trans.cv/add_const.pass.cpp | 43 + .../meta.trans/meta.trans.cv/add_cv.pass.cpp | 43 + .../meta.trans.cv/add_volatile.pass.cpp | 43 + .../meta.trans.cv/remove_const.pass.cpp | 43 + .../meta.trans.cv/remove_cv.pass.cpp | 43 + .../meta.trans.cv/remove_volatile.pass.cpp | 43 + .../meta.trans.other/aligned_storage.pass.cpp | 194 + .../meta.trans.other/aligned_union.pass.cpp | 92 + .../meta.trans.other/common_type.pass.cpp | 52 + .../meta.trans.other/conditional.pass.cpp | 24 + .../meta.trans.other/decay.pass.cpp | 34 + .../meta.trans.other/enable_if.fail.cpp | 19 + .../meta.trans.other/enable_if.pass.cpp | 24 + .../meta.trans.other/enable_if2.fail.cpp | 23 + .../meta.trans.other/result_of.pass.cpp | 252 + .../meta.trans.other/result_of11.pass.cpp | 88 + .../meta.trans.other/underlying_type.pass.cpp | 41 + .../meta.trans.ptr/add_pointer.pass.cpp | 34 + .../meta.trans.ptr/remove_pointer.pass.cpp | 43 + .../meta.trans.ref/add_lvalue_ref.pass.cpp | 34 + .../meta.trans.ref/add_rvalue_ref.pass.cpp | 40 + .../meta.trans.ref/remove_ref.pass.cpp | 46 + .../meta.trans.sign/make_signed.pass.cpp | 64 + .../meta.trans.sign/make_unsigned.pass.cpp | 65 + .../meta/meta.trans/nothing_to_do.pass.cpp | 12 + .../meta.type.synop/nothing_to_do.pass.cpp | 12 + .../alignment_of.pass.cpp | 47 + .../meta.unary.prop.query/extent.pass.cpp | 60 + .../meta/meta.unary.prop.query/rank.pass.cpp | 46 + .../meta.unary.prop.query/void_t.pass.cpp | 69 + .../meta.unary/meta.unary.cat/array.pass.cpp | 55 + .../meta.unary/meta.unary.cat/class.pass.cpp | 53 + .../meta.unary/meta.unary.cat/enum.pass.cpp | 51 + .../meta.unary.cat/floating_point.pass.cpp | 51 + .../meta.unary.cat/function.pass.cpp | 88 + .../meta.unary.cat/integral.pass.cpp | 65 + .../meta.unary.cat/lvalue_ref.pass.cpp | 41 + .../member_function_pointer.pass.cpp | 136 + ...ber_function_pointer_no_variadics.pass.cpp | 76 + .../member_object_pointer.pass.cpp | 53 + .../meta.unary.cat/nullptr.pass.cpp | 52 + .../meta.unary.cat/pointer.pass.cpp | 52 + .../meta.unary.cat/rvalue_ref.pass.cpp | 43 + .../meta.unary/meta.unary.cat/union.pass.cpp | 55 + .../meta.unary/meta.unary.cat/void.pass.cpp | 49 + .../meta.unary/meta.unary.comp/array.pass.cpp | 46 + .../meta.unary/meta.unary.comp/class.pass.cpp | 44 + .../meta.unary/meta.unary.comp/enum.pass.cpp | 42 + .../meta.unary.comp/floating_point.pass.cpp | 42 + .../meta.unary.comp/function.pass.cpp | 43 + .../meta.unary.comp/integral.pass.cpp | 56 + .../meta.unary.comp/lvalue_ref.pass.cpp | 32 + .../member_function_pointer.pass.cpp | 46 + .../member_object_pointer.pass.cpp | 44 + .../meta.unary.comp/pointer.pass.cpp | 43 + .../meta.unary.comp/rvalue_ref.pass.cpp | 34 + .../meta.unary/meta.unary.comp/union.pass.cpp | 46 + .../meta.unary/meta.unary.comp/void.pass.cpp | 40 + .../__has_operator_addressof.pass.cpp | 71 + .../has_virtual_destructor.pass.cpp | 77 + .../meta.unary.prop/is_abstract.pass.cpp | 71 + .../meta.unary.prop/is_assignable.pass.cpp | 76 + .../meta.unary.prop/is_const.pass.cpp | 37 + .../meta.unary.prop/is_constructible.pass.cpp | 86 + .../is_copy_assignable.pass.cpp | 80 + .../is_copy_constructible.pass.cpp | 88 + .../is_default_constructible.pass.cpp | 93 + .../meta.unary.prop/is_destructible.pass.cpp | 121 + .../meta.unary.prop/is_empty.pass.cpp | 65 + .../meta.unary.prop/is_final.pass.cpp | 53 + .../meta.unary.prop/is_literal_type.pass.cpp | 46 + .../is_move_assignable.pass.cpp | 65 + .../is_move_constructible.pass.cpp | 81 + .../is_nothrow_assignable.pass.cpp | 55 + .../is_nothrow_constructible.pass.cpp | 103 + .../is_nothrow_copy_assignable.pass.cpp | 65 + .../is_nothrow_copy_constructible.pass.cpp | 61 + .../is_nothrow_default_constructible.pass.cpp | 64 + .../is_nothrow_destructible.pass.cpp | 91 + .../is_nothrow_move_assignable.pass.cpp | 63 + .../is_nothrow_move_constructible.pass.cpp | 61 + .../meta.unary.prop/is_pod.pass.cpp | 52 + .../meta.unary.prop/is_polymorphic.pass.cpp | 82 + .../meta.unary.prop/is_signed.pass.cpp | 59 + .../is_standard_layout.pass.cpp | 48 + .../meta.unary.prop/is_trivial.pass.cpp | 50 + .../is_trivially_assignable.pass.cpp | 53 + .../is_trivially_constructible.pass.cpp | 61 + .../is_trivially_copy_assignable.pass.cpp | 71 + .../is_trivially_copy_constructible.pass.cpp | 73 + .../is_trivially_copyable.pass.cpp | 63 + ...s_trivially_default_constructible.pass.cpp | 76 + .../is_trivially_destructible.pass.cpp | 83 + .../is_trivially_move_assignable.pass.cpp | 71 + .../is_trivially_move_constructible.pass.cpp | 89 + .../meta.unary.prop/is_unsigned.pass.cpp | 59 + .../meta.unary.prop/is_volatile.pass.cpp | 37 + .../meta/meta.unary/nothing_to_do.pass.cpp | 12 + test/std/utilities/meta/version.pass.cpp | 20 + test/std/utilities/nothing_to_do.pass.cpp | 12 + .../ratio/ratio.arithmetic/ratio_add.fail.cpp | 19 + .../ratio/ratio.arithmetic/ratio_add.pass.cpp | 76 + .../ratio.arithmetic/ratio_divide.fail.cpp | 19 + .../ratio.arithmetic/ratio_divide.pass.cpp | 58 + .../ratio.arithmetic/ratio_multiply.fail.cpp | 19 + .../ratio.arithmetic/ratio_multiply.pass.cpp | 58 + .../ratio.arithmetic/ratio_subtract.fail.cpp | 19 + .../ratio.arithmetic/ratio_subtract.pass.cpp | 76 + .../ratio.comparison/ratio_equal.pass.cpp | 56 + .../ratio.comparison/ratio_greater.pass.cpp | 56 + .../ratio_greater_equal.pass.cpp | 56 + .../ratio.comparison/ratio_less.pass.cpp | 86 + .../ratio_less_equal.pass.cpp | 56 + .../ratio.comparison/ratio_not_equal.pass.cpp | 56 + .../ratio/ratio.ratio/ratio.pass.cpp | 44 + .../ratio/ratio.ratio/ratio1.fail.cpp | 18 + .../ratio/ratio.ratio/ratio2.fail.cpp | 19 + .../ratio/ratio.ratio/ratio3.fail.cpp | 19 + .../ratio/ratio.si/nothing_to_do.pass.cpp | 12 + test/std/utilities/ratio/typedefs.pass.cpp | 32 + test/std/utilities/ratio/version.pass.cpp | 20 + .../bitset.cons/char_ptr_ctor.pass.cpp | 56 + .../bitset.cons/default.pass.cpp | 39 + .../bitset.cons/string_ctor.pass.cpp | 88 + .../bitset.cons/ull_ctor.pass.cpp | 42 + .../bitset.hash/bitset.pass.cpp | 44 + .../bitset.members/all.pass.cpp | 41 + .../bitset.members/any.pass.cpp | 44 + .../bitset.members/count.pass.cpp | 51 + .../bitset.members/flip_all.pass.cpp | 49 + .../bitset.members/flip_one.pass.cpp | 60 + .../bitset.members/index.pass.cpp | 67 + .../bitset.members/index_const.pass.cpp | 49 + .../bitset.members/left_shift.pass.cpp | 50 + .../bitset.members/left_shift_eq.pass.cpp | 55 + .../bitset.members/none.pass.cpp | 44 + .../bitset.members/not_all.pass.cpp | 48 + .../bitset.members/op_and_eq.pass.cpp | 50 + .../bitset.members/op_eq_eq.pass.cpp | 55 + .../bitset.members/op_or_eq.pass.cpp | 50 + .../bitset.members/op_xor_eq.pass.cpp | 50 + .../bitset.members/reset_all.pass.cpp | 38 + .../bitset.members/reset_one.pass.cpp | 50 + .../bitset.members/right_shift.pass.cpp | 50 + .../bitset.members/right_shift_eq.pass.cpp | 55 + .../bitset.members/set_all.pass.cpp | 37 + .../bitset.members/set_one.pass.cpp | 52 + .../bitset.members/size.pass.cpp | 33 + .../bitset.members/test.pass.cpp | 55 + .../bitset.members/to_string.pass.cpp | 162 + .../bitset.members/to_ullong.pass.cpp | 50 + .../bitset.members/to_ulong.pass.cpp | 51 + .../bitset.operators/op_and.pass.cpp | 48 + .../bitset.operators/op_not.pass.cpp | 48 + .../bitset.operators/op_or.pass.cpp | 48 + .../bitset.operators/stream_in.pass.cpp | 26 + .../bitset.operators/stream_out.pass.cpp | 26 + .../template.bitset/includes.pass.cpp | 32 + .../template.bitset/version.pass.cpp | 20 + test/std/utilities/time/clock.h | 26 + test/std/utilities/time/hours.pass.cpp | 27 + test/std/utilities/time/microseconds.pass.cpp | 27 + test/std/utilities/time/milliseconds.pass.cpp | 27 + test/std/utilities/time/minutes.pass.cpp | 27 + test/std/utilities/time/nanoseconds.pass.cpp | 27 + test/std/utilities/time/rep.h | 27 + test/std/utilities/time/seconds.pass.cpp | 27 + .../time.clock.req/nothing_to_do.pass.cpp | 12 + .../time/time.clock/nothing_to_do.pass.cpp | 12 + .../time.clock.hires/consistency.pass.cpp | 34 + .../time.clock/time.clock.hires/now.pass.cpp | 26 + .../time.clock.steady/consistency.pass.cpp | 35 + .../time.clock/time.clock.steady/now.pass.cpp | 27 + .../time.clock.system/consistency.pass.cpp | 35 + .../time.clock.system/from_time_t.pass.cpp | 24 + .../time.clock/time.clock.system/now.pass.cpp | 26 + .../time.clock.system/rep_signed.pass.cpp | 23 + .../time.clock.system/to_time_t.pass.cpp | 24 + .../time/time.duration/default_ratio.pass.cpp | 26 + .../time/time.duration/duration.fail.cpp | 23 + .../time/time.duration/positive_num.fail.cpp | 22 + .../time/time.duration/ratio.fail.cpp | 30 + .../time.duration.arithmetic/op_++.pass.cpp | 25 + .../op_++int.pass.cpp | 25 + .../time.duration.arithmetic/op_+.pass.cpp | 33 + .../time.duration.arithmetic/op_+=.pass.cpp | 26 + .../time.duration.arithmetic/op_--.pass.cpp | 25 + .../op_--int.pass.cpp | 25 + .../time.duration.arithmetic/op_-.pass.cpp | 33 + .../time.duration.arithmetic/op_-=.pass.cpp | 26 + .../op_divide=.pass.cpp | 24 + .../op_mod=duration.pass.cpp | 27 + .../op_mod=rep.pass.cpp | 24 + .../op_times=.pass.cpp | 24 + .../time.duration.cast/duration_cast.pass.cpp | 52 + .../time.duration.cast/toduration.fail.cpp | 25 + .../op_equal.pass.cpp | 115 + .../op_less.pass.cpp | 153 + .../time.duration.cons/convert_exact.pass.cpp | 36 + .../convert_float_to_int.fail.cpp | 25 + .../convert_inexact.fail.cpp | 25 + .../convert_inexact.pass.cpp | 36 + .../convert_int_to_float.pass.cpp | 36 + .../convert_overflow.pass.cpp | 37 + .../time.duration.cons/default.pass.cpp | 38 + .../time.duration.cons/rep.pass.cpp | 40 + .../time.duration.cons/rep01.fail.cpp | 26 + .../time.duration.cons/rep02.fail.cpp | 26 + .../time.duration.cons/rep02.pass.cpp | 30 + .../time.duration.cons/rep03.fail.cpp | 24 + .../time.duration.literals/literals.pass.cpp | 59 + .../time.duration.literals/literals1.fail.cpp | 21 + .../time.duration.literals/literals1.pass.cpp | 48 + .../time.duration.literals/literals2.fail.cpp | 22 + .../time.duration.literals/literals2.pass.cpp | 51 + .../time.duration.nonmember/op_+.pass.cpp | 73 + .../time.duration.nonmember/op_-.pass.cpp | 74 + .../op_divide_duration.pass.cpp | 66 + .../op_divide_rep.fail.cpp | 26 + .../op_divide_rep.pass.cpp | 36 + .../op_mod_duration.pass.cpp | 62 + .../op_mod_rep.fail.cpp | 26 + .../op_mod_rep.pass.cpp | 36 + .../op_times_rep.pass.cpp | 45 + .../op_times_rep1.fail.cpp | 30 + .../op_times_rep2.fail.cpp | 30 + .../tested_elsewhere.pass.cpp | 12 + .../time.duration.special/max.pass.cpp | 43 + .../time.duration.special/min.pass.cpp | 43 + .../time.duration.special/zero.pass.cpp | 42 + .../time/time.duration/types.pass.cpp | 27 + .../time/time.point/default_duration.pass.cpp | 26 + .../time/time.point/duration.fail.cpp | 22 + .../time.point.arithmetic/op_+=.pass.cpp | 26 + .../time.point.arithmetic/op_-=.pass.cpp | 26 + .../time.point.cast/time_point_cast.pass.cpp | 80 + .../time.point.cast/toduration.fail.cpp | 28 + .../time.point.comparisons/op_equal.fail.cpp | 40 + .../time.point.comparisons/op_equal.pass.cpp | 84 + .../time.point.comparisons/op_less.fail.cpp | 48 + .../time.point.comparisons/op_less.pass.cpp | 108 + .../time.point.cons/convert.fail.cpp | 30 + .../time.point.cons/convert.pass.cpp | 37 + .../time.point.cons/default.pass.cpp | 35 + .../time.point.cons/duration.fail.cpp | 25 + .../time.point.cons/duration.pass.cpp | 41 + .../time.point.nonmember/op_+.pass.cpp | 46 + .../op_-duration.pass.cpp | 38 + .../op_-time_point.pass.cpp | 38 + .../tested_elsewhere.pass.cpp | 12 + .../time.point.special/max.pass.cpp | 25 + .../time.point.special/min.pass.cpp | 25 + .../time/time.traits/nothing_to_do.pass.cpp | 12 + .../time.traits.duration_values/max.pass.cpp | 36 + .../time.traits.duration_values/min.pass.cpp | 36 + .../time.traits.duration_values/zero.pass.cpp | 27 + .../treat_as_floating_point.pass.cpp | 37 + .../duration.pass.cpp | 42 + .../time_point.pass.cpp | 46 + test/std/utilities/time/version.pass.cpp | 20 + .../tuple.general/tuple.smartptr.pass.cpp | 38 + .../tuple/tuple.tuple/TupleFunction.pass.cpp | 35 + .../utilities/tuple/tuple.tuple/alloc_first.h | 58 + .../utilities/tuple/tuple.tuple/alloc_last.h | 58 + .../tuple/tuple.tuple/empty_member.pass.cpp | 46 + .../tuple.assign/const_pair.pass.cpp | 34 + .../tuple.assign/convert_copy.pass.cpp | 77 + .../tuple.assign/convert_move.pass.cpp | 91 + .../tuple.tuple/tuple.assign/copy.fail.cpp | 31 + .../tuple.tuple/tuple.assign/copy.pass.cpp | 54 + .../tuple.tuple/tuple.assign/move.pass.cpp | 56 + .../tuple.assign/move_pair.pass.cpp | 50 + .../tuple_array_template_depth.pass.cpp | 34 + .../tuple.tuple/tuple.cnstr/UTypes.fail.cpp | 51 + .../tuple.tuple/tuple.cnstr/UTypes.pass.cpp | 146 + .../tuple.tuple/tuple.cnstr/alloc.pass.cpp | 81 + .../tuple.cnstr/alloc_UTypes.pass.cpp | 141 + .../tuple.cnstr/alloc_const_Types.pass.cpp | 76 + .../tuple.cnstr/alloc_const_pair.pass.cpp | 59 + .../tuple.cnstr/alloc_convert_copy.pass.cpp | 69 + .../tuple.cnstr/alloc_convert_move.pass.cpp | 84 + .../tuple.cnstr/alloc_copy.pass.cpp | 78 + .../tuple.cnstr/alloc_move.pass.cpp | 77 + .../tuple.cnstr/alloc_move_pair.pass.cpp | 55 + .../tuple.cnstr/const_Types.fail.cpp | 27 + .../tuple.cnstr/const_Types.pass.cpp | 132 + .../tuple.cnstr/const_Types2.fail.cpp | 27 + .../tuple.cnstr/const_pair.pass.cpp | 44 + .../tuple.cnstr/convert_copy.pass.cpp | 118 + .../tuple.cnstr/convert_move.pass.cpp | 84 + .../tuple.tuple/tuple.cnstr/copy.fail.cpp | 30 + .../tuple.tuple/tuple.cnstr/copy.pass.cpp | 68 + .../tuple.tuple/tuple.cnstr/default.pass.cpp | 110 + .../tuple.tuple/tuple.cnstr/move.pass.cpp | 73 + .../tuple.cnstr/move_pair.pass.cpp | 48 + .../tuple_array_template_depth.pass.cpp | 36 + .../tuple.creation/forward_as_tuple.pass.cpp | 86 + .../tuple.creation/make_tuple.pass.cpp | 52 + .../tuple.tuple/tuple.creation/tie.pass.cpp | 41 + .../tuple.creation/tuple_cat.pass.cpp | 241 + .../tuple.tuple/tuple.elem/get_const.fail.cpp | 41 + .../tuple.tuple/tuple.elem/get_const.pass.cpp | 66 + .../tuple.elem/get_non_const.pass.cpp | 83 + .../tuple.tuple/tuple.elem/get_rv.pass.cpp | 33 + .../tuple.elem/tuple.by.type.pass.cpp | 60 + .../tuple.elem/tuple.by.type1.fail.cpp | 27 + .../tuple.elem/tuple.by.type2.fail.cpp | 27 + .../tuple.elem/tuple.by.type3.fail.cpp | 27 + .../tuple.elem/tuple.by.type4.fail.cpp | 27 + .../tuple.helper/tuple.include.array.pass.cpp | 52 + .../tuple.include.utility.pass.cpp | 49 + .../tuple.helper/tuple_element.pass.cpp | 49 + .../tuple.helper/tuple_size.pass.cpp | 42 + .../tuple/tuple.tuple/tuple.rel/eq.pass.cpp | 156 + .../tuple/tuple.tuple/tuple.rel/lt.pass.cpp | 210 + .../tuple.special/non_member_swap.pass.cpp | 62 + .../tuple.swap/member_swap.pass.cpp | 61 + .../tuple.traits/uses_allocator.pass.cpp | 46 + test/std/utilities/tuple/version.pass.cpp | 20 + .../type.index/type.index.hash/hash.pass.cpp | 32 + .../type.index.members/ctor.pass.cpp | 25 + .../type.index/type.index.members/eq.pass.cpp | 27 + .../type.index.members/hash_code.pass.cpp | 24 + .../type.index/type.index.members/lt.pass.cpp | 45 + .../type.index.members/name.pass.cpp | 25 + .../type.index.overview/copy_assign.pass.cpp | 26 + .../type.index.overview/copy_ctor.pass.cpp | 24 + .../hash_type_index.pass.cpp | 26 + .../std/utilities/type.index/version.pass.cpp | 20 + .../utilities.general/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../hash.requirements/nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../nothing_to_do.pass.cpp | 12 + .../utility/declval/declval.pass.cpp | 30 + .../utility/exchange/exchange.pass.cpp | 58 + .../utility/forward/forward.pass.cpp | 80 + .../utility/forward/forward1.fail.cpp | 24 + .../utility/forward/forward2.fail.cpp | 25 + .../utility/forward/forward3.fail.cpp | 24 + .../utility/forward/forward4.fail.cpp | 25 + .../utility/forward/forward5.fail.cpp | 25 + .../utility/forward/forward6.fail.cpp | 22 + .../utility/forward/move_copy.pass.cpp | 61 + .../utility/forward/move_if_noexcept.pass.cpp | 74 + .../utility/forward/move_only.pass.cpp | 39 + .../utility/forward/move_only1.fail.cpp | 52 + .../utility/forward/move_only2.fail.cpp | 52 + .../utility/forward/move_only3.fail.cpp | 49 + .../utility/forward/move_only4.fail.cpp | 52 + .../utility/operators/rel_ops.pass.cpp | 49 + .../utility/pairs/nothing_to_do.pass.cpp | 12 + .../pairs/pair.astuple/get_const.fail.cpp | 30 + .../pairs/pair.astuple/get_const.pass.cpp | 38 + .../pairs/pair.astuple/get_non_const.pass.cpp | 51 + .../pairs/pair.astuple/get_rv.pass.cpp | 32 + .../pairs/pair.astuple/pairs.by.type.pass.cpp | 44 + .../pair.astuple/pairs.by.type1.fail.cpp | 24 + .../pair.astuple/pairs.by.type2.fail.cpp | 24 + .../pair.astuple/pairs.by.type3.fail.cpp | 24 + .../pairs/pair.astuple/tuple_element.pass.cpp | 55 + .../pairs/pair.astuple/tuple_size.pass.cpp | 36 + .../piecewise_construct.pass.cpp | 55 + .../pairs.general/nothing_to_do.pass.cpp | 12 + .../utility/pairs/pairs.pair/U_V.pass.cpp | 30 + .../pairs.pair/assign_const_pair_U_V.pass.cpp | 30 + .../pairs/pairs.pair/assign_rv_pair.pass.cpp | 32 + .../pairs.pair/assign_rv_pair_U_V.pass.cpp | 43 + .../const_first_const_second.pass.cpp | 68 + .../pairs/pairs.pair/const_pair_U_V.pass.cpp | 40 + .../pairs/pairs.pair/copy_ctor.pass.cpp | 40 + .../utility/pairs/pairs.pair/default.pass.cpp | 36 + .../pairs/pairs.pair/piecewise.pass.cpp | 35 + .../pairs/pairs.pair/rv_pair_U_V.pass.cpp | 42 + .../utility/pairs/pairs.pair/swap.pass.cpp | 31 + .../utility/pairs/pairs.pair/types.pass.cpp | 26 + .../pairs/pairs.spec/comparison.pass.cpp | 95 + .../pairs/pairs.spec/make_pair.pass.cpp | 51 + .../pairs/pairs.spec/non_member_swap.pass.cpp | 31 + .../utility/utility.swap/swap.pass.cpp | 53 + .../utility/utility.swap/swap_array.pass.cpp | 65 + test/std/utilities/utility/version.pass.cpp | 20 + test/support/Counter.h | 52 + test/support/DefaultOnly.h | 35 + test/support/MoveOnly.h | 50 + test/support/allocators.h | 185 + test/support/asan_testing.h | 37 + test/support/cmpxchg_loop.h | 51 + test/support/constexpr_char_traits.hpp | 138 + test/support/count_new.hpp | 206 + test/support/counting_predicates.hpp | 46 + test/support/hexfloat.h | 38 + test/support/is_transparent.h | 73 + test/support/min_allocator.h | 291 + test/support/nasty_containers.hpp | 282 + test/support/nasty_macros.hpp | 32 + test/support/nothing_to_do.pass.cpp | 14 + test/support/platform_support.h | 98 + test/support/private_constructor.hpp | 31 + test/support/test_allocator.h | 226 + test/support/test_iterators.h | 329 + test/support/test_macros.h | 83 + test/support/tracked_value.h | 50 + test/support/user_defined_integral.hpp | 44 + test/testit | 180 + utils/not/not.py | 35 + utils/sym_check/linux_blacklist.txt | 19 + utils/sym_check/osx_blacklist.txt | 19 + utils/sym_check/sym_check/__init__.py | 8 + utils/sym_check/sym_check/diff.py | 93 + utils/sym_check/sym_check/extract.py | 177 + utils/sym_check/sym_check/match.py | 32 + utils/sym_check/sym_check/util.py | 128 + utils/sym_check/sym_diff.py | 47 + utils/sym_check/sym_extract.py | 29 + utils/sym_check/sym_match.py | 42 + www/atomic_design.html | 92 + www/atomic_design_a.html | 309 + www/atomic_design_b.html | 250 + www/atomic_design_c.html | 458 + www/content.css | 27 + www/cxx1y_status.html | 277 + www/cxx1z_status.html | 151 + www/debug_mode.html | 162 + www/index.html | 487 + www/lit_usage.html | 207 + www/menu.css | 39 + www/results.Linux.html | 513 + www/results.Windows.html | 487 + www/ts1z_status.html | 102 + www/type_traits_design.html | 286 + 5150 files changed, 429136 insertions(+), 1365 deletions(-) create mode 100644 .arcconfig create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 Makefile create mode 100644 TODO.TXT create mode 100644 cmake/Modules/CodeCoverage.cmake create mode 100644 cmake/Modules/HandleLibCXXABI.cmake create mode 100644 cmake/Modules/MacroEnsureOutOfSourceBuild.cmake create mode 100644 cmake/config-ix.cmake create mode 100644 include/CMakeLists.txt create mode 100644 include/__undef___deallocate create mode 100644 include/experimental/algorithm create mode 100644 include/experimental/chrono create mode 100644 include/experimental/ratio create mode 100644 include/experimental/system_error create mode 100644 include/experimental/tuple create mode 100644 include/support/android/locale_bionic.h create mode 100644 include/support/ibm/limits.h create mode 100644 include/support/ibm/support.h create mode 100644 include/support/ibm/xlocale.h create mode 100644 include/support/newlib/xlocale.h create mode 100644 include/support/solaris/floatingpoint.h create mode 100644 include/support/solaris/wchar.h create mode 100644 include/support/solaris/xlocale.h create mode 100644 include/support/win32/limits_win32.h create mode 100644 include/support/win32/locale_win32.h create mode 100644 include/support/win32/math_win32.h create mode 100644 include/support/win32/support.h create mode 100644 include/support/xlocale/xlocale.h create mode 100644 lib/CMakeLists.txt create mode 100755 lib/buildit create mode 100644 lib/libc++abi.exp create mode 100644 lib/libc++abi2.exp create mode 100644 lib/libc++sjlj-abi.exp create mode 100644 lib/libc++unexp.exp create mode 100644 lib/notweak.exp create mode 100644 lib/weak.exp create mode 100644 src/config_elast.h create mode 100644 src/support/atomic_support.h create mode 100644 src/support/solaris/README create mode 100644 src/support/solaris/mbsnrtowcs.inc create mode 100644 src/support/solaris/wcsnrtombs.inc create mode 100644 src/support/solaris/xlocale.c create mode 100644 src/support/win32/locale_win32.cpp create mode 100644 src/support/win32/support.cpp create mode 100644 test/CMakeLists.txt create mode 100644 test/libcxx/__init__.py create mode 100644 test/libcxx/compiler.py create mode 100644 test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp create mode 100644 test/libcxx/double_include.sh.cpp create mode 100644 test/libcxx/experimental/algorithms/header.algorithm.synop/includes.pass.cpp create mode 100644 test/libcxx/experimental/algorithms/version.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp rename include/__tuple_03 => test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp (51%) create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp create mode 100644 test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp create mode 100644 test/libcxx/experimental/utilities/ratio/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp create mode 100644 test/libcxx/experimental/utilities/syserror/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp create mode 100644 test/libcxx/experimental/utilities/time/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp create mode 100644 test/libcxx/experimental/utilities/tuple/version.pass.cpp create mode 100644 test/libcxx/selftest/not_test.sh.cpp create mode 100644 test/libcxx/selftest/test.fail.cpp create mode 100644 test/libcxx/selftest/test.pass.cpp create mode 100644 test/libcxx/selftest/test.sh.cpp create mode 100644 test/libcxx/selftest/test_macros.pass.cpp create mode 100644 test/libcxx/test/__init__.py create mode 100644 test/libcxx/test/config.py create mode 100644 test/libcxx/test/executor.py create mode 100644 test/libcxx/test/format.py create mode 100644 test/libcxx/test/target_info.py create mode 100644 test/libcxx/test/tracing.py create mode 100644 test/libcxx/type_traits/convert_to_integral.pass.cpp create mode 100644 test/libcxx/util.py create mode 100644 test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp create mode 100644 test/lit.cfg create mode 100644 test/lit.site.cfg.in create mode 100644 test/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/alg.c.library/tested_elsewhere.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp create mode 100644 test/std/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp create mode 100644 test/std/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/min.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp create mode 100644 test/std/algorithms/alg.sorting/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/algorithms.general/nothing_to_do.pass.cpp create mode 100644 test/std/algorithms/version.pass.cpp create mode 100644 test/std/atomics/atomics.fences/atomic_signal_fence.pass.cpp create mode 100644 test/std/atomics/atomics.fences/atomic_thread_fence.pass.cpp create mode 100644 test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp create mode 100644 test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp create mode 100644 test/std/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.flag/clear.pass.cpp create mode 100644 test/std/atomics/atomics.flag/copy_assign.fail.cpp create mode 100644 test/std/atomics/atomics.flag/copy_ctor.fail.cpp create mode 100644 test/std/atomics/atomics.flag/copy_volatile_assign.fail.cpp create mode 100644 test/std/atomics/atomics.flag/default.pass.cpp create mode 100644 test/std/atomics/atomics.flag/init.pass.cpp create mode 100644 test/std/atomics/atomics.flag/test_and_set.pass.cpp create mode 100644 test/std/atomics/atomics.general/nothing_to_do.pass.cpp create mode 100644 test/std/atomics/atomics.general/replace_failure_order.pass.cpp create mode 100644 test/std/atomics/atomics.lockfree/lockfree.pass.cpp create mode 100644 test/std/atomics/atomics.order/kill_dependency.pass.cpp create mode 100644 test/std/atomics/atomics.order/memory_order.pass.cpp create mode 100644 test/std/atomics/atomics.syn/nothing_to_do.pass.cpp create mode 100644 test/std/atomics/atomics.types.generic/address.pass.cpp create mode 100644 test/std/atomics/atomics.types.generic/bool.pass.cpp create mode 100644 test/std/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp create mode 100644 test/std/atomics/atomics.types.generic/integral.pass.cpp create mode 100644 test/std/atomics/atomics.types.generic/integral_typedefs.pass.cpp create mode 100644 test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp create mode 100644 test/std/atomics/atomics.types.generic/trivially_copyable.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp create mode 100644 test/std/atomics/atomics.types.operations/nothing_to_do.pass.cpp create mode 100644 test/std/atomics/libcpp-has-no-threads.fail.cpp create mode 100644 test/std/atomics/libcpp-has-no-threads.pass.cpp create mode 100644 test/std/atomics/version.pass.cpp create mode 100644 test/std/containers/Copyable.h create mode 100644 test/std/containers/Emplaceable.h create mode 100644 test/std/containers/NotConstructible.h create mode 100644 test/std/containers/associative/map/compare.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/at.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/empty.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/index_key.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/index_rv_key.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/index_tuple.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/iterator.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/max_size.pass.cpp create mode 100644 test/std/containers/associative/map/map.access/size.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/alloc.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/compare.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/copy.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/copy_assign.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/default.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/default_recursive.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/iter_iter.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/move.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/move_assign.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/clear.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/emplace.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp create mode 100644 test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/count.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/count0.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/count1.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/count2.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/count3.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/equal_range.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/equal_range0.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/equal_range1.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/equal_range2.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/equal_range3.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/find.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/find0.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/find1.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/find2.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/find3.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/lower_bound.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/upper_bound.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp create mode 100644 test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp create mode 100644 test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp create mode 100644 test/std/containers/associative/map/map.special/member_swap.pass.cpp create mode 100644 test/std/containers/associative/map/map.special/non_member_swap.pass.cpp create mode 100644 test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/associative/map/types.pass.cpp create mode 100644 test/std/containers/associative/map/version.pass.cpp create mode 100644 test/std/containers/associative/multimap/empty.pass.cpp create mode 100644 test/std/containers/associative/multimap/iterator.pass.cpp create mode 100644 test/std/containers/associative/multimap/max_size.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/default.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/move.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/count.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/find.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp create mode 100644 test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp create mode 100644 test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multimap/scary.pass.cpp create mode 100644 test/std/containers/associative/multimap/size.pass.cpp create mode 100644 test/std/containers/associative/multimap/types.pass.cpp create mode 100644 test/std/containers/associative/multiset/clear.pass.cpp create mode 100644 test/std/containers/associative/multiset/count.pass.cpp create mode 100644 test/std/containers/associative/multiset/emplace.pass.cpp create mode 100644 test/std/containers/associative/multiset/emplace_hint.pass.cpp create mode 100644 test/std/containers/associative/multiset/empty.pass.cpp create mode 100644 test/std/containers/associative/multiset/equal_range.pass.cpp create mode 100644 test/std/containers/associative/multiset/erase_iter.pass.cpp create mode 100644 test/std/containers/associative/multiset/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/multiset/erase_key.pass.cpp create mode 100644 test/std/containers/associative/multiset/find.pass.cpp create mode 100644 test/std/containers/associative/multiset/insert_cv.pass.cpp create mode 100644 test/std/containers/associative/multiset/insert_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/multiset/insert_iter_cv.pass.cpp create mode 100644 test/std/containers/associative/multiset/insert_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/multiset/insert_iter_rv.pass.cpp create mode 100644 test/std/containers/associative/multiset/insert_rv.pass.cpp create mode 100644 test/std/containers/associative/multiset/iterator.pass.cpp create mode 100644 test/std/containers/associative/multiset/lower_bound.pass.cpp create mode 100644 test/std/containers/associative/multiset/max_size.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/default.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/move.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp create mode 100644 test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/associative/multiset/scary.pass.cpp create mode 100644 test/std/containers/associative/multiset/size.pass.cpp create mode 100644 test/std/containers/associative/multiset/types.pass.cpp create mode 100644 test/std/containers/associative/multiset/upper_bound.pass.cpp create mode 100644 test/std/containers/associative/set/clear.pass.cpp create mode 100644 test/std/containers/associative/set/count.pass.cpp create mode 100644 test/std/containers/associative/set/emplace.pass.cpp create mode 100644 test/std/containers/associative/set/emplace_hint.pass.cpp create mode 100644 test/std/containers/associative/set/empty.pass.cpp create mode 100644 test/std/containers/associative/set/equal_range.pass.cpp create mode 100644 test/std/containers/associative/set/erase_iter.pass.cpp create mode 100644 test/std/containers/associative/set/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/set/erase_key.pass.cpp create mode 100644 test/std/containers/associative/set/find.pass.cpp create mode 100644 test/std/containers/associative/set/insert_cv.pass.cpp create mode 100644 test/std/containers/associative/set/insert_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/set/insert_iter_cv.pass.cpp create mode 100644 test/std/containers/associative/set/insert_iter_iter.pass.cpp create mode 100644 test/std/containers/associative/set/insert_iter_rv.pass.cpp create mode 100644 test/std/containers/associative/set/insert_rv.pass.cpp create mode 100644 test/std/containers/associative/set/iterator.pass.cpp create mode 100644 test/std/containers/associative/set/lower_bound.pass.cpp create mode 100644 test/std/containers/associative/set/max_size.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/alloc.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/compare.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/copy.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/copy_assign.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/default.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/iter_iter.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/move.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/move_assign.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/associative/set/set.special/member_swap.pass.cpp create mode 100644 test/std/containers/associative/set/set.special/non_member_swap.pass.cpp create mode 100644 test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/associative/set/size.pass.cpp create mode 100644 test/std/containers/associative/set/types.pass.cpp create mode 100644 test/std/containers/associative/set/upper_bound.pass.cpp create mode 100644 test/std/containers/associative/set/version.pass.cpp create mode 100644 test/std/containers/associative/tree_balance_after_insert.pass.cpp create mode 100644 test/std/containers/associative/tree_left_rotate.pass.cpp create mode 100644 test/std/containers/associative/tree_remove.pass.cpp create mode 100644 test/std/containers/associative/tree_right_rotate.pass.cpp create mode 100644 test/std/containers/container.adaptors/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/priority.queue/types.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/queue/version.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/container.adaptors/stack/version.pass.cpp create mode 100644 test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp create mode 100644 test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp create mode 100644 test/std/containers/containers.general/nothing_to_do.pass.cpp create mode 100644 test/std/containers/nothing_to_do.pass.cpp create mode 100644 test/std/containers/sequences/array/array.cons/default.pass.cpp create mode 100644 test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/array/array.data/data.pass.cpp create mode 100644 test/std/containers/sequences/array/array.data/data_const.pass.cpp create mode 100644 test/std/containers/sequences/array/array.fill/fill.pass.cpp create mode 100644 test/std/containers/sequences/array/array.size/size.pass.cpp create mode 100644 test/std/containers/sequences/array/array.special/swap.pass.cpp create mode 100644 test/std/containers/sequences/array/array.swap/swap.pass.cpp create mode 100644 test/std/containers/sequences/array/array.tuple/get.fail.cpp create mode 100644 test/std/containers/sequences/array/array.tuple/get.pass.cpp create mode 100644 test/std/containers/sequences/array/array.tuple/get_const.pass.cpp create mode 100644 test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp create mode 100644 test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp create mode 100644 test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp create mode 100644 test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp create mode 100644 test/std/containers/sequences/array/at.pass.cpp create mode 100644 test/std/containers/sequences/array/begin.pass.cpp create mode 100644 test/std/containers/sequences/array/contiguous.pass.cpp create mode 100644 test/std/containers/sequences/array/front_back.pass.cpp create mode 100644 test/std/containers/sequences/array/indexing.pass.cpp create mode 100644 test/std/containers/sequences/array/iterators.pass.cpp create mode 100644 test/std/containers/sequences/array/types.pass.cpp create mode 100644 test/std/containers/sequences/array/version.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.capacity/access.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/copy.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/default.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/move.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/size.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.special/copy.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.special/move.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.special/swap.pass.cpp create mode 100644 test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/deque/iterators.pass.cpp create mode 100644 test/std/containers/sequences/deque/types.pass.cpp create mode 100644 test/std/containers/sequences/deque/version.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/max_size.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/types.pass.cpp create mode 100644 test/std/containers/sequences/forwardlist/version.pass.cpp create mode 100644 test/std/containers/sequences/list/db_back.pass.cpp create mode 100644 test/std/containers/sequences/list/db_cback.pass.cpp create mode 100644 test/std/containers/sequences/list/db_cfront.pass.cpp create mode 100644 test/std/containers/sequences/list/db_front.pass.cpp create mode 100644 test/std/containers/sequences/list/db_iterators_6.pass.cpp create mode 100644 test/std/containers/sequences/list/db_iterators_7.pass.cpp create mode 100644 test/std/containers/sequences/list/db_iterators_8.pass.cpp create mode 100644 test/std/containers/sequences/list/db_iterators_9.pass.cpp create mode 100644 test/std/containers/sequences/list/iterators.pass.cpp create mode 100644 test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp create mode 100644 test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/assign_move.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/copy.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/default.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/move.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/size_type.pass.cpp create mode 100644 test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/clear.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp create mode 100644 test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/merge.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/remove.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/remove_if.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/reverse.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/sort.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/unique.pass.cpp create mode 100644 test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp create mode 100644 test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp create mode 100644 test/std/containers/sequences/list/list.special/swap.pass.cpp create mode 100644 test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/list/types.pass.cpp create mode 100644 test/std/containers/sequences/list/version.pass.cpp create mode 100644 test/std/containers/sequences/nothing_to_do.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/assign_copy.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/assign_move.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/capacity.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/construct_default.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/construct_size.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/copy.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/emplace.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/emplace_back.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/erase_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/find.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/iterators.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/move.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/move_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/push_back.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/reserve.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/resize_size.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/swap.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/types.pass.cpp create mode 100644 test/std/containers/sequences/vector.bool/vector_bool.pass.cpp create mode 100644 test/std/containers/sequences/vector/asan.pass.cpp create mode 100644 test/std/containers/sequences/vector/asan_throw.pass.cpp create mode 100644 test/std/containers/sequences/vector/const_value_type.pass.cpp create mode 100644 test/std/containers/sequences/vector/contiguous.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_back.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_cback.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_cfront.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_cindex.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_front.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_index.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_iterators_2.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_iterators_3.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_iterators_4.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_iterators_5.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_iterators_6.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_iterators_7.pass.cpp create mode 100644 test/std/containers/sequences/vector/db_iterators_8.pass.cpp create mode 100644 test/std/containers/sequences/vector/iterators.pass.cpp create mode 100644 test/std/containers/sequences/vector/types.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/copy.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/move.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.data/data.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.data/data_const.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.special/swap.pass.cpp create mode 100644 test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp create mode 100644 test/std/containers/sequences/vector/version.pass.cpp create mode 100644 test/std/containers/stack_allocator.h create mode 100644 test/std/containers/test_compare.h create mode 100644 test/std/containers/test_hash.h create mode 100644 test/std/containers/unord/next_prime.pass.cpp create mode 100644 test/std/containers/unord/unord.map/bucket.pass.cpp create mode 100644 test/std/containers/unord/unord.map/bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.map/bucket_size.pass.cpp create mode 100644 test/std/containers/unord/unord.map/compare.pass.cpp create mode 100644 test/std/containers/unord/unord.map/count.pass.cpp create mode 100644 test/std/containers/unord/unord.map/db_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.map/db_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.map/eq.pass.cpp create mode 100644 test/std/containers/unord/unord.map/equal_range_const.pass.cpp create mode 100644 test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.map/find_const.pass.cpp create mode 100644 test/std/containers/unord/unord.map/find_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.map/iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.map/load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.map/local_iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.map/max_bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.map/max_load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.map/max_size.pass.cpp create mode 100644 test/std/containers/unord/unord.map/rehash.pass.cpp create mode 100644 test/std/containers/unord/unord.map/reserve.pass.cpp create mode 100644 test/std/containers/unord/unord.map/swap_member.pass.cpp create mode 100644 test/std/containers/unord/unord.map/types.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp create mode 100644 test/std/containers/unord/unord.map/version.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/bucket.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/bucket_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/count.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/eq.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/find_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/find_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/iterators.fail.cpp create mode 100644 test/std/containers/unord/unord.multimap/iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/local_iterators.fail.cpp create mode 100644 test/std/containers/unord/unord.multimap/local_iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/max_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/rehash.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/reserve.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/scary.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/swap_member.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/types.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/bucket.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/bucket_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/clear.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/count.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/emplace.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/eq.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_key.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/erase_range.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/find_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/find_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/insert_init.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/insert_range.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/iterators.fail.cpp create mode 100644 test/std/containers/unord/unord.multiset/iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/local_iterators.fail.cpp create mode 100644 test/std/containers/unord/unord.multiset/local_iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/max_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/rehash.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/reserve.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/scary.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/swap_member.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/types.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp create mode 100644 test/std/containers/unord/unord.set/bucket.pass.cpp create mode 100644 test/std/containers/unord/unord.set/bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.set/bucket_size.pass.cpp create mode 100644 test/std/containers/unord/unord.set/clear.pass.cpp create mode 100644 test/std/containers/unord/unord.set/count.pass.cpp create mode 100644 test/std/containers/unord/unord.set/db_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.set/db_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp create mode 100644 test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp create mode 100644 test/std/containers/unord/unord.set/emplace.pass.cpp create mode 100644 test/std/containers/unord/unord.set/emplace_hint.pass.cpp create mode 100644 test/std/containers/unord/unord.set/eq.pass.cpp create mode 100644 test/std/containers/unord/unord.set/equal_range_const.pass.cpp create mode 100644 test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_const_iter.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_key.pass.cpp create mode 100644 test/std/containers/unord/unord.set/erase_range.pass.cpp create mode 100644 test/std/containers/unord/unord.set/find_const.pass.cpp create mode 100644 test/std/containers/unord/unord.set/find_non_const.pass.cpp create mode 100644 test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.set/insert_init.pass.cpp create mode 100644 test/std/containers/unord/unord.set/insert_range.pass.cpp create mode 100644 test/std/containers/unord/unord.set/insert_rvalue.pass.cpp create mode 100644 test/std/containers/unord/unord.set/iterators.fail.cpp create mode 100644 test/std/containers/unord/unord.set/iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.set/load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.set/local_iterators.fail.cpp create mode 100644 test/std/containers/unord/unord.set/local_iterators.pass.cpp create mode 100644 test/std/containers/unord/unord.set/max_bucket_count.pass.cpp create mode 100644 test/std/containers/unord/unord.set/max_load_factor.pass.cpp create mode 100644 test/std/containers/unord/unord.set/max_size.pass.cpp create mode 100644 test/std/containers/unord/unord.set/rehash.pass.cpp create mode 100644 test/std/containers/unord/unord.set/reserve.pass.cpp create mode 100644 test/std/containers/unord/unord.set/swap_member.pass.cpp create mode 100644 test/std/containers/unord/unord.set/types.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp create mode 100644 test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp create mode 100644 test/std/containers/unord/unord.set/version.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/A.h create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/AB.h create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp create mode 100644 test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp create mode 100644 test/std/depr/depr.c.headers/assert_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/ciso646.pass.cpp create mode 100644 test/std/depr/depr.c.headers/complex.h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/ctype_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/errno_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/fenv_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/float_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/inttypes_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/iso646_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/limits_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/locale_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/math_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/setjmp_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/signal_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/stdarg_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/stdbool_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/stddef_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/stdint_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/stdio_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/stdlib_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/string_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/tgmath_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/time_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/uchar_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/wchar_h.pass.cpp create mode 100644 test/std/depr/depr.c.headers/wctype_h.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp create mode 100644 test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp create mode 100644 test/std/depr/depr.function.objects/nothing_to_do.pass.cpp create mode 100644 test/std/depr/depr.ios.members/io_state.pass.cpp create mode 100644 test/std/depr/depr.ios.members/open_mode.pass.cpp create mode 100644 test/std/depr/depr.ios.members/seek_dir.pass.cpp create mode 100644 test/std/depr/depr.ios.members/streamoff.pass.cpp create mode 100644 test/std/depr/depr.ios.members/streampos.pass.cpp create mode 100644 test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp create mode 100644 test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp create mode 100644 test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp create mode 100644 test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp create mode 100644 test/std/depr/depr.lib.binders/nothing_to_do.pass.cpp create mode 100644 test/std/depr/depr.lib.binders/test_func.h create mode 100644 test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstream/types.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp create mode 100644 test/std/depr/depr.str.strstreams/version.pass.cpp create mode 100644 test/std/depr/exception.unexpected/nothing_to_do.pass.cpp create mode 100644 test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp create mode 100644 test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp create mode 100644 test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp create mode 100644 test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp create mode 100644 test/std/depr/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/assertions/cassert.pass.cpp create mode 100644 test/std/diagnostics/diagnostics.general/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/errno/cerrno.pass.cpp create mode 100644 test/std/diagnostics/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp create mode 100644 test/std/diagnostics/std.exceptions/version.pass.cpp create mode 100644 test/std/diagnostics/syserr/errc.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp create mode 100644 test/std/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp create mode 100644 test/std/diagnostics/syserr/version.pass.cpp create mode 100644 test/std/experimental/algorithms/alg.random.sample/sample.fail.cpp create mode 100644 test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp create mode 100644 test/std/experimental/algorithms/alg.random.sample/sample.stable.pass.cpp create mode 100644 test/std/experimental/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/optional/optional.bad_optional_access/default.pass.cpp create mode 100644 test/std/experimental/optional/optional.bad_optional_access/derive.pass.cpp create mode 100644 test/std/experimental/optional/optional.comp_with_t/equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.comp_with_t/greater.pass.cpp create mode 100644 test/std/experimental/optional/optional.comp_with_t/greater_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.comp_with_t/less_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.comp_with_t/less_than.pass.cpp create mode 100644 test/std/experimental/optional/optional.comp_with_t/not_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.defs/tested_elsewhere.pass.cpp create mode 100644 test/std/experimental/optional/optional.general/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/optional/optional.hash/hash.pass.cpp create mode 100644 test/std/experimental/optional/optional.inplace/in_place_t.pass.cpp create mode 100644 test/std/experimental/optional/optional.nullops/equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.nullops/greater.pass.cpp create mode 100644 test/std/experimental/optional/optional.nullops/greater_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.nullops/less_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.nullops/less_than.pass.cpp create mode 100644 test/std/experimental/optional/optional.nullops/not_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.nullopt/nullopt_t.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.assign/assign_value.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/default.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.dtor/dtor.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp create mode 100644 test/std/experimental/optional/optional.object/optional_const_void.fail.cpp create mode 100644 test/std/experimental/optional/optional.object/optional_not_destructible.fail.cpp create mode 100644 test/std/experimental/optional/optional.object/optional_not_noexcept_destructible.fail.cpp create mode 100644 test/std/experimental/optional/optional.object/optional_void.fail.cpp create mode 100644 test/std/experimental/optional/optional.object/types.pass.cpp create mode 100644 test/std/experimental/optional/optional.relops/equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.relops/greater_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.relops/greater_than.pass.cpp create mode 100644 test/std/experimental/optional/optional.relops/less_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.relops/less_than.pass.cpp create mode 100644 test/std/experimental/optional/optional.relops/not_equal.pass.cpp create mode 100644 test/std/experimental/optional/optional.specalg/make_optional.pass.cpp create mode 100644 test/std/experimental/optional/optional.specalg/swap.pass.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_const_in_place_t.fail.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_const_lvalue_ref.fail.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_const_nullopt_t.fail.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_in_place_t.fail.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_includes_initializer_list.pass.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_lvalue_ref.fail.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_nullopt_t.fail.cpp create mode 100644 test/std/experimental/optional/optional.syn/optional_rvalue_ref.fail.cpp create mode 100644 test/std/experimental/optional/version.pass.cpp create mode 100644 test/std/experimental/string.view/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.access/at.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.access/back.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.access/data.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.access/front.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.access/index.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.capacity/capacity.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.cons/default.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.cons/from_literal.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.cons/from_string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.cons/from_string1.fail.cpp create mode 100644 test/std/experimental/string.view/string.view.cons/from_string2.fail.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_char_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/find_string_view_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/rfind_char_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.hash/string_view.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.io/stream_insert.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.iterators/begin.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.iterators/end.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.iterators/rbegin.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.iterators/rend.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.modifiers/clear.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.modifiers/swap.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.nonmem/quoted.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/basic_string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/compare.pointer.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/compare.sv.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/copy.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/substr.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.ops/to_string.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/string.view/string.view.template/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp create mode 100644 test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp create mode 100644 test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp create mode 100644 test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp create mode 100644 test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp create mode 100644 test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp create mode 100644 test/std/experimental/utilities/meta/version.pass.cpp create mode 100644 test/std/experimental/utilities/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp create mode 100644 test/std/experimental/utilities/ratio/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp create mode 100644 test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.pass.cpp create mode 100644 test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp create mode 100644 test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp create mode 100644 test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple.apply/return_type.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp create mode 100644 test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp create mode 100644 test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp create mode 100644 test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp create mode 100644 test/std/experimental/utilities/utility/version.pass.cpp create mode 100644 test/std/extensions/hash/specializations.fail.cpp create mode 100644 test/std/extensions/hash/specializations.pass.cpp create mode 100644 test/std/extensions/hash_map/const_iterator.fail.cpp create mode 100644 test/std/extensions/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/file.streams/c.files/cinttypes.pass.cpp create mode 100644 test/std/input.output/file.streams/c.files/cstdio.pass.cpp create mode 100644 test/std/input.output/file.streams/c.files/gets.fail.cpp create mode 100644 test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp create mode 100644 test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg create mode 100644 test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp create mode 100644 test/std/input.output/file.streams/c.files/version_ccstdio.pass.cpp create mode 100644 test/std/input.output/file.streams/c.files/version_cinttypes.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat create mode 100644 test/std/input.output/file.streams/fstreams/filebuf/types.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.members/close.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/fstream/types.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.assign/test.dat create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.assign/test2.dat create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.cons/test.dat create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ifstream.members/test.dat create mode 100644 test/std/input.output/file.streams/fstreams/ifstream/types.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/lit.local.cfg create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/ofstream/types.pass.cpp create mode 100644 test/std/input.output/file.streams/fstreams/version.pass.cpp create mode 100644 test/std/input.output/file.streams/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/input.output.general/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostream.format/ext.manip/get_money.pass.cpp create mode 100644 test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp create mode 100644 test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp create mode 100644 test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/istream/types.pass.cpp create mode 100644 test/std/input.output/iostream.format/input.streams/version.pass.cpp create mode 100644 test/std/input.output/iostream.format/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream/types.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp create mode 100644 test/std/input.output/iostream.format/output.streams/version.pass.cpp create mode 100644 test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp create mode 100644 test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp create mode 100644 test/std/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp create mode 100644 test/std/input.output/iostream.format/std.manip/resetiosflags.pass.cpp create mode 100644 test/std/input.output/iostream.format/std.manip/setbase.pass.cpp create mode 100644 test/std/input.output/iostream.format/std.manip/setfill.pass.cpp create mode 100644 test/std/input.output/iostream.format/std.manip/setiosflags.pass.cpp create mode 100644 test/std/input.output/iostream.format/std.manip/setprecision.pass.cpp create mode 100644 test/std/input.output/iostream.format/std.manip/setw.pass.cpp create mode 100644 test/std/input.output/iostream.format/std.manip/version.pass.cpp create mode 100644 test/std/input.output/iostream.forward/iosfwd.pass.cpp create mode 100644 test/std/input.output/iostream.forward/version.pass.cpp create mode 100644 test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp create mode 100644 test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp create mode 100644 test/std/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp create mode 100644 test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp create mode 100644 test/std/input.output/iostream.objects/version.pass.cpp create mode 100644 test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp create mode 100644 test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp create mode 100644 test/std/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp create mode 100644 test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp create mode 100644 test/std/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp create mode 100644 test/std/input.output/iostreams.base/ios/types.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp create mode 100644 test/std/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostreams.base/stream.types/streamoff.pass.cpp create mode 100644 test/std/input.output/iostreams.base/stream.types/streamsize.pass.cpp create mode 100644 test/std/input.output/iostreams.base/version.pass.cpp create mode 100644 test/std/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp create mode 100644 test/std/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/iostreams.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp create mode 100644 test/std/input.output/stream.buffers/streambuf/types.pass.cpp create mode 100644 test/std/input.output/stream.buffers/version.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp create mode 100644 test/std/input.output/string.streams/istringstream/types.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp create mode 100644 test/std/input.output/string.streams/ostringstream/types.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp create mode 100644 test/std/input.output/string.streams/stringbuf/types.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.cons/default.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.cons/move.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.cons/string.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream.members/str.pass.cpp create mode 100644 test/std/input.output/string.streams/stringstream/types.pass.cpp create mode 100644 test/std/input.output/string.streams/version.pass.cpp create mode 100644 test/std/iterators/iterator.container/data.pass.cpp create mode 100644 test/std/iterators/iterator.container/empty.pass.cpp create mode 100644 test/std/iterators/iterator.container/size.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp create mode 100644 test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp create mode 100644 test/std/iterators/iterator.range/begin-end.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/iterators.general/gcc_workaround.pass.cpp create mode 100644 test/std/iterators/iterators.general/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp create mode 100644 test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp create mode 100644 test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp create mode 100644 test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp create mode 100644 test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp create mode 100644 test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp create mode 100644 test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp create mode 100644 test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp create mode 100644 test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp create mode 100644 test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp create mode 100644 test/std/iterators/stream.iterators/nothing_to_do.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp create mode 100644 test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp create mode 100644 test/std/iterators/version.pass.cpp create mode 100644 test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp create mode 100644 test/std/language.support/cstdint/version.pass.cpp create mode 100644 test/std/language.support/nothing_to_do.pass.cpp create mode 100644 test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp create mode 100644 test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp create mode 100644 test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp create mode 100644 test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp create mode 100644 test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp create mode 100644 test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp create mode 100644 test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp create mode 100644 test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp create mode 100644 test/std/language.support/support.dynamic/version.pass.cpp create mode 100644 test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp create mode 100644 test/std/language.support/support.exception/except.nested/assign.pass.cpp create mode 100644 test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp create mode 100644 test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp create mode 100644 test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp create mode 100644 test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp create mode 100644 test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp create mode 100644 test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp create mode 100644 test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp create mode 100644 test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp create mode 100644 test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp create mode 100644 test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp create mode 100644 test/std/language.support/support.exception/exception/exception.pass.cpp create mode 100644 test/std/language.support/support.exception/propagation/current_exception.pass.cpp create mode 100644 test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp create mode 100644 test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp create mode 100644 test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp create mode 100644 test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp create mode 100644 test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp create mode 100644 test/std/language.support/support.exception/version.pass.cpp create mode 100644 test/std/language.support/support.general/nothing_to_do.pass.cpp create mode 100644 test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp create mode 100644 test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp create mode 100644 test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp create mode 100644 test/std/language.support/support.initlist/types.pass.cpp create mode 100644 test/std/language.support/support.initlist/version.pass.cpp create mode 100644 test/std/language.support/support.limits/c.limits/cfloat.pass.cpp create mode 100644 test/std/language.support/support.limits/c.limits/climits.pass.cpp create mode 100644 test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp create mode 100644 test/std/language.support/support.limits/c.limits/version_climits.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/is_specialized.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.limits/default.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/round.style/check_values.pass.cpp create mode 100644 test/std/language.support/support.limits/limits/version.pass.cpp create mode 100644 test/std/language.support/support.limits/nothing_to_do.pass.cpp create mode 100644 test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp create mode 100644 test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp create mode 100644 test/std/language.support/support.rtti/type.info/type_info.pass.cpp create mode 100644 test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp create mode 100644 test/std/language.support/support.rtti/version.pass.cpp create mode 100644 test/std/language.support/support.runtime/csetjmp.pass.cpp create mode 100644 test/std/language.support/support.runtime/csignal.pass.cpp create mode 100644 test/std/language.support/support.runtime/cstdarg.pass.cpp create mode 100644 test/std/language.support/support.runtime/cstdbool.pass.cpp create mode 100644 test/std/language.support/support.runtime/cstdlib.pass.cpp create mode 100644 test/std/language.support/support.runtime/ctime.pass.cpp create mode 100644 test/std/language.support/support.runtime/version_csetjmp.pass.cpp create mode 100644 test/std/language.support/support.runtime/version_csignal.pass.cpp create mode 100644 test/std/language.support/support.runtime/version_cstdarg.pass.cpp create mode 100644 test/std/language.support/support.runtime/version_cstdbool.pass.cpp create mode 100644 test/std/language.support/support.runtime/version_cstdlib.pass.cpp create mode 100644 test/std/language.support/support.runtime/version_ctime.pass.cpp create mode 100644 test/std/language.support/support.start.term/quick_exit.pass.cpp create mode 100644 test/std/language.support/support.start.term/quick_exit_check1.fail.cpp create mode 100644 test/std/language.support/support.start.term/quick_exit_check2.fail.cpp create mode 100644 test/std/language.support/support.types/max_align_t.pass.cpp create mode 100644 test/std/language.support/support.types/null.pass.cpp create mode 100644 test/std/language.support/support.types/nullptr_t.pass.cpp create mode 100644 test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp create mode 100644 test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp create mode 100644 test/std/language.support/support.types/offsetof.pass.cpp create mode 100644 test/std/language.support/support.types/ptrdiff_t.pass.cpp create mode 100644 test/std/language.support/support.types/size_t.pass.cpp create mode 100644 test/std/language.support/support.types/version.pass.cpp create mode 100644 test/std/localization/c.locales/clocale.pass.cpp create mode 100644 test/std/localization/c.locales/version.pass.cpp create mode 100644 test/std/localization/locale.categories/__scan_keyword.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.collate/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/mask.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp create mode 100644 test/std/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp create mode 100644 test/std/localization/locale.categories/category.messages/locale.messages/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.messages/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.get/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/locale.time.put/types.pass.cpp create mode 100644 test/std/localization/locale.categories/category.time/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp create mode 100644 test/std/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp create mode 100644 test/std/localization/locale.stdcvt/version.pass.cpp create mode 100644 test/std/localization/locale.syn/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isalnum.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isalpha.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/iscntrl.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isdigit.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isgraph.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/islower.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isprint.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/ispunct.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isspace.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isupper.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/classification/isxdigit.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/lit.local.cfg create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locales/locale.convenience/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locales/locale.global.templates/has_facet.pass.cpp create mode 100644 test/std/localization/locales/locale.global.templates/use_facet.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/assign.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/copy.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/default.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.cons/string.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.members/combine.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.members/name.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.operators/compare.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.operators/eq.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.statics/classic.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.statics/global.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp create mode 100644 test/std/localization/locales/locale/locale.types/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locales/locale/nothing_to_do.pass.cpp create mode 100644 test/std/localization/locales/nothing_to_do.pass.cpp create mode 100644 test/std/localization/localization.general/nothing_to_do.pass.cpp create mode 100644 test/std/localization/version.pass.cpp create mode 100644 test/std/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/c.math/cmath.pass.cpp create mode 100644 test/std/numerics/c.math/cmath_isinf.pass.cpp create mode 100644 test/std/numerics/c.math/cmath_isnan.pass.cpp create mode 100644 test/std/numerics/c.math/ctgmath.pass.cpp create mode 100644 test/std/numerics/c.math/tgmath_h.pass.cpp create mode 100644 test/std/numerics/c.math/version_cmath.pass.cpp create mode 100644 test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp create mode 100644 test/std/numerics/cfenv/version.pass.cpp create mode 100644 test/std/numerics/complex.number/cases.h create mode 100644 test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp create mode 100644 test/std/numerics/complex.number/cmplx.over/arg.pass.cpp create mode 100644 test/std/numerics/complex.number/cmplx.over/conj.pass.cpp create mode 100644 test/std/numerics/complex.number/cmplx.over/imag.pass.cpp create mode 100644 test/std/numerics/complex.number/cmplx.over/norm.pass.cpp create mode 100644 test/std/numerics/complex.number/cmplx.over/pow.pass.cpp create mode 100644 test/std/numerics/complex.number/cmplx.over/proj.pass.cpp create mode 100644 test/std/numerics/complex.number/cmplx.over/real.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.literals/literals.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.literals/literals1.fail.cpp create mode 100644 test/std/numerics/complex.number/complex.literals/literals1.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.literals/literals2.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.members/construct.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.members/real_imag.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp create mode 100644 test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp create mode 100644 test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp create mode 100644 test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp create mode 100644 test/std/numerics/complex.number/complex.value.ops/real.pass.cpp create mode 100644 test/std/numerics/complex.number/complex/types.pass.cpp create mode 100644 test/std/numerics/complex.number/layout.pass.cpp create mode 100644 test/std/numerics/complex.number/version.pass.cpp create mode 100644 test/std/numerics/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp create mode 100644 test/std/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp create mode 100644 test/std/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp create mode 100644 test/std/numerics/numarray/class.gslice/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/numarray/class.slice/cons.slice/default.pass.cpp create mode 100644 test/std/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp create mode 100644 test/std/numerics/numarray/class.slice/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/default.fail.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.gslice.array/types.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/default.fail.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.indirect.array/types.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/default.fail.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.mask.array/types.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/default.fail.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.slice.array/types.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/types.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp create mode 100644 test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.range/begin_const.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.range/end_const.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp create mode 100644 test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/numarray/version.pass.cpp create mode 100644 test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp create mode 100644 test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp create mode 100644 test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp create mode 100644 test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp create mode 100644 test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp create mode 100644 test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp create mode 100644 test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp create mode 100644 test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp create mode 100644 test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp create mode 100644 test/std/numerics/numeric.ops/version.pass.cpp create mode 100644 test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/numerics.general/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp create mode 100644 test/std/numerics/rand/rand.device/ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.device/entropy.pass.cpp create mode 100644 test/std/numerics/rand/rand.device/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp create mode 100644 test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp create mode 100644 test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/knuth_b.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/minstd_rand.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/minstd_rand0.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/mt19937.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/mt19937_64.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/ranlux24.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/ranlux24_base.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/ranlux48.pass.cpp create mode 100644 test/std/numerics/rand/rand.predef/ranlux48_base.pass.cpp create mode 100644 test/std/numerics/rand/rand.req/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.synopsis/version.pass.cpp create mode 100644 test/std/numerics/rand/rand.util/nothing_to_do.pass.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp create mode 100644 test/std/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp create mode 100644 test/std/re/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.alg/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/awk.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/basic.fail.cpp create mode 100644 test/std/re/re.alg/re.alg.match/basic.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/ecma.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/egrep.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/extended.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/grep.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.replace/test1.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.replace/test2.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.replace/test3.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.replace/test4.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.replace/test5.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.replace/test6.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/awk.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/backup.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/basic.fail.cpp create mode 100644 test/std/re/re.alg/re.alg.search/basic.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/ecma.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/egrep.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/extended.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/grep.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/lookahead.pass.cpp create mode 100644 test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp create mode 100644 test/std/re/re.alg/re.except/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.badexp/regex_error.pass.cpp create mode 100644 test/std/re/re.const/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.const/re.err/error_type.pass.cpp create mode 100644 test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp create mode 100644 test/std/re/re.const/re.matchflag/match_not_bol.pass.cpp create mode 100644 test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp create mode 100644 test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp create mode 100644 test/std/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.def/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.general/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.grammar/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.iter/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp create mode 100644 test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp create mode 100644 test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp create mode 100644 test/std/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp create mode 100644 test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp create mode 100644 test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp create mode 100644 test/std/re/re.iter/re.regiter/types.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp create mode 100644 test/std/re/re.iter/re.tokiter/types.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/assign.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/copy.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/il.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/ptr.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.assign/string.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.const/constants.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/copy.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/default.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/ptr.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/string.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.locale/imbue.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.swap/swap.pass.cpp create mode 100644 test/std/re/re.regex/types.pass.cpp create mode 100644 test/std/re/re.req/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/begin_end.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/index.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/length.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/position.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/prefix.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/str.pass.cpp create mode 100644 test/std/re/re.results/re.results.acc/suffix.pass.cpp create mode 100644 test/std/re/re.results/re.results.all/get_allocator.pass.cpp create mode 100644 test/std/re/re.results/re.results.const/allocator.pass.cpp create mode 100644 test/std/re/re.results/re.results.const/default.pass.cpp create mode 100644 test/std/re/re.results/re.results.form/form1.pass.cpp create mode 100644 test/std/re/re.results/re.results.form/form2.pass.cpp create mode 100644 test/std/re/re.results/re.results.form/form3.pass.cpp create mode 100644 test/std/re/re.results/re.results.form/form4.pass.cpp create mode 100644 test/std/re/re.results/re.results.nonmember/equal.pass.cpp create mode 100644 test/std/re/re.results/re.results.size/empty.pass.cpp create mode 100644 test/std/re/re.results/re.results.size/max_size.pass.cpp create mode 100644 test/std/re/re.results/re.results.state/ready.pass.cpp create mode 100644 test/std/re/re.results/re.results.swap/member_swap.pass.cpp create mode 100644 test/std/re/re.results/re.results.swap/non_member_swap.pass.cpp create mode 100644 test/std/re/re.results/types.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.members/default.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.members/length.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.members/operator_string.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.members/str.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.op/compare.pass.cpp create mode 100644 test/std/re/re.submatch/re.submatch.op/stream.pass.cpp create mode 100644 test/std/re/re.submatch/types.pass.cpp create mode 100644 test/std/re/re.syn/cmatch.pass.cpp create mode 100644 test/std/re/re.syn/cregex_iterator.pass.cpp create mode 100644 test/std/re/re.syn/cregex_token_iterator.pass.cpp create mode 100644 test/std/re/re.syn/csub_match.pass.cpp create mode 100644 test/std/re/re.syn/regex.pass.cpp create mode 100644 test/std/re/re.syn/smatch.pass.cpp create mode 100644 test/std/re/re.syn/sregex_iterator.pass.cpp create mode 100644 test/std/re/re.syn/sregex_token_iterator.pass.cpp create mode 100644 test/std/re/re.syn/ssub_match.pass.cpp create mode 100644 test/std/re/re.syn/wcmatch.pass.cpp create mode 100644 test/std/re/re.syn/wcregex_iterator.pass.cpp create mode 100644 test/std/re/re.syn/wcregex_token_iterator.pass.cpp create mode 100644 test/std/re/re.syn/wcsub_match.pass.cpp create mode 100644 test/std/re/re.syn/wregex.pass.cpp create mode 100644 test/std/re/re.syn/wsmatch.pass.cpp create mode 100644 test/std/re/re.syn/wsregex_iterator.pass.cpp create mode 100644 test/std/re/re.syn/wsregex_token_iterator.pass.cpp create mode 100644 test/std/re/re.syn/wssub_match.pass.cpp create mode 100644 test/std/re/re.traits/default.pass.cpp create mode 100644 test/std/re/re.traits/getloc.pass.cpp create mode 100644 test/std/re/re.traits/imbue.pass.cpp create mode 100644 test/std/re/re.traits/isctype.pass.cpp create mode 100644 test/std/re/re.traits/length.pass.cpp create mode 100644 test/std/re/re.traits/lookup_classname.pass.cpp create mode 100644 test/std/re/re.traits/lookup_collatename.pass.cpp create mode 100644 test/std/re/re.traits/transform.pass.cpp create mode 100644 test/std/re/re.traits/transform_primary.pass.cpp create mode 100644 test/std/re/re.traits/translate.pass.cpp create mode 100644 test/std/re/re.traits/translate_nocase.pass.cpp create mode 100644 test/std/re/re.traits/types.pass.cpp create mode 100644 test/std/re/re.traits/value.pass.cpp create mode 100644 test/std/strings/basic.string.hash/strings.pass.cpp create mode 100644 test/std/strings/basic.string.literals/literal.pass.cpp create mode 100644 test/std/strings/basic.string.literals/literal1.fail.cpp create mode 100644 test/std/strings/basic.string.literals/literal1.pass.cpp create mode 100644 test/std/strings/basic.string.literals/literal2.fail.cpp create mode 100644 test/std/strings/basic.string.literals/literal2.pass.cpp create mode 100644 test/std/strings/basic.string.literals/literal3.pass.cpp create mode 100644 test/std/strings/basic.string/input_iterator.h create mode 100644 test/std/strings/basic.string/string.access/at.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/back.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/db_back.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/db_cback.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/db_cfront.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/db_cindex.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/db_front.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/db_index.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/front.pass.cpp create mode 100644 test/std/strings/basic.string/string.access/index.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/capacity.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/clear.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/empty.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/length.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/max_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/reserve.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/resize_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp create mode 100644 test/std/strings/basic.string/string.capacity/size.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/alloc.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/char_assignment.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/copy.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/initializer_list.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/move.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/move_alloc.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/move_assignment.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp create mode 100644 test/std/strings/basic.string/string.cons/substr.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/begin.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/cbegin.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/cend.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/crbegin.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/crend.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/db_iterators_2.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/db_iterators_3.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/db_iterators_4.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/db_iterators_5.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/db_iterators_6.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/db_iterators_7.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/db_iterators_8.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/end.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/iterators.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/rbegin.pass.cpp create mode 100644 test/std/strings/basic.string/string.iterators/rend.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/nothing_to_do.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp create mode 100644 test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp create mode 100644 test/std/strings/basic.string/string.require/contiguous.pass.cpp create mode 100644 test/std/strings/basic.string/test_traits.h create mode 100644 test/std/strings/basic.string/types.pass.cpp create mode 100644 test/std/strings/c.strings/cctype.pass.cpp create mode 100644 test/std/strings/c.strings/cstring.pass.cpp create mode 100644 test/std/strings/c.strings/cuchar.pass.cpp create mode 100644 test/std/strings/c.strings/cwchar.pass.cpp create mode 100644 test/std/strings/c.strings/cwctype.pass.cpp create mode 100644 test/std/strings/c.strings/version_cctype.pass.cpp create mode 100644 test/std/strings/c.strings/version_cstring.pass.cpp create mode 100644 test/std/strings/c.strings/version_cuchar.pass.cpp create mode 100644 test/std/strings/c.strings/version_cwchar.pass.cpp create mode 100644 test/std/strings/c.strings/version_cwctype.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp create mode 100644 test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp create mode 100644 test/std/strings/char.traits/nothing_to_do.pass.cpp create mode 100644 test/std/strings/string.classes/typedefs.pass.cpp create mode 100644 test/std/strings/string.conversions/stod.pass.cpp create mode 100644 test/std/strings/string.conversions/stof.pass.cpp create mode 100644 test/std/strings/string.conversions/stoi.pass.cpp create mode 100644 test/std/strings/string.conversions/stol.pass.cpp create mode 100644 test/std/strings/string.conversions/stold.pass.cpp create mode 100644 test/std/strings/string.conversions/stoll.pass.cpp create mode 100644 test/std/strings/string.conversions/stoul.pass.cpp create mode 100644 test/std/strings/string.conversions/stoull.pass.cpp create mode 100644 test/std/strings/string.conversions/to_string.pass.cpp create mode 100644 test/std/strings/string.conversions/to_wstring.pass.cpp create mode 100644 test/std/strings/strings.general/nothing_to_do.pass.cpp create mode 100644 test/std/strings/version.pass.cpp create mode 100644 test/std/thread/futures/futures.async/async.pass.cpp create mode 100644 test/std/thread/futures/futures.async/async_race.pass.cpp create mode 100644 test/std/thread/futures/futures.errors/default_error_condition.pass.cpp create mode 100644 test/std/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp create mode 100644 test/std/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp create mode 100644 test/std/thread/futures/futures.errors/future_category.pass.cpp create mode 100644 test/std/thread/futures/futures.errors/make_error_code.pass.cpp create mode 100644 test/std/thread/futures/futures.errors/make_error_condition.pass.cpp create mode 100644 test/std/thread/futures/futures.future_error/code.pass.cpp create mode 100644 test/std/thread/futures/futures.future_error/types.pass.cpp create mode 100644 test/std/thread/futures/futures.future_error/what.pass.cpp create mode 100644 test/std/thread/futures/futures.overview/future_errc.pass.cpp create mode 100644 test/std/thread/futures/futures.overview/future_status.pass.cpp create mode 100644 test/std/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp create mode 100644 test/std/thread/futures/futures.overview/launch.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/copy_assign.fail.cpp create mode 100644 test/std/thread/futures/futures.promise/copy_ctor.fail.cpp create mode 100644 test/std/thread/futures/futures.promise/default.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/dtor.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/get_future.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/move_assign.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/move_ctor.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_exception.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_lvalue.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_rvalue.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_value_const.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/set_value_void.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/swap.pass.cpp create mode 100644 test/std/thread/futures/futures.promise/uses_allocator.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/default.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/dtor.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/get.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/move_assign.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/wait.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/wait_for.pass.cpp create mode 100644 test/std/thread/futures/futures.shared_future/wait_until.pass.cpp create mode 100644 test/std/thread/futures/futures.state/nothing_to_do.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp create mode 100644 test/std/thread/futures/futures.tas/types.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp create mode 100644 test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp create mode 100644 test/std/thread/futures/futures.unique_future/default.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/dtor.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/get.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/move_assign.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/share.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/wait.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/wait_for.pass.cpp create mode 100644 test/std/thread/futures/futures.unique_future/wait_until.pass.cpp create mode 100644 test/std/thread/futures/test_allocator.h create mode 100644 test/std/thread/futures/version.pass.cpp create mode 100644 test/std/thread/macro.pass.cpp create mode 100644 test/std/thread/thread.condition/cv_status.pass.cpp create mode 100644 test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/assign.fail.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/copy.fail.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/default.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/wait.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp create mode 100644 test/std/thread/thread.condition/version.pass.cpp create mode 100644 test/std/thread/thread.general/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.lock/types.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/try_lock_shared.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until_deadlock_bug.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp create mode 100644 test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp create mode 100644 test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp create mode 100644 test/std/thread/thread.mutex/version.pass.cpp create mode 100644 test/std/thread/thread.req/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.class/types.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp create mode 100644 test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp create mode 100644 test/std/thread/thread.threads/version.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/types.pass.cpp create mode 100644 test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp create mode 100644 test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp create mode 100644 test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp create mode 100644 test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp create mode 100644 test/std/utilities/date.time/tested_elsewhere.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/function.objects/bitwise.operations/bit_and.pass.cpp create mode 100644 test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp create mode 100644 test/std/utilities/function.objects/bitwise.operations/bit_or.pass.cpp create mode 100644 test/std/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp create mode 100644 test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp create mode 100644 test/std/utilities/function.objects/comparisons/equal_to.pass.cpp create mode 100644 test/std/utilities/function.objects/comparisons/greater.pass.cpp create mode 100644 test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp create mode 100644 test/std/utilities/function.objects/comparisons/less.pass.cpp create mode 100644 test/std/utilities/function.objects/comparisons/less_equal.pass.cpp create mode 100644 test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp create mode 100644 test/std/utilities/function.objects/comparisons/transparent.pass.cpp create mode 100644 test/std/utilities/function.objects/func.def/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/function.objects/func.invoke/invoke.pass.cpp create mode 100644 test/std/utilities/function.objects/func.memfn/member_data.fail.cpp create mode 100644 test/std/utilities/function.objects/func.memfn/member_data.pass.cpp create mode 100644 test/std/utilities/function.objects/func.memfn/member_function.pass.cpp create mode 100644 test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp create mode 100644 test/std/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp create mode 100644 test/std/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp create mode 100644 test/std/utilities/function.objects/func.require/binary_function.pass.cpp create mode 100644 test/std/utilities/function.objects/func.require/invoke.pass.cpp create mode 100644 test/std/utilities/function.objects/func.require/unary_function.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp create mode 100644 test/std/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/function.objects/logical.operations/logical_and.pass.cpp create mode 100644 test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp create mode 100644 test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp create mode 100644 test/std/utilities/function.objects/logical.operations/transparent.pass.cpp create mode 100644 test/std/utilities/function.objects/negators/binary_negate.pass.cpp create mode 100644 test/std/utilities/function.objects/negators/not1.pass.cpp create mode 100644 test/std/utilities/function.objects/negators/not2.pass.cpp create mode 100644 test/std/utilities/function.objects/negators/unary_negate.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/binary.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/type.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/type_properties.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/unary.pass.cpp create mode 100644 test/std/utilities/function.objects/refwrap/weak_result.pass.cpp create mode 100644 test/std/utilities/function.objects/unord.hash/enum.fail.cpp create mode 100644 test/std/utilities/function.objects/unord.hash/enum.pass.cpp create mode 100644 test/std/utilities/function.objects/unord.hash/floating.pass.cpp create mode 100644 test/std/utilities/function.objects/unord.hash/integral.pass.cpp create mode 100644 test/std/utilities/function.objects/unord.hash/pointer.pass.cpp create mode 100644 test/std/utilities/function.objects/version.pass.cpp create mode 100644 test/std/utilities/intseq/intseq.general/integer_seq.pass.cpp create mode 100644 test/std/utilities/intseq/intseq.intseq/integer_seq.fail.cpp create mode 100644 test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp create mode 100644 test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp create mode 100644 test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp create mode 100644 test/std/utilities/intseq/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp create mode 100644 test/std/utilities/memory/allocator.traits/value_type.pass.cpp create mode 100644 test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp create mode 100644 test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp create mode 100644 test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator_types.pass.cpp create mode 100644 test/std/utilities/memory/default.allocator/allocator_void.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/difference_type.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/element_type.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/pointer.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp create mode 100644 test/std/utilities/memory/pointer.traits/rebind.pass.cpp create mode 100644 test/std/utilities/memory/ptr.align/align.pass.cpp create mode 100644 test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp create mode 100644 test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp create mode 100644 test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp create mode 100644 test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp create mode 100644 test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp create mode 100644 test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp create mode 100644 test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp create mode 100644 test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/deleter.h create mode 100644 test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp create mode 100644 test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp create mode 100644 test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp create mode 100644 test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp create mode 100644 test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp create mode 100644 test/std/utilities/memory/version.pass.cpp create mode 100644 test/std/utilities/meta/meta.hel/bool_constant.pass.cpp create mode 100644 test/std/utilities/meta/meta.hel/integral_constant.pass.cpp create mode 100644 test/std/utilities/meta/meta.rel/is_base_of.pass.cpp create mode 100644 test/std/utilities/meta/meta.rel/is_convertible.pass.cpp create mode 100644 test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp create mode 100644 test/std/utilities/meta/meta.rel/is_same.pass.cpp create mode 100644 test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp create mode 100644 test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/meta/version.pass.cpp create mode 100644 test/std/utilities/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp create mode 100644 test/std/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.ratio/ratio.pass.cpp create mode 100644 test/std/utilities/ratio/ratio.ratio/ratio1.fail.cpp create mode 100644 test/std/utilities/ratio/ratio.ratio/ratio2.fail.cpp create mode 100644 test/std/utilities/ratio/ratio.ratio/ratio3.fail.cpp create mode 100644 test/std/utilities/ratio/ratio.si/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/ratio/typedefs.pass.cpp create mode 100644 test/std/utilities/ratio/version.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.cons/default.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/all.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/any.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/count.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/flip_all.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/index.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/left_shift.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/none.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/not_all.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/right_shift.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/set_all.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/size.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/test.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.operators/op_and.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.operators/op_not.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.operators/op_or.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp create mode 100644 test/std/utilities/template.bitset/bitset.operators/stream_out.pass.cpp create mode 100644 test/std/utilities/template.bitset/includes.pass.cpp create mode 100644 test/std/utilities/template.bitset/version.pass.cpp create mode 100644 test/std/utilities/time/clock.h create mode 100644 test/std/utilities/time/hours.pass.cpp create mode 100644 test/std/utilities/time/microseconds.pass.cpp create mode 100644 test/std/utilities/time/milliseconds.pass.cpp create mode 100644 test/std/utilities/time/minutes.pass.cpp create mode 100644 test/std/utilities/time/nanoseconds.pass.cpp create mode 100644 test/std/utilities/time/rep.h create mode 100644 test/std/utilities/time/seconds.pass.cpp create mode 100644 test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/time/time.clock/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp create mode 100644 test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp create mode 100644 test/std/utilities/time/time.duration/default_ratio.pass.cpp create mode 100644 test/std/utilities/time/time.duration/duration.fail.cpp create mode 100644 test/std/utilities/time/time.duration/positive_num.fail.cpp create mode 100644 test/std/utilities/time/time.duration/ratio.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp create mode 100644 test/std/utilities/time/time.duration/types.pass.cpp create mode 100644 test/std/utilities/time/time.point/default_duration.pass.cpp create mode 100644 test/std/utilities/time/time.point/duration.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cons/default.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.special/max.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.special/min.pass.cpp create mode 100644 test/std/utilities/time/time.traits/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp create mode 100644 test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp create mode 100644 test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp create mode 100644 test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp create mode 100644 test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp create mode 100644 test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp create mode 100644 test/std/utilities/time/version.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/alloc_first.h create mode 100644 test/std/utilities/tuple/tuple.tuple/alloc_last.h create mode 100644 test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.cnstr/tuple_array_template_depth.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp create mode 100644 test/std/utilities/tuple/version.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.hash/hash.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.members/ctor.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.members/eq.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.members/hash_code.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.members/lt.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.members/name.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.overview/copy_assign.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.overview/copy_ctor.pass.cpp create mode 100644 test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp create mode 100644 test/std/utilities/type.index/version.pass.cpp create mode 100644 test/std/utilities/utilities.general/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility/declval/declval.pass.cpp create mode 100644 test/std/utilities/utility/exchange/exchange.pass.cpp create mode 100644 test/std/utilities/utility/forward/forward.pass.cpp create mode 100644 test/std/utilities/utility/forward/forward1.fail.cpp create mode 100644 test/std/utilities/utility/forward/forward2.fail.cpp create mode 100644 test/std/utilities/utility/forward/forward3.fail.cpp create mode 100644 test/std/utilities/utility/forward/forward4.fail.cpp create mode 100644 test/std/utilities/utility/forward/forward5.fail.cpp create mode 100644 test/std/utilities/utility/forward/forward6.fail.cpp create mode 100644 test/std/utilities/utility/forward/move_copy.pass.cpp create mode 100644 test/std/utilities/utility/forward/move_if_noexcept.pass.cpp create mode 100644 test/std/utilities/utility/forward/move_only.pass.cpp create mode 100644 test/std/utilities/utility/forward/move_only1.fail.cpp create mode 100644 test/std/utilities/utility/forward/move_only2.fail.cpp create mode 100644 test/std/utilities/utility/forward/move_only3.fail.cpp create mode 100644 test/std/utilities/utility/forward/move_only4.fail.cpp create mode 100644 test/std/utilities/utility/operators/rel_ops.pass.cpp create mode 100644 test/std/utilities/utility/pairs/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp create mode 100644 test/std/utilities/utility/utility.swap/swap.pass.cpp create mode 100644 test/std/utilities/utility/utility.swap/swap_array.pass.cpp create mode 100644 test/std/utilities/utility/version.pass.cpp create mode 100644 test/support/Counter.h create mode 100644 test/support/DefaultOnly.h create mode 100644 test/support/MoveOnly.h create mode 100644 test/support/allocators.h create mode 100644 test/support/asan_testing.h create mode 100644 test/support/cmpxchg_loop.h create mode 100644 test/support/constexpr_char_traits.hpp create mode 100644 test/support/count_new.hpp create mode 100644 test/support/counting_predicates.hpp create mode 100644 test/support/hexfloat.h create mode 100644 test/support/is_transparent.h create mode 100644 test/support/min_allocator.h create mode 100644 test/support/nasty_containers.hpp create mode 100644 test/support/nasty_macros.hpp create mode 100644 test/support/nothing_to_do.pass.cpp create mode 100644 test/support/platform_support.h create mode 100644 test/support/private_constructor.hpp create mode 100644 test/support/test_allocator.h create mode 100644 test/support/test_iterators.h create mode 100644 test/support/test_macros.h create mode 100644 test/support/tracked_value.h create mode 100644 test/support/user_defined_integral.hpp create mode 100755 test/testit create mode 100644 utils/not/not.py create mode 100644 utils/sym_check/linux_blacklist.txt create mode 100644 utils/sym_check/osx_blacklist.txt create mode 100644 utils/sym_check/sym_check/__init__.py create mode 100644 utils/sym_check/sym_check/diff.py create mode 100644 utils/sym_check/sym_check/extract.py create mode 100644 utils/sym_check/sym_check/match.py create mode 100644 utils/sym_check/sym_check/util.py create mode 100755 utils/sym_check/sym_diff.py create mode 100755 utils/sym_check/sym_extract.py create mode 100755 utils/sym_check/sym_match.py create mode 100644 www/atomic_design.html create mode 100644 www/atomic_design_a.html create mode 100644 www/atomic_design_b.html create mode 100644 www/atomic_design_c.html create mode 100644 www/content.css create mode 100644 www/cxx1y_status.html create mode 100644 www/cxx1z_status.html create mode 100644 www/debug_mode.html create mode 100644 www/index.html create mode 100644 www/lit_usage.html create mode 100644 www/menu.css create mode 100644 www/results.Linux.html create mode 100644 www/results.Windows.html create mode 100644 www/ts1z_status.html create mode 100644 www/type_traits_design.html diff --git a/.arcconfig b/.arcconfig new file mode 100644 index 000000000000..6d07e827fcb8 --- /dev/null +++ b/.arcconfig @@ -0,0 +1,4 @@ +{ + "project_id" : "libcxx", + "conduit_uri" : "http://reviews.llvm.org/" +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..b26d5f7aa908 --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +#lib/ # We actually have things checked in to lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000000..687c4cfc29a9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,345 @@ +# See www/CMake.html for instructions on how to build libcxx with CMake. + +#=============================================================================== +# Setup Project +#=============================================================================== + +project(libcxx CXX C) +cmake_minimum_required(VERSION 2.8) + +if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default +endif() + +set(PACKAGE_NAME libcxx) +set(PACKAGE_VERSION trunk-svn) +set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") +set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") + +# Add path for custom modules +set(CMAKE_MODULE_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" + ${CMAKE_MODULE_PATH} + ) + +# Require out of source build. +include(MacroEnsureOutOfSourceBuild) +MACRO_ENSURE_OUT_OF_SOURCE_BUILD( + "${PROJECT_NAME} requires an out of source build. Please create a separate + build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." + ) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(LIBCXX_LIBDIR_SUFFIX "" CACHE STRING + "Define suffix of library directory name (32/64)") + + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) + + set(LIBCXX_BUILT_STANDALONE 1) +else() + set(LIBCXX_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX}) +endif() + +#=============================================================================== +# Setup CMake Options +#=============================================================================== + +# Define options. +option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) +option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) +option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) +option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) +option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) +option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF) +option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) +option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) +option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) +option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) +option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) +option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) +option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++" OFF) +option(LIBCXX_ENABLE_MONOTONIC_CLOCK + "Build libc++ with support for a monotonic clock. + This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON) +option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) +option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) +option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) +set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING + "The Profile-rt library used to build with code coverage") +option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) +set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") +set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") +if (LIBCXX_BUILT_STANDALONE) + set(LLVM_USE_SANITIZER "" CACHE STRING + "Define the sanitizer used to build the library and tests") +endif() + +if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) + if (APPLE) + message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X") + else() + message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") + endif() +endif() + +set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++) +if (NOT LIBCXX_CXX_ABI) + if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND + IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi") + set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") + set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include") + set(LIBCXX_CXX_ABI_INTREE 1) + else () + set(LIBCXX_CXX_ABI_LIBNAME "none") + endif () +else () + set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") +endif () +set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING + "Specify C++ ABI library to use." FORCE) +set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) + +# Build libc++abi with libunwind. We need this option to determine whether to +# link with libunwind or libgcc_s while running the test cases. +option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) + +#=============================================================================== +# Configure System +#=============================================================================== + +set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) +set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) + +# Declare libc++ configuration variables. +# They are intended for use as follows: +# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. +# LIBCXX_COMPILE_FLAGS: Compile only flags. +# LIBCXX_LINK_FLAGS: Linker only flags. +set(LIBCXX_CXX_FLAGS "") +set(LIBCXX_COMPILE_FLAGS "") +set(LIBCXX_LINK_FLAGS "") + +# Configure compiler. +include(config-ix) +# Configure ABI library +include(HandleLibCXXABI) +# Configure coverage options. +if (LIBCXX_GENERATE_COVERAGE) + include(CodeCoverage) + set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) +endif() + +#=============================================================================== +# Setup Compiler Flags +#=============================================================================== + +# Get required flags. +# On all systems the system c++ standard library headers need to be excluded. +if (MSVC) + # MSVC only has -X, which disables all default includes; including the crt. + # Thus, we do nothing and hope we don't accidentally include any of the C++ + # headers. +else() + if (LIBCXX_HAS_NOSTDINCXX_FLAG) + list(APPEND LIBCXX_COMPILE_FLAGS -nostdinc++) + string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + endif() + # If c++1y has been enabled then attempt to use it. Fail if it is no supported + # by the compiler. Otherwise choose c++11 and ensure the compiler supports it. + if (LIBCXX_ENABLE_CXX1Y) + if (LIBCXX_HAS_STDCXX1Y_FLAG) + set(LIBCXX_STD_VERSION c++1y) + else() + message(FATAL_ERROR "c++1y was enabled but the compiler does not support it.") + endif() + else() + if (LIBCXX_HAS_STDCXX11_FLAG) + set(LIBCXX_STD_VERSION c++11) + else() + message(FATAL_ERROR "c++11 is required by libc++ but is not supported by the compiler") + endif() + endif() + # LIBCXX_STD_VERSION should always be set at this point. + list(APPEND LIBCXX_CXX_FLAGS "-std=${LIBCXX_STD_VERSION}") +endif() + +macro(append_if list condition var) + if (${condition}) + list(APPEND ${list} ${var}) + endif() +endmacro() + +# Get warning flags +if (NOT MSVC) + append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WALL_FLAG -Wall) + list(APPEND LIBCXX_COMPILE_FLAGS -Werror=return-type) +endif() + +append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_W_FLAG -W) +append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter) +append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings) +append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_LONG_LONG_FLAG -Wno-long-long) +if (LIBCXX_ENABLE_WERROR) + append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WERROR_FLAG -Werror) + append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WX_FLAG -WX) +else() + append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_ERROR_FLAG -Wno-error) + append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_NO_WX_FLAG -WX-) +endif() +if (LIBCXX_ENABLE_PEDANTIC) + append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_PEDANTIC_FLAG -pedantic) +endif() + +# Get feature flags. +# Exceptions +if (LIBCXX_ENABLE_EXCEPTIONS) + # Catches C++ exceptions only and tells the compiler to assume that extern C + # functions never throw a C++ exception. + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_EHSC_FLAG -EHsc) +else() + list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_EXCEPTIONS) + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHS_FLAG -EHs-) + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHA_FLAG -EHa-) + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions) +endif() +# RTTI +if (NOT LIBCXX_ENABLE_RTTI) + list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_RTTI) + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_GR_FLAG -GR-) + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_RTTI_FLAG -fno-rtti) +endif() +# Assert +string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) +if (LIBCXX_ENABLE_ASSERTIONS) + # MSVC doesn't like _DEBUG on release builds. See PR 4379. + if (NOT MSVC) + list(APPEND LIBCXX_COMPILE_FLAGS -D_DEBUG) + endif() + # On Release builds cmake automatically defines NDEBUG, so we + # explicitly undefine it: + if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") + list(APPEND LIBCXX_COMPILE_FLAGS -UNDEBUG) + endif() +else() + if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") + list(APPEND LIBCXX_COMPILE_FLAGS -DNDEBUG) + endif() +endif() +# Static library +if (NOT LIBCXX_ENABLE_SHARED) + list(APPEND LIBCXX_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC) +endif() + +if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) + if (LIBCXX_BUILD_32_BITS) + message(STATUS "Building 32 bits executables and libraries.") + list(APPEND LIBCXX_CXX_FLAGS "-m32") + endif() +elseif(LIBCXX_BUILD_32_BITS) + message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") +endif() +# This is the _ONLY_ place where add_definitions is called. +if (MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() + +# LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE configuration +if (NOT LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE) + add_definitions(-D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) +endif() + +# LIBCXX_ENABLE_STDIN configuration +if (NOT LIBCXX_ENABLE_STDIN) + add_definitions(-D_LIBCPP_HAS_NO_STDIN) +endif() + +# LIBCXX_ENABLE_STDOUT configuration +if (NOT LIBCXX_ENABLE_STDOUT) + add_definitions(-D_LIBCPP_HAS_NO_STDOUT) +endif() + +# LIBCXX_ENABLE_THREADS configuration +if (NOT LIBCXX_ENABLE_THREADS) + add_definitions(-D_LIBCPP_HAS_NO_THREADS) + if (NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) + add_definitions(-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK) + endif() +# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON. +elseif(NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) + message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" + " when LIBCXX_ENABLE_THREADS is also set to OFF.") +endif() + +# LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS configuration +if (NOT LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS) + add_definitions(-D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) +endif() + +# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do +# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. +if (LIBCXX_BUILT_STANDALONE) + # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. + # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. + if (LLVM_USE_SANITIZER AND NOT MSVC) + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG + "-fno-omit-frame-pointer") + if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND + NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") + append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG + "-gline-tables-only") + endif() + if (LLVM_USE_SANITIZER STREQUAL "Address") + list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=address") + elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?") + list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=memory") + if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins") + list(APPEND LIBCXX_CXX_FLAGS "-fsanitize-memory-track-origins") + endif() + elseif (LLVM_USE_SANITIZER STREQUAL "Undefined") + list(APPEND LIBCXX_CXX_FLAGS + "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover") + elseif (LLVM_USE_SANITIZER STREQUAL "Thread") + list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=thread") + else() + message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}") + endif() + elseif(MSVC) + message(WARNING "LLVM_USE_SANITIZER is not supported with MSVC") + endif() +endif() + +append_if(LIBCXX_CXX_FLAGS LIBCXX_TARGET_TRIPLE + "-target ${LIBCXX_TARGET_TRIPLE}") + +append_if(LIBCXX_CXX_FLAGS LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}") +append_if(LIBCXX_CXX_FLAGS LIBCXX_GCC_TOOLCHAIN + "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}") + +if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) + message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") +endif() + +string(REPLACE ";" " " LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FLAGS}") + +#=============================================================================== +# Setup Source Code +#=============================================================================== + +include_directories(include) +add_subdirectory(include) + +# Add source code. This also contains all of the logic for deciding linker flags +# soname, etc... +add_subdirectory(lib) + +#=============================================================================== +# Setup Tests +#=============================================================================== + +add_subdirectory(test) diff --git a/CREDITS.TXT b/CREDITS.TXT index 7a28adae0965..1cf713a68842 100644 --- a/CREDITS.TXT +++ b/CREDITS.TXT @@ -12,6 +12,10 @@ N: Saleem Abdulrasool E: compnerd@compnerd.org D: Minor patches and Linux fixes. +N: Dan Albert +E: danalbert@google.com +D: Android support and test runner improvements. + N: Dimitry Andric E: dimitry@andric.com D: Visibility fixes, minor FreeBSD portability patches. @@ -84,6 +88,10 @@ N: Nico Rieck E: nico.rieck@gmail.com D: Windows fixes +N: Jon Roelofs +E: jonathan@codesourcery.com +D: Remote testing, Newlib port, baremetal/single-threaded support. + N: Jonathan Sauer D: Minor patches, mostly related to constexpr @@ -105,6 +113,9 @@ D: Minor fix N: Michael van der Westhuizen E: r1mikey at gmail dot com +N: Larisse Voufo +D: Minor patches. + N: Klaas de Vries E: klaas at klaasgaaf dot nl D: Minor bug fix. diff --git a/LICENSE.TXT b/LICENSE.TXT index 41ca5d19cc65..53352e42dd1f 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -14,7 +14,7 @@ Full text of the relevant licenses is included below. University of Illinois/NCSA Open Source License -Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT All rights reserved. diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..ab7b5b603a04 --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +## +# libc++ Makefile +## + +SRCDIRS = . +DESTDIR = $(DSTROOT) + +OBJROOT=. +SYMROOT=. +export TRIPLE=-apple- + +ifeq (,$(RC_INDIGO)) + INSTALL_PREFIX="" +else + INSTALL_PREFIX="$(SDKROOT)" +endif +INSTALL_DIR=$(DSTROOT)/$(INSTALL_PREFIX) + +.PHONY: help installsrc clean installheaders install + +help:: + @echo "Use make install DSTROOT=" + +installsrc:: $(SRCROOT) + + ditto $(SRCDIRS)/include $(SRCROOT)/include + ditto $(SRCDIRS)/lib $(SRCROOT)/lib + ditto $(SRCDIRS)/src $(SRCROOT)/src + ditto $(SRCDIRS)/Makefile $(SRCROOT)/Makefile + +clean:: + +# The installheaders target is used by clang's runtime/libcxx makefile. +installheaders:: + mkdir -p $(HEADER_DIR)/c++/v1/ext + (cd $(SRCDIRS)/include && \ + tar cf - --exclude=".*" --exclude=support \ + --exclude=CMakeLists.txt *) | \ + (cd $(HEADER_DIR)/c++/v1 && tar xf -) + chmod 755 $(HEADER_DIR)/c++/v1 + chmod 644 $(HEADER_DIR)/c++/v1/* + chmod 755 $(HEADER_DIR)/c++/v1/ext + chmod 644 $(HEADER_DIR)/c++/v1/ext/* + chmod 755 $(HEADER_DIR)/c++/v1/experimental + chmod 644 $(HEADER_DIR)/c++/v1/experimental/* + +install:: + + cd lib && ./buildit + ditto lib/libc++.1.dylib $(SYMROOT)/usr/lib/libc++.1.dylib + cd lib && dsymutil -o $(SYMROOT)/libc++.1.dylib.dSYM \ + $(SYMROOT)/usr/lib/libc++.1.dylib + mkdir -p $(INSTALL_DIR)/usr/lib + strip -S -o $(INSTALL_DIR)/usr/lib/libc++.1.dylib \ + $(SYMROOT)/usr/lib/libc++.1.dylib + cd $(INSTALL_DIR)/usr/lib && ln -s libc++.1.dylib libc++.dylib diff --git a/TODO.TXT b/TODO.TXT new file mode 100644 index 000000000000..513b86377244 --- /dev/null +++ b/TODO.TXT @@ -0,0 +1,49 @@ +This is meant to be a general place to list things that should be done "someday" + +ABI Related Tasks +================= +* Explicitly manage and verify symbols exported from the dylib. +* Explore using namespaces for managing symbol visibility. +* Introduce and document ABI versioning/evolution policy. + +CXX Runtime Library Tasks +========================= +* Cleanup #ifdef hell in sources files that supports the different ABI libraries. +* Fix that CMake always link to /usr/lib/libc++abi.dylib on OS X. +* Fix selection of ABI symbol list on OS X. +* Have CMake generate linker scripts for libc++.so that it properly links the + runtime library. +* Look into mirroring libsupc++'s typeinfo vtable layout when libsupc++/libstdc++ + is used as the runtime library. +* Audit libraries that CMake links into libc++. Are they all required? +* Investigate and document interoperability between libc++ and libstdc++ on + linux. Do this for every supported c++ runtime library. + +Atomic Related Tasks +==================== +* Support in C++03 (needed for internal use). +* Audit use of libatomic builtins in with GCC. +* future should use for synchronization. +* call_once should use for synchronization. +* Audit shared_ptr use of + +Test Suite Tasks +================ +* Get test suite passing in C++03. +* Move all libc++ specific tests from test/std into test/libcxx. +* Improve how LIT handles compiler warnings. +* Improve the quality and portability of the locale test data. + +Misc Tasks +========== +* Find all sequences of >2 underscores and eradicate them. +* run clang-tidy on libc++ +* Document the "conditionally-supported" bits of libc++ +* Look at basic_string's move assignment operator, re LWG 2063 and POCMA +* libc++ is missing try_emplace +* Put a static_assert in std::allocator to deny const/volatile types (LWG 2447) +* Investigate the effect of using __decltype instead of __typeof__ to provide + decltype in C++03. What code could be broken by this change? +* Convert failure tests to use Clang Verify. +* Document support (or lack of) for C++11 libraries in C++03. +* Document supported compilers. diff --git a/cmake/Modules/CodeCoverage.cmake b/cmake/Modules/CodeCoverage.cmake new file mode 100644 index 000000000000..addd10abdfe1 --- /dev/null +++ b/cmake/Modules/CodeCoverage.cmake @@ -0,0 +1,36 @@ +find_program(CODE_COVERAGE_LCOV lcov) +if (NOT CODE_COVERAGE_LCOV) + message(FATAL_ERROR "Cannot find lcov...") +endif() + +find_program(CODE_COVERAGE_GENHTML genhtml) +if (NOT CODE_COVERAGE_GENHTML) + message(FATAL_ERROR "Cannot find genhtml...") +endif() + +set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage") + +function(setup_lcov_test_target_coverage target_name output_dir capture_dirs source_dirs) + file(MAKE_DIRECTORY ${output_dir}) + + set(CAPTURE_DIRS "") + foreach(cdir ${capture_dirs}) + list(APPEND CAPTURE_DIRS "-d;${cdir}") + endforeach() + + set(EXTRACT_DIRS "") + foreach(sdir ${source_dirs}) + list(APPEND EXTRACT_DIRS "'${sdir}/*'") + endforeach() + + message(STATUS "Capture Directories: ${CAPTURE_DIRS}") + message(STATUS "Extract Directories: ${EXTRACT_DIRS}") + + add_custom_target(generate-lib${target_name}-coverage + COMMAND ${CODE_COVERAGE_LCOV} --capture ${CAPTURE_DIRS} -o test_coverage.info + COMMAND ${CODE_COVERAGE_LCOV} --extract test_coverage.info ${EXTRACT_DIRS} -o test_coverage.info + COMMAND ${CODE_COVERAGE_GENHTML} --demangle-cpp test_coverage.info -o test_coverage + COMMAND ${CMAKE_COMMAND} -E remove test_coverage.info + WORKING_DIRECTORY ${output_dir} + COMMENT "Generating coverage results") +endfunction() diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake new file mode 100644 index 000000000000..73723e3559b1 --- /dev/null +++ b/cmake/Modules/HandleLibCXXABI.cmake @@ -0,0 +1,103 @@ + +#=============================================================================== +# Add an ABI library if appropriate +#=============================================================================== + +# +# _setup_abi: Set up the build to use an ABI library +# +# Parameters: +# abidefines: A list of defines needed to compile libc++ with the ABI library +# abilib : The ABI library to link against. +# abifiles : A list of files (which may be relative paths) to copy into the +# libc++ build tree for the build. These files will also be +# installed alongside the libc++ headers. +# abidirs : A list of relative paths to create under an include directory +# in the libc++ build directory. +# +macro(setup_abi_lib abidefines abilib abifiles abidirs) + list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines}) + set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}" + CACHE PATH + "Paths to C++ ABI header directories separated by ';'." FORCE + ) + + set(LIBCXX_CXX_ABI_LIBRARY ${abilib}) + + set(LIBCXX_ABILIB_FILES ${abifiles}) + + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include") + foreach(_d ${abidirs}) + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/${_d}") + endforeach() + + foreach(fpath ${LIBCXX_ABILIB_FILES}) + set(found FALSE) + foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS}) + if (EXISTS "${incpath}/${fpath}") + set(found TRUE) + get_filename_component(dstdir ${fpath} PATH) + get_filename_component(ifile ${fpath} NAME) + file(COPY "${incpath}/${fpath}" + DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}" + ) + install(FILES "${CMAKE_BINARY_DIR}/include/${fpath}" + DESTINATION include/c++/v1/${dstdir} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) + list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}") + endif() + endforeach() + if (NOT found) + message(WARNING "Failed to find ${fpath}") + endif() + endforeach() + + add_custom_target(LIBCXX_CXX_ABI_DEPS DEPENDS ${abilib_headers}) + include_directories("${CMAKE_BINARY_DIR}/include") + +endmacro() + +if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR + "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++") + set(_LIBSUPCXX_INCLUDE_FILES + cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h + bits/cxxabi_tweaks.h bits/cxxabi_forced.h + ) + if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++") + set(_LIBSUPCXX_DEFINES "-DLIBSTDCXX") + set(_LIBSUPCXX_LIBNAME stdc++) + else() + set(_LIBSUPCXX_DEFINES "") + set(_LIBSUPCXX_LIBNAME supc++) + endif() + setup_abi_lib( + "-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}" + "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits" + ) +elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") + if (LIBCXX_CXX_ABI_INTREE) + # Link against just-built "cxxabi" target. + if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) + set(CXXABI_LIBNAME cxxabi_static) + else() + set(CXXABI_LIBNAME cxxabi_shared) + endif() + set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE) + else() + # Assume c++abi is installed in the system, rely on -lc++abi link flag. + set(CXXABI_LIBNAME "c++abi") + endif() + setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI" + ${CXXABI_LIBNAME} "cxxabi.h;__cxxabi_config.h" "" + ) +elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") + setup_abi_lib("-DLIBCXXRT" + "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" "" + ) +elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none") + message(FATAL_ERROR + "Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are " + "supported for c++ abi." + ) +endif () diff --git a/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake b/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake new file mode 100644 index 000000000000..a0669365bf99 --- /dev/null +++ b/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake @@ -0,0 +1,18 @@ +# MACRO_ENSURE_OUT_OF_SOURCE_BUILD() + +macro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage ) + +string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource ) +if( _insource ) + message( SEND_ERROR "${_errorMessage}" ) + message( FATAL_ERROR + "In-source builds are not allowed. + CMake would overwrite the makefiles distributed with Compiler-RT. + Please create a directory and run cmake from there, passing the path + to this source directory as the last argument. + This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. + Please delete them." + ) +endif( _insource ) + +endmacro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD ) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake new file mode 100644 index 000000000000..428d737c749d --- /dev/null +++ b/cmake/config-ix.cmake @@ -0,0 +1,35 @@ +include(CheckLibraryExists) +include(CheckCXXCompilerFlag) + +# Check compiler flags +check_cxx_compiler_flag(-std=c++11 LIBCXX_HAS_STDCXX11_FLAG) +check_cxx_compiler_flag(-std=c++1y LIBCXX_HAS_STDCXX1Y_FLAG) +check_cxx_compiler_flag(-fPIC LIBCXX_HAS_FPIC_FLAG) +check_cxx_compiler_flag(-fno-omit-frame-pointer LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG) +check_cxx_compiler_flag(-nodefaultlibs LIBCXX_HAS_NODEFAULTLIBS_FLAG) +check_cxx_compiler_flag(-nostdinc++ LIBCXX_HAS_NOSTDINCXX_FLAG) +check_cxx_compiler_flag(-Wall LIBCXX_HAS_WALL_FLAG) +check_cxx_compiler_flag(-W LIBCXX_HAS_W_FLAG) +check_cxx_compiler_flag(-Wno-unused-parameter LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG) +check_cxx_compiler_flag(-Wwrite-strings LIBCXX_HAS_WWRITE_STRINGS_FLAG) +check_cxx_compiler_flag(-Wno-long-long LIBCXX_HAS_WNO_LONG_LONG_FLAG) +check_cxx_compiler_flag(-pedantic LIBCXX_HAS_PEDANTIC_FLAG) +check_cxx_compiler_flag(-Werror LIBCXX_HAS_WERROR_FLAG) +check_cxx_compiler_flag(-Wno-error LIBCXX_HAS_WNO_ERROR_FLAG) +check_cxx_compiler_flag(-fno-exceptions LIBCXX_HAS_FNO_EXCEPTIONS_FLAG) +check_cxx_compiler_flag(-fno-rtti LIBCXX_HAS_FNO_RTTI_FLAG) +check_cxx_compiler_flag(-gline-tables-only LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG) +check_cxx_compiler_flag(/WX LIBCXX_HAS_WX_FLAG) +check_cxx_compiler_flag(/WX- LIBCXX_HAS_NO_WX_FLAG) +check_cxx_compiler_flag(/EHsc LIBCXX_HAS_EHSC_FLAG) +check_cxx_compiler_flag(/EHs- LIBCXX_HAS_NO_EHS_FLAG) +check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG) +check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG) + +# Check libraries +check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB) +check_library_exists(c printf "" LIBCXX_HAS_C_LIB) +check_library_exists(m ccos "" LIBCXX_HAS_M_LIB) +check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB) +check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB) + diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 000000000000..95206bfeeaff --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,24 @@ +if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS) + set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE) +endif() +set(LIBCXX_HEADER_PATTERN + PATTERN "*" + PATTERN "CMakeLists.txt" EXCLUDE + PATTERN ".svn" EXCLUDE + ${LIBCXX_SUPPORT_HEADER_PATTERN} + ) + +file(COPY . + DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1" + FILES_MATCHING + ${LIBCXX_HEADER_PATTERN} + ) + +if (LIBCXX_INSTALL_HEADERS) + install(DIRECTORY . + DESTINATION include/c++/v1 + FILES_MATCHING + ${LIBCXX_HEADER_PATTERN} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) +endif() diff --git a/include/__bit_reference b/include/__bit_reference index 4938f44608f1..5659ed068246 100644 --- a/include/__bit_reference +++ b/include/__bit_reference @@ -906,7 +906,6 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, { typedef __bit_iterator<_Cp, false> _I1; typedef typename _I1::difference_type difference_type; - typedef typename _I1::__storage_type __storage_type; difference_type __d1 = __middle - __first; difference_type __d2 = __last - __middle; _I1 __r = __first + __d2; diff --git a/include/__config b/include/__config index 8fd80bcb7136..888f3c098cf4 100644 --- a/include/__config +++ b/include/__config @@ -17,14 +17,11 @@ #ifdef __GNUC__ #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) +#else +#define _GNUC_VER 0 #endif -#if !_WIN32 -#include -#include // for ELAST on FreeBSD -#endif - -#define _LIBCPP_VERSION 1101 +#define _LIBCPP_VERSION 3700 #define _LIBCPP_ABI_VERSION 1 @@ -33,6 +30,23 @@ #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) + +#ifndef __has_attribute +#define __has_attribute(__x) 0 +#endif +#ifndef __has_builtin +#define __has_builtin(__x) 0 +#endif +#ifndef __has_feature +#define __has_feature(__x) 0 +#endif +// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by +// the compiler and '1' otherwise. +#ifndef __is_identifier +#define __is_identifier(__x) 1 +#endif + + #ifdef __LITTLE_ENDIAN__ #if __LITTLE_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 1 @@ -76,10 +90,8 @@ #ifdef _WIN32 # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 -// Compiler intrinsics (GCC or MSVC) -# if defined(__clang__) \ - || (defined(_MSC_VER) && _MSC_VER >= 1400) \ - || (defined(__GNUC__) && _GNUC_VER > 403) +// Compiler intrinsics (MSVC) +#if defined(_MSC_VER) && _MSC_VER >= 1400 # define _LIBCPP_HAS_IS_BASE_OF # endif # if defined(_MSC_VER) && !defined(__clang__) @@ -94,12 +106,6 @@ # endif #endif // _WIN32 -#ifdef __linux__ -# if defined(__GNUC__) && _GNUC_VER >= 403 -# define _LIBCPP_HAS_IS_BASE_OF -# endif -#endif - #ifdef __sun__ # include # ifdef _LITTLE_ENDIAN @@ -111,12 +117,22 @@ # endif #endif // __sun__ -#if defined(__native_client__) +#if defined(__CloudABI__) + // Certain architectures provide arc4random(). Prefer using + // arc4random() over /dev/{u,}random to make it possible to obtain + // random data even when using sandboxing mechanisms such as chroots, + // Capsicum, etc. +# define _LIBCPP_USING_ARC4_RANDOM +#elif defined(__native_client__) // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, // including accesses to the special files under /dev. C++11's // std::random_device is instead exposed through a NaCl syscall. # define _LIBCPP_USING_NACL_RANDOM -#endif // defined(__native_client__) +#elif defined(_WIN32) +# define _LIBCPP_USING_WIN32_RANDOM +#else +# define _LIBCPP_USING_DEV_RANDOM +#endif #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) # include @@ -173,10 +189,6 @@ #endif // _WIN32 -#ifndef __has_attribute -#define __has_attribute(__x) 0 -#endif - #ifndef _LIBCPP_HIDDEN #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) #endif @@ -259,6 +271,8 @@ typedef __char32_t char32_t; # define _LIBCPP_NORETURN __attribute__ ((noreturn)) #endif +#define _LIBCPP_UNUSED __attribute__((__unused__)) + #if !(__has_feature(cxx_defaulted_functions)) #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // !(__has_feature(cxx_defaulted_functions)) @@ -307,6 +321,10 @@ typedef __char32_t char32_t; # define _LIBCPP_HAS_IS_BASE_OF #endif +#if __has_feature(is_final) +# define _LIBCPP_HAS_IS_FINAL +#endif + // Objective-C++ features (opt-in) #if __has_feature(objc_arc) #define _LIBCPP_HAS_OBJC_ARC @@ -325,6 +343,10 @@ typedef __char32_t char32_t; #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #endif +#if !(__has_feature(cxx_variable_templates)) +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#endif + #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L #if defined(__FreeBSD__) #define _LIBCPP_HAS_QUICK_EXIT @@ -381,9 +403,16 @@ namespace std { #define _LIBCPP_NORETURN __attribute__((noreturn)) +#define _LIBCPP_UNUSED __attribute__((__unused__)) + #if _GNUC_VER >= 407 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T) +#define _LIBCPP_HAS_IS_FINAL +#endif + +#if defined(__GNUC__) && _GNUC_VER >= 403 +# define _LIBCPP_HAS_IS_BASE_OF #endif #if !__EXCEPTIONS @@ -402,6 +431,8 @@ namespace std { // No version of GCC supports relaxed constexpr rules #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR +// GCC 5 will support variable templates +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #define _NOEXCEPT throw() #define _NOEXCEPT_(x) @@ -473,11 +504,13 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) +#define _LIBCPP_UNUSED #define _ALIGNAS(x) __declspec(align(x)) #define _LIBCPP_HAS_NO_VARIADICS @@ -501,6 +534,7 @@ namespace std { #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _ATTRIBUTE(x) __attribute__((x)) #define _LIBCPP_NORETURN __attribute__((noreturn)) +#define _LIBCPP_UNUSED #define _NOEXCEPT throw() #define _NOEXCEPT_(x) @@ -513,6 +547,8 @@ namespace std { #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_IS_BASE_OF +#define _LIBCPP_HAS_IS_FINAL +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #if defined(_AIX) #define __MULTILOCALE_API @@ -552,7 +588,12 @@ template struct __static_assert_check {}; #endif // _LIBCPP_HAS_NO_STATIC_ASSERT #ifdef _LIBCPP_HAS_NO_DECLTYPE -#define decltype(x) __typeof__(x) +// GCC 4.6 provides __decltype in all standard modes. +#if !__is_identifier(__decltype) || _GNUC_VER >= 406 +# define decltype(__x) __decltype(__x) +#else +# define decltype(__x) __typeof__(__x) +#endif #endif #ifdef _LIBCPP_HAS_NO_CONSTEXPR @@ -573,14 +614,6 @@ template struct __static_assert_check {}; #define _NOALIAS #endif -#ifndef __has_feature -#define __has_feature(__x) 0 -#endif - -#ifndef __has_builtin -#define __has_builtin(__x) 0 -#endif - #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) # define _LIBCPP_EXPLICIT explicit #else @@ -627,10 +660,16 @@ template struct __static_assert_check {}; #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) #endif -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \ + defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif +#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \ + !defined(__CloudABI__) +#define _LIBCPP_HAS_CATOPEN 1 +#endif + #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif @@ -643,21 +682,6 @@ template struct __static_assert_check {}; #define _LIBCPP_WCTYPE_IS_MASK #endif -#if defined(ELAST) -#define _LIBCPP_ELAST ELAST -#elif defined(__linux__) -#define _LIBCPP_ELAST 4095 -#elif defined(_NEWLIB_VERSION) -#define _LIBCPP_ELAST __ELASTERROR -#elif defined(__APPLE__) -// Not _LIBCPP_ELAST needed on Apple -#elif defined(__sun__) -#define _LIBCPP_ELAST ESTALE -#else -// Warn here so that the person doing the libcxx port has an easier time: -#warning This platform's ELAST hasn't been ported yet -#endif - #ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR # define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1 #endif @@ -718,4 +742,29 @@ extern "C" void __sanitizer_annotate_contiguous_container( _LIBCPP_HAS_NO_THREADS is defined. #endif +// Systems that use capability-based security (FreeBSD with Capsicum, +// Nuxi CloudABI) may only provide local filesystem access (using *at()). +// Functions like open(), rename(), unlink() and stat() should not be +// used, as they attempt to access the global filesystem namespace. +#ifdef __CloudABI__ +#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE +#endif + +// CloudABI is intended for running networked services. Processes do not +// have standard input and output channels. +#ifdef __CloudABI__ +#define _LIBCPP_HAS_NO_STDIN +#define _LIBCPP_HAS_NO_STDOUT +#endif + +#if defined(__ANDROID__) || defined(__CloudABI__) +#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE +#endif + +// Thread-unsafe functions such as strtok(), mbtowc() and localtime() +// are not available. +#ifdef __CloudABI__ +#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS +#endif + #endif // _LIBCPP_CONFIG diff --git a/include/__debug b/include/__debug index c1512246bfcf..a21f9a89884b 100644 --- a/include/__debug +++ b/include/__debug @@ -22,7 +22,7 @@ # include # include # ifndef _LIBCPP_ASSERT -# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort())) +# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::fprintf(stderr, "%s\n", m), _VSTD::abort())) # endif #endif diff --git a/include/__functional_03 b/include/__functional_03 index d8a9f05fa124..13c38d8548d9 100644 --- a/include/__functional_03 +++ b/include/__functional_03 @@ -333,7 +333,8 @@ template __base<_Rp()>* __func<_Fp, _Alloc, _Rp()>::__clone() const { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -359,7 +360,8 @@ template void __func<_Fp, _Alloc, _Rp()>::destroy_deallocate() { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(this, 1); @@ -369,7 +371,8 @@ template _Rp __func<_Fp, _Alloc, _Rp()>::operator()() { - return __invoke(__f_.first()); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first()); } #ifndef _LIBCPP_NO_RTTI @@ -416,7 +419,8 @@ template __base<_Rp(_A0)>* __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -442,7 +446,8 @@ template void __func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate() { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(this, 1); @@ -452,7 +457,8 @@ template _Rp __func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0) { - return __invoke(__f_.first(), __a0); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0); } #ifndef _LIBCPP_NO_RTTI @@ -499,7 +505,8 @@ template __base<_Rp(_A0, _A1)>* __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -525,7 +532,8 @@ template void __func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate() { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(this, 1); @@ -535,7 +543,8 @@ template _Rp __func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) { - return __invoke(__f_.first(), __a0, __a1); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0, __a1); } #ifndef _LIBCPP_NO_RTTI @@ -582,7 +591,8 @@ template __base<_Rp(_A0, _A1, _A2)>* __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -608,7 +618,8 @@ template void __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate() { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(this, 1); @@ -618,7 +629,8 @@ template _Rp __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) { - return __invoke(__f_.first(), __a0, __a1, __a2); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0, __a1, __a2); } #ifndef _LIBCPP_NO_RTTI @@ -790,17 +802,11 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); + ::new (__f_) _FF(__f, __a0); } else { - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -827,6 +833,7 @@ function<_Rp()>::operator=(nullptr_t) else if (__f_) __f_->destroy_deallocate(); __f_ = 0; + return *this; } template @@ -1092,17 +1099,11 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); + ::new (__f_) _FF(__f, __a0); } else { - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -1129,6 +1130,7 @@ function<_Rp(_A0)>::operator=(nullptr_t) else if (__f_) __f_->destroy_deallocate(); __f_ = 0; + return *this; } template @@ -1394,17 +1396,11 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); + ::new (__f_) _FF(__f, __a0); } else { - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -1431,6 +1427,7 @@ function<_Rp(_A0, _A1)>::operator=(nullptr_t) else if (__f_) __f_->destroy_deallocate(); __f_ = 0; + return *this; } template @@ -1696,17 +1693,11 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); + ::new (__f_) _FF(__f, __a0); } else { - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -1733,6 +1724,7 @@ function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t) else if (__f_) __f_->destroy_deallocate(); __f_ = 0; + return *this; } template @@ -2099,14 +2091,16 @@ public: result_type operator()(_Args&& ...__args) { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } template result_type operator()(_Args&& ...__args) const { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } }; diff --git a/include/__functional_base b/include/__functional_base index 6766793d7c8a..09424bc025a9 100644 --- a/include/__functional_base +++ b/include/__functional_base @@ -70,7 +70,9 @@ struct _LIBCPP_TYPE_VIS_ONLY less template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -419,6 +421,26 @@ struct __invoke_return typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; }; +template +struct __invoke_void_return_wrapper +{ + template + static _Ret __call(_Args&&... __args) + { + return __invoke(_VSTD::forward<_Args>(__args)...); + } +}; + +template <> +struct __invoke_void_return_wrapper +{ + template + static void __call(_Args&&... __args) + { + __invoke(_VSTD::forward<_Args>(__args)...); + } +}; + template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> diff --git a/include/__functional_base_03 b/include/__functional_base_03 index 22c06add90f4..655027786665 100644 --- a/include/__functional_base_03 +++ b/include/__functional_base_03 @@ -995,6 +995,63 @@ struct __invoke_return2 _VSTD::declval<_A2>())) type; }; +template +struct __invoke_void_return_wrapper +{ + template + static _Ret __call(_Fn __f) + { + return __invoke(__f); + } + + template + static _Ret __call(_Fn __f, _A0& __a0) + { + return __invoke(__f, __a0); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) + { + return __invoke(__f, __a0, __a1); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) + { + return __invoke(__f, __a0, __a1, __a2); + } +}; + + +template <> +struct __invoke_void_return_wrapper +{ + template + static void __call(_Fn __f) + { + __invoke(__f); + } + + template + static void __call(_Fn __f, _A0& __a0) + { + __invoke(__f, __a0); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1) + { + __invoke(__f, __a0, __a1); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) + { + __invoke(__f, __a0, __a1, __a2); + } +}; + template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> diff --git a/include/__hash_table b/include/__hash_table index 7c954b68011d..f3a20309df71 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -19,6 +19,7 @@ #include #include <__undef_min_max> +#include <__undef___deallocate> #include <__debug> @@ -61,7 +62,7 @@ struct __hash_node inline _LIBCPP_INLINE_VISIBILITY bool -__is_power2(size_t __bc) +__is_hash_power2(size_t __bc) { return __bc > 2 && !(__bc & (__bc - 1)); } @@ -75,7 +76,7 @@ __constrain_hash(size_t __h, size_t __bc) inline _LIBCPP_INLINE_VISIBILITY size_t -__next_pow2(size_t __n) +__next_hash_pow2(size_t __n) { return size_t(1) << (std::numeric_limits::digits - __clz(__n-1)); } @@ -84,8 +85,6 @@ template class __hash_table template class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; template class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; template class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; -template - class _LIBCPP_TYPE_VIS_ONLY unordered_map; template class _LIBCPP_TYPE_VIS_ONLY __hash_iterator @@ -776,13 +775,7 @@ public: public: // Create __node typedef __hash_node __node; - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__node> -#else - rebind_alloc<__node>::other -#endif - __node_allocator; + typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator; typedef allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; typedef typename __node_traits::pointer __node_const_pointer; @@ -797,13 +790,7 @@ public: private: - typedef typename __node_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__node_pointer> -#else - rebind_alloc<__node_pointer>::other -#endif - __pointer_allocator; + typedef typename __rebind_alloc_helper<__node_traits, __node_pointer>::type __pointer_allocator; typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter; typedef unique_ptr<__node_pointer[], __bucket_list_deleter> __bucket_list; typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits; @@ -909,11 +896,21 @@ public: iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + template + _LIBCPP_INLINE_VISIBILITY + pair __insert_unique_value(_ValueTp&& __x); +#else + _LIBCPP_INLINE_VISIBILITY + pair __insert_unique_value(const value_type& __x); +#endif + pair __insert_unique(const value_type& __x); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + pair __insert_unique(value_type&& __x); template - pair __insert_unique(_Pp&& __x); + pair __insert_unique(_Pp&& __x); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -988,12 +985,14 @@ public: void swap(__hash_table& __u) _NOEXCEPT_( - (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || - __is_nothrow_swappable<__pointer_allocator>::value) && - (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); + __is_nothrow_swappable::value && __is_nothrow_swappable::value +#if _LIBCPP_STD_VER <= 11 + && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value + || __is_nothrow_swappable<__pointer_allocator>::value) + && (!__node_traits::propagate_on_container_swap::value + || __is_nothrow_swappable<__node_allocator>::value) +#endif + ); _LIBCPP_INLINE_VISIBILITY size_type max_bucket_count() const _NOEXCEPT @@ -1121,38 +1120,6 @@ private: _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {} - template - _LIBCPP_INLINE_VISIBILITY - static - void - __swap_alloc(_Ap& __x, _Ap& __y) - _NOEXCEPT_( - !allocator_traits<_Ap>::propagate_on_container_swap::value || - __is_nothrow_swappable<_Ap>::value) - { - __swap_alloc(__x, __y, - integral_constant::propagate_on_container_swap::value - >()); - } - - template - _LIBCPP_INLINE_VISIBILITY - static - void - __swap_alloc(_Ap& __x, _Ap& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable<_Ap>::value) - { - using _VSTD::swap; - swap(__x, __y); - } - - template - _LIBCPP_INLINE_VISIBILITY - static - void - __swap_alloc(_Ap&, _Ap&, false_type) _NOEXCEPT {} - void __deallocate(__node_pointer __np) _NOEXCEPT; __node_pointer __detach() _NOEXCEPT; @@ -1615,7 +1582,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __ { if (size()+1 > __bc * max_load_factor() || __bc == 0) { - rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), + rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); __chash = __constrain_hash(__nd->__hash_, __bc); @@ -1658,7 +1625,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c size_type __bc = bucket_count(); if (size()+1 > __bc * max_load_factor() || __bc == 0) { - rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), + rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } @@ -1728,7 +1695,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( size_type __bc = bucket_count(); if (size()+1 > __bc * max_load_factor() || __bc == 0) { - rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), + rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } @@ -1752,6 +1719,26 @@ template pair::iterator, bool> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x) { + return __insert_unique_value(__x); +} + + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +template +template +_LIBCPP_INLINE_VISIBILITY +pair::iterator, bool> +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(_ValueTp&& __x) +#else +template +_LIBCPP_INLINE_VISIBILITY +pair::iterator, bool> +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(const value_type& __x) +#endif +{ +#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) + typedef const value_type& _ValueTp; +#endif size_t __hash = hash_function()(__x); size_type __bc = bucket_count(); bool __inserted = false; @@ -1773,10 +1760,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x) } } { - __node_holder __h = __construct_node(__x, __hash); + __node_holder __h = __construct_node(_VSTD::forward<_ValueTp>(__x), __hash); if (size()+1 > __bc * max_load_factor() || __bc == 0) { - rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), + rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); __chash = __constrain_hash(__hash, __bc); @@ -1856,6 +1843,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( #endif // _LIBCPP_HAS_NO_VARIADICS +template +pair::iterator, bool> +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(value_type&& __x) +{ + return __insert_unique_value(_VSTD::move(__x)); +} + template template pair::iterator, bool> @@ -1946,8 +1940,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n) __n = _VSTD::max ( __n, - __is_power2(__bc) ? __next_pow2(size_t(ceil(float(size()) / max_load_factor()))) : - __next_prime(size_t(ceil(float(size()) / max_load_factor()))) + __is_hash_power2(__bc) ? __next_hash_pow2(size_t(ceil(float(size()) / max_load_factor()))) : + __next_prime(size_t(ceil(float(size()) / max_load_factor()))) ); if (__n < __bc) __rehash(__n); @@ -2358,12 +2352,14 @@ template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) _NOEXCEPT_( - (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || - __is_nothrow_swappable<__pointer_allocator>::value) && - (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value) + __is_nothrow_swappable::value && __is_nothrow_swappable::value +#if _LIBCPP_STD_VER <= 11 + && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value + || __is_nothrow_swappable<__pointer_allocator>::value) + && (!__node_traits::propagate_on_container_swap::value + || __is_nothrow_swappable<__node_allocator>::value) +#endif + ) { { __node_pointer_pointer __npp = __bucket_list_.release(); @@ -2371,9 +2367,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) __u.__bucket_list_.reset(__npp); } _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size()); - __swap_alloc(__bucket_list_.get_deleter().__alloc(), + __swap_allocator(__bucket_list_.get_deleter().__alloc(), __u.__bucket_list_.get_deleter().__alloc()); - __swap_alloc(__node_alloc(), __u.__node_alloc()); + __swap_allocator(__node_alloc(), __u.__node_alloc()); _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_); __p2_.swap(__u.__p2_); __p3_.swap(__u.__p3_); diff --git a/include/__locale b/include/__locale index 0097fc28d79e..19895582cac8 100644 --- a/include/__locale +++ b/include/__locale @@ -30,6 +30,7 @@ # include # endif #elif defined(__sun__) +# include # include #elif defined(_NEWLIB_VERSION) # include @@ -352,16 +353,15 @@ public: static const mask punct = _PUNCT; static const mask xdigit = _HEX; static const mask blank = _BLANK; -#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__ANDROID__) -#ifdef __APPLE__ +# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT +#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) +# ifdef __APPLE__ typedef __uint32_t mask; -#elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) typedef unsigned long mask; -#elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) +# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) typedef unsigned short mask; -#elif defined(__ANDROID__) - typedef unsigned char mask; -#endif +# endif static const mask space = _CTYPE_S; static const mask print = _CTYPE_R; static const mask cntrl = _CTYPE_C; @@ -370,11 +370,7 @@ public: static const mask alpha = _CTYPE_A; static const mask digit = _CTYPE_D; static const mask punct = _CTYPE_P; -# if defined(__ANDROID__) - static const mask xdigit = _CTYPE_X | _CTYPE_D; -# else static const mask xdigit = _CTYPE_X; -# endif # if defined(__NetBSD__) static const mask blank = _CTYPE_BL; @@ -393,7 +389,23 @@ public: static const mask punct = _ISPUNCT; static const mask xdigit = _ISXDIGIT; static const mask blank = _ISBLANK; -#else // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || __EMSCRIPTEN__ || __sun__ +#elif defined(_NEWLIB_VERSION) + // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. + typedef char mask; + static const mask space = _S; + static const mask print = _P | _U | _L | _N | _B; + static const mask cntrl = _C; + static const mask upper = _U; + static const mask lower = _L; + static const mask alpha = _U | _L; + static const mask digit = _N; + static const mask punct = _P; + static const mask xdigit = _X | _N; + static const mask blank = _B; +# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT +# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA +# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT +#else typedef unsigned long mask; static const mask space = 1<<0; static const mask print = 1<<1; @@ -405,7 +417,7 @@ public: static const mask punct = 1<<7; static const mask xdigit = 1<<8; static const mask blank = 1<<9; -#endif // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ +#endif static const mask alnum = alpha | digit; static const mask graph = alnum | punct; @@ -1420,7 +1432,7 @@ protected: // template class numpunct_byname -template class _LIBCPP_TYPE_VIS_ONLY numpunct_byname; +template class _LIBCPP_TYPE_VIS_ONLY numpunct_byname; template <> class _LIBCPP_TYPE_VIS numpunct_byname diff --git a/include/__refstring b/include/__refstring index 6866bf1b9736..61ccc75122a5 100644 --- a/include/__refstring +++ b/include/__refstring @@ -13,7 +13,7 @@ #include <__config> #include #include -#if __APPLE__ +#ifdef __APPLE__ #include #include #endif @@ -49,7 +49,7 @@ private: return data + sizeof(*rep); } -#if __APPLE__ +#ifdef __APPLE__ static const char* compute_gcc_empty_string_storage() _NOEXCEPT diff --git a/include/__split_buffer b/include/__split_buffer index 1d529cbe27d2..727b1b6b5674 100644 --- a/include/__split_buffer +++ b/include/__split_buffer @@ -156,25 +156,6 @@ private: _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| - __is_nothrow_swappable<__alloc_rr>::value) - {__swap_alloc(__x, __y, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable<__alloc_rr>::value) - { - using _VSTD::swap; - swap(__x, __y); - } - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__alloc_rr&, __alloc_rr&, false_type) _NOEXCEPT - {} }; template @@ -431,7 +412,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) _VSTD::swap(__begin_, __x.__begin_); _VSTD::swap(__end_, __x.__end_); _VSTD::swap(__end_cap(), __x.__end_cap()); - __swap_alloc(__alloc(), __x.__alloc()); + __swap_allocator(__alloc(), __x.__alloc()); } template diff --git a/include/__sso_allocator b/include/__sso_allocator index 645f2ba17459..ca3b937c0138 100644 --- a/include/__sso_allocator +++ b/include/__sso_allocator @@ -15,6 +15,8 @@ #include #include +#include <__undef___deallocate> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif diff --git a/include/__tree b/include/__tree index 8e5447a2ffb5..574e74baf26b 100644 --- a/include/__tree +++ b/include/__tree @@ -28,14 +28,6 @@ template class _LIBCPP_TYPE_VIS_ONLY __tree_iterator; template class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; -template - class _LIBCPP_TYPE_VIS_ONLY map; -template - class _LIBCPP_TYPE_VIS_ONLY multimap; -template - class _LIBCPP_TYPE_VIS_ONLY set; -template - class _LIBCPP_TYPE_VIS_ONLY multiset; /* @@ -522,9 +514,9 @@ public: bool __value_constructed; _LIBCPP_INLINE_VISIBILITY - explicit __tree_node_destructor(allocator_type& __na) _NOEXCEPT + explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT : __na_(__na), - __value_constructed(false) + __value_constructed(__val) {} _LIBCPP_INLINE_VISIBILITY @@ -622,8 +614,6 @@ class _LIBCPP_TYPE_VIS_ONLY __tree_iterator { typedef _NodePtr __node_pointer; typedef typename pointer_traits<__node_pointer>::element_type __node; - typedef typename __node::base __node_base; - typedef typename __node_base::pointer __node_base_pointer; __node_pointer __ptr_; @@ -652,17 +642,21 @@ public: {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY - __tree_iterator& operator++() - {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_))); - return *this;} + __tree_iterator& operator++() { + __ptr_ = static_cast<__node_pointer>( + __tree_next(static_cast(__ptr_))); + return *this; + } _LIBCPP_INLINE_VISIBILITY __tree_iterator operator++(int) {__tree_iterator __t(*this); ++(*this); return __t;} _LIBCPP_INLINE_VISIBILITY - __tree_iterator& operator--() - {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_))); - return *this;} + __tree_iterator& operator--() { + __ptr_ = static_cast<__node_pointer>( + __tree_prev(static_cast(__ptr_))); + return *this; + } _LIBCPP_INLINE_VISIBILITY __tree_iterator operator--(int) {__tree_iterator __t(*this); --(*this); return __t;} @@ -691,14 +685,6 @@ class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator { typedef _ConstNodePtr __node_pointer; typedef typename pointer_traits<__node_pointer>::element_type __node; - typedef typename __node::base __node_base; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__node_base> -#else - rebind<__node_base>::other -#endif - __node_base_pointer; __node_pointer __ptr_; @@ -743,17 +729,39 @@ public: {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator& operator++() - {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_))); - return *this;} + __tree_const_iterator& operator++() { + typedef typename pointer_traits<__node_pointer>::template +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + rebind +#else + rebind::other +#endif + __node_base_pointer; + + __ptr_ = static_cast<__node_pointer>( + __tree_next(static_cast<__node_base_pointer>(__ptr_))); + return *this; + } + _LIBCPP_INLINE_VISIBILITY __tree_const_iterator operator++(int) {__tree_const_iterator __t(*this); ++(*this); return __t;} _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator& operator--() - {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_))); - return *this;} + __tree_const_iterator& operator--() { + typedef typename pointer_traits<__node_pointer>::template +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + rebind +#else + rebind::other +#endif + __node_base_pointer; + + __ptr_ = static_cast<__node_pointer>( + __tree_prev(static_cast<__node_base_pointer>(__ptr_))); + return *this; + } + _LIBCPP_INLINE_VISIBILITY __tree_const_iterator operator--(int) {__tree_const_iterator __t(*this); --(*this); return __t;} @@ -794,13 +802,7 @@ public: typedef __tree_node __node; typedef __tree_node_base<__void_pointer> __node_base; - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__node> -#else - rebind_alloc<__node>::other -#endif - __node_allocator; + typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator; typedef allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; typedef typename __node_traits::pointer __node_const_pointer; @@ -924,9 +926,12 @@ public: void swap(__tree& __t) _NOEXCEPT_( - __is_nothrow_swappable::value && - (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value)); + __is_nothrow_swappable::value +#if _LIBCPP_STD_VER <= 11 + && (!__node_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<__node_allocator>::value) +#endif + ); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1094,25 +1099,6 @@ private: _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__tree& __t, false_type) _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y) - _NOEXCEPT_( - !__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - {__swap_alloc(__x, __y, integral_constant());} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value) - { - using _VSTD::swap; - swap(__x, __y); - } - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type) - _NOEXCEPT - {} - __node_pointer __detach(); static __node_pointer __detach(__node_pointer); @@ -1450,15 +1436,18 @@ __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT template void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) - _NOEXCEPT_( - __is_nothrow_swappable::value && - (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value)) + _NOEXCEPT_( + __is_nothrow_swappable::value +#if _LIBCPP_STD_VER <= 11 + && (!__node_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<__node_allocator>::value) +#endif + ) { using _VSTD::swap; swap(__begin_node_, __t.__begin_node_); swap(__pair1_.first(), __t.__pair1_.first()); - __swap_alloc(__node_alloc(), __t.__node_alloc()); + __swap_allocator(__node_alloc(), __t.__node_alloc()); __pair3_.swap(__t.__pair3_); if (size() == 0) __begin_node() = __end_node(); @@ -2069,7 +2058,6 @@ template typename __tree<_Tp, _Compare, _Allocator>::size_type __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const { - typedef pair _Pp; __node_const_pointer __result = __end_node(); __node_const_pointer __rt = __root(); while (__rt != nullptr) @@ -2291,7 +2279,7 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT --size(); __tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); - return __node_holder(__np, _Dp(__node_alloc())); + return __node_holder(__np, _Dp(__node_alloc(), true)); } template diff --git a/include/__tuple b/include/__tuple index bffb95cb72c5..2837ce708f09 100644 --- a/include/__tuple +++ b/include/__tuple @@ -19,40 +19,9 @@ #pragma GCC system_header #endif -#ifdef _LIBCPP_HAS_NO_VARIADICS - -#include <__tuple_03> - -#else // _LIBCPP_HAS_NO_VARIADICS _LIBCPP_BEGIN_NAMESPACE_STD -// __lazy_and - -template -struct __lazy_and_impl; - -template -struct __lazy_and_impl : false_type {}; - -template <> -struct __lazy_and_impl : true_type {}; - -template -struct __lazy_and_impl : integral_constant {}; - -template -struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {}; - -template -struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; - -// __lazy_not - -template -struct __lazy_not : integral_constant {}; - - template class _LIBCPP_TYPE_VIS_ONLY tuple_size; template @@ -90,19 +59,18 @@ public: typedef typename add_cv::type>::type type; }; -template class _LIBCPP_TYPE_VIS_ONLY tuple; -template struct _LIBCPP_TYPE_VIS_ONLY pair; -template struct _LIBCPP_TYPE_VIS_ONLY array; - template struct __tuple_like : false_type {}; template struct __tuple_like : public __tuple_like<_Tp> {}; template struct __tuple_like : public __tuple_like<_Tp> {}; template struct __tuple_like : public __tuple_like<_Tp> {}; +// tuple specializations + +#if !defined(_LIBCPP_HAS_NO_VARIADICS) +template class _LIBCPP_TYPE_VIS_ONLY tuple; + template struct __tuple_like > : true_type {}; -template struct __tuple_like > : true_type {}; -template struct __tuple_like > : true_type {}; template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 @@ -118,6 +86,13 @@ template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type&& get(tuple<_Tp...>&&) _NOEXCEPT; +#endif + +// pair specializations + +template struct _LIBCPP_TYPE_VIS_ONLY pair; + +template struct __tuple_like > : true_type {}; template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 @@ -129,10 +104,18 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(const pair<_T1, _T2>&) _NOEXCEPT; +#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(pair<_T1, _T2>&&) _NOEXCEPT; +#endif + +// array specializations + +template struct _LIBCPP_TYPE_VIS_ONLY array; + +template struct __tuple_like > : true_type {}; template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 @@ -144,10 +127,39 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& get(const array<_Tp, _Size>&) _NOEXCEPT; +#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT; +#endif + +#if !defined(_LIBCPP_HAS_NO_VARIADICS) + +// __lazy_and + +template +struct __lazy_and_impl; + +template +struct __lazy_and_impl : false_type {}; + +template <> +struct __lazy_and_impl : true_type {}; + +template +struct __lazy_and_impl : integral_constant {}; + +template +struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {}; + +template +struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; + +// __lazy_not + +template +struct __lazy_not : integral_constant {}; // __make_tuple_indices @@ -354,8 +366,8 @@ struct __tuple_assignable<_Tp, _Up, true, true> tuple_size<_Up>::value, _Tp, _Up> {}; -_LIBCPP_END_NAMESPACE_STD - #endif // _LIBCPP_HAS_NO_VARIADICS +_LIBCPP_END_NAMESPACE_STD + #endif // _LIBCPP___TUPLE diff --git a/include/__undef___deallocate b/include/__undef___deallocate new file mode 100644 index 000000000000..2b4ad99dad38 --- /dev/null +++ b/include/__undef___deallocate @@ -0,0 +1,18 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +#ifdef __deallocate +#if defined(_MSC_VER) && !defined(__clang__) +_LIBCPP_WARNING("macro __deallocate is incompatible with C++. #undefining __deallocate") +#else +#warning: macro __deallocate is incompatible with C++. #undefining __deallocate +#endif +#undef __deallocate +#endif diff --git a/include/algorithm b/include/algorithm index 02cbc816f61f..7b0c53e05a5a 100644 --- a/include/algorithm +++ b/include/algorithm @@ -521,11 +521,11 @@ template template ForwardIterator - min_element(ForwardIterator first, ForwardIterator last); + min_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14 template ForwardIterator - min_element(ForwardIterator first, ForwardIterator last, Compare comp); + min_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14 template const T& @@ -545,11 +545,11 @@ template template ForwardIterator - max_element(ForwardIterator first, ForwardIterator last); + max_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14 template ForwardIterator - max_element(ForwardIterator first, ForwardIterator last, Compare comp); + max_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14 template const T& @@ -569,11 +569,11 @@ template template pair - minmax_element(ForwardIterator first, ForwardIterator last); + minmax_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14 template pair - minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); + minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14 template pair @@ -1672,7 +1672,8 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) { return _VSTD::__search_n::type> - (__first, __last, __count, __value_, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); + (__first, __last, __convert_to_integral(__count), __value_, __pred, + typename iterator_traits<_ForwardIterator>::iterator_category()); } template @@ -1681,7 +1682,8 @@ _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) { typedef typename iterator_traits<_ForwardIterator>::value_type __v; - return _VSTD::search_n(__first, __last, __count, __value_, __equal_to<__v, _Tp>()); + return _VSTD::search_n(__first, __last, __convert_to_integral(__count), + __value_, __equal_to<__v, _Tp>()); } // copy @@ -1761,7 +1763,8 @@ typename enable_if __copy(_Tp* __first, _Tp* __last, _Up* __result) { const size_t __n = static_cast(__last - __first); - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + if (__n > 0) + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); return __result + __n; } @@ -1796,8 +1799,11 @@ typename enable_if __copy_backward(_Tp* __first, _Tp* __last, _Up* __result) { const size_t __n = static_cast(__last - __first); - __result -= __n; - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + if (__n > 0) + { + __result -= __n; + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + } return __result; } @@ -1839,8 +1845,10 @@ typename enable_if !__is_random_access_iterator<_InputIterator>::value, _OutputIterator >::type -copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) +copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { + typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize; + _IntegralSize __n = __orig_n; if (__n > 0) { *__result = *__first; @@ -1862,8 +1870,10 @@ typename enable_if __is_random_access_iterator<_InputIterator>::value, _OutputIterator >::type -copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) +copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { + typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize; + _IntegralSize __n = __orig_n; return _VSTD::copy(__first, __first + __n, __result); } @@ -1890,7 +1900,8 @@ typename enable_if __move(_Tp* __first, _Tp* __last, _Up* __result) { const size_t __n = static_cast(__last - __first); - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + if (__n > 0) + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); return __result + __n; } @@ -1925,8 +1936,11 @@ typename enable_if __move_backward(_Tp* __first, _Tp* __last, _Up* __result) { const size_t __n = static_cast(__last - __first); - __result -= __n; - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + if (__n > 0) + { + __result -= __n; + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + } return __result; } @@ -2055,7 +2069,7 @@ inline _LIBCPP_INLINE_VISIBILITY _OutputIterator fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) { - return _VSTD::__fill_n(__first, __n, __value_); + return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_); } // fill @@ -2101,8 +2115,10 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator -generate_n(_OutputIterator __first, _Size __n, _Generator __gen) +generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) { + typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize; + _IntegralSize __n = __orig_n; for (; __n > 0; ++__first, (void) --__n) *__first = __gen(); return __first; @@ -2536,7 +2552,7 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { @@ -2548,20 +2564,12 @@ __min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp return __first; } -template -inline _LIBCPP_INLINE_VISIBILITY -_ForwardIterator -min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) -{ - return __min_element(__first, __last, __comp); -} - template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last) { - return __min_element(__first, __last, + return _VSTD::min_element(__first, __last, __less::value_type>()); } @@ -2590,7 +2598,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp min(initializer_list<_Tp> __t, _Compare __comp) { - return *__min_element(__t.begin(), __t.end(), __comp); + return *_VSTD::min_element(__t.begin(), __t.end(), __comp); } template @@ -2598,7 +2606,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp min(initializer_list<_Tp> __t) { - return *__min_element(__t.begin(), __t.end(), __less<_Tp>()); + return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -2608,7 +2616,7 @@ min(initializer_list<_Tp> __t) template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { @@ -2621,20 +2629,12 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp } -template -inline _LIBCPP_INLINE_VISIBILITY -_ForwardIterator -max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) -{ - return __max_element(__first, __last, __comp); -} - template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last) { - return __max_element(__first, __last, + return _VSTD::max_element(__first, __last, __less::value_type>()); } @@ -2663,7 +2663,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp max(initializer_list<_Tp> __t, _Compare __comp) { - return *__max_element(__t.begin(), __t.end(), __comp); + return *_VSTD::max_element(__t.begin(), __t.end(), __comp); } template @@ -2671,7 +2671,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp max(initializer_list<_Tp> __t) { - return *__max_element(__t.begin(), __t.end(), __less<_Tp>()); + return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -2679,6 +2679,7 @@ max(initializer_list<_Tp> __t) // minmax_element template +_LIBCPP_CONSTEXPR_AFTER_CXX11 std::pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { @@ -2726,7 +2727,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 std::pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) { @@ -2763,7 +2764,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp) typedef typename initializer_list<_Tp>::const_iterator _Iter; _Iter __first = __t.begin(); _Iter __last = __t.end(); - std::pair<_Tp, _Tp> __result ( *__first, *__first ); + std::pair<_Tp, _Tp> __result(*__first, *__first); ++__first; if (__t.size() % 2 == 0) @@ -2778,13 +2779,13 @@ minmax(initializer_list<_Tp> __t, _Compare __comp) while (__first != __last) { _Tp __prev = *__first++; - if (__comp(__prev, *__first)) { - if (__comp(__prev, __result.first)) __result.first = __prev; - if (__comp(__result.second, *__first)) __result.second = *__first; + if (__comp(*__first, __prev)) { + if ( __comp(*__first, __result.first)) __result.first = *__first; + if (!__comp(__prev, __result.second)) __result.second = __prev; } else { - if (__comp(*__first, __result.first)) __result.first = *__first; - if (__comp(__result.second, __prev)) __result.second = __prev; + if ( __comp(__prev, __result.first)) __result.first = __prev; + if (!__comp(*__first, __result.second)) __result.second = *__first; } __first++; @@ -3148,6 +3149,9 @@ is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) for (; __first != __last; ++__first) if (!__pred(*__first)) break; + if ( __first == __last ) + return true; + ++__first; for (; __first != __last; ++__first) if (__pred(*__first)) return false; @@ -4357,6 +4361,34 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1, // inplace_merge +template +void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) +{ + for (; __first1 != __last1; ++__result) + { + if (__first2 == __last2) + { + _VSTD::move(__first1, __last1, __result); + return; + } + + if (__comp(*__first2, *__first1)) + { + *__result = _VSTD::move(*__first2); + ++__first2; + } + else + { + *__result = _VSTD::move(*__first1); + ++__first1; + } + } + // __first2 through __last2 are already in the right spot. +} + template void __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, @@ -4365,8 +4397,6 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator typename iterator_traits<_BidirectionalIterator>::value_type* __buff) { typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; - typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; - typedef typename iterator_traits<_BidirectionalIterator>::pointer pointer; __destruct_n __d(0); unique_ptr __h2(__buff, __d); if (__len1 <= __len2) @@ -4374,11 +4404,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator value_type* __p = __buff; for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, ++__p) ::new(__p) value_type(_VSTD::move(*__i)); - __merge<_Compare>(move_iterator(__buff), - move_iterator(__p), - move_iterator<_BidirectionalIterator>(__middle), - move_iterator<_BidirectionalIterator>(__last), - __first, __comp); + __half_inplace_merge(__buff, __p, __middle, __last, __first, __comp); } else { @@ -4387,9 +4413,9 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator ::new(__p) value_type(_VSTD::move(*__i)); typedef reverse_iterator<_BidirectionalIterator> _RBi; typedef reverse_iterator _Rv; - __merge(move_iterator<_RBi>(_RBi(__middle)), move_iterator<_RBi>(_RBi(__first)), - move_iterator<_Rv>(_Rv(__p)), move_iterator<_Rv>(_Rv(__buff)), - _RBi(__last), __negate<_Compare>(__comp)); + __half_inplace_merge(_Rv(__p), _Rv(__buff), + _RBi(__middle), _RBi(__first), + _RBi(__last), __negate<_Compare>(__comp)); } } @@ -4400,13 +4426,15 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, typename iterator_traits<_BidirectionalIterator>::difference_type __len2, typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size) { - typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; while (true) { // if __middle == __last, we're done if (__len2 == 0) return; + if (__len1 <= __buff_size || __len2 <= __buff_size) + return __buffered_inplace_merge<_Compare> + (__first, __middle, __last, __comp, __len1, __len2, __buff); // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0 for (; true; ++__first, (void) --__len1) { @@ -4415,11 +4443,6 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, if (__comp(*__middle, *__first)) break; } - if (__len1 <= __buff_size || __len2 <= __buff_size) - { - __buffered_inplace_merge<_Compare>(__first, __middle, __last, __comp, __len1, __len2, __buff); - return; - } // __first < __middle < __last // *__first > *__middle // partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that @@ -4484,12 +4507,6 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, } } -template -struct __inplace_merge_switch -{ - static const unsigned value = is_trivially_copy_assignable<_Tp>::value; -}; - template inline _LIBCPP_INLINE_VISIBILITY void @@ -4501,13 +4518,9 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _ difference_type __len1 = _VSTD::distance(__first, __middle); difference_type __len2 = _VSTD::distance(__middle, __last); difference_type __buf_size = _VSTD::min(__len1, __len2); - pair __buf(0, 0); - unique_ptr __h; - if (__inplace_merge_switch::value && __buf_size > 8) - { - __buf = _VSTD::get_temporary_buffer(__buf_size); - __h.reset(__buf.first); - } + pair __buf = _VSTD::get_temporary_buffer(__buf_size); + unique_ptr __h(__buf.first); + #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); @@ -4799,7 +4812,6 @@ void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, typename iterator_traits<_RandomAccessIterator>::difference_type __len) { - typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; if (__len > 1) { diff --git a/include/array b/include/array index d37075da1a2a..2e02a43ed524 100644 --- a/include/array +++ b/include/array @@ -288,10 +288,6 @@ template class _LIBCPP_TYPE_VIS_ONLY tuple_size > : public integral_constant {}; -template -class _LIBCPP_TYPE_VIS_ONLY tuple_size > - : public integral_constant {}; - template class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, array<_Tp, _Size> > { @@ -299,13 +295,6 @@ public: typedef _Tp type; }; -template -class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const array<_Tp, _Size> > -{ -public: - typedef const _Tp type; -}; - template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp& diff --git a/include/atomic b/include/atomic index b01a59f5f96f..97a998d33633 100644 --- a/include/atomic +++ b/include/atomic @@ -551,26 +551,27 @@ typedef enum memory_order #if _GNUC_VER >= 407 namespace __gcc_atomic { -template +template struct __gcc_atomic_t { __gcc_atomic_t() _NOEXCEPT {} - explicit __gcc_atomic_t(T value) _NOEXCEPT : __a_value(value) {} - T __a_value; + _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT + : __a_value(value) {} + _Tp __a_value; }; #define _Atomic(x) __gcc_atomic::__gcc_atomic_t -template T __create(); +template _Tp __create(); -template -typename enable_if__a_value = __create<__Td>()), char>::type +template +typename enable_if__a_value = __create<_Td>()), char>::type __test_atomic_assignable(int); -template +template __two __test_atomic_assignable(...); -template +template struct __can_assign { static const bool value = - sizeof(__test_atomic_assignable<__Tp, __Td>(1)) == sizeof(char); + sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char); }; static inline constexpr int __to_gcc_order(memory_order __order) { @@ -583,6 +584,16 @@ static inline constexpr int __to_gcc_order(memory_order __order) { __ATOMIC_CONSUME)))); } +static inline constexpr int __to_gcc_failure_order(memory_order __order) { + // Avoid switch statement to make this a constexpr. + return __order == memory_order_relaxed ? __ATOMIC_RELAXED: + (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: + (__order == memory_order_release ? __ATOMIC_RELAXED: + (__order == memory_order_seq_cst ? __ATOMIC_SEQ_CST: + (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE: + __ATOMIC_CONSUME)))); +} + } // namespace __gcc_atomic template @@ -623,10 +634,6 @@ static inline void __c11_atomic_signal_fence(memory_order __order) { __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order)); } -static inline bool __c11_atomic_is_lock_free(size_t __size) { - return __atomic_is_lock_free(__size, 0); -} - template static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, memory_order __order) { @@ -637,8 +644,8 @@ static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val, template static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val, memory_order __order) { - return __atomic_store(&__a->__a_value, &__val, - __gcc_atomic::__to_gcc_order(__order)); + __atomic_store(&__a->__a_value, &__val, + __gcc_atomic::__to_gcc_order(__order)); } template @@ -683,7 +690,7 @@ static inline bool __c11_atomic_compare_exchange_strong( return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, false, __gcc_atomic::__to_gcc_order(__success), - __gcc_atomic::__to_gcc_order(__failure)); + __gcc_atomic::__to_gcc_failure_order(__failure)); } template @@ -693,7 +700,7 @@ static inline bool __c11_atomic_compare_exchange_strong( return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, false, __gcc_atomic::__to_gcc_order(__success), - __gcc_atomic::__to_gcc_order(__failure)); + __gcc_atomic::__to_gcc_failure_order(__failure)); } template @@ -703,7 +710,7 @@ static inline bool __c11_atomic_compare_exchange_weak( return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, true, __gcc_atomic::__to_gcc_order(__success), - __gcc_atomic::__to_gcc_order(__failure)); + __gcc_atomic::__to_gcc_failure_order(__failure)); } template @@ -713,7 +720,7 @@ static inline bool __c11_atomic_compare_exchange_weak( return __atomic_compare_exchange(&__a->__a_value, __expected, &__value, true, __gcc_atomic::__to_gcc_order(__success), - __gcc_atomic::__to_gcc_order(__failure)); + __gcc_atomic::__to_gcc_failure_order(__failure)); } template @@ -817,10 +824,16 @@ struct __atomic_base // false _LIBCPP_INLINE_VISIBILITY bool is_lock_free() const volatile _NOEXCEPT - {return __c11_atomic_is_lock_free(sizeof(_Tp));} + { +#if __has_feature(cxx_atomic) + return __c11_atomic_is_lock_free(sizeof(_Tp)); +#else + return __atomic_is_lock_free(sizeof(_Tp), 0); +#endif + } _LIBCPP_INLINE_VISIBILITY bool is_lock_free() const _NOEXCEPT - {return __c11_atomic_is_lock_free(sizeof(_Tp));} + {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();} _LIBCPP_INLINE_VISIBILITY void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {__c11_atomic_store(&__a_, __d, __m);} diff --git a/include/cctype b/include/cctype index b647903c45cd..26c740f7382d 100644 --- a/include/cctype +++ b/include/cctype @@ -39,6 +39,7 @@ int toupper(int c); #include #if defined(_LIBCPP_MSVCRT) #include "support/win32/support.h" +#include "support/win32/locale_win32.h" #endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/include/cinttypes b/include/cinttypes index 786692b8fec3..cfd763c98f4a 100644 --- a/include/cinttypes +++ b/include/cinttypes @@ -247,7 +247,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD using::imaxdiv_t; +#undef imaxabs using::imaxabs; +#undef imaxdiv using::imaxdiv; using::strtoimax; using::strtoumax; diff --git a/include/clocale b/include/clocale index f8b8f0dd34b6..05fa9c6edda8 100644 --- a/include/clocale +++ b/include/clocale @@ -45,7 +45,9 @@ lconv* localeconv(); _LIBCPP_BEGIN_NAMESPACE_STD using ::lconv; +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS using ::setlocale; +#endif using ::localeconv; _LIBCPP_END_NAMESPACE_STD diff --git a/include/cmath b/include/cmath index d3aa4beeb584..5f9aaedd5afa 100644 --- a/include/cmath +++ b/include/cmath @@ -654,7 +654,11 @@ using ::double_t; // abs -#if !defined(_AIX) +#if defined(__sun__) +using ::abs; +#endif + +#if !defined(_AIX) && !defined(__sun__) inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} @@ -1109,8 +1113,16 @@ cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);} using ::copysign; using ::copysignf; -inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return copysignf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return copysignl(__lcpp_x, __lcpp_y);} +#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12) +inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, + float __lcpp_y) _NOEXCEPT { + return copysignf(__lcpp_x, __lcpp_y); +} +inline _LIBCPP_INLINE_VISIBILITY long double +copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { + return copysignl(__lcpp_x, __lcpp_y); +} +#endif template inline _LIBCPP_INLINE_VISIBILITY diff --git a/include/cstdio b/include/cstdio index ce3af4d91dc4..d8ba6c2ef383 100644 --- a/include/cstdio +++ b/include/cstdio @@ -120,36 +120,44 @@ inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {ret inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);} #endif // putc +#ifdef clearerr +inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) { return clearerr(__stream); } +#undef clearerr +inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) { return __libcpp_clearerr(__stream); } +#endif // clearerr + +#ifdef feof +inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) { return feof(__stream); } +#undef feof +inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) { return __libcpp_feof(__stream); } +#endif // feof + +#ifdef ferror +inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) { return ferror(__stream); } +#undef ferror +inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) { return __libcpp_ferror(__stream); } +#endif // ferror + _LIBCPP_BEGIN_NAMESPACE_STD using ::FILE; using ::fpos_t; using ::size_t; -using ::remove; -using ::rename; -using ::tmpfile; -using ::tmpnam; using ::fclose; using ::fflush; -using ::fopen; -using ::freopen; using ::setbuf; using ::setvbuf; using ::fprintf; using ::fscanf; -using ::printf; -using ::scanf; using ::snprintf; using ::sprintf; using ::sscanf; #ifndef _LIBCPP_MSVCRT using ::vfprintf; using ::vfscanf; -using ::vscanf; using ::vsscanf; #endif // _LIBCPP_MSVCRT -using ::vprintf; using ::vsnprintf; using ::vsprintf; using ::fgetc; @@ -157,13 +165,7 @@ using ::fgets; using ::fputc; using ::fputs; using ::getc; -using ::getchar; -#if _LIBCPP_STD_VER <= 11 -using ::gets; -#endif using ::putc; -using ::putchar; -using ::puts; using ::ungetc; using ::fread; using ::fwrite; @@ -177,6 +179,31 @@ using ::feof; using ::ferror; using ::perror; +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE +using ::fopen; +using ::freopen; +using ::remove; +using ::rename; +using ::tmpfile; +using ::tmpnam; +#endif + +#ifndef _LIBCPP_HAS_NO_STDIN +using ::getchar; +#if _LIBCPP_STD_VER <= 11 +using ::gets; +#endif +using ::scanf; +using ::vscanf; +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT +using ::printf; +using ::putchar; +using ::puts; +using ::vprintf; +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CSTDIO diff --git a/include/cstdlib b/include/cstdlib index 152b891de78e..55e15c82192e 100644 --- a/include/cstdlib +++ b/include/cstdlib @@ -131,19 +131,27 @@ using ::getenv; using ::system; using ::bsearch; using ::qsort; +#undef abs using ::abs; +#undef labs using ::labs; #ifndef _LIBCPP_HAS_NO_LONG_LONG +#undef llabs using ::llabs; #endif // _LIBCPP_HAS_NO_LONG_LONG +#undef div using ::div; +#undef ldiv using ::ldiv; #ifndef _LIBCPP_HAS_NO_LONG_LONG +#undef lldiv using ::lldiv; #endif // _LIBCPP_HAS_NO_LONG_LONG +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS using ::mblen; using ::mbtowc; using ::wctomb; +#endif using ::mbstowcs; using ::wcstombs; #ifdef _LIBCPP_HAS_QUICK_EXIT diff --git a/include/cstring b/include/cstring index 21c9155cd4d9..d60b9923c6c2 100644 --- a/include/cstring +++ b/include/cstring @@ -102,7 +102,9 @@ inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, si inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);} #endif +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS using ::strtok; +#endif using ::memset; using ::strerror; using ::strlen; diff --git a/include/ctime b/include/ctime index fc4eb26f5430..da9e3290bbb2 100644 --- a/include/ctime +++ b/include/ctime @@ -61,10 +61,12 @@ using ::clock; using ::difftime; using ::mktime; using ::time; +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS using ::asctime; using ::ctime; using ::gmtime; using ::localtime; +#endif using ::strftime; _LIBCPP_END_NAMESPACE_STD diff --git a/include/cwchar b/include/cwchar index 9f51587caa5f..797a1777c22f 100644 --- a/include/cwchar +++ b/include/cwchar @@ -126,24 +126,18 @@ using ::fwscanf; using ::swprintf; using ::vfwprintf; using ::vswprintf; -using ::vwprintf; #ifndef _LIBCPP_MSVCRT using ::swscanf; using ::vfwscanf; using ::vswscanf; -using ::vwscanf; #endif // _LIBCPP_MSVCRT -using ::wprintf; -using ::wscanf; using ::fgetwc; using ::fgetws; using ::fputwc; using ::fputws; using ::fwide; using ::getwc; -using ::getwchar; using ::putwc; -using ::putwchar; using ::ungetwc; using ::wcstod; #ifndef _LIBCPP_MSVCRT @@ -212,6 +206,20 @@ using ::wcrtomb; using ::mbsrtowcs; using ::wcsrtombs; +#ifndef _LIBCPP_HAS_NO_STDIN +using ::getwchar; +#ifndef _LIBCPP_MSVCRT +using ::vwscanf; +#endif // _LIBCPP_MSVCRT +using ::wscanf; +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT +using ::putwchar; +using ::vwprintf; +using ::wprintf; +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CWCHAR diff --git a/include/deque b/include/deque index 5602d4a3fdc5..5e152e425d0b 100644 --- a/include/deque +++ b/include/deque @@ -117,15 +117,14 @@ public: iterator insert(const_iterator p, value_type&& v); iterator insert(const_iterator p, size_type n, const value_type& v); template - iterator insert (const_iterator p, InputIterator f, InputIterator l); + iterator insert(const_iterator p, InputIterator f, InputIterator l); iterator insert(const_iterator p, initializer_list il); void pop_front(); void pop_back(); iterator erase(const_iterator p); iterator erase(const_iterator f, const_iterator l); void swap(deque& c) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value); + noexcept(allocator_traits::is_always_equal::value); // C++17 void clear() noexcept; }; @@ -168,6 +167,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD template class __deque_base; +template > class _LIBCPP_TYPE_VIS_ONLY deque; template @@ -911,22 +911,10 @@ protected: static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16; - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc -#else - rebind_alloc::other -#endif - __pointer_allocator; + typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator; typedef allocator_traits<__pointer_allocator> __map_traits; typedef typename __map_traits::pointer __map_pointer; - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc -#else - rebind_alloc::other -#endif - __const_pointer_allocator; + typedef typename __rebind_alloc_helper<__alloc_traits, const_pointer>::type __const_pointer_allocator; typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer; typedef __split_buffer __map; @@ -965,8 +953,12 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void swap(__deque_base& __c) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value); +#endif protected: void clear() _NOEXCEPT; @@ -1002,26 +994,6 @@ private: _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__deque_base&, false_type) _NOEXCEPT {} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) - {__swap_alloc(__x, __y, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable::value) - { - using _VSTD::swap; - swap(__x, __y); - } - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type&, allocator_type&, false_type) - _NOEXCEPT - {} }; template @@ -1145,13 +1117,17 @@ __deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_ template void __deque_base<_Tp, _Allocator>::swap(__deque_base& __c) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| - __is_nothrow_swappable::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value) +#endif { __map_.swap(__c.__map_); _VSTD::swap(__start_, __c.__start_); _VSTD::swap(size(), __c.size()); - __swap_alloc(__alloc(), __c.__alloc()); + __swap_allocator(__alloc(), __c.__alloc()); } template @@ -1178,7 +1154,7 @@ __deque_base<_Tp, _Allocator>::clear() _NOEXCEPT } } -template > +template */> class _LIBCPP_TYPE_VIS_ONLY deque : private __deque_base<_Tp, _Allocator> { @@ -1332,11 +1308,15 @@ public: iterator insert(const_iterator __p, const value_type& __v); iterator insert(const_iterator __p, size_type __n, const value_type& __v); template - iterator insert (const_iterator __p, _InputIter __f, _InputIter __l, + iterator insert(const_iterator __p, _InputIter __f, _InputIter __l, typename enable_if<__is_input_iterator<_InputIter>::value - &&!__is_bidirectional_iterator<_InputIter>::value>::type* = 0); + &&!__is_forward_iterator<_InputIter>::value>::type* = 0); + template + iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l, + typename enable_if<__is_forward_iterator<_ForwardIterator>::value + &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type* = 0); template - iterator insert (const_iterator __p, _BiIter __f, _BiIter __l, + iterator insert(const_iterator __p, _BiIter __f, _BiIter __l, typename enable_if<__is_bidirectional_iterator<_BiIter>::value>::type* = 0); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY @@ -1349,8 +1329,12 @@ public: iterator erase(const_iterator __f, const_iterator __l); void swap(deque& __c) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); +#endif void clear() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -2098,7 +2082,7 @@ template typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l, typename enable_if<__is_input_iterator<_InputIter>::value - &&!__is_bidirectional_iterator<_InputIter>::value>::type*) + &&!__is_forward_iterator<_InputIter>::value>::type*) { __split_buffer __buf(__base::__alloc()); __buf.__construct_at_end(__f, __l); @@ -2106,6 +2090,20 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __ return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end())); } +template +template +typename deque<_Tp, _Allocator>::iterator +deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l, + typename enable_if<__is_forward_iterator<_ForwardIterator>::value + &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type*) +{ + size_type __n = _VSTD::distance(__f, __l); + __split_buffer __buf(__n, 0, __base::__alloc()); + __buf.__construct_at_end(__f, __l); + typedef typename __split_buffer::iterator __fwd; + return insert(__p, move_iterator<__fwd>(__buf.begin()), move_iterator<__fwd>(__buf.end())); +} + template template typename deque<_Tp, _Allocator>::iterator @@ -2269,19 +2267,14 @@ deque<_Tp, _Allocator>::__add_front_capacity() __split_buffer __buf(max(2 * __base::__map_.capacity(), 1), 0, __base::__map_.__alloc()); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size)); -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __alloc_traits::deallocate(__a, __buf.front(), __base::__block_size); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS + + typedef __allocator_destructor<_Allocator> _Dp; + unique_ptr __hold( + __alloc_traits::allocate(__a, __base::__block_size), + _Dp(__a, __base::__block_size)); + __buf.push_back(__hold.get()); + __hold.release(); + for (typename __base::__map_pointer __i = __base::__map_.begin(); __i != __base::__map_.end(); ++__i) __buf.push_back(*__i); @@ -2417,19 +2410,14 @@ deque<_Tp, _Allocator>::__add_back_capacity() __buf(max(2* __base::__map_.capacity(), 1), __base::__map_.size(), __base::__map_.__alloc()); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size)); -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __alloc_traits::deallocate(__a, __buf.back(), __base::__block_size); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS + + typedef __allocator_destructor<_Allocator> _Dp; + unique_ptr __hold( + __alloc_traits::allocate(__a, __base::__block_size), + _Dp(__a, __base::__block_size)); + __buf.push_back(__hold.get()); + __hold.release(); + for (typename __base::__map_pointer __i = __base::__map_.end(); __i != __base::__map_.begin();) __buf.push_front(*--__i); @@ -2702,7 +2690,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f) difference_type __pos = __f - __b; iterator __p = __b + __pos; allocator_type& __a = __base::__alloc(); - if (__pos < (__base::size() - 1) / 2) + if (__pos <= (__base::size() - 1) / 2) { // erase from front _VSTD::move_backward(__b, __p, _VSTD::next(__p)); __alloc_traits::destroy(__a, _VSTD::addressof(*__b)); @@ -2740,7 +2728,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l) if (__n > 0) { allocator_type& __a = __base::__alloc(); - if (__pos < (__base::size() - __n) / 2) + if (__pos <= (__base::size() - __n) / 2) { // erase from front iterator __i = _VSTD::move_backward(__b, __p, __p + __n); for (; __b != __i; ++__b) @@ -2796,8 +2784,12 @@ template inline _LIBCPP_INLINE_VISIBILITY void deque<_Tp, _Allocator>::swap(deque& __c) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value) +#endif { __base::swap(__c); } diff --git a/include/exception b/include/exception index cad802e056a5..5a905e7e58d8 100644 --- a/include/exception +++ b/include/exception @@ -48,7 +48,8 @@ terminate_handler set_terminate(terminate_handler f ) noexcept; terminate_handler get_terminate() noexcept; [[noreturn]] void terminate() noexcept; -bool uncaught_exception() noexcept; +bool uncaught_exception() noexcept; +int uncaught_exceptions() noexcept; // C++17 typedef unspecified exception_ptr; @@ -115,6 +116,7 @@ _LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT; _LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT; +_LIBCPP_FUNC_VIS int uncaught_exceptions() _NOEXCEPT; class _LIBCPP_TYPE_VIS exception_ptr; @@ -193,6 +195,7 @@ void throw_with_nested(_Tp&& __t, typename enable_if< is_class::type>::value && !is_base_of::type>::value + && !__libcpp_is_final::type>::value >::type* = 0) #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES throw_with_nested (_Tp& __t, typename enable_if< @@ -212,6 +215,7 @@ void throw_with_nested(_Tp&& __t, typename enable_if< !is_class::type>::value || is_base_of::type>::value + || __libcpp_is_final::type>::value >::type* = 0) #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES throw_with_nested (_Tp& __t, typename enable_if< diff --git a/include/experimental/__config b/include/experimental/__config index 684a3b4d83d8..f64a3a90cd12 100644 --- a/include/experimental/__config +++ b/include/experimental/__config @@ -13,6 +13,10 @@ #include <__config> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } } #define _VSTD_EXPERIMENTAL std::experimental @@ -21,4 +25,8 @@ #define _LIBCPP_END_NAMESPACE_LFTS } } } #define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1 +#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \ + namespace chrono { namespace experimental { inline namespace fundamentals_v1 { +#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } } + #endif diff --git a/include/experimental/algorithm b/include/experimental/algorithm new file mode 100644 index 000000000000..a2e956f281a0 --- /dev/null +++ b/include/experimental/algorithm @@ -0,0 +1,114 @@ +// -*- C++ -*- +//===-------------------------- algorithm ---------------------------------===// +// +// The 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 _LIBCPP_EXPERIMENTAL_ALGORITHM +#define _LIBCPP_EXPERIMENTAL_ALGORITHM + +/* + experimental/algorithm synopsis + +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + +template +ForwardIterator search(ForwardIterator first, ForwardIterator last, + const Searcher &searcher); +template +SampleIterator sample(PopulationIterator first, PopulationIterator last, + SampleIterator out, Distance n, + UniformRandomNumberGenerator &&g); + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include +#include +#include + +#include <__undef_min_max> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + + +template +_LIBCPP_INLINE_VISIBILITY +_SampleIterator __sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __out, + _Distance __n, + _UniformRandomNumberGenerator &&__g, + input_iterator_tag) { + + _Distance __k = 0; + for (; __first != __last && __k < __n; ++__first, (void)++__k) + __out[__k] = *__first; + _Distance __sz = __k; + for (; __first != __last; ++__first, (void)++__k) { + _Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g); + if (__r < __sz) + __out[__r] = *__first; + } + return __out + _VSTD::min(__n, __k); +} + +template +_LIBCPP_INLINE_VISIBILITY +_SampleIterator __sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __out, + _Distance __n, + _UniformRandomNumberGenerator &&__g, + forward_iterator_tag) { + _Distance __unsampled_sz = _VSTD::distance(__first, __last); + for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) { + _Distance __r = + _VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g); + if (__r < __n) { + *__out++ = *__first; + --__n; + } + } + return __out; +} + +template +_LIBCPP_INLINE_VISIBILITY +_SampleIterator sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __out, + _Distance __n, _UniformRandomNumberGenerator &&__g) { + typedef typename iterator_traits<_PopulationIterator>::iterator_category + _PopCategory; + typedef typename iterator_traits<_PopulationIterator>::difference_type + _Difference; + typedef typename common_type<_Distance, _Difference>::type _CommonType; + _LIBCPP_ASSERT(__n >= 0, "N must be a positive number."); + return _VSTD_LFTS::__sample( + __first, __last, __out, _CommonType(__n), + _VSTD::forward<_UniformRandomNumberGenerator>(__g), + _PopCategory()); +} + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */ diff --git a/include/experimental/chrono b/include/experimental/chrono new file mode 100644 index 000000000000..ca9e5f852ea2 --- /dev/null +++ b/include/experimental/chrono @@ -0,0 +1,59 @@ +// -*- C++ -*- +//===------------------------------ chrono ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_CHRONO +#define _LIBCPP_EXPERIMENTAL_CHRONO + +/** + experimental/chrono synopsis + +// C++1y + +#include + +namespace std { +namespace chrono { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.12.4, customization traits + template constexpr bool treat_as_floating_point_v + = treat_as_floating_point::value; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace chrono +} // namespace std + + */ + +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER > 11 + +_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES + +template _LIBCPP_CONSTEXPR bool treat_as_floating_point_v + = treat_as_floating_point<_Rep>::value; + +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ + +_LIBCPP_END_NAMESPACE_CHRONO_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */ diff --git a/include/experimental/dynarray b/include/experimental/dynarray index 0bc8dfe2cb7b..a0258628dfa6 100644 --- a/include/experimental/dynarray +++ b/include/experimental/dynarray @@ -104,6 +104,8 @@ public: #include #include +#include <__undef___deallocate> + #if defined(_LIBCPP_NO_EXCEPTIONS) #include #endif diff --git a/include/experimental/ratio b/include/experimental/ratio new file mode 100644 index 000000000000..757f24e08614 --- /dev/null +++ b/include/experimental/ratio @@ -0,0 +1,77 @@ +// -*- C++ -*- +//===------------------------------ ratio ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_RATIO +#define _LIBCPP_EXPERIMENTAL_RATIO + +/** + experimental/ratio synopsis + C++1y +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.11.5, ratio comparison + template constexpr bool ratio_equal_v + = ratio_equal::value; + template constexpr bool ratio_not_equal_v + = ratio_not_equal::value; + template constexpr bool ratio_less_v + = ratio_less::value; + template constexpr bool ratio_less_equal_v + = ratio_less_equal::value; + template constexpr bool ratio_greater_v + = ratio_greater::value; + template constexpr bool ratio_greater_equal_v + = ratio_greater_equal::value; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include + +#if _LIBCPP_STD_VER > 11 + +#include + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES + +template _LIBCPP_CONSTEXPR bool ratio_equal_v + = ratio_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_not_equal_v + = ratio_not_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_less_v + = ratio_less<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_less_equal_v + = ratio_less_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_greater_v + = ratio_greater<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_greater_equal_v + = ratio_greater_equal<_R1, _R2>::value; + +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif // _LIBCPP_EXPERIMENTAL_RATIO diff --git a/include/experimental/string_view b/include/experimental/string_view index d423f39003a5..2a20d7caa687 100644 --- a/include/experimental/string_view +++ b/include/experimental/string_view @@ -280,11 +280,8 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS const_reference at(size_type __pos) const { return __pos >= size() - ? throw out_of_range("string_view::at") + ? (throw out_of_range("string_view::at"), __data[0]) : __data[__pos]; -// if (__pos >= size()) -// throw out_of_range("string_view::at"); -// return __data[__pos]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY @@ -313,7 +310,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_prefix(size_type __n) _NOEXCEPT { - _LIBCPP_ASSERT(n <= size(), "remove_prefix() can't remove more than size()"); + _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()"); __data += __n; __size -= __n; } @@ -321,7 +318,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_suffix(size_type __n) _NOEXCEPT { - _LIBCPP_ASSERT(n <= size(), "remove_suffix() can't remove more than size()"); + _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()"); __size -= __n; } diff --git a/include/experimental/system_error b/include/experimental/system_error new file mode 100644 index 000000000000..2ec238544615 --- /dev/null +++ b/include/experimental/system_error @@ -0,0 +1,63 @@ +// -*- C++ -*- +//===-------------------------- system_error ------------------------------===// +// +// The 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 _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR +#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR + +/** + experimental/system_error synopsis + +// C++1y + +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 19.5, System error support + template constexpr bool is_error_code_enum_v + = is_error_code_enum::value; + template constexpr bool is_error_condition_enum_v + = is_error_condition_enum::value; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include + +#if _LIBCPP_STD_VER > 11 + +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES + +template _LIBCPP_CONSTEXPR bool is_error_code_enum_v + = is_error_code_enum<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_error_condition_enum_v + = is_error_condition_enum<_Tp>::value; + +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR */ diff --git a/include/experimental/tuple b/include/experimental/tuple new file mode 100644 index 000000000000..50d1e0555bc4 --- /dev/null +++ b/include/experimental/tuple @@ -0,0 +1,81 @@ +// -*- C++ -*- +//===----------------------------- tuple ----------------------------------===// +// +// The 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 _LIBCPP_EXPERIMENTAL_TUPLE +#define _LIBCPP_EXPERIMENTAL_TUPLE + +/* + experimental/tuple synopsis + +// C++1y + +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.4.2.5, tuple helper classes + template constexpr size_t tuple_size_v + = tuple_size::value; + + // 3.2.2, Calling a function with a tuple of arguments + template + constexpr decltype(auto) apply(F&& f, Tuple&& t); + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +# include + +#if _LIBCPP_STD_VER > 11 + +# include +# include +# include <__functional_base> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +template +_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value; +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t, + integer_sequence) { + return _VSTD::__invoke( + _VSTD::forward<_Fn>(__f), + _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))... + ); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +decltype(auto) apply(_Fn && __f, _Tuple && __t) { + return _VSTD_LFTS::__apply_tuple_impl( + _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t), + make_index_sequence::type>::value>() + ); +} + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */ diff --git a/include/experimental/type_traits b/include/experimental/type_traits index ab2c8cdf81d6..ae49fc176c01 100644 --- a/include/experimental/type_traits +++ b/include/experimental/type_traits @@ -184,9 +184,13 @@ inline namespace fundamentals_v1 { #include +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + _LIBCPP_BEGIN_NAMESPACE_LFTS -#if __has_feature(cxx_variable_templates) +#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES // C++14 20.10.4.1, primary type categories @@ -393,7 +397,7 @@ template _LIBCPP_CONSTEXPR bool is_base_of_v template _LIBCPP_CONSTEXPR bool is_convertible_v = is_convertible<_Tp, _Up>::value; -#endif /* __has_feature(cxx_variable_templates) */ +#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */ // 3.3.2, Other type transformations /* diff --git a/include/experimental/utility b/include/experimental/utility index 84e461af073f..b5fca6c775bc 100644 --- a/include/experimental/utility +++ b/include/experimental/utility @@ -31,9 +31,12 @@ inline namespace fundamentals_v1 { */ -# include +#include +#include -# include +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif _LIBCPP_BEGIN_NAMESPACE_LFTS diff --git a/include/ext/hash_map b/include/ext/hash_map index 36cd595e0343..31fcedfb9f9e 100644 --- a/include/ext/hash_map +++ b/include/ext/hash_map @@ -203,6 +203,7 @@ template #include <__hash_table> #include #include +#include #include #if __DEPRECATED @@ -213,16 +214,16 @@ template #endif #endif +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header +#endif namespace __gnu_cxx { using namespace std; -template ::value -#if __has_feature(is_final) - && !__is_final(_Hash) -#endif +template ::value && !__libcpp_is_final<_Hash>::value > class __hash_map_hasher : private _Hash @@ -255,10 +256,8 @@ public: {return __hash_(__x);} }; -template ::value -#if __has_feature(is_final) - && !__is_final(_Pred) -#endif +template ::value && !__libcpp_is_final<_Pred>::value > class __hash_map_equal : private _Pred @@ -493,13 +492,7 @@ private: typedef pair __value_type; typedef __hash_map_hasher<__value_type, hasher> __hasher; typedef __hash_map_equal<__value_type, key_equal> __key_equal; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__value_type> -#else - rebind_alloc<__value_type>::other -#endif - __allocator_type; + typedef typename __rebind_alloc_helper, __value_type>::type __allocator_type; typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; @@ -772,13 +765,7 @@ private: typedef pair __value_type; typedef __hash_map_hasher<__value_type, hasher> __hasher; typedef __hash_map_equal<__value_type, key_equal> __key_equal; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__value_type> -#else - rebind_alloc<__value_type>::other -#endif - __allocator_type; + typedef typename __rebind_alloc_helper, __value_type>::type __allocator_type; typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; diff --git a/include/forward_list b/include/forward_list index 651452f3fe8d..8a87fc5e1f26 100644 --- a/include/forward_list +++ b/include/forward_list @@ -107,8 +107,7 @@ public: iterator erase_after(const_iterator first, const_iterator last); void swap(forward_list& x) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value); + noexcept(allocator_traits::is_always_equal::value); // C++17 void resize(size_type n); void resize(size_type n, const value_type& v); @@ -218,7 +217,7 @@ struct __forward_list_node value_type __value_; }; -template class _LIBCPP_TYPE_VIS_ONLY forward_list; +template > class _LIBCPP_TYPE_VIS_ONLY forward_list; template class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; template @@ -365,24 +364,12 @@ protected: typedef typename allocator_traits::void_pointer void_pointer; typedef __forward_list_node __node; typedef typename __begin_node_of::type __begin_node; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__node> -#else - rebind_alloc<__node>::other -#endif - __node_allocator; + typedef typename __rebind_alloc_helper, __node>::type __node_allocator; typedef allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; typedef typename __node_traits::pointer __node_const_pointer; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__begin_node> -#else - rebind_alloc<__begin_node>::other -#endif - __begin_node_allocator; + typedef typename __rebind_alloc_helper, __begin_node>::type __begin_node_allocator; typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer; __compressed_pair<__begin_node, __node_allocator> __before_begin_; @@ -443,8 +430,12 @@ protected: public: void swap(__forward_list_base& __x) - _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || + __is_nothrow_swappable<__node_allocator>::value); +#endif protected: void clear() _NOEXCEPT; @@ -466,26 +457,6 @@ private: void __move_assign_alloc(__forward_list_base& __x, true_type) _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {__alloc() = _VSTD::move(__x.__alloc());} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y) - _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - {__swap_alloc(__x, __y, integral_constant());} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, - false_type) - _NOEXCEPT - {} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, - true_type) - _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value) - { - using _VSTD::swap; - swap(__x, __y); - } }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -524,10 +495,15 @@ template inline _LIBCPP_INLINE_VISIBILITY void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) - _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || + __is_nothrow_swappable<__node_allocator>::value) +#endif { - __swap_alloc(__alloc(), __x.__alloc()); + __swap_allocator(__alloc(), __x.__alloc(), + integral_constant()); using _VSTD::swap; swap(__before_begin()->__next_, __x.__before_begin()->__next_); } @@ -547,7 +523,7 @@ __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT __before_begin()->__next_ = nullptr; } -template > +template */> class _LIBCPP_TYPE_VIS_ONLY forward_list : private __forward_list_base<_Tp, _Alloc> { @@ -715,8 +691,12 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(forward_list& __x) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) +#endif {base::swap(__x);} void resize(size_type __n); diff --git a/include/fstream b/include/fstream index 38778c6779aa..1f289eddc56f 100644 --- a/include/fstream +++ b/include/fstream @@ -206,8 +206,10 @@ public: // 27.9.1.4 Members: bool is_open() const; +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE basic_filebuf* open(const char* __s, ios_base::openmode __mode); basic_filebuf* open(const string& __s, ios_base::openmode __mode); +#endif basic_filebuf* close(); protected: @@ -463,6 +465,7 @@ basic_filebuf<_CharT, _Traits>::is_open() const return __file_ != 0; } +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE template basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) @@ -550,6 +553,7 @@ basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod { return open(__s.c_str(), __mode); } +#endif template basic_filebuf<_CharT, _Traits>* @@ -807,7 +811,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, default: return pos_type(off_type(-1)); } -#if _WIN32 +#if defined(_WIN32) || defined(_NEWLIB_VERSION) if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) return pos_type(off_type(-1)); pos_type __r = ftell(__file_); @@ -826,7 +830,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) { if (__file_ == 0 || sync()) return pos_type(off_type(-1)); -#if _WIN32 +#if defined(_WIN32) || defined(_NEWLIB_VERSION) if (fseek(__file_, __sp, SEEK_SET)) return pos_type(off_type(-1)); #else @@ -891,7 +895,7 @@ basic_filebuf<_CharT, _Traits>::sync() } } } -#if _WIN32 +#if defined(_WIN32) || defined(_NEWLIB_VERSION) if (fseek(__file_, -__c, SEEK_CUR)) return -1; #else @@ -1005,8 +1009,10 @@ public: typedef typename traits_type::off_type off_type; basic_ifstream(); +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in); explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES basic_ifstream(basic_ifstream&& __rhs); #endif @@ -1018,8 +1024,10 @@ public: basic_filebuf* rdbuf() const; bool is_open() const; +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE void open(const char* __s, ios_base::openmode __mode = ios_base::in); void open(const string& __s, ios_base::openmode __mode = ios_base::in); +#endif void close(); private: @@ -1033,6 +1041,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream() { } +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE template inline _LIBCPP_INLINE_VISIBILITY basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode) @@ -1050,6 +1059,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::ope if (__sb_.open(__s, __mode | ios_base::in) == 0) this->setstate(ios_base::failbit); } +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1107,6 +1117,7 @@ basic_ifstream<_CharT, _Traits>::is_open() const return __sb_.is_open(); } +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE template void basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) @@ -1126,6 +1137,7 @@ basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo else this->setstate(ios_base::failbit); } +#endif template inline _LIBCPP_INLINE_VISIBILITY @@ -1163,8 +1175,10 @@ public: basic_filebuf* rdbuf() const; bool is_open() const; +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE void open(const char* __s, ios_base::openmode __mode = ios_base::out); void open(const string& __s, ios_base::openmode __mode = ios_base::out); +#endif void close(); private: @@ -1178,6 +1192,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream() { } +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE template inline _LIBCPP_INLINE_VISIBILITY basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode) @@ -1195,6 +1210,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::ope if (__sb_.open(__s, __mode | ios_base::out) == 0) this->setstate(ios_base::failbit); } +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1252,6 +1268,7 @@ basic_ofstream<_CharT, _Traits>::is_open() const return __sb_.is_open(); } +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE template void basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) @@ -1271,6 +1288,7 @@ basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo else this->setstate(ios_base::failbit); } +#endif template inline _LIBCPP_INLINE_VISIBILITY @@ -1295,8 +1313,10 @@ public: typedef typename traits_type::off_type off_type; basic_fstream(); +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES basic_fstream(basic_fstream&& __rhs); #endif @@ -1308,8 +1328,10 @@ public: basic_filebuf* rdbuf() const; bool is_open() const; +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); +#endif void close(); private: @@ -1323,6 +1345,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream() { } +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE template inline _LIBCPP_INLINE_VISIBILITY basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode) @@ -1340,6 +1363,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openm if (__sb_.open(__s, __mode) == 0) this->setstate(ios_base::failbit); } +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1397,6 +1421,7 @@ basic_fstream<_CharT, _Traits>::is_open() const return __sb_.is_open(); } +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE template void basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) @@ -1416,6 +1441,7 @@ basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod else this->setstate(ios_base::failbit); } +#endif template inline _LIBCPP_INLINE_VISIBILITY diff --git a/include/functional b/include/functional index d14b46bb76af..5ee941763020 100644 --- a/include/functional +++ b/include/functional @@ -504,7 +504,9 @@ struct _LIBCPP_TYPE_VIS_ONLY plus template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -529,7 +531,9 @@ struct _LIBCPP_TYPE_VIS_ONLY minus template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -554,7 +558,9 @@ struct _LIBCPP_TYPE_VIS_ONLY multiplies template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -579,7 +585,9 @@ struct _LIBCPP_TYPE_VIS_ONLY divides template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -604,7 +612,9 @@ struct _LIBCPP_TYPE_VIS_ONLY modulus template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -629,7 +639,9 @@ struct _LIBCPP_TYPE_VIS_ONLY negate template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const - { return -_VSTD::forward<_Tp>(__x); } + _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) + -> decltype (- _VSTD::forward<_Tp>(__x)) + { return - _VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif @@ -654,7 +666,9 @@ struct _LIBCPP_TYPE_VIS_ONLY equal_to template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -679,7 +693,9 @@ struct _LIBCPP_TYPE_VIS_ONLY not_equal_to template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -704,7 +720,9 @@ struct _LIBCPP_TYPE_VIS_ONLY greater template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -731,7 +749,9 @@ struct _LIBCPP_TYPE_VIS_ONLY greater_equal template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -756,7 +776,9 @@ struct _LIBCPP_TYPE_VIS_ONLY less_equal template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -781,7 +803,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_and template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -806,7 +830,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_or template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -831,7 +857,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_not template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const - { return !_VSTD::forward<_Tp>(__x); } + _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) + -> decltype (!_VSTD::forward<_Tp>(__x)) + { return !_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif @@ -856,7 +884,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_and template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -881,7 +911,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_or template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -906,7 +938,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -927,7 +961,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_not template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const - { return ~_VSTD::forward<_Tp>(__x); } + _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) + -> decltype (~_VSTD::forward<_Tp>(__x)) + { return ~_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif @@ -1331,7 +1367,8 @@ template __base<_Rp(_ArgTypes...)>* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); @@ -1357,7 +1394,8 @@ template void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT { - typedef typename _Alloc::template rebind<__func>::other _Ap; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(this, 1); @@ -1367,7 +1405,8 @@ template _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) { - return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); } #ifndef _LIBCPP_NO_RTTI @@ -1429,7 +1468,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> template struct __callable<_Fp, true> { - static const bool value = + static const bool value = is_same::value || is_convertible::type, _Rp>::value; }; @@ -1617,13 +1656,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _ if (__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<_FF> -#else - rebind_alloc<_FF>::other -#endif - _Ap; + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; _Ap __a(__a0); if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value) @@ -1963,27 +1996,27 @@ struct __mu_return }; template -struct _is_valid_bind_return +struct __is_valid_bind_return { static const bool value = false; }; template -struct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> +struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> { static const bool value = __invokable<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; }; template -struct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> +struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> { static const bool value = __invokable<_Fp, typename __mu_return::type...>::value; }; template ::value> + bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> struct __bind_return; template @@ -2153,12 +2186,13 @@ public: typename enable_if < is_convertible >::type, - result_type>::value, + result_type>::value || is_void<_Rp>::value, result_type >::type operator()(_Args&& ...__args) { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } template @@ -2166,12 +2200,13 @@ public: typename enable_if < is_convertible >::type, - result_type>::value, + result_type>::value || is_void<_Rp>::value, result_type >::type operator()(_Args&& ...__args) const { - return base::operator()(_VSTD::forward<_Args>(__args)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } }; @@ -2412,6 +2447,15 @@ struct _LIBCPP_TYPE_VIS_ONLY hash }; #endif + +#if _LIBCPP_STD_VER > 14 +template +result_of_t<_Fn&&(_Args&&...)> +invoke(_Fn&& __f, _Args&&... __args) { + return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); +} +#endif + // struct hash in _LIBCPP_END_NAMESPACE_STD diff --git a/include/future b/include/future index 6fe6f8da5049..5b5afe6e2771 100644 --- a/include/future +++ b/include/future @@ -329,7 +329,7 @@ public: template explicit packaged_task(F&& f); template - explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f); + packaged_task(allocator_arg_t, const Allocator& a, F&& f); ~packaged_task(); // no copy @@ -651,7 +651,6 @@ __assoc_state<_Rp>::set_value(_Arg& __arg) #endif ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed | base::ready; - __lk.unlock(); __cv_.notify_all(); } @@ -672,7 +671,6 @@ __assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg) ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); - __lk.unlock(); } template @@ -733,7 +731,6 @@ __assoc_state<_Rp&>::set_value(_Rp& __arg) #endif __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed | base::ready; - __lk.unlock(); __cv_.notify_all(); } @@ -749,7 +746,6 @@ __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); - __lk.unlock(); } template @@ -783,10 +779,10 @@ __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp(); - typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _A; - typedef allocator_traits<_A> _ATraits; + typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al; + typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; - _A __a(__alloc_); + _Al __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } @@ -809,10 +805,10 @@ template void __assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT { - typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _A; - typedef allocator_traits<_A> _ATraits; + typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al; + typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; - _A __a(__alloc_); + _Al __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } @@ -835,10 +831,10 @@ template void __assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT { - typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _A; - typedef allocator_traits<_A> _ATraits; + typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _Al; + typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; - _A __a(__alloc_); + _Al __a(__alloc_); this->~__assoc_sub_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } @@ -2046,7 +2042,7 @@ public: >::type > _LIBCPP_INLINE_VISIBILITY - explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) + packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), __p_(allocator_arg, __a) {} // ~packaged_task() = default; @@ -2177,7 +2173,7 @@ public: >::type > _LIBCPP_INLINE_VISIBILITY - explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) + packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), __p_(allocator_arg, __a) {} // ~packaged_task() = default; diff --git a/include/iosfwd b/include/iosfwd index d24c227bef79..eccfd349a4a5 100644 --- a/include/iosfwd +++ b/include/iosfwd @@ -180,7 +180,12 @@ typedef fpos u16streampos; typedef fpos u32streampos; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS +#if defined(_NEWLIB_VERSION) +// On newlib, off_t is 'long int' +typedef long int streamoff; // for char_traits in +#else typedef long long streamoff; // for char_traits in +#endif template class _Traits = char_traits<_CharT>, diff --git a/include/iostream b/include/iostream index ddf248411448..136a849777fe 100644 --- a/include/iostream +++ b/include/iostream @@ -46,13 +46,17 @@ extern wostream wclog; _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_HAS_NO_STDIN extern _LIBCPP_FUNC_VIS istream cin; -extern _LIBCPP_FUNC_VIS ostream cout; -extern _LIBCPP_FUNC_VIS ostream cerr; -extern _LIBCPP_FUNC_VIS ostream clog; extern _LIBCPP_FUNC_VIS wistream wcin; +#endif +#ifndef _LIBCPP_HAS_NO_STDOUT +extern _LIBCPP_FUNC_VIS ostream cout; extern _LIBCPP_FUNC_VIS wostream wcout; +#endif +extern _LIBCPP_FUNC_VIS ostream cerr; extern _LIBCPP_FUNC_VIS wostream wcerr; +extern _LIBCPP_FUNC_VIS ostream clog; extern _LIBCPP_FUNC_VIS wostream wclog; _LIBCPP_END_NAMESPACE_STD diff --git a/include/iterator b/include/iterator index bcf142a6c833..c06ef8f6777d 100644 --- a/include/iterator +++ b/include/iterator @@ -214,7 +214,7 @@ public: typedef traits traits_type; typedef basic_istream istream_type; - istream_iterator(); + constexpr istream_iterator(); istream_iterator(istream_type& s); istream_iterator(const istream_iterator& x); ~istream_iterator(); @@ -575,7 +575,7 @@ public: _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const - {return current[-__n-1];} + {return *(*this + __n);} }; template @@ -765,7 +765,7 @@ private: istream_type* __in_stream_; _Tp __value_; public: - _LIBCPP_INLINE_VISIBILITY istream_iterator() : __in_stream_(0) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {} _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(&__s) { if (!(*__in_stream_ >> __value_)) @@ -1241,7 +1241,7 @@ private: template friend class __wrap_iter; template friend class basic_string; - template friend class vector; + template friend class _LIBCPP_TYPE_VIS_ONLY vector; template friend @@ -1580,29 +1580,29 @@ end(const _Cp& __c) #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) #if _LIBCPP_STD_VER > 14 -template -constexpr auto size(const _C& __c) -> decltype(__c.size()) { return __c.size(); } +template +constexpr auto size(const _Cont& __c) -> decltype(__c.size()) { return __c.size(); } -template -constexpr size_t size(const _Tp (&__array)[_N]) noexcept { return _N; } +template +constexpr size_t size(const _Tp (&__array)[_Sz]) noexcept { return _Sz; } -template -constexpr auto empty(const _C& __c) -> decltype(__c.empty()) { return __c.empty(); } +template +constexpr auto empty(const _Cont& __c) -> decltype(__c.empty()) { return __c.empty(); } -template -constexpr bool empty(const _Tp (&__array)[_N]) noexcept { return false; } +template +constexpr bool empty(const _Tp (&__array)[_Sz]) noexcept { return false; } template constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; } -template constexpr -auto data(_C& __c) -> decltype(__c.data()) { return __c.data(); } +template constexpr +auto data(_Cont& __c) -> decltype(__c.data()) { return __c.data(); } -template constexpr -auto data(const _C& __c) -> decltype(__c.data()) { return __c.data(); } +template constexpr +auto data(const _Cont& __c) -> decltype(__c.data()) { return __c.data(); } -template -constexpr _Tp* data(_Tp (&__array)[_N]) noexcept { return __array; } +template +constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; } template constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); } diff --git a/include/list b/include/list index 13f8a53bf25f..14201a80e348 100644 --- a/include/list +++ b/include/list @@ -118,8 +118,7 @@ public: void resize(size_type sz, const value_type& c); void swap(list&) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value); + noexcept(allocator_traits::is_always_equal::value); // C++17 void clear() noexcept; void splice(const_iterator position, list& x); @@ -226,7 +225,7 @@ struct __list_node _Tp __value_; }; -template class _LIBCPP_TYPE_VIS_ONLY list; +template > class _LIBCPP_TYPE_VIS_ONLY list; template class __list_imp; template class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator; @@ -515,13 +514,7 @@ protected: typedef __list_const_iterator const_iterator; typedef __list_node_base __node_base; typedef __list_node __node; - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__node> -#else - rebind_alloc<__node>::other -#endif - __node_allocator; + typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator; typedef allocator_traits<__node_allocator> __node_alloc_traits; typedef typename __node_alloc_traits::pointer __node_pointer; typedef typename __node_alloc_traits::pointer __node_const_pointer; @@ -529,13 +522,7 @@ protected: typedef typename __alloc_traits::const_pointer const_pointer; typedef typename __alloc_traits::difference_type difference_type; - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__node_base> -#else - rebind_alloc<__node_base>::other -#endif - __node_base_allocator; + typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator; typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer; __node_base __end_; @@ -605,8 +592,12 @@ protected: } void swap(__list_imp& __c) - _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value); +#endif _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __list_imp& __c) @@ -622,24 +613,6 @@ protected: __node_alloc_traits::propagate_on_container_move_assignment::value>());} private: - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y) - _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - {__swap_alloc(__x, __y, integral_constant());} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value) - { - using _VSTD::swap; - swap(__x, __y); - } - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type) - _NOEXCEPT - {} - _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __list_imp& __c, true_type) { @@ -740,15 +713,19 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT template void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) - _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value) +#endif { _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || this->__node_alloc() == __c.__node_alloc(), "list::swap: Either propagate_on_container_swap must be true" " or the allocators must compare equal"); using _VSTD::swap; - __swap_alloc(__node_alloc(), __c.__node_alloc()); + __swap_allocator(__node_alloc(), __c.__node_alloc()); swap(__sz(), __c.__sz()); swap(__end_, __c.__end_); if (__sz() == 0) @@ -799,7 +776,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) #endif } -template > +template */> class _LIBCPP_TYPE_VIS_ONLY list : private __list_imp<_Tp, _Alloc> { @@ -984,8 +961,12 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(list& __c) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) +#endif {base::swap(__c);} _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT {base::clear();} @@ -1480,7 +1461,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, try { #endif // _LIBCPP_NO_EXCEPTIONS - for (++__f; __f != __l; ++__f, ++__e, ++__ds) + for (++__f; __f != __l; ++__f, (void) ++__e, (void) ++__ds) { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); diff --git a/include/locale b/include/locale index 0d0100204204..e683ba33ae9d 100644 --- a/include/locale +++ b/include/locale @@ -198,7 +198,8 @@ template class messages_byname; // include of once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html // has had a chance to bake for a bit #include -#elif !defined(__ANDROID__) +#endif +#ifdef _LIBCPP_HAS_CATOPEN #include #endif @@ -216,7 +217,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if defined(__APPLE__) || defined(__FreeBSD__) # define _LIBCPP_GET_C_LOCALE 0 -#elif defined(__NetBSD__) +#elif defined(__CloudABI__) || defined(__NetBSD__) # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE #else # define _LIBCPP_GET_C_LOCALE __cloc() @@ -235,7 +236,7 @@ typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii; // locale. Linux, not so much. The following functions avoid the locale when // that's possible and otherwise do the wrong thing. FIXME. #if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) || \ - defined(_NEWLIB_VERSION) + defined(_NEWLIB_VERSION) || defined(__GLIBC__) #ifdef _LIBCPP_LOCALE__L_EXTENSIONS decltype(MB_CUR_MAX_L(_VSTD::declval())) @@ -1190,7 +1191,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) #else - if (__sscanf_l(__buf.c_str(), __cloc(), "%p", &__v) != 1) + if (__sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) #endif __err = ios_base::failbit; // EOF checked @@ -1560,7 +1561,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v); + int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); @@ -1585,12 +1586,12 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, this->__format_int(__fmt+1, __len, true, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) - + 1; + + 2; char __nar[__nbuf]; #ifdef _LIBCPP_LOCALE__L_EXTENSIONS int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v); + int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); @@ -1620,7 +1621,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v); + int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); @@ -1650,7 +1651,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v); + int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); @@ -1682,14 +1683,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); #else - __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, - (int)__iob.precision(), __v); + __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, + (int)__iob.precision(), __v); #endif else #ifdef _LIBCPP_LOCALE__L_EXTENSIONS __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v); + __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif unique_ptr __nbh(0, free); if (__nc > static_cast(__nbuf-1)) @@ -1698,14 +1699,13 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); #else - __nc = __asprintf_l(&__nb, __cloc(), __fmt, - (int)__iob.precision(), __v); + __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); #endif else #ifdef _LIBCPP_LOCALE__L_EXTENSIONS __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - __nc = __asprintf_l(&__nb, __cloc(), __fmt, (int)__iob.precision(), __v); + __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); #endif if (__nb == 0) __throw_bad_alloc(); @@ -1751,14 +1751,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); #else - __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, - (int)__iob.precision(), __v); + __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, + (int)__iob.precision(), __v); #endif else #ifdef _LIBCPP_LOCALE__L_EXTENSIONS __nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - __nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v); + __nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif unique_ptr __nbh(0, free); if (__nc > static_cast(__nbuf-1)) @@ -1767,14 +1767,13 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); #else - __nc = __asprintf_l(&__nb, __cloc(), __fmt, - (int)__iob.precision(), __v); + __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); #endif else #ifdef _LIBCPP_LOCALE__L_EXTENSIONS __nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - __nc = __asprintf_l(&__nb, __cloc(), __fmt, __v); + __nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif if (__nb == 0) __throw_bad_alloc(); @@ -1814,7 +1813,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #else - int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v); + int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); #endif char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); @@ -3527,7 +3526,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, #ifdef _LIBCPP_LOCALE__L_EXTENSIONS __n = static_cast(asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units)); #else - __n = __asprintf_l(&__bb, __cloc(), "%.0Lf", __units); + __n = __asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units); #endif if (__bb == 0) __throw_bad_alloc(); @@ -3681,14 +3680,14 @@ template typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string& __nm, const locale&) const { -#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION) - return -1; -#else // _WIN32 || __ANDROID__ +#ifdef _LIBCPP_HAS_CATOPEN catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); if (__cat != -1) __cat = static_cast((static_cast(__cat) >> 1)); return __cat; -#endif // _WIN32 || __ANDROID__ +#else // !_LIBCPP_HAS_CATOPEN + return -1; +#endif // _LIBCPP_HAS_CATOPEN } template @@ -3696,9 +3695,7 @@ typename messages<_CharT>::string_type messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { -#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION) - return __dflt; -#else // _WIN32 +#ifdef _LIBCPP_HAS_CATOPEN string __ndflt; __narrow_to_utf8()(back_inserter(__ndflt), __dflt.c_str(), @@ -3711,19 +3708,21 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, __widen_from_utf8()(back_inserter(__w), __n, __n + strlen(__n)); return __w; -#endif // _WIN32 +#else // !_LIBCPP_HAS_CATOPEN + return __dflt; +#endif // _LIBCPP_HAS_CATOPEN } template void messages<_CharT>::do_close(catalog __c) const { -#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) +#ifdef _LIBCPP_HAS_CATOPEN if (__c != -1) __c <<= 1; nl_catd __cat = (nl_catd)__c; catclose(__cat); -#endif // !_WIN32 +#endif // _LIBCPP_HAS_CATOPEN } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages) diff --git a/include/map b/include/map index 5c3969acdd28..eb6b8ed05308 100644 --- a/include/map +++ b/include/map @@ -135,16 +135,32 @@ public: void insert(InputIterator first, InputIterator last); void insert(initializer_list il); + template + pair try_emplace(const key_type& k, Args&&... args); // C++17 + template + pair try_emplace(key_type&& k, Args&&... args); // C++17 + template + iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 + template + iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 + template + pair insert_or_assign(const key_type& k, M&& obj); // C++17 + template + pair insert_or_assign(key_type&& k, M&& obj); // C++17 + template + iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 + template + iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 + iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; void swap(map& m) - noexcept( - __is_nothrow_swappable::value && - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value)); + noexcept(allocator_traits::is_always_equal::value && + __is_nothrow_swappable::value); // C++17 // observers: allocator_type get_allocator() const noexcept; @@ -330,15 +346,14 @@ public: void insert(initializer_list il); iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; void swap(multimap& m) - noexcept( - __is_nothrow_swappable::value && - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value)); + noexcept(allocator_traits::is_always_equal::value && + __is_nothrow_swappable::value); // C++17 // observers: allocator_type get_allocator() const noexcept; @@ -426,6 +441,7 @@ swap(multimap& x, #include #include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -433,10 +449,8 @@ swap(multimap& x, _LIBCPP_BEGIN_NAMESPACE_STD -template ::value -#if __has_feature(is_final) - && !__is_final(_Compare) -#endif +template ::value && !__libcpp_is_final<_Compare>::value > class __map_value_compare : private _Compare @@ -461,6 +475,12 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return static_cast(*this)(__x, __y.__cc.first);} + void swap(__map_value_compare&__y) + _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) + { + using _VSTD::swap; + swap(static_cast(*this), static_cast(__y)); + } #if _LIBCPP_STD_VER > 11 template @@ -503,7 +523,13 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return comp(__x, __y.__cc.first);} - + void swap(__map_value_compare&__y) + _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) + { + using _VSTD::swap; + swap(comp, __y.comp); + } + #if _LIBCPP_STD_VER > 11 template _LIBCPP_INLINE_VISIBILITY @@ -519,6 +545,16 @@ public: #endif }; +template +inline _LIBCPP_INLINE_VISIBILITY +void +swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, + __map_value_compare<_Key, _CP, _Compare, __b>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) +{ + __x.swap(__y); +} + template class __map_node_destructor { @@ -644,14 +680,25 @@ struct __value_type #endif +template +struct __extract_key_value_types; + +template +struct __extract_key_value_types<__value_type<_Key, _Tp> > +{ + typedef _Key const __key_type; + typedef _Tp __mapped_type; +}; + template class _LIBCPP_TYPE_VIS_ONLY __map_iterator { _TreeIterator __i_; typedef typename _TreeIterator::__pointer_traits __pointer_traits; - typedef const typename _TreeIterator::value_type::value_type::first_type __key_type; - typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type; + typedef typename _TreeIterator::value_type __value_type; + typedef typename __extract_key_value_types<__value_type>::__key_type __key_type; + typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type; public: typedef bidirectional_iterator_tag iterator_category; typedef pair<__key_type, __mapped_type> value_type; @@ -715,8 +762,9 @@ class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator _TreeIterator __i_; typedef typename _TreeIterator::__pointer_traits __pointer_traits; - typedef const typename _TreeIterator::value_type::value_type::first_type __key_type; - typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type; + typedef typename _TreeIterator::value_type __value_type; + typedef typename __extract_key_value_types<__value_type>::__key_type __key_type; + typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type; public: typedef bidirectional_iterator_tag iterator_category; typedef pair<__key_type, __mapped_type> value_type; @@ -736,10 +784,9 @@ public: _LIBCPP_INLINE_VISIBILITY __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} _LIBCPP_INLINE_VISIBILITY - __map_const_iterator( - __map_iterator __i) - _NOEXCEPT - : __i_(__i.__i_) {} + __map_const_iterator(__map_iterator< + typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT + : __i_(__i.__i_) {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __i_->__cc;} @@ -811,13 +858,8 @@ private: typedef _VSTD::__value_type __value_type; typedef __map_value_compare __vc; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__value_type> -#else - rebind_alloc<__value_type>::other -#endif - __allocator_type; + typedef typename __rebind_alloc_helper, + __value_type>::type __allocator_type; typedef __tree<__value_type, __vc, __allocator_type> __base; typedef typename __base::__node_traits __node_traits; typedef allocator_traits __alloc_traits; @@ -829,7 +871,7 @@ public: typedef typename __alloc_traits::const_pointer const_pointer; typedef typename __alloc_traits::size_type size_type; typedef typename __alloc_traits::difference_type difference_type; - typedef __map_iterator iterator; + typedef __map_iterator iterator; typedef __map_const_iterator const_iterator; typedef _VSTD::reverse_iterator reverse_iterator; typedef _VSTD::reverse_iterator const_reverse_iterator; @@ -1070,9 +1112,125 @@ public: #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 14 +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_HAS_NO_VARIADICS + template + _LIBCPP_INLINE_VISIBILITY + pair try_emplace(const key_type& __k, _Args&&... __args) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + return _VSTD::make_pair(__p, false); + else + return _VSTD::make_pair( + emplace_hint(__p, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), + true); + } + + template + _LIBCPP_INLINE_VISIBILITY + pair try_emplace(key_type&& __k, _Args&&... __args) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + return _VSTD::make_pair(__p, false); + else + return _VSTD::make_pair( + emplace_hint(__p, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), + true); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + return __p; + else + return emplace_hint(__p, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + return __p; + else + return emplace_hint(__p, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); + } + + template + _LIBCPP_INLINE_VISIBILITY + pair insert_or_assign(const key_type& __k, _Vp&& __v) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + { + __p->second = _VSTD::forward<_Vp>(__v); + return _VSTD::make_pair(__p, false); + } + return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true); + } + + template + _LIBCPP_INLINE_VISIBILITY + pair insert_or_assign(key_type&& __k, _Vp&& __v) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + { + __p->second = _VSTD::forward<_Vp>(__v); + return _VSTD::make_pair(__p, false); + } + return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + { + __p->second = _VSTD::forward<_Vp>(__v); + return __p; + } + return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v)); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) + { + iterator __p = lower_bound(__k); + if ( __p != end() && !key_comp()(__k, __p->first)) + { + __p->second = _VSTD::forward<_Vp>(__v); + return __p; + } + return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)); + } +#endif +#endif +#endif + _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} _LIBCPP_INLINE_VISIBILITY + iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} + _LIBCPP_INLINE_VISIBILITY size_type erase(const key_type& __k) {return __tree_.__erase_unique(__k);} _LIBCPP_INLINE_VISIBILITY @@ -1108,7 +1266,7 @@ public: template _LIBCPP_INLINE_VISIBILITY typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type - count(const _K2& __k) {return __tree_.__count_unique(__k);} + count(const _K2& __k) const {return __tree_.__count_unique(__k);} #endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) @@ -1557,13 +1715,8 @@ private: typedef _VSTD::__value_type __value_type; typedef __map_value_compare __vc; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__value_type> -#else - rebind_alloc<__value_type>::other -#endif - __allocator_type; + typedef typename __rebind_alloc_helper, + __value_type>::type __allocator_type; typedef __tree<__value_type, __vc, __allocator_type> __base; typedef typename __base::__node_traits __node_traits; typedef allocator_traits __alloc_traits; @@ -1810,6 +1963,8 @@ public: _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} _LIBCPP_INLINE_VISIBILITY + iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} + _LIBCPP_INLINE_VISIBILITY size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __f, const_iterator __l) @@ -1844,7 +1999,7 @@ public: template _LIBCPP_INLINE_VISIBILITY typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type - count(const _K2& __k) {return __tree_.__count_multi(__k);} + count(const _K2& __k) const {return __tree_.__count_multi(__k);} #endif _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) diff --git a/include/memory b/include/memory index 662faa0a74ff..22311aaace92 100644 --- a/include/memory +++ b/include/memory @@ -75,6 +75,8 @@ struct allocator_traits | false_type propagate_on_container_move_assignment; typedef Alloc::propagate_on_container_swap | false_type propagate_on_container_swap; + typedef Alloc::is_always_equal + | is_empty is_always_equal; template using rebind_alloc = Alloc::rebind::other | Alloc; template using rebind_traits = allocator_traits>; @@ -615,6 +617,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #endif #include <__undef_min_max> +#include <__undef___deallocate> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -622,6 +625,18 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); _LIBCPP_BEGIN_NAMESPACE_STD +template +inline _LIBCPP_ALWAYS_INLINE +_ValueType __libcpp_relaxed_load(_ValueType const* __value) { +#if !defined(_LIBCPP_HAS_NO_THREADS) && \ + defined(__ATOMIC_RELAXED) && \ + (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407) + return __atomic_load_n(__value, __ATOMIC_RELAXED); +#else + return *__value; +#endif +} + // addressof moved to <__functional_base> template class allocator; @@ -1143,6 +1158,29 @@ struct __propagate_on_container_swap<_Alloc, true> typedef typename _Alloc::propagate_on_container_swap type; }; +template +struct __has_is_always_equal +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename _Up::is_always_equal* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; +}; + +template ::value> +struct __is_always_equal +{ + typedef typename _VSTD::is_empty<_Alloc>::type type; +}; + +template +struct __is_always_equal<_Alloc, true> +{ + typedef typename _Alloc::is_always_equal type; +}; + template ::value> struct __has_rebind_other { @@ -1422,6 +1460,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits propagate_on_container_move_assignment; typedef typename __propagate_on_container_swap::type propagate_on_container_swap; + typedef typename __is_always_equal::type + is_always_equal; #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES template using rebind_alloc = @@ -1520,8 +1560,42 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) { ptrdiff_t _Np = __end1 - __begin1; - _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); - __begin2 += _Np; + if (_Np > 0) + { + _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); + __begin2 += _Np; + } + } + + template + _LIBCPP_INLINE_VISIBILITY + static + void + __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) + { + for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) + construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1); + } + + template + _LIBCPP_INLINE_VISIBILITY + static + typename enable_if + < + (is_same >::value + || !__has_construct::value) && + is_trivially_move_constructible<_Tp>::value, + void + >::type + __construct_range_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) + { + typedef typename remove_const<_Tp>::type _Vp; + ptrdiff_t _Np = __end1 - __begin1; + if (_Np > 0) + { + _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp)); + __begin2 += _Np; + } } template @@ -1551,7 +1625,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits { ptrdiff_t _Np = __end1 - __begin1; __end2 -= _Np; - _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp)); + if (_Np > 0) + _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp)); } private: @@ -1606,6 +1681,16 @@ private: {return __a;} }; +template +struct __rebind_alloc_helper +{ +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + typedef typename _Traits::template rebind_alloc<_Tp> type; +#else + typedef typename _Traits::template rebind_alloc<_Tp>::other type; +#endif +}; + // allocator template @@ -1621,6 +1706,7 @@ public: typedef _Tp value_type; typedef true_type propagate_on_container_move_assignment; + typedef true_type is_always_equal; template struct rebind {typedef allocator<_Up> other;}; @@ -1713,6 +1799,7 @@ public: typedef const _Tp value_type; typedef true_type propagate_on_container_move_assignment; + typedef true_type is_always_equal; template struct rebind {typedef allocator<_Up> other;}; @@ -1816,6 +1903,9 @@ public: _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) {raw_storage_iterator __t(*this); ++__x_; return __t;} +#if _LIBCPP_STD_VER >= 14 + _LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; } +#endif }; template @@ -1905,14 +1995,9 @@ public: template ::type, typename remove_cv<_T2>::type>::value, bool = is_empty<_T1>::value -#if __has_feature(is_final) - && !__is_final(_T1) -#endif - , + && !__libcpp_is_final<_T1>::value, bool = is_empty<_T2>::value -#if __has_feature(is_final) - && !__is_final(_T2) -#endif + && !__libcpp_is_final<_T2>::value > struct __libcpp_compressed_pair_switch; @@ -1950,11 +2035,11 @@ public: typedef const typename remove_reference<_T1>::type& _T1_const_reference; typedef const typename remove_reference<_T2>::type& _T2_const_reference; - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} + _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) - : __first_(_VSTD::forward<_T1_param>(__t1)) {} + : __first_(_VSTD::forward<_T1_param>(__t1)), __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) - : __second_(_VSTD::forward<_T2_param>(__t2)) {} + : __first_(), __second_(_VSTD::forward<_T2_param>(__t2)) {} _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} @@ -2043,9 +2128,9 @@ public: typedef const _T1& _T1_const_reference; typedef const typename remove_reference<_T2>::type& _T2_const_reference; - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} + _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) - : _T1(_VSTD::forward<_T1_param>(__t1)) {} + : _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) : __second_(_VSTD::forward<_T2_param>(__t2)) {} _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) @@ -2133,11 +2218,11 @@ public: typedef const typename remove_reference<_T1>::type& _T1_const_reference; typedef const _T2& _T2_const_reference; - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} + _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) : __first_(_VSTD::forward<_T1_param>(__t1)) {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) - : _T2(_VSTD::forward<_T2_param>(__t2)) {} + : _T2(_VSTD::forward<_T2_param>(__t2)), __first_() {} _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && is_nothrow_move_constructible<_T2>::value) @@ -2890,8 +2975,8 @@ operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) { typedef typename unique_ptr<_T1, _D1>::pointer _P1; typedef typename unique_ptr<_T2, _D2>::pointer _P2; - typedef typename common_type<_P1, _P2>::type _V; - return less<_V>()(__x.get(), __y.get()); + typedef typename common_type<_P1, _P2>::type _Vp; + return less<_Vp>()(__x.get(), __y.get()); } template @@ -3485,8 +3570,8 @@ uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) try { #endif - for (; __f != __l; ++__f, ++__r) - ::new(&*__r) value_type(*__f); + for (; __f != __l; ++__f, (void) ++__r) + ::new (static_cast(_VSTD::addressof(*__r))) value_type(*__f); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -3509,8 +3594,8 @@ uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) try { #endif - for (; __n > 0; ++__f, ++__r, --__n) - ::new(&*__r) value_type(*__f); + for (; __n > 0; ++__f, (void) ++__r, (void) --__n) + ::new (static_cast(_VSTD::addressof(*__r))) value_type(*__f); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -3534,7 +3619,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) { #endif for (; __f != __l; ++__f) - ::new(&*__f) value_type(__x); + ::new (static_cast(_VSTD::addressof(*__f))) value_type(__x); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -3556,8 +3641,8 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) try { #endif - for (; __n > 0; ++__f, --__n) - ::new(&*__f) value_type(__x); + for (; __n > 0; ++__f, (void) --__n) + ::new (static_cast(_VSTD::addressof(*__f))) value_type(__x); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -3599,7 +3684,9 @@ public: void __add_shared() _NOEXCEPT; bool __release_shared() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} + long use_count() const _NOEXCEPT { + return __libcpp_relaxed_load(&__shared_owners_) + 1; + } }; class _LIBCPP_TYPE_VIS __shared_weak_count @@ -3677,11 +3764,11 @@ template void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT { - typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _A; - typedef allocator_traits<_A> _ATraits; + typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _Al; + typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; - _A __a(__data_.second()); + _Al __a(__data_.second()); __data_.second().~_Alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } @@ -3746,10 +3833,10 @@ template void __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT { - typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _A; - typedef allocator_traits<_A> _ATraits; + typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _Al; + typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; - _A __a(__data_.first()); + _Al __a(__data_.first()); __data_.first().~_Alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } @@ -4001,11 +4088,15 @@ private: __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT { if (__e) - __e->__weak_this_ = *this; + { + __e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast(__e)); + __e->__weak_this_.__cntrl_ = __cntrl_; + __cntrl_->__add_weak(); + } } _LIBCPP_INLINE_VISIBILITY - void __enable_weak_this(const void*) _NOEXCEPT {} + void __enable_weak_this(const volatile void*) _NOEXCEPT {} template friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; template friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; @@ -4235,9 +4326,16 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, >::type) : __ptr_(__r.get()) { - typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; - __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); - __enable_weak_this(__r.get()); +#if _LIBCPP_STD_VER > 11 + if (__ptr_ == nullptr) + __cntrl_ = nullptr; + else +#endif + { + typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; + __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); + __enable_weak_this(__r.get()); + } __r.release(); } @@ -4257,11 +4355,18 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, >::type) : __ptr_(__r.get()) { - typedef __shared_ptr_pointer<_Yp*, - reference_wrapper::type>, - allocator<_Yp> > _CntrlBlk; - __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); - __enable_weak_this(__r.get()); +#if _LIBCPP_STD_VER > 11 + if (__ptr_ == nullptr) + __cntrl_ = nullptr; + else +#endif + { + typedef __shared_ptr_pointer<_Yp*, + reference_wrapper::type>, + allocator<_Yp> > _CntrlBlk; + __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); + __enable_weak_this(__r.get()); + } __r.release(); } @@ -4745,8 +4850,8 @@ inline _LIBCPP_INLINE_VISIBILITY bool operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT { - typedef typename common_type<_Tp*, _Up*>::type _V; - return less<_V>()(__x.get(), __y.get()); + typedef typename common_type<_Tp*, _Up*>::type _Vp; + return less<_Vp>()(__x.get(), __y.get()); } template @@ -5438,6 +5543,38 @@ undeclare_reachable(_Tp* __p) _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); +// --- Helper for container swap -- +template +_LIBCPP_INLINE_VISIBILITY +void __swap_allocator(_Alloc & __a1, _Alloc & __a2) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) +#endif +{ + __swap_allocator(__a1, __a2, + integral_constant::propagate_on_container_swap::value>()); +} + +template +_LIBCPP_INLINE_VISIBILITY +void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) +#endif +{ + using _VSTD::swap; + swap(__a1, __a2); +} + +template +_LIBCPP_INLINE_VISIBILITY +void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} + + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_MEMORY diff --git a/include/module.modulemap b/include/module.modulemap index 6aeb23f028bf..3c0700eca443 100644 --- a/include/module.modulemap +++ b/include/module.modulemap @@ -469,4 +469,5 @@ module std [system] { module __tree { header "__tree" export * } module __tuple { header "__tuple" export * } module __undef_min_max { header "__undef_min_max" export * } + module __undef___deallocate { header "__undef___deallocate" export * } } diff --git a/include/mutex b/include/mutex index e2a0daa3eab5..373d75b09789 100644 --- a/include/mutex +++ b/include/mutex @@ -175,6 +175,7 @@ template #include <__config> #include <__mutex_base> #include +#include #ifndef _LIBCPP_HAS_NO_VARIADICS #include #endif @@ -442,7 +443,11 @@ void call_once(once_flag&, _Callable&&, _Args&&...); template _LIBCPP_INLINE_VISIBILITY -void call_once(once_flag&, _Callable); +void call_once(once_flag&, _Callable&); + +template +_LIBCPP_INLINE_VISIBILITY +void call_once(once_flag&, const _Callable&); #endif // _LIBCPP_HAS_NO_VARIADICS @@ -465,7 +470,11 @@ private: #else // _LIBCPP_HAS_NO_VARIADICS template friend - void call_once(once_flag&, _Callable); + void call_once(once_flag&, _Callable&); + + template + friend + void call_once(once_flag&, const _Callable&); #endif // _LIBCPP_HAS_NO_VARIADICS }; @@ -474,15 +483,10 @@ private: template class __call_once_param { - _Fp __f_; + _Fp& __f_; public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY - explicit __call_once_param(_Fp&& __f) : __f_(_VSTD::move(__f)) {} -#else - _LIBCPP_INLINE_VISIBILITY - explicit __call_once_param(const _Fp& __f) : __f_(__f) {} -#endif + explicit __call_once_param(_Fp& __f) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY void operator()() @@ -496,7 +500,7 @@ private: _LIBCPP_INLINE_VISIBILITY void __execute(__tuple_indices<_Indices...>) { - __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...); + __invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...); } }; @@ -505,15 +509,10 @@ private: template class __call_once_param { - _Fp __f_; + _Fp& __f_; public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY - explicit __call_once_param(_Fp&& __f) : __f_(_VSTD::move(__f)) {} -#else - _LIBCPP_INLINE_VISIBILITY - explicit __call_once_param(const _Fp& __f) : __f_(__f) {} -#endif + explicit __call_once_param(_Fp& __f) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY void operator()() @@ -541,11 +540,11 @@ inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) { - if (__flag.__state_ != ~0ul) + if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul) { - typedef tuple::type, typename decay<_Args>::type...> _Gp; - __call_once_param<_Gp> __p(_Gp(__decay_copy(_VSTD::forward<_Callable>(__func)), - __decay_copy(_VSTD::forward<_Args>(__args))...)); + typedef tuple<_Callable&&, _Args&&...> _Gp; + _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...); + __call_once_param<_Gp> __p(__f); __call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>); } } @@ -555,15 +554,27 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) template inline _LIBCPP_INLINE_VISIBILITY void -call_once(once_flag& __flag, _Callable __func) +call_once(once_flag& __flag, _Callable& __func) { - if (__flag.__state_ != ~0ul) + if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul) { __call_once_param<_Callable> __p(__func); __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); } } +template +inline _LIBCPP_INLINE_VISIBILITY +void +call_once(once_flag& __flag, const _Callable& __func) +{ + if (__flag.__state_ != ~0ul) + { + __call_once_param __p(__func); + __call_once(__flag.__state_, &__p, &__call_once_proxy); + } +} + #endif // _LIBCPP_HAS_NO_VARIADICS _LIBCPP_END_NAMESPACE_STD diff --git a/include/new b/include/new index a710ed93fb43..d2b2ae648b48 100644 --- a/include/new +++ b/include/new @@ -50,11 +50,13 @@ new_handler get_new_handler() noexcept; void* operator new(std::size_t size); // replaceable void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable void operator delete(void* ptr) noexcept; // replaceable +void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14 void operator delete(void* ptr, const std::nothrow_t&) noexcept; // replaceable void* operator new[](std::size_t size); // replaceable void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable void operator delete[](void* ptr) noexcept; // replaceable +void operator delete[](void* ptr, std::size_t size) noexcept; // replaceable, C++14 void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // replaceable void* operator new (std::size_t size, void* ptr) noexcept; @@ -68,6 +70,8 @@ void operator delete[](void* ptr, void*) noexcept; #include #include +#include <__undef___deallocate> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -132,6 +136,10 @@ _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz) _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; _LIBCPP_NEW_DELETE_VIS void operator delete(void* __p) _NOEXCEPT; _LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; +#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \ + (defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309) +_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; +#endif _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz) #if !__has_feature(cxx_noexcept) @@ -141,6 +149,10 @@ _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz) _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; _LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p) _NOEXCEPT; _LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; +#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \ + (defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309) +_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; +#endif inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} diff --git a/include/ostream b/include/ostream index a7af2994b6b9..f55fd40856ec 100644 --- a/include/ostream +++ b/include/ostream @@ -1004,7 +1004,7 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { sentry __s(*this); - if (__s) + if (!this->fail()) { if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) this->setstate(ios_base::failbit); @@ -1018,7 +1018,7 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { sentry __s(*this); - if (__s) + if (!this->fail()) { if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) this->setstate(ios_base::failbit); diff --git a/include/queue b/include/queue index bdfd70603553..6f49c87acdc5 100644 --- a/include/queue +++ b/include/queue @@ -177,7 +177,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS_ONLY queue; +template > class _LIBCPP_TYPE_VIS_ONLY queue; template _LIBCPP_INLINE_VISIBILITY @@ -189,7 +189,7 @@ _LIBCPP_INLINE_VISIBILITY bool operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); -template > +template */> class _LIBCPP_TYPE_VIS_ONLY queue { public: diff --git a/include/random b/include/random index a8d21a224dfa..64382a3d9aa6 100644 --- a/include/random +++ b/include/random @@ -1634,9 +1634,10 @@ class piecewise_linear_distribution #include <__config> #include +#include +#include #include #include -#include #include #include #include @@ -1644,7 +1645,6 @@ class piecewise_linear_distribution #include #include #include -#include #include <__undef_min_max> @@ -3475,9 +3475,9 @@ typedef shuffle_order_engine knuth_b; class _LIBCPP_TYPE_VIS random_device { -#if !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)) +#ifdef _LIBCPP_USING_DEV_RANDOM int __f_; -#endif // !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)) +#endif // defined(_LIBCPP_USING_DEV_RANDOM) public: // types typedef unsigned result_type; diff --git a/include/ratio b/include/ratio index 48dcd81c1a72..f623a062f2ce 100644 --- a/include/ratio +++ b/include/ratio @@ -21,8 +21,8 @@ template class ratio { public: - static const intmax_t num; - static const intmax_t den; + static constexpr intmax_t num; + static constexpr intmax_t den; typedef ratio type; }; @@ -236,19 +236,22 @@ class _LIBCPP_TYPE_VIS_ONLY ratio static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range"); static_assert(_Den != 0, "ratio divide by 0"); static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range"); - static const intmax_t __na = __static_abs<_Num>::value; - static const intmax_t __da = __static_abs<_Den>::value; - static const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value; - static const intmax_t __gcd = __static_gcd<__na, __da>::value; + static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value; + static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value; + static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value; + static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value; public: - static const intmax_t num = __s * __na / __gcd; - static const intmax_t den = __da / __gcd; + static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd; + static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd; typedef ratio type; }; -template const intmax_t ratio<_Num, _Den>::num; -template const intmax_t ratio<_Num, _Den>::den; +template +_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num; + +template +_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den; template struct __is_ratio : false_type {}; template struct __is_ratio > : true_type {}; @@ -398,11 +401,11 @@ struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract template struct _LIBCPP_TYPE_VIS_ONLY ratio_equal - : public integral_constant {}; + : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {}; template struct _LIBCPP_TYPE_VIS_ONLY ratio_not_equal - : public integral_constant::value> {}; + : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {}; // ratio_less @@ -461,19 +464,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> template struct _LIBCPP_TYPE_VIS_ONLY ratio_less - : public integral_constant::value> {}; + : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {}; template struct _LIBCPP_TYPE_VIS_ONLY ratio_less_equal - : public integral_constant::value> {}; + : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {}; template struct _LIBCPP_TYPE_VIS_ONLY ratio_greater - : public integral_constant::value> {}; + : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {}; template struct _LIBCPP_TYPE_VIS_ONLY ratio_greater_equal - : public integral_constant::value> {}; + : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {}; template struct __ratio_gcd diff --git a/include/regex b/include/regex index 690213a978d8..bd48fb8da04b 100644 --- a/include/regex +++ b/include/regex @@ -1947,7 +1947,8 @@ template void __l_anchor<_CharT>::__exec(__state& __s) const { - if (__s.__at_first_ && __s.__current_ == __s.__first_) + if (__s.__at_first_ && __s.__current_ == __s.__first_ && + !(__s.__flags_ & regex_constants::match_not_bol)) { __s.__do_ = __state::__accept_but_not_consume; __s.__node_ = this->first(); @@ -1981,7 +1982,8 @@ template void __r_anchor<_CharT>::__exec(__state& __s) const { - if (__s.__current_ == __s.__last_) + if (__s.__current_ == __s.__last_ && + !(__s.__flags_ & regex_constants::match_not_eol)) { __s.__do_ = __state::__accept_but_not_consume; __s.__node_ = this->first(); @@ -2599,9 +2601,7 @@ public: assign(_ForwardIterator __first, _ForwardIterator __last, flag_type __f = regex_constants::ECMAScript) { - __member_init(__f); - __parse(__first, __last); - return *this; + return assign(basic_regex(__first, __last, __f)); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -5603,12 +5603,17 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma( __node* __st = __start_.get(); if (__st) { + sub_match __unmatched; + __unmatched.first = __last; + __unmatched.second = __last; + __unmatched.matched = false; + __states.push_back(__state()); __states.back().__do_ = 0; __states.back().__first_ = __first; __states.back().__current_ = __first; __states.back().__last_ = __last; - __states.back().__sub_matches_.resize(mark_count()); + __states.back().__sub_matches_.resize(mark_count(), __unmatched); __states.back().__loop_data_.resize(__loop_count()); __states.back().__node_ = __st; __states.back().__flags_ = __flags; @@ -5748,12 +5753,17 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( __node* __st = __start_.get(); if (__st) { + sub_match __unmatched; + __unmatched.first = __last; + __unmatched.second = __last; + __unmatched.matched = false; + __states.push_back(__state()); __states.back().__do_ = 0; __states.back().__first_ = __first; __states.back().__current_ = __first; __states.back().__last_ = __last; - __states.back().__sub_matches_.resize(mark_count()); + __states.back().__sub_matches_.resize(mark_count(), __unmatched); __states.back().__loop_data_.resize(__loop_count()); __states.back().__node_ = __st; __states.back().__flags_ = __flags; diff --git a/include/scoped_allocator b/include/scoped_allocator index aa8bece6d331..cd4987ad9bb6 100644 --- a/include/scoped_allocator +++ b/include/scoped_allocator @@ -38,6 +38,7 @@ public: typedef see below propagate_on_container_copy_assignment; typedef see below propagate_on_container_move_assignment; typedef see below propagate_on_container_swap; + typedef see below is_always_equal; template struct rebind @@ -170,6 +171,22 @@ struct __get_poc_swap<_A0, _Allocs...> __get_poc_swap<_Allocs...>::value; }; +template struct __get_is_always_equal; + +template +struct __get_is_always_equal<_A0> +{ + static const bool value = allocator_traits<_A0>::is_always_equal::value; +}; + +template +struct __get_is_always_equal<_A0, _Allocs...> +{ + static const bool value = + allocator_traits<_A0>::is_always_equal::value && + __get_is_always_equal<_Allocs...>::value; +}; + template class __scoped_allocator_storage; @@ -397,6 +414,11 @@ public: bool, __get_poc_swap::value > propagate_on_container_swap; + typedef integral_constant + < + bool, + __get_is_always_equal::value + > is_always_equal; template struct rebind diff --git a/include/set b/include/set index 22d794da547a..9d64a521da11 100644 --- a/include/set +++ b/include/set @@ -116,6 +116,7 @@ public: void insert(initializer_list il); iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; @@ -297,6 +298,7 @@ public: void insert(initializer_list il); iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; diff --git a/include/shared_mutex b/include/shared_mutex index 9b7f0bf77354..dcb93949e30d 100644 --- a/include/shared_mutex +++ b/include/shared_mutex @@ -19,6 +19,29 @@ namespace std { +class shared_mutex // C++17 +{ +public: + shared_mutex(); + ~shared_mutex(); + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + void lock(); // blocking + bool try_lock(); + void unlock(); + + // Shared ownership + void lock_shared(); // blocking + bool try_lock_shared(); + void unlock_shared(); + + typedef implementation-defined native_handle_type; // See 30.2.3 + native_handle_type native_handle(); // See 30.2.3 +}; + class shared_timed_mutex { public: @@ -118,7 +141,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -class _LIBCPP_TYPE_VIS shared_timed_mutex +struct _LIBCPP_TYPE_VIS __shared_mutex_base { mutex __mut_; condition_variable __gate1_; @@ -127,6 +150,58 @@ class _LIBCPP_TYPE_VIS shared_timed_mutex static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1); static const unsigned __n_readers_ = ~__write_entered_; + + __shared_mutex_base(); + _LIBCPP_INLINE_VISIBILITY ~__shared_mutex_base() = default; + + __shared_mutex_base(const __shared_mutex_base&) = delete; + __shared_mutex_base& operator=(const __shared_mutex_base&) = delete; + + // Exclusive ownership + void lock(); // blocking + bool try_lock(); + void unlock(); + + // Shared ownership + void lock_shared(); // blocking + bool try_lock_shared(); + void unlock_shared(); + +// typedef implementation-defined native_handle_type; // See 30.2.3 +// native_handle_type native_handle(); // See 30.2.3 +}; + + +#if _LIBCPP_STD_VER > 14 +class _LIBCPP_TYPE_VIS shared_mutex +{ + __shared_mutex_base __base; +public: + shared_mutex() : __base() {} + _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default; + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + _LIBCPP_INLINE_VISIBILITY void lock() { return __base.lock(); } + _LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base.try_lock(); } + _LIBCPP_INLINE_VISIBILITY void unlock() { return __base.unlock(); } + + // Shared ownership + _LIBCPP_INLINE_VISIBILITY void lock_shared() { return __base.lock_shared(); } + _LIBCPP_INLINE_VISIBILITY bool try_lock_shared() { return __base.try_lock_shared(); } + _LIBCPP_INLINE_VISIBILITY void unlock_shared() { return __base.unlock_shared(); } + +// typedef __shared_mutex_base::native_handle_type native_handle_type; +// _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() { return __base::unlock_shared(); } +}; +#endif + + +class _LIBCPP_TYPE_VIS shared_timed_mutex +{ + __shared_mutex_base __base; public: shared_timed_mutex(); _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default; @@ -170,29 +245,30 @@ bool shared_timed_mutex::try_lock_until( const chrono::time_point<_Clock, _Duration>& __abs_time) { - unique_lock __lk(__mut_); - if (__state_ & __write_entered_) + unique_lock __lk(__base.__mut_); + if (__base.__state_ & __base.__write_entered_) { while (true) { - cv_status __status = __gate1_.wait_until(__lk, __abs_time); - if ((__state_ & __write_entered_) == 0) + cv_status __status = __base.__gate1_.wait_until(__lk, __abs_time); + if ((__base.__state_ & __base.__write_entered_) == 0) break; if (__status == cv_status::timeout) return false; } } - __state_ |= __write_entered_; - if (__state_ & __n_readers_) + __base.__state_ |= __base.__write_entered_; + if (__base.__state_ & __base.__n_readers_) { while (true) { - cv_status __status = __gate2_.wait_until(__lk, __abs_time); - if ((__state_ & __n_readers_) == 0) + cv_status __status = __base.__gate2_.wait_until(__lk, __abs_time); + if ((__base.__state_ & __base.__n_readers_) == 0) break; if (__status == cv_status::timeout) { - __state_ &= ~__write_entered_; + __base.__state_ &= ~__base.__write_entered_; + __base.__gate1_.notify_all(); return false; } } @@ -205,22 +281,22 @@ bool shared_timed_mutex::try_lock_shared_until( const chrono::time_point<_Clock, _Duration>& __abs_time) { - unique_lock __lk(__mut_); - if ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) + unique_lock __lk(__base.__mut_); + if ((__base.__state_ & __base.__write_entered_) || (__base.__state_ & __base.__n_readers_) == __base.__n_readers_) { while (true) { - cv_status status = __gate1_.wait_until(__lk, __abs_time); - if ((__state_ & __write_entered_) == 0 && - (__state_ & __n_readers_) < __n_readers_) + cv_status status = __base.__gate1_.wait_until(__lk, __abs_time); + if ((__base.__state_ & __base.__write_entered_) == 0 && + (__base.__state_ & __base.__n_readers_) < __base.__n_readers_) break; if (status == cv_status::timeout) return false; } } - unsigned __num_readers = (__state_ & __n_readers_) + 1; - __state_ &= ~__n_readers_; - __state_ |= __num_readers; + unsigned __num_readers = (__base.__state_ & __base.__n_readers_) + 1; + __base.__state_ &= ~__base.__n_readers_; + __base.__state_ |= __num_readers; return true; } diff --git a/include/stack b/include/stack index 30909c1ee3bd..2992b091ee51 100644 --- a/include/stack +++ b/include/stack @@ -91,7 +91,7 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -template class _LIBCPP_TYPE_VIS_ONLY stack; +template > class _LIBCPP_TYPE_VIS_ONLY stack; template _LIBCPP_INLINE_VISIBILITY @@ -103,7 +103,7 @@ _LIBCPP_INLINE_VISIBILITY bool operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); -template > +template */> class _LIBCPP_TYPE_VIS_ONLY stack { public: diff --git a/include/stdexcept b/include/stdexcept index 5fc912a644be..f251806fba62 100644 --- a/include/stdexcept +++ b/include/stdexcept @@ -53,7 +53,7 @@ public: #ifndef _LIBCPP___REFSTRING _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_HIDDEN __libcpp_refstring { - const char *__imp_; + const char *__imp_ _LIBCPP_UNUSED; }; _LIBCPP_END_NAMESPACE_STD #endif diff --git a/include/streambuf b/include/streambuf index 6adfc9237c7d..603c68038796 100644 --- a/include/streambuf +++ b/include/streambuf @@ -536,12 +536,23 @@ basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n) { streamsize __i = 0; int_type __eof = traits_type::eof(); - for (; __i < __n; ++__s, ++__i) + while( __i < __n) { - if (__nout_ < __eout_) - *__nout_++ = *__s; - else if (overflow(traits_type::to_int_type(*__s)) == __eof) - break; + if (__nout_ >= __eout_) + { + if (overflow(traits_type::to_int_type(*__s)) == __eof) + break; + ++__s; + ++__i; + } + else + { + streamsize __chunk_size = _VSTD::min(__eout_ - __nout_, __n - __i); + traits_type::copy(__nout_, __s, __chunk_size); + __nout_ += __chunk_size; + __s += __chunk_size; + __i += __chunk_size; + } } return __i; } diff --git a/include/string b/include/string index fe42bbf1d998..6be21955b146 100644 --- a/include/string +++ b/include/string @@ -220,8 +220,8 @@ public: basic_string substr(size_type pos = 0, size_type n = npos) const; void swap(basic_string& str) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) + noexcept(allocator_traits::propagate_on_container_swap::value || + allocator_traits::is_always_equal::value); // C++17 const value_type* c_str() const noexcept; const value_type* data() const noexcept; @@ -636,19 +636,19 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits {return (unsigned char)__c1 < (unsigned char)__c2;} static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return memcmp(__s1, __s2, __n);} + {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);} static inline size_t length(const char_type* __s) {return strlen(__s);} static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - {return (const char_type*)memchr(__s, to_int_type(__a), __n);} + {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a), __n);} static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)memmove(__s1, __s2, __n);} + {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return (char_type*)memcpy(__s1, __s2, __n); + return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); } static inline char_type* assign(char_type* __s, size_t __n, char_type __a) - {return (char_type*)memset(__s, to_int_type(__a), __n);} + {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} @@ -681,20 +681,20 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits {return __c1 < __c2;} static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return wmemcmp(__s1, __s2, __n);} + {return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);} static inline size_t length(const char_type* __s) {return wcslen(__s);} static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - {return (const char_type*)wmemchr(__s, __a, __n);} + {return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);} static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)wmemmove(__s1, __s2, __n);} + {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);} static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return (char_type*)wmemcpy(__s1, __s2, __n); + return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n); } static inline char_type* assign(char_type* __s, size_t __n, char_type __a) - {return (char_type*)wmemset(__s, __a, __n);} + {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);} static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} @@ -1322,13 +1322,26 @@ public: _LIBCPP_INLINE_VISIBILITY basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a); + + _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value); +#else + _NOEXCEPT; +#endif + basic_string(const basic_string& __str); basic_string(const basic_string& __str, const allocator_type& __a); + #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str) +#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible::value); +#else + _NOEXCEPT; +#endif + _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1591,8 +1604,12 @@ public: _LIBCPP_INLINE_VISIBILITY void swap(basic_string& __str) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value); +#endif _LIBCPP_INLINE_VISIBILITY const value_type* c_str() const _NOEXCEPT {return data();} @@ -1855,24 +1872,6 @@ private: _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) - {__swap_alloc(__x, __y, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable::value) - { - using _VSTD::swap; - swap(__x, __y); - } - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type&, allocator_type&, false_type) _NOEXCEPT - {} - _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); @@ -2070,7 +2069,11 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) +#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible::value) +#else + _NOEXCEPT +#endif : __r_(_VSTD::move(__str.__r_)) { __str.__zero(); @@ -3349,8 +3352,12 @@ template inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value) +#endif { #if _LIBCPP_DEBUG_LEVEL >= 2 if (!__is_long()) @@ -3360,7 +3367,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) __get_db()->swap(this, &__str); #endif _VSTD::swap(__r_.first(), __str.__r_.first()); - __swap_alloc(__alloc(), __str.__alloc()); + __swap_allocator(__alloc(), __str.__alloc()); } // find diff --git a/include/support/android/locale_bionic.h b/include/support/android/locale_bionic.h new file mode 100644 index 000000000000..3a020da67e6b --- /dev/null +++ b/include/support/android/locale_bionic.h @@ -0,0 +1,31 @@ +// -*- C++ -*- +//===------------------- support/android/locale_bionic.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 _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H +#define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H + +#if defined(__ANDROID__) + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#ifdef __cplusplus +} +#endif + +// Share implementation with Newlib +#include + +#endif // defined(__ANDROID__) +#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H diff --git a/include/support/ibm/limits.h b/include/support/ibm/limits.h new file mode 100644 index 000000000000..efdb35965965 --- /dev/null +++ b/include/support/ibm/limits.h @@ -0,0 +1,99 @@ +// -*- C++ -*- +//===--------------------- support/ibm/limits.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 _LIBCPP_SUPPORT_IBM_LIMITS_H +#define _LIBCPP_SUPPORT_IBM_LIMITS_H + +#if !defined(_AIX) // Linux +#include // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN + +static const unsigned int _QNAN_F = 0x7fc00000; +#define NANF (*((float *)(&_QNAN_F))) +static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0}; +#define NANL (*((long double *)(&_QNAN_LDBL128))) +static const unsigned int _SNAN_F= 0x7f855555; +#define NANSF (*((float *)(&_SNAN_F))) +static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555}; +#define NANS (*((double *)(&_SNAN_D))) +static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0}; +#define NANSL (*((long double *)(&_SNAN_LDBL128))) + +#define __builtin_huge_val() HUGE_VAL +#define __builtin_huge_valf() HUGE_VALF +#define __builtin_huge_vall() HUGE_VALL +#define __builtin_nan(__dummy) NAN +#define __builtin_nanf(__dummy) NANF +#define __builtin_nanl(__dummy) NANL +#define __builtin_nans(__dummy) NANS +#define __builtin_nansf(__dummy) NANSF +#define __builtin_nansl(__dummy) NANSL + +#else + +#include +#include // limit constants + +#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000 +#define __builtin_huge_valf() HUGE_VALF //0x7f800000 +#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000 +#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000 +#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000 +#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000 +#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555 +#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555 +#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555 + +#define __FLT_MANT_DIG__ FLT_MANT_DIG +#define __FLT_DIG__ FLT_DIG +#define __FLT_RADIX__ FLT_RADIX +#define __FLT_MIN_EXP__ FLT_MIN_EXP +#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP +#define __FLT_MAX_EXP__ FLT_MAX_EXP +#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP +#define __FLT_MIN__ FLT_MIN +#define __FLT_MAX__ FLT_MAX +#define __FLT_EPSILON__ FLT_EPSILON +// predefined by XLC on LoP +#define __FLT_DENORM_MIN__ 1.40129846e-45F + +#define __DBL_MANT_DIG__ DBL_MANT_DIG +#define __DBL_DIG__ DBL_DIG +#define __DBL_MIN_EXP__ DBL_MIN_EXP +#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP +#define __DBL_MAX_EXP__ DBL_MAX_EXP +#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP +#define __DBL_MIN__ DBL_MIN +#define __DBL_MAX__ DBL_MAX +#define __DBL_EPSILON__ DBL_EPSILON +// predefined by XLC on LoP +#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 + +#define __LDBL_MANT_DIG__ LDBL_MANT_DIG +#define __LDBL_DIG__ LDBL_DIG +#define __LDBL_MIN_EXP__ LDBL_MIN_EXP +#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP +#define __LDBL_MAX_EXP__ LDBL_MAX_EXP +#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP +#define __LDBL_MIN__ LDBL_MIN +#define __LDBL_MAX__ LDBL_MAX +#define __LDBL_EPSILON__ LDBL_EPSILON +// predefined by XLC on LoP +#if __LONGDOUBLE128 +#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L +#else +#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L +#endif + +// predefined by XLC on LoP +#define __CHAR_BIT__ 8 + +#endif // _AIX + +#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H diff --git a/include/support/ibm/support.h b/include/support/ibm/support.h new file mode 100644 index 000000000000..0abfa7f95a65 --- /dev/null +++ b/include/support/ibm/support.h @@ -0,0 +1,54 @@ +// -*- C++ -*- +//===----------------------- support/ibm/support.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 _LIBCPP_SUPPORT_IBM_SUPPORT_H +#define _LIBCPP_SUPPORT_IBM_SUPPORT_H + +extern "builtin" int __popcnt4(unsigned int); +extern "builtin" int __popcnt8(unsigned long long); +extern "builtin" unsigned int __cnttz4(unsigned int); +extern "builtin" unsigned int __cnttz8(unsigned long long); +extern "builtin" unsigned int __cntlz4(unsigned int); +extern "builtin" unsigned int __cntlz8(unsigned long long); + +// Builtin functions for counting population +#define __builtin_popcount(x) __popcnt4(x) +#define __builtin_popcountll(x) __popcnt8(x) +#if defined(__64BIT__) +#define __builtin_popcountl(x) __builtin_popcountll(x) +#else +#define __builtin_popcountl(x) __builtin_popcount(x) +#endif + +// Builtin functions for counting trailing zeros +#define __builtin_ctz(x) __cnttz4(x) +#define __builtin_ctzll(x) __cnttz8(x) +#if defined(__64BIT__) +#define __builtin_ctzl(x) __builtin_ctzll(x) +#else +#define __builtin_ctzl(x) __builtin_ctz(x) +#endif + +// Builtin functions for counting leading zeros +#define __builtin_clz(x) __cntlz4(x) +#define __builtin_clzll(x) __cntlz8(x) +#if defined(__64BIT__) +#define __builtin_clzl(x) __builtin_clzll(x) +#else +#define __builtin_clzl(x) __builtin_clz(x) +#endif + +#if defined(__64BIT__) +#define __SIZE_WIDTH__ 64 +#else +#define __SIZE_WIDTH__ 32 +#endif + +#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H diff --git a/include/support/ibm/xlocale.h b/include/support/ibm/xlocale.h new file mode 100644 index 000000000000..8d99a5c7d34d --- /dev/null +++ b/include/support/ibm/xlocale.h @@ -0,0 +1,326 @@ +// -*- C++ -*- +//===--------------------- support/ibm/xlocale.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 _LIBCPP_SUPPORT_IBM_XLOCALE_H +#define _LIBCPP_SUPPORT_IBM_XLOCALE_H + +#if defined(_AIX) +#include "cstdlib" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_AIX71) +// AIX 7.1 and higher has these definitions. Definitions and stubs +// are provied here as a temporary workaround on AIX 6.1. + +#define LC_COLLATE_MASK 1 +#define LC_CTYPE_MASK 2 +#define LC_MESSAGES_MASK 4 +#define LC_MONETARY_MASK 8 +#define LC_NUMERIC_MASK 16 +#define LC_TIME_MASK 32 +#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ + LC_MESSAGES_MASK | LC_MONETARY_MASK |\ + LC_NUMERIC_MASK | LC_TIME_MASK) + +typedef void* locale_t; + +// The following are stubs. They are not supported on AIX 6.1. +static inline +locale_t newlocale(int category_mask, const char *locale, locale_t base) +{ + _LC_locale_t *newloc, *loc; + if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) + { + errno = EINVAL; + return (locale_t)0; + } + if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) + { + errno = ENOMEM; + return (locale_t)0; + } + if (!base) + base = (_LC_locale_t *)__xopen_locale("C"); + memcpy(newloc, base, sizeof (_LC_locale_t)); + if (category_mask & LC_COLLATE_MASK) + newloc->lc_collate = loc->lc_collate; + if (category_mask & LC_CTYPE_MASK) + newloc->lc_ctype = loc->lc_ctype; + //if (category_mask & LC_MESSAGES_MASK) + // newloc->lc_messages = loc->lc_messages; + if (category_mask & LC_MONETARY_MASK) + newloc->lc_monetary = loc->lc_monetary; + if (category_mask & LC_TIME_MASK) + newloc->lc_time = loc->lc_time; + if (category_mask & LC_NUMERIC_MASK) + newloc->lc_numeric = loc->lc_numeric; + return (locale_t)newloc; +} +static inline +void freelocale(locale_t locobj) +{ + free(locobj); +} +static inline +locale_t uselocale(locale_t newloc) +{ + return (locale_t)0; +} + +static inline +int isalnum_l(int c, locale_t locale) +{ + return __xisalnum(locale, c); +} +static inline +int isalpha_l(int c, locale_t locale) +{ + return __xisalpha(locale, c); +} +static inline +int isblank_l(int c, locale_t locale) +{ + return __xisblank(locale, c); +} +static inline +int iscntrl_l(int c, locale_t locale) +{ + return __xiscntrl(locale, c); +} +static inline +int isdigit_l(int c, locale_t locale) +{ + return __xisdigit(locale, c); +} +static inline +int isgraph_l(int c, locale_t locale) +{ + return __xisgraph(locale, c); +} +static inline +int islower_l(int c, locale_t locale) +{ + return __xislower(locale, c); +} +static inline +int isprint_l(int c, locale_t locale) +{ + return __xisprint(locale, c); +} + +static inline +int ispunct_l(int c, locale_t locale) +{ + return __xispunct(locale, c); +} +static inline +int isspace_l(int c, locale_t locale) +{ + return __xisspace(locale, c); +} +static inline +int isupper_l(int c, locale_t locale) +{ + return __xisupper(locale, c); +} + +static inline +int isxdigit_l(int c, locale_t locale) +{ + return __xisxdigit(locale, c); +} + +static inline +int iswalnum_l(wchar_t wc, locale_t locale) +{ + return __xiswalnum(locale, wc); +} + +static inline +int iswalpha_l(wchar_t wc, locale_t locale) +{ + return __xiswalpha(locale, wc); +} + +static inline +int iswblank_l(wchar_t wc, locale_t locale) +{ + return __xiswblank(locale, wc); +} + +static inline +int iswcntrl_l(wchar_t wc, locale_t locale) +{ + return __xiswcntrl(locale, wc); +} + +static inline +int iswdigit_l(wchar_t wc, locale_t locale) +{ + return __xiswdigit(locale, wc); +} + +static inline +int iswgraph_l(wchar_t wc, locale_t locale) +{ + return __xiswgraph(locale, wc); +} + +static inline +int iswlower_l(wchar_t wc, locale_t locale) +{ + return __xiswlower(locale, wc); +} + +static inline +int iswprint_l(wchar_t wc, locale_t locale) +{ + return __xiswprint(locale, wc); +} + +static inline +int iswpunct_l(wchar_t wc, locale_t locale) +{ + return __xiswpunct(locale, wc); +} + +static inline +int iswspace_l(wchar_t wc, locale_t locale) +{ + return __xiswspace(locale, wc); +} + +static inline +int iswupper_l(wchar_t wc, locale_t locale) +{ + return __xiswupper(locale, wc); +} + +static inline +int iswxdigit_l(wchar_t wc, locale_t locale) +{ + return __xiswxdigit(locale, wc); +} + +static inline +int iswctype_l(wint_t wc, wctype_t desc, locale_t locale) +{ + return __xiswctype(locale, wc, desc); +} + +static inline +int toupper_l(int c, locale_t locale) +{ + return __xtoupper(locale, c); +} +static inline +int tolower_l(int c, locale_t locale) +{ + return __xtolower(locale, c); +} +static inline +wint_t towupper_l(wint_t wc, locale_t locale) +{ + return __xtowupper(locale, wc); +} +static inline +wint_t towlower_l(wint_t wc, locale_t locale) +{ + return __xtowlower(locale, wc); +} + +static inline +int strcoll_l(const char *__s1, const char *__s2, locale_t locale) +{ + return __xstrcoll(locale, __s1, __s2); +} +static inline +int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t locale) +{ + return __xwcscoll(locale, __s1, __s2); +} +static inline +size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t locale) +{ + return __xstrxfrm(locale, __s1, __s2, __n); +} + +static inline +size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n, + locale_t locale) +{ + return __xwcsxfrm(locale, __ws1, __ws2, __n); +} +#endif // !defined(_AIX71) + +// strftime_l() is defined by POSIX. However, AIX 7.1 does not have it +// implemented yet. +static inline +size_t strftime_l(char *__s, size_t __size, const char *__fmt, + const struct tm *__tm, locale_t locale) { + return __xstrftime(locale, __s, __size, __fmt, __tm); +} + +// The following are not POSIX routines. These are quick-and-dirty hacks +// to make things pretend to work +static inline +long long strtoll_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoll(__nptr, __endptr, __base); +} +static inline +long strtol_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtol(__nptr, __endptr, __base); +} +static inline +long double strtold_l(const char *__nptr, char **__endptr, + locale_t locale) { + return strtold(__nptr, __endptr); +} +static inline +unsigned long long strtoull_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoull(__nptr, __endptr, __base); +} +static inline +unsigned long strtoul_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoul(__nptr, __endptr, __base); +} + +static inline +int vasprintf(char **strp, const char *fmt, va_list ap) +{ + const size_t buff_size = 256; + int str_size; + if ((*strp = (char *)malloc(buff_size)) == NULL) + { + return -1; + } + if ((str_size = vsnprintf(*strp, buff_size, fmt, ap)) >= buff_size) + { + if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL) + { + return -1; + } + str_size = vsnprintf(*strp, str_size + 1, fmt, ap); + } + return str_size; +} + +#ifdef __cplusplus +} +#endif +#endif // defined(_AIX) +#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H diff --git a/include/support/newlib/xlocale.h b/include/support/newlib/xlocale.h new file mode 100644 index 000000000000..d067cf85a3bc --- /dev/null +++ b/include/support/newlib/xlocale.h @@ -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. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H +#define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H + +#if defined(_NEWLIB_VERSION) + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Patch over newlib's lack of extended locale support +typedef void *locale_t; +static inline locale_t duplocale(locale_t) { + return NULL; +} + +static inline void freelocale(locale_t) { +} + +static inline locale_t newlocale(int, const char *, locale_t) { + return NULL; +} + +static inline locale_t uselocale(locale_t) { + return NULL; +} + +#define LC_COLLATE_MASK (1 << LC_COLLATE) +#define LC_CTYPE_MASK (1 << LC_CTYPE) +#define LC_MESSAGES_MASK (1 << LC_MESSAGES) +#define LC_MONETARY_MASK (1 << LC_MONETARY) +#define LC_NUMERIC_MASK (1 << LC_NUMERIC) +#define LC_TIME_MASK (1 << LC_TIME) +#define LC_ALL_MASK (LC_COLLATE_MASK|\ + LC_CTYPE_MASK|\ + LC_MONETARY_MASK|\ + LC_NUMERIC_MASK|\ + LC_TIME_MASK|\ + LC_MESSAGES_MASK) + +// Share implementation with Android's Bionic +#include + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _NEWLIB_VERSION + +#endif diff --git a/include/support/solaris/floatingpoint.h b/include/support/solaris/floatingpoint.h new file mode 100644 index 000000000000..999d144b1f2e --- /dev/null +++ b/include/support/solaris/floatingpoint.h @@ -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. +// +//===----------------------------------------------------------------------===// + +#define atof sun_atof +#define strtod sun_strtod +#include_next "floatingpoint.h" +#undef atof +#undef strtod diff --git a/include/support/solaris/wchar.h b/include/support/solaris/wchar.h new file mode 100644 index 000000000000..0e8e660c8bd4 --- /dev/null +++ b/include/support/solaris/wchar.h @@ -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. +// +//===----------------------------------------------------------------------===// + +#define iswalpha sun_iswalpha +#define iswupper sun_iswupper +#define iswlower sun_iswlower +#define iswdigit sun_iswdigit +#define iswxdigit sun_iswxdigit +#define iswalnum sun_iswalnum +#define iswspace sun_iswspace +#define iswpunct sun_iswpunct +#define iswprint sun_iswprint +#define iswgraph sun_iswgraph +#define iswcntrl sun_iswcntrl +#define iswctype sun_iswctype +#define towlower sun_towlower +#define towupper sun_towupper +#define wcswcs sun_wcswcs +#define wcswidth sun_wcswidth +#define wcwidth sun_wcwidth +#define wctype sun_wctype +#define _WCHAR_T 1 +#include_next "wchar.h" +#undef iswalpha +#undef iswupper +#undef iswlower +#undef iswdigit +#undef iswxdigit +#undef iswalnum +#undef iswspace +#undef iswpunct +#undef iswprint +#undef iswgraph +#undef iswcntrl +#undef iswctype +#undef towlower +#undef towupper +#undef wcswcs +#undef wcswidth +#undef wcwidth +#undef wctype diff --git a/include/support/solaris/xlocale.h b/include/support/solaris/xlocale.h new file mode 100644 index 000000000000..62b0d74a6d23 --- /dev/null +++ b/include/support/solaris/xlocale.h @@ -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. +// +//===----------------------------------------------------------------------===// + +//////////////////////////////////////////////////////////////////////////////// +// Minimal xlocale implementation for Solaris. This implements the subset of +// the xlocale APIs that libc++ depends on. +//////////////////////////////////////////////////////////////////////////////// +#ifndef __XLOCALE_H_INCLUDED +#define __XLOCALE_H_INCLUDED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...); +int asprintf_l(char **__s, locale_t __l, const char *__format, ...); + +int sscanf_l(const char *__s, locale_t __l, const char *__format, ...); + +int toupper_l(int __c, locale_t __l); +int tolower_l(int __c, locale_t __l); + +struct lconv *localeconv(void); +struct lconv *localeconv_l(locale_t __l); + +// FIXME: These are quick-and-dirty hacks to make things pretend to work +static inline +long long strtoll_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtoll(__nptr, __endptr, __base); +} +static inline +long strtol_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtol(__nptr, __endptr, __base); +} +static inline +long double strtold_l(const char *__nptr, char **__endptr, + locale_t __loc) { + return strtold(__nptr, __endptr); +} +static inline +unsigned long long strtoull_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtoull(__nptr, __endptr, __base); +} +static inline +unsigned long strtoul_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtoul(__nptr, __endptr, __base); +} + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/support/win32/limits_win32.h b/include/support/win32/limits_win32.h new file mode 100644 index 000000000000..406cd3025bf8 --- /dev/null +++ b/include/support/win32/limits_win32.h @@ -0,0 +1,79 @@ +// -*- C++ -*- +//===--------------------- support/win32/limits_win32.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 _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H +#define _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H + +#if !defined(_LIBCPP_MSVCRT) +#error "This header complements the Microsoft C Runtime library, and should not be included otherwise." +#else + +#include // CHAR_BIT +#include // limit constants + +#if ! defined(__clang__) +#define __CHAR_BIT__ CHAR_BIT + +#define __FLT_MANT_DIG__ FLT_MANT_DIG +#define __FLT_DIG__ FLT_DIG +#define __FLT_RADIX__ FLT_RADIX +#define __FLT_MIN_EXP__ FLT_MIN_EXP +#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP +#define __FLT_MAX_EXP__ FLT_MAX_EXP +#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP +#define __FLT_MIN__ FLT_MIN +#define __FLT_MAX__ FLT_MAX +#define __FLT_EPSILON__ FLT_EPSILON +// predefined by MinGW GCC +#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F + +#define __DBL_MANT_DIG__ DBL_MANT_DIG +#define __DBL_DIG__ DBL_DIG +#define __DBL_RADIX__ DBL_RADIX +#define __DBL_MIN_EXP__ DBL_MIN_EXP +#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP +#define __DBL_MAX_EXP__ DBL_MAX_EXP +#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP +#define __DBL_MIN__ DBL_MIN +#define __DBL_MAX__ DBL_MAX +#define __DBL_EPSILON__ DBL_EPSILON +// predefined by MinGW GCC +#define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L) + +#define __LDBL_MANT_DIG__ LDBL_MANT_DIG +#define __LDBL_DIG__ LDBL_DIG +#define __LDBL_RADIX__ LDBL_RADIX +#define __LDBL_MIN_EXP__ LDBL_MIN_EXP +#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP +#define __LDBL_MAX_EXP__ LDBL_MAX_EXP +#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP +#define __LDBL_MIN__ LDBL_MIN +#define __LDBL_MAX__ LDBL_MAX +#define __LDBL_EPSILON__ LDBL_EPSILON +// predefined by MinGW GCC +#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L + +// __builtin replacements/workarounds +#include // HUGE_VAL +#include // internal MSVC header providing the needed functionality +#define __builtin_huge_val() HUGE_VAL +#define __builtin_huge_valf() _FInf._Float +#define __builtin_huge_vall() _LInf._Long_double +#define __builtin_nan(__dummy) _Nan._Double +#define __builtin_nanf(__dummy) _FNan._Float +#define __builtin_nanl(__dummmy) _LNan._Long_double +#define __builtin_nans(__dummy) _Snan._Double +#define __builtin_nansf(__dummy) _FSnan._Float +#define __builtin_nansl(__dummy) _LSnan._Long_double +#endif // ! defined(__clang__) + +#endif // _LIBCPP_MSVCRT + +#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h new file mode 100644 index 000000000000..f728d234472f --- /dev/null +++ b/include/support/win32/locale_win32.h @@ -0,0 +1,129 @@ +// -*- C++ -*- +//===--------------------- support/win32/locale_win32.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 _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H +#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H + +// ctype mask table defined in msvcrt.dll +extern "C" unsigned short __declspec(dllimport) _ctype[]; + +#include "support/win32/support.h" +#include +#include +#include // _locale_t +#define locale_t _locale_t +#define LC_COLLATE_MASK _M_COLLATE +#define LC_CTYPE_MASK _M_CTYPE +#define LC_MONETARY_MASK _M_MONETARY +#define LC_NUMERIC_MASK _M_NUMERIC +#define LC_TIME_MASK _M_TIME +#define LC_MESSAGES_MASK _M_MESSAGES +#define LC_ALL_MASK ( LC_COLLATE_MASK \ + | LC_CTYPE_MASK \ + | LC_MESSAGES_MASK \ + | LC_MONETARY_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK ) +#define freelocale _free_locale +// FIXME: base currently unused. Needs manual work to construct the new locale +locale_t newlocale( int mask, const char * locale, locale_t base ); +locale_t uselocale( locale_t newloc ); +lconv *localeconv_l( locale_t loc ); +size_t mbrlen_l( const char *__restrict s, size_t n, + mbstate_t *__restrict ps, locale_t loc); +size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t len, mbstate_t *__restrict ps, locale_t loc ); +size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps, + locale_t loc); +size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s, + size_t n, mbstate_t *__restrict ps, locale_t loc); +size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc); +size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc); +wint_t btowc_l( int c, locale_t loc ); +int wctob_l( wint_t c, locale_t loc ); +typedef _VSTD::remove_pointer::type __locale_struct; +typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii; +inline _LIBCPP_ALWAYS_INLINE +decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) +{ + __locale_raii __current( uselocale(__l), uselocale ); + return MB_CUR_MAX; +} + +// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ +#define mbtowc_l _mbtowc_l +#define strtoll_l _strtoi64_l +#define strtoull_l _strtoui64_l +// FIXME: current msvcrt does not know about long double +#define strtold_l _strtod_l + +inline _LIBCPP_INLINE_VISIBILITY +int +islower_l(int c, _locale_t loc) +{ + return _islower_l((int)c, loc); +} + +inline _LIBCPP_INLINE_VISIBILITY +int +isupper_l(int c, _locale_t loc) +{ + return _isupper_l((int)c, loc); +} + +#define isdigit_l _isdigit_l +#define isxdigit_l _isxdigit_l +#define strcoll_l _strcoll_l +#define strxfrm_l _strxfrm_l +#define wcscoll_l _wcscoll_l +#define wcsxfrm_l _wcsxfrm_l +#define toupper_l _toupper_l +#define tolower_l _tolower_l +#define iswspace_l _iswspace_l +#define iswprint_l _iswprint_l +#define iswcntrl_l _iswcntrl_l +#define iswupper_l _iswupper_l +#define iswlower_l _iswlower_l +#define iswalpha_l _iswalpha_l +#define iswdigit_l _iswdigit_l +#define iswpunct_l _iswpunct_l +#define iswxdigit_l _iswxdigit_l +#define towupper_l _towupper_l +#define towlower_l _towlower_l +#define strftime_l _strftime_l +#define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ ) +#define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ ) +#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ ) +#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ ) +#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ ) +int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...); +int asprintf_l( char **ret, locale_t loc, const char *format, ... ); +int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap ); + + +// not-so-pressing FIXME: use locale to determine blank characters +inline int isblank_l( int c, locale_t /*loc*/ ) +{ + return ( c == ' ' || c == '\t' ); +} +inline int iswblank_l( wint_t c, locale_t /*loc*/ ) +{ + return ( c == L' ' || c == L'\t' ); +} + +#if defined(_LIBCPP_MSVCRT) +inline int isblank( int c, locale_t /*loc*/ ) +{ return ( c == ' ' || c == '\t' ); } +inline int iswblank( wint_t c, locale_t /*loc*/ ) +{ return ( c == L' ' || c == L'\t' ); } +#endif // _LIBCPP_MSVCRT +#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H diff --git a/include/support/win32/math_win32.h b/include/support/win32/math_win32.h new file mode 100644 index 000000000000..0d6b422a165c --- /dev/null +++ b/include/support/win32/math_win32.h @@ -0,0 +1,117 @@ +// -*- C++ -*- +//===---------------------- support/win32/math_win32.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 _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H +#define _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H + +#if !defined(_LIBCPP_MSVCRT) +#error "This header complements Microsoft's C Runtime library, and should not be included otherwise." +#else + +#include +#include // _FPCLASS_PN etc. +#include + +#if ((_VC_CRT_MAJOR_VERSION-0) < 12) +// Necessary? +typedef float float_t; +typedef double double_t; + +_LIBCPP_ALWAYS_INLINE bool isfinite( double num ) +{ + return _finite(num) != 0; +} +_LIBCPP_ALWAYS_INLINE bool isinf( double num ) +{ + return !isfinite(num) && !_isnan(num); +} +_LIBCPP_ALWAYS_INLINE bool isnan( double num ) +{ + return _isnan(num) != 0; +} +_LIBCPP_ALWAYS_INLINE bool isnormal( double num ) +{ + int class_ = _fpclass(num); + return class_ == _FPCLASS_NN || class_ == _FPCLASS_PN; +} + +_LIBCPP_ALWAYS_INLINE bool isgreater( double x, double y ) +{ + if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false; + else return x > y; +} + +_LIBCPP_ALWAYS_INLINE bool isgreaterequal( double x, double y ) +{ + if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false; + else return x >= y; +} + +_LIBCPP_ALWAYS_INLINE bool isless( double x, double y ) +{ + if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false; + else return x < y; +} + +_LIBCPP_ALWAYS_INLINE bool islessequal( double x, double y ) +{ + if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false; + else return x <= y; +} + +_LIBCPP_ALWAYS_INLINE bool islessgreater( double x, double y ) +{ + if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false; + else return x < y || x > y; +} + +_LIBCPP_ALWAYS_INLINE bool isunordered( double x, double y ) +{ + return isnan(x) || isnan(y); +} +_LIBCPP_ALWAYS_INLINE bool signbit( double num ) +{ + switch(_fpclass(num)) + { + case _FPCLASS_SNAN: + case _FPCLASS_QNAN: + case _FPCLASS_NINF: + case _FPCLASS_NN: + case _FPCLASS_ND: + case _FPCLASS_NZ: + return true; + case _FPCLASS_PZ: + case _FPCLASS_PD: + case _FPCLASS_PN: + case _FPCLASS_PINF: + return false; + } + return false; +} +_LIBCPP_ALWAYS_INLINE float copysignf( float x, float y ) +{ + return (signbit (x) != signbit (y) ? - x : x); +} +_LIBCPP_ALWAYS_INLINE double copysign( double x, double y ) +{ + return ::_copysign(x,y); +} +_LIBCPP_ALWAYS_INLINE double copysignl( long double x, long double y ) +{ + return ::_copysignl(x,y); +} +_LIBCPP_ALWAYS_INLINE int fpclassify( double num ) +{ + return _fpclass(num); +} +#endif +#endif // _LIBCPP_MSVCRT + +#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H diff --git a/include/support/win32/support.h b/include/support/win32/support.h new file mode 100644 index 000000000000..5765babcd13b --- /dev/null +++ b/include/support/win32/support.h @@ -0,0 +1,206 @@ +// -*- C++ -*- +//===----------------------- support/win32/support.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 _LIBCPP_SUPPORT_WIN32_SUPPORT_H +#define _LIBCPP_SUPPORT_WIN32_SUPPORT_H + +// Functions and constants used in libc++ that +// are missing from the Windows C library. + +#include // mbstate_t +#include // va_ macros +// "builtins" not implemented here for Clang or GCC as they provide +// implementations. Assuming required for elsewhere else, certainly MSVC. +#if defined(_LIBCPP_MSVC) +#include +#endif +#if defined(_LIBCPP_MSVCRT) +#include +#endif +#define swprintf _snwprintf +#define vswprintf _vsnwprintf + +#ifndef NOMINMAX +#define NOMINMAX +#endif + +// The mingw headers already define these as static. +#ifndef __MINGW32__ +extern "C" { + +int vasprintf(char **sptr, const char *__restrict fmt, va_list ap); +int asprintf(char **sptr, const char *__restrict fmt, ...); +size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, + size_t nmc, size_t len, mbstate_t *__restrict ps); +size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps); +} +#endif // __MINGW32__ + +#if defined(_LIBCPP_MSVCRT) +#define snprintf _snprintf +#define atoll _atoi64 +#define strtoll _strtoi64 +#define strtoull _strtoui64 +#define wcstoll _wcstoi64 +#define wcstoull _wcstoui64 +_LIBCPP_ALWAYS_INLINE float strtof(const char *nptr, char **endptr) +{ + return _Stof(nptr, endptr, 0); +} +_LIBCPP_ALWAYS_INLINE double strtod(const char *nptr, char **endptr) +{ + return _Stod(nptr, endptr, 0); +} +_LIBCPP_ALWAYS_INLINE long double strtold(const char *nptr, char **endptr) +{ + return _Stold(nptr, endptr, 0); +} + +#define _Exit _exit +#endif + +#if defined(_LIBCPP_MSVC) + +// Bit builtin's make these assumptions when calling _BitScanForward/Reverse +// etc. These assumptions are expected to be true for Win32/Win64 which this +// file supports. +static_assert(sizeof(unsigned long long) == 8, ""); +static_assert(sizeof(unsigned long) == 4, ""); +static_assert(sizeof(unsigned int) == 4, ""); + +_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x) +{ + // Binary: 0101... + static const unsigned int m1 = 0x55555555; + // Binary: 00110011.. + static const unsigned int m2 = 0x33333333; + // Binary: 4 zeros, 4 ones ... + static const unsigned int m4 = 0x0f0f0f0f; + // The sum of 256 to the power of 0,1,2,3... + static const unsigned int h01 = 0x01010101; + // Put count of each 2 bits into those 2 bits. + x -= (x >> 1) & m1; + // Put count of each 4 bits into those 4 bits. + x = (x & m2) + ((x >> 2) & m2); + // Put count of each 8 bits into those 8 bits. + x = (x + (x >> 4)) & m4; + // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24). + return (x * h01) >> 24; +} + +_LIBCPP_ALWAYS_INLINE int __builtin_popcountl(unsigned long x) +{ + return __builtin_popcount(static_cast(x)); +} + +_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x) +{ + // Binary: 0101... + static const unsigned long long m1 = 0x5555555555555555; + // Binary: 00110011.. + static const unsigned long long m2 = 0x3333333333333333; + // Binary: 4 zeros, 4 ones ... + static const unsigned long long m4 = 0x0f0f0f0f0f0f0f0f; + // The sum of 256 to the power of 0,1,2,3... + static const unsigned long long h01 = 0x0101010101010101; + // Put count of each 2 bits into those 2 bits. + x -= (x >> 1) & m1; + // Put count of each 4 bits into those 4 bits. + x = (x & m2) + ((x >> 2) & m2); + // Put count of each 8 bits into those 8 bits. + x = (x + (x >> 4)) & m4; + // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ... + return static_cast((x * h01) >> 56); +} + +// Returns the number of trailing 0-bits in x, starting at the least significant +// bit position. If x is 0, the result is undefined. +_LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask) +{ + unsigned long where; +// Search from LSB to MSB for first set bit. +// Returns zero if no set bit is found. +#if defined(_WIN64) + if (_BitScanForward64(&where, mask)) + return static_cast(where); +#elif defined(_WIN32) + // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls. + // Scan the Low Word. + if (_BitScanForward(&where, static_cast(mask))) + return static_cast(where); + // Scan the High Word. + if (_BitScanForward(&where, static_cast(mask >> 32))) + return static_cast(where + 32); // Create a bit offset from the LSB. +#else +#error "Implementation of __builtin_ctzll required" +#endif + return 64; +} + +_LIBCPP_ALWAYS_INLINE int __builtin_ctzl(unsigned long mask) +{ + unsigned long where; + // Search from LSB to MSB for first set bit. + // Returns zero if no set bit is found. + if (_BitScanForward(&where, mask)) + return static_cast(where); + return 32; +} + +_LIBCPP_ALWAYS_INLINE int __builtin_ctz(unsigned int mask) +{ + // Win32 and Win64 expectations. + static_assert(sizeof(mask) == 4, ""); + static_assert(sizeof(unsigned long) == 4, ""); + return __builtin_ctzl(static_cast(mask)); +} + +// Returns the number of leading 0-bits in x, starting at the most significant +// bit position. If x is 0, the result is undefined. +_LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask) +{ + unsigned long where; +// BitScanReverse scans from MSB to LSB for first set bit. +// Returns 0 if no set bit is found. +#if defined(_WIN64) + if (_BitScanReverse64(&where, mask)) + return static_cast(63 - where); +#elif defined(_WIN32) + // Scan the high 32 bits. + if (_BitScanReverse(&where, static_cast(mask >> 32))) + return static_cast(63 - + (where + 32)); // Create a bit offset from the MSB. + // Scan the low 32 bits. + if (_BitScanReverse(&where, static_cast(mask))) + return static_cast(63 - where); +#else +#error "Implementation of __builtin_clzll required" +#endif + return 64; // Undefined Behavior. +} + +_LIBCPP_ALWAYS_INLINE int __builtin_clzl(unsigned long mask) +{ + unsigned long where; + // Search from LSB to MSB for first set bit. + // Returns zero if no set bit is found. + if (_BitScanReverse(&where, mask)) + return static_cast(31 - where); + return 32; // Undefined Behavior. +} + +_LIBCPP_ALWAYS_INLINE int __builtin_clz(unsigned int x) +{ + return __builtin_clzl(x); +} +#endif // _LIBCPP_MSVC + +#endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H diff --git a/include/support/xlocale/xlocale.h b/include/support/xlocale/xlocale.h new file mode 100644 index 000000000000..99f710e8f44e --- /dev/null +++ b/include/support/xlocale/xlocale.h @@ -0,0 +1,194 @@ +// -*- C++ -*- +//===------------------- support/xlocale/xlocale.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. +// +//===----------------------------------------------------------------------===// +// This is a shared implementation of a shim to provide extended locale support +// on top of libc's that don't support it (like Android's bionic, and Newlib). +// +// The 'illusion' only works when the specified locale is "C" or "POSIX", but +// that's about as good as we can do without implementing full xlocale support +// in the underlying libc. +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H +#define _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H + +#ifdef __cplusplus +extern "C" { +#endif + +static inline int isalnum_l(int c, locale_t) { + return isalnum(c); +} + +static inline int isalpha_l(int c, locale_t) { + return isalpha(c); +} + +static inline int isblank_l(int c, locale_t) { + return isblank(c); +} + +static inline int iscntrl_l(int c, locale_t) { + return iscntrl(c); +} + +static inline int isdigit_l(int c, locale_t) { + return isdigit(c); +} + +static inline int isgraph_l(int c, locale_t) { + return isgraph(c); +} + +static inline int islower_l(int c, locale_t) { + return islower(c); +} + +static inline int isprint_l(int c, locale_t) { + return isprint(c); +} + +static inline int ispunct_l(int c, locale_t) { + return ispunct(c); +} + +static inline int isspace_l(int c, locale_t) { + return isspace(c); +} + +static inline int isupper_l(int c, locale_t) { + return isupper(c); +} + +static inline int isxdigit_l(int c, locale_t) { + return isxdigit(c); +} + +static inline int iswalnum_l(wint_t c, locale_t) { + return iswalnum(c); +} + +static inline int iswalpha_l(wint_t c, locale_t) { + return iswalpha(c); +} + +static inline int iswblank_l(wint_t c, locale_t) { + return iswblank(c); +} + +static inline int iswcntrl_l(wint_t c, locale_t) { + return iswcntrl(c); +} + +static inline int iswdigit_l(wint_t c, locale_t) { + return iswdigit(c); +} + +static inline int iswgraph_l(wint_t c, locale_t) { + return iswgraph(c); +} + +static inline int iswlower_l(wint_t c, locale_t) { + return iswlower(c); +} + +static inline int iswprint_l(wint_t c, locale_t) { + return iswprint(c); +} + +static inline int iswpunct_l(wint_t c, locale_t) { + return iswpunct(c); +} + +static inline int iswspace_l(wint_t c, locale_t) { + return iswspace(c); +} + +static inline int iswupper_l(wint_t c, locale_t) { + return iswupper(c); +} + +static inline int iswxdigit_l(wint_t c, locale_t) { + return iswxdigit(c); +} + +static inline int toupper_l(int c, locale_t) { + return toupper(c); +} + +static inline int tolower_l(int c, locale_t) { + return tolower(c); +} + +static inline int towupper_l(int c, locale_t) { + return towupper(c); +} + +static inline int towlower_l(int c, locale_t) { + return towlower(c); +} + +static inline int strcoll_l(const char *s1, const char *s2, locale_t) { + return strcoll(s1, s2); +} + +static inline size_t strxfrm_l(char *dest, const char *src, size_t n, + locale_t) { + return strxfrm(dest, src, n); +} + +static inline size_t strftime_l(char *s, size_t max, const char *format, + const struct tm *tm, locale_t) { + return strftime(s, max, format, tm); +} + +static inline int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t) { + return wcscoll(ws1, ws2); +} + +static inline size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, + locale_t) { + return wcsxfrm(dest, src, n); +} + +static inline long double strtold_l(const char *nptr, char **endptr, locale_t) { + return strtold(nptr, endptr); +} + +static inline long long strtoll_l(const char *nptr, char **endptr, int base, + locale_t) { + return strtoll(nptr, endptr, base); +} + +static inline unsigned long long strtoull_l(const char *nptr, char **endptr, + int base, locale_t) { + return strtoull(nptr, endptr, base); +} + +static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, + int base, locale_t) { + return wcstoll(nptr, endptr, base); +} + +static inline unsigned long long wcstoull_l(const wchar_t *nptr, + wchar_t **endptr, int base, + locale_t) { + return wcstoull(nptr, endptr, base); +} + +static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr, + locale_t) { + return wcstold(nptr, endptr); +} + +#ifdef __cplusplus +} +#endif + +#endif // _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H diff --git a/include/tuple b/include/tuple index 5fc27f982790..3a22aa5ff5ac 100644 --- a/include/tuple +++ b/include/tuple @@ -161,10 +161,8 @@ using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // __tuple_leaf -template ::value -#if __has_feature(is_final) - && !__is_final(_Hp) -#endif +template ::value && !__libcpp_is_final<_Hp>::value > class __tuple_leaf; @@ -511,8 +509,8 @@ class _LIBCPP_TYPE_VIS_ONLY tuple typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; public: - template ::value)...>::value + template , _Dummy>::value...>::value >::type> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR tuple() @@ -846,8 +844,6 @@ struct __ignore_t namespace { const __ignore_t ignore = __ignore_t(); } -template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; - template struct __make_tuple_return_impl { @@ -927,8 +923,12 @@ struct __tuple_less _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp& __x, const _Up& __y) { - return __tuple_less<_Ip-1>()(__x, __y) || - (!__tuple_less<_Ip-1>()(__y, __x) && _VSTD::get<_Ip-1>(__x) < _VSTD::get<_Ip-1>(__y)); + const size_t __idx = tuple_size<_Tp>::value - _Ip; + if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y)) + return true; + if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x)) + return false; + return __tuple_less<_Ip-1>()(__x, __y); } }; diff --git a/include/type_traits b/include/type_traits index f4677358a560..a0c1bc565c04 100644 --- a/include/type_traits +++ b/include/type_traits @@ -19,8 +19,13 @@ namespace std // helper class: template struct integral_constant; - typedef integral_constant true_type; - typedef integral_constant false_type; + typedef integral_constant true_type; // C++11 + typedef integral_constant false_type; // C++11 + + template // C++14 + using bool_constant = integral_constant; // C++14 + typedef bool_constant true_type; // C++14 + typedef bool_constant false_type; // C++14 // helper traits template struct enable_if; @@ -211,10 +216,14 @@ namespace std _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_VARIADICS -template +template struct __void_t { typedef void type; }; -#endif + +template +struct __identity { typedef _Tp type; }; + +template +struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {}; template struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; @@ -257,8 +266,16 @@ struct _LIBCPP_TYPE_VIS_ONLY integral_constant template _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; -typedef integral_constant true_type; -typedef integral_constant false_type; +#if _LIBCPP_STD_VER > 14 +template +using bool_constant = integral_constant; +#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> +#else +#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant +#endif + +typedef _LIBCPP_BOOL_CONSTANT(true) true_type; +typedef _LIBCPP_BOOL_CONSTANT(false) false_type; // is_const @@ -430,9 +447,12 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : namespace __libcpp_is_function_imp { +struct __dummy_type {}; template char __test(_Tp*); +template char __test(__dummy_type); template __two __test(...); -template _Tp& __source(); +template _Tp& __source(int); +template __dummy_type __source(...); } template ::value || @@ -441,7 +461,7 @@ template ::value || is_reference<_Tp>::value || __is_nullptr_t<_Tp>::value > struct __libcpp_is_function - : public integral_constant(__libcpp_is_function_imp::__source<_Tp>())) == 1> + : public integral_constant(__libcpp_is_function_imp::__source<_Tp>(0))) == 1> {}; template struct __libcpp_is_function<_Tp, true> : public false_type {}; @@ -460,19 +480,15 @@ struct __member_pointer_traits_imp }; -namespace __libcpp_is_member_function_pointer_imp { - template - char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); - - template - std::__two __test(...); -}; - template struct __libcpp_is_member_function_pointer - : public integral_constant(nullptr)) == 1> {}; + : public false_type {}; + +template +struct __libcpp_is_member_function_pointer<_Ret _Class::*> + : public is_function<_Ret> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer - : public __libcpp_is_member_function_pointer::type> {}; + : public __libcpp_is_member_function_pointer::type>::type {}; // is_member_pointer @@ -673,7 +689,7 @@ template using add_pointer_t = typename add_pointer<_Tp>::type; // is_signed template ::value> -struct __libcpp_is_signed_impl : public integral_constant {}; +struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; template struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point @@ -688,7 +704,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is // is_unsigned template ::value> -struct __libcpp_is_unsigned_impl : public integral_constant {}; +struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; template struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point @@ -790,8 +806,16 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_ // is_final -#if _LIBCPP_STD_VER > 11 && __has_feature(is_final) -template struct _LIBCPP_TYPE_VIS_ONLY +#if defined(_LIBCPP_HAS_IS_FINAL) +template struct _LIBCPP_TYPE_VIS_ONLY +__libcpp_is_final : public integral_constant {}; +#else +template struct _LIBCPP_TYPE_VIS_ONLY +__libcpp_is_final : public false_type {}; +#endif + +#if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11 +template struct _LIBCPP_TYPE_VIS_ONLY is_final : public integral_constant {}; #endif @@ -832,7 +856,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of // is_convertible -#if __has_feature(is_convertible_to) +#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) template struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public integral_constant struct _LIBCPP_TYPE_VIS_ONLY is_convertible namespace __is_convertible_imp { -template char __test(_Tp); +template void __test_convert(_Tp); + +template +struct __is_convertible_test : public false_type {}; + +template +struct __is_convertible_test<_From, _To, + decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type +{}; + template __two __test(...); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template _Tp&& __source(); @@ -877,10 +910,8 @@ template ::value> struct __is_convertible : public integral_constant(__is_convertible_imp::__source<_T1>())) == 1 -#else - sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 + __is_convertible_imp::__is_convertible_test<_T1, _T2>::value +#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value && (!is_const::type>::value || is_volatile::type>::value) @@ -894,6 +925,7 @@ struct __is_convertible template struct __is_convertible<_T1, _T2, 1, 0> : false_type {}; template struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {}; +template struct __is_convertible : true_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {}; template struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {}; @@ -1433,11 +1465,11 @@ template using make_unsigned_t = typename make_unsigned<_Tp>::type; #ifdef _LIBCPP_HAS_NO_VARIADICS -template +template struct _LIBCPP_TYPE_VIS_ONLY common_type { public: - typedef typename common_type::type, V>::type type; + typedef typename common_type::type, _Vp>::type type; }; template @@ -1519,7 +1551,7 @@ template ::value || is_void<_Arg>::va struct __is_assignable_imp : public common_type < - decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>())) + decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>())) >::type {}; template @@ -1766,7 +1798,8 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil typedef _Rp (_FnType) (_Param..., ...); }; -#if __has_feature(cxx_reference_qualified_functions) +#if __has_feature(cxx_reference_qualified_functions) || \ + (defined(_GNUC_VER) && _GNUC_VER >= 409) template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> @@ -1896,7 +1929,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil typedef _Rp (_FnType) (_Param..., ...); }; -#endif // __has_feature(cxx_reference_qualified_functions) +#endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409 #else // _LIBCPP_HAS_NO_VARIADICS @@ -2222,7 +2255,7 @@ struct __result_of_mp; template struct __result_of_mp<_MP, _Tp, true> - : public common_type::_ReturnType> + : public __identity::_ReturnType> { }; @@ -2290,7 +2323,7 @@ template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()> : public __result_of<_Fn(), is_class::type>::value || - is_function::type>::value, + is_function::type>::type>::value, is_member_pointer::type>::value > { @@ -2300,7 +2333,7 @@ template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)> : public __result_of<_Fn(_A0), is_class::type>::value || - is_function::type>::value, + is_function::type>::type>::value, is_member_pointer::type>::value > { @@ -2310,7 +2343,7 @@ template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)> : public __result_of<_Fn(_A0, _A1), is_class::type>::value || - is_function::type>::value, + is_function::type>::type>::value, is_member_pointer::type>::value > { @@ -2320,7 +2353,7 @@ template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)> : public __result_of<_Fn(_A0, _A1, _A2), is_class::type>::value || - is_function::type>::value, + is_function::type>::type>::value, is_member_pointer::type>::value > { @@ -2668,7 +2701,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS -#if __has_feature(is_trivially_constructible) +#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible @@ -2727,7 +2760,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible { }; -#if __has_feature(is_trivially_constructible) +#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, @@ -2815,7 +2848,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl // is_trivially_assignable -#if __has_feature(is_trivially_assignable) +#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 template struct is_trivially_assignable @@ -3253,6 +3286,8 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #if __has_feature(is_trivially_copyable) : public integral_constant +#elif _GNUC_VER >= 501 + : public integral_constant::value && __is_trivially_copyable(_Tp)> #else : integral_constant::type>::value> #endif @@ -3261,7 +3296,7 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable // is_trivial; template struct _LIBCPP_TYPE_VIS_ONLY is_trivial -#if __has_feature(is_trivial) || (_GNUC_VER >= 407) +#if __has_feature(is_trivial) || _GNUC_VER >= 407 : public integral_constant #else : integral_constant::value && @@ -3646,6 +3681,48 @@ struct underlying_type #endif // _LIBCPP_UNDERLYING_TYPE + +template ::value> +struct __sfinae_underlying_type +{ + typedef typename underlying_type<_Tp>::type type; + typedef decltype(((type)1) + 0) __promoted_type; +}; + +template +struct __sfinae_underlying_type<_Tp, false> {}; + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +int __convert_to_integral(int __val) { return __val; } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +unsigned __convert_to_integral(unsigned __val) { return __val; } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +long __convert_to_integral(long __val) { return __val; } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +unsigned long __convert_to_integral(unsigned long __val) { return __val; } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +long long __convert_to_integral(long long __val) { return __val; } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } + +#ifndef _LIBCPP_HAS_NO_INT128 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +__int128_t __convert_to_integral(__int128_t __val) { return __val; } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +__uint128_t __convert_to_integral(__uint128_t __val) { return __val; } +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +typename __sfinae_underlying_type<_Tp>::__promoted_type +__convert_to_integral(_Tp __val) { return __val; } + #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE template diff --git a/include/unordered_map b/include/unordered_map index 0fa87d19ad03..cf70ab62f69e 100644 --- a/include/unordered_map +++ b/include/unordered_map @@ -122,7 +122,25 @@ public: void insert(InputIterator first, InputIterator last); void insert(initializer_list); + template + pair try_emplace(const key_type& k, Args&&... args); // C++17 + template + pair try_emplace(key_type&& k, Args&&... args); // C++17 + template + iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 + template + iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 + template + pair insert_or_assign(const key_type& k, M&& obj); // C++17 + template + pair insert_or_assign(key_type&& k, M&& obj); // C++17 + template + iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 + template + iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 + iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; @@ -287,6 +305,7 @@ public: void insert(initializer_list); iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; @@ -359,10 +378,8 @@ template _LIBCPP_BEGIN_NAMESPACE_STD -template ::value -#if __has_feature(is_final) - && !__is_final(_Hash) -#endif +template ::value && !__libcpp_is_final<_Hash>::value > class __unordered_map_hasher : private _Hash @@ -384,6 +401,12 @@ public: _LIBCPP_INLINE_VISIBILITY size_t operator()(const _Key& __x) const {return static_cast(*this)(__x);} + void swap(__unordered_map_hasher&__y) + _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) + { + using _VSTD::swap; + swap(static_cast(*this), static_cast(__y)); + } }; template @@ -408,12 +431,26 @@ public: _LIBCPP_INLINE_VISIBILITY size_t operator()(const _Key& __x) const {return __hash_(__x);} + void swap(__unordered_map_hasher&__y) + _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) + { + using _VSTD::swap; + swap(__hash_, __y.__hash_); + } }; -template ::value -#if __has_feature(is_final) - && !__is_final(_Pred) -#endif +template +inline _LIBCPP_INLINE_VISIBILITY +void +swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x, + __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) +{ + __x.swap(__y); +} + +template ::value && !__libcpp_is_final<_Pred>::value > class __unordered_map_equal : private _Pred @@ -438,6 +475,12 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _Cp& __y) const {return static_cast(*this)(__x, __y.__cc.first);} + void swap(__unordered_map_equal&__y) + _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) + { + using _VSTD::swap; + swap(static_cast(*this), static_cast(__y)); + } }; template @@ -465,8 +508,24 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _Cp& __y) const {return __pred_(__x, __y.__cc.first);} + void swap(__unordered_map_equal&__y) + _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) + { + using _VSTD::swap; + swap(__pred_, __y.__pred_); + } }; +template +inline _LIBCPP_INLINE_VISIBILITY +void +swap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x, + __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y) + _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) +{ + __x.swap(__y); +} + template class __hash_map_node_destructor { @@ -551,7 +610,7 @@ union __hash_value_type _LIBCPP_INLINE_VISIBILITY __hash_value_type(__hash_value_type&& __v) - : __nc(std::move(__v.__nc)) {} + : __nc(_VSTD::move(__v.__nc)) {} _LIBCPP_INLINE_VISIBILITY __hash_value_type& operator=(const __hash_value_type& __v) @@ -559,7 +618,7 @@ union __hash_value_type _LIBCPP_INLINE_VISIBILITY __hash_value_type& operator=(__hash_value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} + {__nc = _VSTD::move(__v.__nc); return *this;} _LIBCPP_INLINE_VISIBILITY ~__hash_value_type() {__cc.~value_type();} @@ -730,13 +789,8 @@ private: typedef __hash_value_type __value_type; typedef __unordered_map_hasher __hasher; typedef __unordered_map_equal __key_equal; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__value_type> -#else - rebind_alloc<__value_type>::other -#endif - __allocator_type; + typedef typename __rebind_alloc_helper, + __value_type>::type __allocator_type; typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; @@ -946,9 +1000,125 @@ public: {insert(__il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 14 +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_HAS_NO_VARIADICS + template + _LIBCPP_INLINE_VISIBILITY + pair try_emplace(const key_type& __k, _Args&&... __args) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + return _VSTD::make_pair(__p, false); + else + return _VSTD::make_pair( + emplace_hint(__p, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), + true); + } + + template + _LIBCPP_INLINE_VISIBILITY + pair try_emplace(key_type&& __k, _Args&&... __args) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + return _VSTD::make_pair(__p, false); + else + return _VSTD::make_pair( + emplace_hint(__p, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), + true); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + return __p; + else + return emplace_hint(__h, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + return __p; + else + return emplace_hint(__h, + _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); + } + + template + _LIBCPP_INLINE_VISIBILITY + pair insert_or_assign(const key_type& __k, _Vp&& __v) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + { + __p->second = _VSTD::move(__v); + return _VSTD::make_pair(__p, false); + } + return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true); + } + + template + _LIBCPP_INLINE_VISIBILITY + pair insert_or_assign(key_type&& __k, _Vp&& __v) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + { + __p->second = _VSTD::move(__v); + return _VSTD::make_pair(__p, false); + } + return _VSTD::make_pair(emplace_hint(__p, _VSTD::forward(__k), _VSTD::forward<_Vp>(__v)), true); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + { + __p->second = _VSTD::move(__v); + return __p; + } + return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v)); + } + + template + _LIBCPP_INLINE_VISIBILITY + iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) + { + iterator __p = __table_.find(__k); + if ( __p != end()) + { + __p->second = _VSTD::move(__v); + return __p; + } + return emplace_hint(__h, _VSTD::forward(__k), _VSTD::forward<_Vp>(__v)); + } +#endif +#endif +#endif + _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);} _LIBCPP_INLINE_VISIBILITY + iterator erase(iterator __p) {return __table_.erase(__p.__i_);} + _LIBCPP_INLINE_VISIBILITY size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __first, const_iterator __last) @@ -1469,13 +1639,8 @@ private: typedef __hash_value_type __value_type; typedef __unordered_map_hasher __hasher; typedef __unordered_map_equal __key_equal; - typedef typename allocator_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__value_type> -#else - rebind_alloc<__value_type>::other -#endif - __allocator_type; + typedef typename __rebind_alloc_helper, + __value_type>::type __allocator_type; typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; @@ -1654,6 +1819,8 @@ public: _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);} _LIBCPP_INLINE_VISIBILITY + iterator erase(iterator __p) {return __table_.erase(__p.__i_);} + _LIBCPP_INLINE_VISIBILITY size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __first, const_iterator __last) diff --git a/include/unordered_set b/include/unordered_set index d06629fdcd47..f6ccdc3734f2 100644 --- a/include/unordered_set +++ b/include/unordered_set @@ -114,16 +114,15 @@ public: void insert(initializer_list); iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; void swap(unordered_set&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); + noexcept(allocator_traits::is_always_equal::value && + noexcept(swap(declval(), declval())) && + noexcept(swap(declval(), declval()))); // C++17 hasher hash_function() const; key_equal key_eq() const; @@ -263,16 +262,15 @@ public: void insert(initializer_list); iterator erase(const_iterator position); + iterator erase(iterator position); // C++14 size_type erase(const key_type& k); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; void swap(unordered_multiset&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); + noexcept(allocator_traits::is_always_equal::value && + noexcept(swap(declval(), declval())) && + noexcept(swap(declval(), declval()))); // C++17 hasher hash_function() const; key_equal key_eq() const; diff --git a/include/utility b/include/utility index 6f324dbd6f94..54cfc8bc1592 100644 --- a/include/utility +++ b/include/utility @@ -202,6 +202,11 @@ operator>=(const _Tp& __x, const _Tp& __y) // swap_ranges +// forward +template +inline _LIBCPP_INLINE_VISIBILITY +void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); + template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator2 @@ -507,10 +512,6 @@ template class _LIBCPP_TYPE_VIS_ONLY tuple_size > : public integral_constant {}; -template - class _LIBCPP_TYPE_VIS_ONLY tuple_size > - : public integral_constant {}; - template class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> > { @@ -525,20 +526,6 @@ public: typedef _T2 type; }; -template -class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, const pair<_T1, _T2> > -{ -public: - typedef const _T1 type; -}; - -template -class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, const pair<_T1, _T2> > -{ -public: - typedef const _T2 type; -}; - template struct __get_pair; template <> diff --git a/include/valarray b/include/valarray index 2b942046db9d..bdaa58836f39 100644 --- a/include/valarray +++ b/include/valarray @@ -348,6 +348,7 @@ template unspecified2 end(const valarray& v); #include #include <__undef_min_max> +#include <__undef___deallocate> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/include/vector b/include/vector index 22a63439a763..c168c8ea60ad 100644 --- a/include/vector +++ b/include/vector @@ -119,8 +119,8 @@ public: void resize(size_type sz, const value_type& c); void swap(vector&) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value); + noexcept(allocator_traits::propagate_on_container_swap::value || + allocator_traits::is_always_equal::value); // C++17 bool __invariants() const; }; @@ -237,8 +237,8 @@ public: void resize(size_type sz, value_type x); void swap(vector&) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value); + noexcept(allocator_traits::propagate_on_container_swap::value || + allocator_traits::is_always_equal::value); // C++17 void flip() noexcept; bool __invariants() const; @@ -385,14 +385,6 @@ protected: is_nothrow_move_assignable::value) {__move_assign_alloc(__c, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y) - _NOEXCEPT_( - !__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) - {__swap_alloc(__x, __y, integral_constant());} private: _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __vector_base& __c, true_type) @@ -421,18 +413,6 @@ private: void __move_assign_alloc(__vector_base&, false_type) _NOEXCEPT {} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value) - { - using _VSTD::swap; - swap(__x, __y); - } - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(allocator_type&, allocator_type&, false_type) - _NOEXCEPT - {} }; template @@ -500,14 +480,18 @@ public: "Allocator::value_type must be same type as value_type"); _LIBCPP_INLINE_VISIBILITY - vector() - _NOEXCEPT_(is_nothrow_default_constructible::value) + vector() _NOEXCEPT_(is_nothrow_default_constructible::value) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif } _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value) +#else + _NOEXCEPT +#endif : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -569,7 +553,11 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY vector(vector&& __x) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT; +#else _NOEXCEPT_(is_nothrow_move_constructible::value); +#endif _LIBCPP_INLINE_VISIBILITY vector(vector&& __x, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY @@ -756,8 +744,12 @@ public: void resize(size_type __sz, const_reference __x); void swap(vector&) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value); +#endif bool __invariants() const; @@ -783,7 +775,7 @@ private: __is_forward_iterator<_ForwardIterator>::value, void >::type - __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); + __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n); void __append(size_type __n); void __append(size_type __n, const_reference __x); _LIBCPP_INLINE_VISIBILITY @@ -868,17 +860,17 @@ private: // but if an exception is thrown after that the annotation has to be undone. struct __RAII_IncreaseAnnotator { __RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1) - : __commit(false), __v(__v), __n(__n) { + : __commit(false), __v(__v), __old_size(__v.size() + __n) { __v.__annotate_increase(__n); } void __done() { __commit = true; } ~__RAII_IncreaseAnnotator() { if (__commit) return; - __v.__annotate_shrink(__v.size() + __n); + __v.__annotate_shrink(__old_size); } bool __commit; - size_type __n; const vector &__v; + size_type __old_size; }; #else struct __RAII_IncreaseAnnotator { @@ -1021,16 +1013,12 @@ typename enable_if __is_forward_iterator<_ForwardIterator>::value, void >::type -vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) +vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n) { allocator_type& __a = this->__alloc(); - for (; __first != __last; ++__first) - { - __RAII_IncreaseAnnotator __annotator(*this); - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); - __annotator.__done(); - ++this->__end_; - } + __RAII_IncreaseAnnotator __annotator(*this, __n); + __alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_); + __annotator.__done(); } // Default constructs __n objects starting at __end_ @@ -1177,7 +1165,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, if (__n > 0) { allocate(__n); - __construct_at_end(__first, __last); + __construct_at_end(__first, __last, __n); } } @@ -1197,7 +1185,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las if (__n > 0) { allocate(__n); - __construct_at_end(__first, __last); + __construct_at_end(__first, __last, __n); } } @@ -1212,7 +1200,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x) if (__n > 0) { allocate(__n); - __construct_at_end(__x.__begin_, __x.__end_); + __construct_at_end(__x.__begin_, __x.__end_, __n); } } @@ -1227,7 +1215,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) if (__n > 0) { allocate(__n); - __construct_at_end(__x.__begin_, __x.__end_); + __construct_at_end(__x.__begin_, __x.__end_, __n); } } @@ -1236,7 +1224,11 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT +#else _NOEXCEPT_(is_nothrow_move_constructible::value) +#endif : __base(_VSTD::move(__x.__alloc())) { #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1286,7 +1278,7 @@ vector<_Tp, _Allocator>::vector(initializer_list __il) if (__il.size() > 0) { allocate(__il.size()); - __construct_at_end(__il.begin(), __il.end()); + __construct_at_end(__il.begin(), __il.end(), __il.size()); } } @@ -1301,7 +1293,7 @@ vector<_Tp, _Allocator>::vector(initializer_list __il, const allocat if (__il.size() > 0) { allocate(__il.size()); - __construct_at_end(__il.begin(), __il.end()); + __construct_at_end(__il.begin(), __il.end(), __il.size()); } } @@ -1394,12 +1386,12 @@ typename enable_if >::type vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { - typename iterator_traits<_ForwardIterator>::difference_type __new_size = _VSTD::distance(__first, __last); - if (static_cast(__new_size) <= capacity()) + size_type __new_size = static_cast(_VSTD::distance(__first, __last)); + if (__new_size <= capacity()) { _ForwardIterator __mid = __last; bool __growing = false; - if (static_cast(__new_size) > size()) + if (__new_size > size()) { __growing = true; __mid = __first; @@ -1407,15 +1399,15 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las } pointer __m = _VSTD::copy(__first, __mid, this->__begin_); if (__growing) - __construct_at_end(__mid, __last); + __construct_at_end(__mid, __last, __new_size - size()); else this->__destruct_at_end(__m); } else { deallocate(); - allocate(__recommend(static_cast(__new_size))); - __construct_at_end(__first, __last); + allocate(__recommend(__new_size)); + __construct_at_end(__first, __last, __new_size); } } @@ -1967,8 +1959,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi if (__n > __dx) { __m = __first; - _VSTD::advance(__m, this->__end_ - __p); - __construct_at_end(__m, __last); + difference_type __diff = this->__end_ - __p; + _VSTD::advance(__m, __diff); + __construct_at_end(__m, __last, __n - __diff); __n = __dx; } if (__n > 0) @@ -2015,8 +2008,12 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) template void vector<_Tp, _Allocator>::swap(vector& __x) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value) +#endif { _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || this->__alloc() == __x.__alloc(), @@ -2025,7 +2022,8 @@ vector<_Tp, _Allocator>::swap(vector& __x) _VSTD::swap(this->__begin_, __x.__begin_); _VSTD::swap(this->__end_, __x.__end_); _VSTD::swap(this->__end_cap(), __x.__end_cap()); - __base::__swap_alloc(this->__alloc(), __x.__alloc()); + __swap_allocator(this->__alloc(), __x.__alloc(), + integral_constant()); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->swap(this, &__x); #endif // _LIBCPP_DEBUG_LEVEL >= 2 @@ -2128,13 +2126,7 @@ public: typedef _VSTD::reverse_iterator const_reverse_iterator; private: - typedef typename __alloc_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind_alloc<__storage_type> -#else - rebind_alloc<__storage_type>::other -#endif - __storage_allocator; + typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator; typedef allocator_traits<__storage_allocator> __storage_traits; typedef typename __storage_traits::pointer __storage_pointer; typedef typename __storage_traits::const_pointer __const_storage_pointer; @@ -2170,9 +2162,14 @@ private: public: _LIBCPP_INLINE_VISIBILITY - vector() - _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a); + vector() _NOEXCEPT_(is_nothrow_default_constructible::value); + + _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value); +#else + _NOEXCEPT; +#endif ~vector(); explicit vector(size_type __n); #if _LIBCPP_STD_VER > 11 @@ -2206,7 +2203,11 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY vector(vector&& __v) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT; +#else _NOEXCEPT_(is_nothrow_move_constructible::value); +#endif vector(vector&& __v, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __v) @@ -2354,8 +2355,12 @@ public: void clear() _NOEXCEPT {__size_ = 0;} void swap(vector&) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value); +#endif void resize(size_type __sz, value_type __x = false); void flip() _NOEXCEPT; @@ -2433,26 +2438,6 @@ private: _NOEXCEPT {} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y) - _NOEXCEPT_( - !__storage_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) - {__swap_alloc(__x, __y, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable::value) - { - using _VSTD::swap; - swap(__x, __y); - } - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__storage_allocator&, __storage_allocator&, false_type) - _NOEXCEPT - {} - size_t __hash_code() const _NOEXCEPT; friend class __bit_reference; @@ -2559,7 +2544,7 @@ vector::__construct_at_end(_ForwardIterator __first, _ForwardI template inline _LIBCPP_INLINE_VISIBILITY vector::vector() - _NOEXCEPT_(is_nothrow_default_constructible::value) + _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), __size_(0), __cap_alloc_(0) @@ -2569,6 +2554,11 @@ vector::vector() template inline _LIBCPP_INLINE_VISIBILITY vector::vector(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value) +#else + _NOEXCEPT +#endif : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) @@ -2807,7 +2797,11 @@ vector::operator=(const vector& __v) template inline _LIBCPP_INLINE_VISIBILITY vector::vector(vector&& __v) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT +#else _NOEXCEPT_(is_nothrow_move_constructible::value) +#endif : __begin_(__v.__begin_), __size_(__v.__size_), __cap_alloc_(__v.__cap_alloc_) @@ -3150,13 +3144,18 @@ vector::erase(const_iterator __first, const_iterator __last) template void vector::swap(vector& __x) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable::value) +#endif { _VSTD::swap(this->__begin_, __x.__begin_); _VSTD::swap(this->__size_, __x.__size_); _VSTD::swap(this->__cap(), __x.__cap()); - __swap_alloc(this->__alloc(), __x.__alloc()); + __swap_allocator(this->__alloc(), __x.__alloc(), + integral_constant()); } template diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 000000000000..d3d5f381d815 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,131 @@ +set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" PARENT_SCOPE) + +# Get sources +file(GLOB LIBCXX_SOURCES ../src/*.cpp) +if(WIN32) + file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp) + list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES}) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS") + file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c) + list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES}) +endif() + +# Add all the headers to the project for IDEs. +if (MSVC_IDE OR XCODE) + file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*) + if(WIN32) + file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h) + list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS}) + endif() + # Force them all into the headers dir on MSVC, otherwise they end up at + # project scope because they don't have extensions. + if (MSVC_IDE) + source_group("Header Files" FILES ${LIBCXX_HEADERS}) + endif() +endif() + +if (LIBCXX_ENABLE_SHARED) + add_library(cxx SHARED + ${LIBCXX_SOURCES} + ${LIBCXX_HEADERS} + ) +else() + add_library(cxx STATIC + ${LIBCXX_SOURCES} + ${LIBCXX_HEADERS} + ) +endif() + +#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path. +if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH) + target_link_libraries(cxx "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") +endif() + +if (DEFINED LIBCXX_CXX_ABI_DEPS) + add_dependencies(cxx LIBCXX_CXX_ABI_DEPS) +endif() + +set(libraries "") +if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) + # TODO(ericwf): Remove these GNU specific linker flags and let CMake do the + # configuration. This will be more portable. + list(APPEND libraries "-Wl,--whole-archive" "-Wl,-Bstatic") + list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}") + list(APPEND libraries "-Wl,-Bdynamic" "-Wl,--no-whole-archive") +else() + list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}") +endif() + +# Generate library list. +append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread) +append_if(libraries LIBCXX_HAS_C_LIB c) +append_if(libraries LIBCXX_HAS_M_LIB m) +append_if(libraries LIBCXX_HAS_RT_LIB rt) +append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s) + +if (LIBCXX_COVERAGE_LIBRARY) + target_link_libraries(cxx ${LIBCXX_COVERAGE_LIBRARY}) +endif() +target_link_libraries(cxx ${libraries}) + + +# Setup flags. +append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC) +append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) + +if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR + LIBCXX_CXX_ABI_LIBNAME STREQUAL "none")) + if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION) + set(LIBCXX_LIBCPPABI_VERSION "2") + endif() + + if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) + list(APPEND LIBCXX_COMPILE_FLAGS "-U__STRICT_ANSI__") + list(APPEND LIBCXX_LINK_FLAGS + "-compatibility_version 1" + "-current_version 1" + "-install_name /usr/lib/libc++.1.dylib" + "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "/usr/lib/libSystem.B.dylib") + else() + if ( ${CMAKE_OSX_SYSROOT} ) + list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7) + if (OSX_HAS_ARMV7) + set(OSX_RE_EXPORT_LINE + "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" + "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") + else() + set(OSX_RE_EXPORT_LINE + "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") + endif() + else() + set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") + endif() + + list(APPEND LIBCXX_LINK_FLAGS + "-compatibility_version 1" + "-install_name /usr/lib/libc++.1.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "${OSX_RE_EXPORT_LINE}" + "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp" + "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp") + endif() +endif() + +string(REPLACE ";" " " LIBCXX_COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}") +string(REPLACE ";" " " LIBCXX_LINK_FLAGS "${LIBCXX_LINK_FLAGS}") + +set_target_properties(cxx + PROPERTIES + COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" + LINK_FLAGS "${LIBCXX_LINK_FLAGS}" + OUTPUT_NAME "c++" + VERSION "1.0" + SOVERSION "1" + ) + +install(TARGETS cxx + LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} + ) diff --git a/lib/buildit b/lib/buildit new file mode 100755 index 000000000000..7e3bc2ed2a96 --- /dev/null +++ b/lib/buildit @@ -0,0 +1,179 @@ +#! /bin/sh +# +# Set the $TRIPLE environment variable to your system's triple before +# running this script. If you set $CXX, that will be used to compile +# the library. Otherwise we'll use clang++. + +set -e + +if [ `basename $(pwd)` != "lib" ] +then + echo "current directory must be lib" + exit 1 +fi + +if [ -z "$CXX" ] +then + CXX=clang++ +fi + +if [ -z "$CXX_LANG" ] +then + CXX_LANG=c++11 +fi + +if [ -z "$CC" ] +then + CC=clang +fi + +if [ -z "$MACOSX_DEPLOYMENT_TARGET" ] +then + if [ -z "$IPHONEOS_DEPLOYMENT_TARGET" ] + then + MACOSX_DEPLOYMENT_TARGET=10.7 + fi +fi + +if [ -z "$RC_ProjectSourceVersion" ] +then + RC_ProjectSourceVersion=1 +fi + +EXTRA_FLAGS="-nostdinc++ -std=${CXX_LANG} -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \ + -Wpadded -Wstrict-aliasing=2 -Wstrict-overflow=4 " + +case $TRIPLE in + *-apple-*) + if [ -z $RC_XBS ] + then + RC_CFLAGS="-arch i386 -arch x86_64" + fi + SOEXT=dylib + if [ "$MACOSX_DEPLOYMENT_TARGET" = "10.6" ] + then + EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__" + LDSHARED_FLAGS="-o libc++.1.dylib \ + -dynamiclib -nodefaultlibs -current_version 1 \ + -compatibility_version 1 \ + -install_name /usr/lib/libc++.1.dylib \ + -Wl,-reexport_library,/usr/lib/libc++abi.dylib \ + -Wl,-unexported_symbols_list,libc++unexp.exp \ + /usr/lib/libSystem.B.dylib" + else + if [ -n "$SDKROOT" ] + then + EXTRA_FLAGS+="-isysroot ${SDKROOT} " + if echo "${RC_ARCHS}" | grep -q "armv7" + then + RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp" + else + RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib" + fi + CXX=`xcrun -sdk "${SDKROOT}" -find clang++` + CC=`xcrun -sdk "${SDKROOT}" -find clang` + else + # Check if we have _LIBCPPABI_VERSION, to determine the reexport list to use. + if (echo "#include " | $CXX -E -dM -x c++ - | \ + grep _LIBCPPABI_VERSION > /dev/null) + then + RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi2.exp" + else + RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp" + fi + fi + LDSHARED_FLAGS="-o libc++.1.dylib \ + -dynamiclib -nodefaultlibs \ + -current_version ${RC_ProjectSourceVersion} \ + -compatibility_version 1 \ + -install_name /usr/lib/libc++.1.dylib \ + -lSystem \ + -Wl,-unexported_symbols_list,libc++unexp.exp \ + ${RE_EXPORT_LINE} \ + -Wl,-force_symbols_not_weak_list,notweak.exp \ + -Wl,-force_symbols_weak_list,weak.exp" + fi + ;; + *-*-mingw*) + # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt + SOEXT=dll + LDSHARED_FLAGS="-o libc++.dll \ + -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \ + -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt" + ;; + *-ibm-*) + hostOS=`uname` + hostOS=`echo $hostOS | sed -e "s/\s+$//"` + hostOS=`echo $hostOS | tr '[A-Z]' '[a-z]'` + + if [ $hostOS = "linux" ] + then + LDSHARED_FLAGS="-o libc++.so.1 \ + -qmkshrobj -Wl,-soname,libc++.so.1 \ + -lpthread -lrt -lc -lstdc++" + EXTRA_FLAGS="-qlanglvl=extended0x -D__GLIBCXX__=1" + else + LDSHARED_FLAGS="-o shr.o -qmkshrobj -lpthread -bnoquiet" + EXTRA_FLAGS="-qlanglvl=extended0x" + fi + RC_CFLAGS="-qpic=large" + ;; + *) + RC_CFLAGS="-fPIC" + SOEXT=so + LDSHARED_FLAGS="-o libc++.so.1.0 \ + -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \ + -lpthread -lrt -lc -lstdc++" + ;; +esac + +if [ -z "$RC_XBS" ] +then + rm -f libc++.1.$SOEXT* +fi + +set -x + +for FILE in ../src/*.cpp; do + $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE +done +case $TRIPLE in + *-*-mingw*) + for FILE in ../src/support/win32/*.cpp; do + $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE + done + ;; +esac +$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS + +#libtool -static -o libc++.a *.o + +# Create the link for the final library name, so that we can use this directory +# as a link target for the tests. +case $TRIPLE in + *-apple-*) + rm -f libc++.dylib + ln -s libc++.1.dylib libc++.dylib + ;; + *-*-mingw*) + ;; + *-ibm-*) + if [ $hostOS = "linux" ] + then + rm -f libc++.so + ln -s libc++.so.1 libc++.so + else #AIX + rm -f libc++.a + ar r libc++.a shr.o + fi + ;; + *) + rm -f libc++.so + ln -s libc++.so.1 libc++.so + ;; +esac + +if [ -z "$RC_XBS" ] +then + rm *.o +fi diff --git a/lib/libc++abi.exp b/lib/libc++abi.exp new file mode 100644 index 000000000000..87035b295f3c --- /dev/null +++ b/lib/libc++abi.exp @@ -0,0 +1,159 @@ +___cxa_allocate_exception +___cxa_end_catch +___cxa_demangle +___cxa_current_exception_type +___cxa_call_unexpected +___cxa_free_exception +___cxa_get_exception_ptr +___cxa_get_globals +___cxa_get_globals_fast +___cxa_guard_abort +___cxa_guard_acquire +___cxa_guard_release +___cxa_rethrow +___cxa_pure_virtual +___cxa_begin_catch +___cxa_throw +___cxa_vec_cctor +___cxa_vec_cleanup +___cxa_vec_ctor +___cxa_vec_delete +___cxa_vec_delete2 +___cxa_vec_delete3 +___cxa_vec_dtor +___cxa_vec_new +___cxa_vec_new2 +___cxa_vec_new3 +___dynamic_cast +___gxx_personality_v0 +__ZTIDi +__ZTIDn +__ZTIDs +__ZTIPDi +__ZTIPDn +__ZTIPDs +__ZTIPKDi +__ZTIPKDn +__ZTIPKDs +__ZTSPm +__ZTSPl +__ZTSPj +__ZTSPi +__ZTSPh +__ZTSPf +__ZTSPe +__ZTSPd +__ZTSPc +__ZTSPb +__ZTSPa +__ZTSPKc +__ZTSPKy +__ZTSPKx +__ZTSPKw +__ZTSPKv +__ZTSPKt +__ZTSPKs +__ZTSPKm +__ZTSPKl +__ZTSPKi +__ZTSPKh +__ZTSPs +__ZTSPt +__ZTSPv +__ZTSPw +__ZTSPKa +__ZTSPx +__ZTSPy +__ZTSPKd +__ZTSPKe +__ZTSPKj +__ZTSPKb +__ZTSPKf +__ZTSv +__ZTSt +__ZTSs +__ZTSm +__ZTSl +__ZTSj +__ZTSi +__ZTSh +__ZTSf +__ZTSe +__ZTSd +__ZTSc +__ZTSw +__ZTSx +__ZTSy +__ZTSb +__ZTSa +__ZTIPKh +__ZTIPKf +__ZTIPKe +__ZTIPKd +__ZTIPKc +__ZTIPKb +__ZTIPKa +__ZTIPy +__ZTIPx +__ZTIPw +__ZTIPv +__ZTIPt +__ZTIPs +__ZTIPm +__ZTIPl +__ZTIPj +__ZTIPi +__ZTIPKi +__ZTIPKj +__ZTIPKl +__ZTIPKm +__ZTIPKs +__ZTIPKt +__ZTIPKv +__ZTIPKw +__ZTIPKx +__ZTIPKy +__ZTIPa +__ZTIPb +__ZTIPc +__ZTIPd +__ZTIPe +__ZTIPf +__ZTIPh +__ZTVN10__cxxabiv129__pointer_to_member_type_infoE +__ZTVN10__cxxabiv116__enum_type_infoE +__ZTVN10__cxxabiv117__array_type_infoE +__ZTVN10__cxxabiv117__class_type_infoE +__ZTVN10__cxxabiv117__pbase_type_infoE +__ZTVN10__cxxabiv119__pointer_type_infoE +__ZTVN10__cxxabiv120__function_type_infoE +__ZTVN10__cxxabiv120__si_class_type_infoE +__ZTVN10__cxxabiv121__vmi_class_type_infoE +__ZTVN10__cxxabiv123__fundamental_type_infoE +__ZTIa +__ZTIb +__ZTIc +__ZTId +__ZTIe +__ZTIf +__ZTIh +__ZTIi +__ZTIj +__ZTIl +__ZTIm +__ZTIs +__ZTIt +__ZTSN10__cxxabiv129__pointer_to_member_type_infoE +__ZTSN10__cxxabiv123__fundamental_type_infoE +__ZTSN10__cxxabiv121__vmi_class_type_infoE +__ZTSN10__cxxabiv120__si_class_type_infoE +__ZTSN10__cxxabiv120__function_type_infoE +__ZTSN10__cxxabiv119__pointer_type_infoE +__ZTSN10__cxxabiv117__pbase_type_infoE +__ZTSN10__cxxabiv117__class_type_infoE +__ZTSN10__cxxabiv117__array_type_infoE +__ZTSN10__cxxabiv116__enum_type_infoE +__ZTIy +__ZTIx +__ZTIw +__ZTIv diff --git a/lib/libc++abi2.exp b/lib/libc++abi2.exp new file mode 100644 index 000000000000..bdfe99c3456e --- /dev/null +++ b/lib/libc++abi2.exp @@ -0,0 +1,310 @@ +___cxa_allocate_exception +___cxa_end_catch +___cxa_demangle +___cxa_current_exception_type +___cxa_call_unexpected +___cxa_free_exception +___cxa_get_exception_ptr +___cxa_get_globals +___cxa_get_globals_fast +___cxa_guard_abort +___cxa_guard_acquire +___cxa_guard_release +___cxa_rethrow +___cxa_pure_virtual +___cxa_begin_catch +___cxa_throw +___cxa_vec_cctor +___cxa_vec_cleanup +___cxa_vec_ctor +___cxa_vec_delete +___cxa_vec_delete2 +___cxa_vec_delete3 +___cxa_vec_dtor +___cxa_vec_new +___cxa_vec_new2 +___cxa_vec_new3 +___dynamic_cast +___gxx_personality_v0 +__ZTIDi +__ZTIDn +__ZTIDs +__ZTIPDi +__ZTIPDn +__ZTIPDs +__ZTIPKDi +__ZTIPKDn +__ZTIPKDs +__ZTSPm +__ZTSPl +__ZTSPj +__ZTSPi +__ZTSPh +__ZTSPf +__ZTSPe +__ZTSPd +__ZTSPc +__ZTSPb +__ZTSPa +__ZTSPKc +__ZTSPKy +__ZTSPKx +__ZTSPKw +__ZTSPKv +__ZTSPKt +__ZTSPKs +__ZTSPKm +__ZTSPKl +__ZTSPKi +__ZTSPKh +__ZTSPs +__ZTSPt +__ZTSPv +__ZTSPw +__ZTSPKa +__ZTSPx +__ZTSPy +__ZTSPKd +__ZTSPKe +__ZTSPKj +__ZTSPKb +__ZTSPKf +__ZTSv +__ZTSt +__ZTSs +__ZTSm +__ZTSl +__ZTSj +__ZTSi +__ZTSh +__ZTSf +__ZTSe +__ZTSd +__ZTSc +__ZTSw +__ZTSx +__ZTSy +__ZTSb +__ZTSa +__ZTIPKh +__ZTIPKf +__ZTIPKe +__ZTIPKd +__ZTIPKc +__ZTIPKb +__ZTIPKa +__ZTIPy +__ZTIPx +__ZTIPw +__ZTIPv +__ZTIPt +__ZTIPs +__ZTIPm +__ZTIPl +__ZTIPj +__ZTIPi +__ZTIPKi +__ZTIPKj +__ZTIPKl +__ZTIPKm +__ZTIPKs +__ZTIPKt +__ZTIPKv +__ZTIPKw +__ZTIPKx +__ZTIPKy +__ZTIPa +__ZTIPb +__ZTIPc +__ZTIPd +__ZTIPe +__ZTIPf +__ZTIPh +__ZTVN10__cxxabiv129__pointer_to_member_type_infoE +__ZTVN10__cxxabiv116__enum_type_infoE +__ZTVN10__cxxabiv117__array_type_infoE +__ZTVN10__cxxabiv117__class_type_infoE +__ZTVN10__cxxabiv117__pbase_type_infoE +__ZTVN10__cxxabiv119__pointer_type_infoE +__ZTVN10__cxxabiv120__function_type_infoE +__ZTVN10__cxxabiv120__si_class_type_infoE +__ZTVN10__cxxabiv121__vmi_class_type_infoE +__ZTVN10__cxxabiv123__fundamental_type_infoE +__ZTIa +__ZTIb +__ZTIc +__ZTId +__ZTIe +__ZTIf +__ZTIh +__ZTIi +__ZTIj +__ZTIl +__ZTIm +__ZTIs +__ZTIt +__ZTSN10__cxxabiv129__pointer_to_member_type_infoE +__ZTSN10__cxxabiv123__fundamental_type_infoE +__ZTSN10__cxxabiv121__vmi_class_type_infoE +__ZTSN10__cxxabiv120__si_class_type_infoE +__ZTSN10__cxxabiv120__function_type_infoE +__ZTSN10__cxxabiv119__pointer_type_infoE +__ZTSN10__cxxabiv117__pbase_type_infoE +__ZTSN10__cxxabiv117__class_type_infoE +__ZTSN10__cxxabiv117__array_type_infoE +__ZTSN10__cxxabiv116__enum_type_infoE +__ZTIy +__ZTIx +__ZTIw +__ZTIv +__ZSt13get_terminatev +__ZSt13set_terminatePFvvE +__ZSt14get_unexpectedv +__ZSt14set_unexpectedPFvvE +__ZSt15get_new_handlerv +__ZSt15set_new_handlerPFvvE +__ZSt9terminatev +__ZNSt9bad_allocD1Ev +__ZTISt9bad_alloc +__ZNSt9bad_allocC1Ev +__ZTISt13bad_exception +__ZTVSt10bad_typeid +__ZTVSt9exception +__ZNSt10bad_typeidC1Ev +__ZNSt10bad_typeidC1Ev +__ZNKSt10bad_typeid4whatEv +__ZNSt10bad_typeidD1Ev +__ZTVSt8bad_cast +__ZNSt8bad_castC1Ev +__ZNSt8bad_castC2Ev +__ZNSt8bad_castD0Ev +__ZNKSt8bad_cast4whatEv +__ZNSt8bad_castD1Ev +__ZNSt8bad_castD2Ev +__ZTVSt9bad_alloc +__ZTVSt20bad_array_new_length +__ZTVSt13bad_exception +__ZNKSt9exception4whatEv +__ZNKSt9bad_alloc4whatEv +__ZNSt9bad_allocC2Ev +__ZNSt9bad_allocD0Ev +__ZNSt9bad_allocD2Ev +__ZNSt9exceptionD0Ev +__ZNSt20bad_array_new_lengthC1Ev +__ZNKSt13bad_exception4whatEv +__ZNSt9exceptionD1Ev +__ZNKSt20bad_array_new_length4whatEv +__ZNSt13bad_exceptionD1Ev +__ZNSt20bad_array_new_lengthD1Ev +__ZNSt9exceptionD2Ev +__ZNSt9type_infoD0Ev +__ZNSt9type_infoD1Ev +__ZNSt9type_infoD2Ev +__ZNSt10bad_typeidC2Ev +__ZNSt10bad_typeidD0Ev +__ZNSt10bad_typeidD2Ev +__ZNSt13bad_exceptionD0Ev +__ZNSt13bad_exceptionD2Ev +__ZNSt20bad_array_new_lengthC2Ev +__ZNSt20bad_array_new_lengthD0Ev +__ZNSt20bad_array_new_lengthD2Ev +__ZSt10unexpectedv +# __ZdaPv +# __ZdlPv +# __ZdlPvRKSt9nothrow_t +# __Znam +# __ZdaPvRKSt9nothrow_t +# __Znwm +# __ZnwmRKSt9nothrow_t +# __ZnamRKSt9nothrow_t +__ZTISt10bad_typeid +__ZTISt8bad_cast +___cxa_bad_typeid +___cxa_bad_cast +__ZTISt9exception +__ZTISt9type_info +__ZTISt20bad_array_new_length + +__ZNKSt11logic_error4whatEv +__ZNSt11logic_errorD0Ev +__ZNSt11logic_errorD1Ev +__ZNSt11logic_errorD2Ev +__ZTISt11logic_error +__ZTSSt11logic_error +__ZTVSt11logic_error + +__ZNKSt13runtime_error4whatEv +__ZNSt13runtime_errorD0Ev +__ZNSt13runtime_errorD1Ev +__ZNSt13runtime_errorD2Ev +__ZTISt13runtime_error +__ZTSSt13runtime_error +__ZTVSt13runtime_error + +__ZNSt11range_errorD0Ev +__ZNSt11range_errorD1Ev +__ZNSt11range_errorD2Ev +__ZTISt11range_error +__ZTSSt11range_error +__ZTVSt11range_error + +__ZNSt12domain_errorD0Ev +__ZNSt12domain_errorD1Ev +__ZNSt12domain_errorD2Ev +__ZTISt12domain_error +__ZTSSt12domain_error +__ZTVSt12domain_error + +__ZNSt12length_errorD0Ev +__ZNSt12length_errorD1Ev +__ZNSt12length_errorD2Ev +__ZTISt12length_error +__ZTSSt12length_error +__ZTVSt12length_error + +__ZNSt12out_of_rangeD0Ev +__ZNSt12out_of_rangeD1Ev +__ZNSt12out_of_rangeD2Ev +__ZTISt12out_of_range +__ZTSSt12out_of_range +__ZTVSt12out_of_range + +__ZNSt14overflow_errorD0Ev +__ZNSt14overflow_errorD1Ev +__ZNSt14overflow_errorD2Ev +__ZTISt14overflow_error +__ZTSSt14overflow_error +__ZTVSt14overflow_error + +__ZNSt15underflow_errorD0Ev +__ZNSt15underflow_errorD1Ev +__ZNSt15underflow_errorD2Ev +__ZTISt15underflow_error +__ZTSSt15underflow_error +__ZTVSt15underflow_error + +__ZNSt16invalid_argumentD0Ev +__ZNSt16invalid_argumentD1Ev +__ZNSt16invalid_argumentD2Ev +__ZTISt16invalid_argument +__ZTSSt16invalid_argument +__ZTVSt16invalid_argument + +__ZTSDi +__ZTSDn +__ZTSDs +__ZTSPDi +__ZTSPDn +__ZTSPDs +__ZTSPKDi +__ZTSPKDn +__ZTSPKDs + +__ZTSSt8bad_cast +__ZTSSt9bad_alloc +__ZTSSt9exception +__ZTSSt9type_info +__ZTSSt10bad_typeid +__ZTSSt13bad_exception +__ZTSSt20bad_array_new_length +__ZTVSt9type_info diff --git a/lib/libc++sjlj-abi.exp b/lib/libc++sjlj-abi.exp new file mode 100644 index 000000000000..e646df1a4bd6 --- /dev/null +++ b/lib/libc++sjlj-abi.exp @@ -0,0 +1,159 @@ +___cxa_allocate_exception +___cxa_end_catch +___cxa_demangle +___cxa_current_exception_type +___cxa_call_unexpected +___cxa_free_exception +___cxa_get_exception_ptr +___cxa_get_globals +___cxa_get_globals_fast +___cxa_guard_abort +___cxa_guard_acquire +___cxa_guard_release +___cxa_rethrow +___cxa_pure_virtual +___cxa_begin_catch +___cxa_throw +___cxa_vec_cctor +___cxa_vec_cleanup +___cxa_vec_ctor +___cxa_vec_delete +___cxa_vec_delete2 +___cxa_vec_delete3 +___cxa_vec_dtor +___cxa_vec_new +___cxa_vec_new2 +___cxa_vec_new3 +___dynamic_cast +___gxx_personality_sj0 +__ZTIDi +__ZTIDn +__ZTIDs +__ZTIPDi +__ZTIPDn +__ZTIPDs +__ZTIPKDi +__ZTIPKDn +__ZTIPKDs +__ZTSPm +__ZTSPl +__ZTSPj +__ZTSPi +__ZTSPh +__ZTSPf +__ZTSPe +__ZTSPd +__ZTSPc +__ZTSPb +__ZTSPa +__ZTSPKc +__ZTSPKy +__ZTSPKx +__ZTSPKw +__ZTSPKv +__ZTSPKt +__ZTSPKs +__ZTSPKm +__ZTSPKl +__ZTSPKi +__ZTSPKh +__ZTSPs +__ZTSPt +__ZTSPv +__ZTSPw +__ZTSPKa +__ZTSPx +__ZTSPy +__ZTSPKd +__ZTSPKe +__ZTSPKj +__ZTSPKb +__ZTSPKf +__ZTSv +__ZTSt +__ZTSs +__ZTSm +__ZTSl +__ZTSj +__ZTSi +__ZTSh +__ZTSf +__ZTSe +__ZTSd +__ZTSc +__ZTSw +__ZTSx +__ZTSy +__ZTSb +__ZTSa +__ZTIPKh +__ZTIPKf +__ZTIPKe +__ZTIPKd +__ZTIPKc +__ZTIPKb +__ZTIPKa +__ZTIPy +__ZTIPx +__ZTIPw +__ZTIPv +__ZTIPt +__ZTIPs +__ZTIPm +__ZTIPl +__ZTIPj +__ZTIPi +__ZTIPKi +__ZTIPKj +__ZTIPKl +__ZTIPKm +__ZTIPKs +__ZTIPKt +__ZTIPKv +__ZTIPKw +__ZTIPKx +__ZTIPKy +__ZTIPa +__ZTIPb +__ZTIPc +__ZTIPd +__ZTIPe +__ZTIPf +__ZTIPh +__ZTVN10__cxxabiv129__pointer_to_member_type_infoE +__ZTVN10__cxxabiv116__enum_type_infoE +__ZTVN10__cxxabiv117__array_type_infoE +__ZTVN10__cxxabiv117__class_type_infoE +__ZTVN10__cxxabiv117__pbase_type_infoE +__ZTVN10__cxxabiv119__pointer_type_infoE +__ZTVN10__cxxabiv120__function_type_infoE +__ZTVN10__cxxabiv120__si_class_type_infoE +__ZTVN10__cxxabiv121__vmi_class_type_infoE +__ZTVN10__cxxabiv123__fundamental_type_infoE +__ZTIa +__ZTIb +__ZTIc +__ZTId +__ZTIe +__ZTIf +__ZTIh +__ZTIi +__ZTIj +__ZTIl +__ZTIm +__ZTIs +__ZTIt +__ZTSN10__cxxabiv129__pointer_to_member_type_infoE +__ZTSN10__cxxabiv123__fundamental_type_infoE +__ZTSN10__cxxabiv121__vmi_class_type_infoE +__ZTSN10__cxxabiv120__si_class_type_infoE +__ZTSN10__cxxabiv120__function_type_infoE +__ZTSN10__cxxabiv119__pointer_type_infoE +__ZTSN10__cxxabiv117__pbase_type_infoE +__ZTSN10__cxxabiv117__class_type_infoE +__ZTSN10__cxxabiv117__array_type_infoE +__ZTSN10__cxxabiv116__enum_type_infoE +__ZTIy +__ZTIx +__ZTIw +__ZTIv diff --git a/lib/libc++unexp.exp b/lib/libc++unexp.exp new file mode 100644 index 000000000000..9507fc57f184 --- /dev/null +++ b/lib/libc++unexp.exp @@ -0,0 +1,19 @@ +# all guard variables +__ZGVNSt3__* +# all vtables +# __ZTV* +# all VTT +# __ZTT* +# all non-virtual thunks +# __ZTh* +# all virtual thunks +# __ZTv* +# typeinfo for std::__1::__types +# There are no std::__types +# __ZTINSt3__1[0-9][0-9]*__* +# typeinfo name for std::__1::__types +__ZTSNSt3__1[0-9][0-9]*__* +# anything using __hidden_allocator +*__hidden_allocator* +# anything using __sso_allocator +*__sso_allocator* diff --git a/lib/notweak.exp b/lib/notweak.exp new file mode 100644 index 000000000000..fafde1c84b63 --- /dev/null +++ b/lib/notweak.exp @@ -0,0 +1,5 @@ +# Remove the weak-def bit from these external symbols +__ZT* +__ZN* +__ZS* + diff --git a/lib/weak.exp b/lib/weak.exp new file mode 100644 index 000000000000..6bdcc0578460 --- /dev/null +++ b/lib/weak.exp @@ -0,0 +1,16 @@ +__ZTISt10bad_typeid +__ZTISt11logic_error +__ZTISt11range_error +__ZTISt12domain_error +__ZTISt12length_error +__ZTISt12out_of_range +__ZTISt13bad_exception +__ZTISt13runtime_error +__ZTISt14overflow_error +__ZTISt15underflow_error +__ZTISt16invalid_argument +__ZTISt16nested_exception +__ZTISt20bad_array_new_length +__ZTISt8bad_cast +__ZTISt9bad_alloc +__ZTISt9exception diff --git a/src/chrono.cpp b/src/chrono.cpp index 456941144e01..62149fbf420c 100644 --- a/src/chrono.cpp +++ b/src/chrono.cpp @@ -8,14 +8,21 @@ //===----------------------------------------------------------------------===// #include "chrono" -#include //for gettimeofday and timeval -#ifdef __APPLE__ +#include "cerrno" // errno +#include "system_error" // __throw_system_error +#include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME + +#if !defined(CLOCK_REALTIME) +#include // for gettimeofday and timeval +#endif + +#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(CLOCK_MONOTONIC) +#if __APPLE__ #include // mach_absolute_time, mach_timebase_info_data_t -#else /* !__APPLE__ */ -#include // errno -#include // __throw_system_error -#include // clock_gettime, CLOCK_MONOTONIC -#endif // __APPLE__ +#else +#error "Monotonic clock not implemented" +#endif +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -29,9 +36,16 @@ const bool system_clock::is_steady; system_clock::time_point system_clock::now() _NOEXCEPT { +#ifdef CLOCK_REALTIME + struct timespec tp; + if (0 != clock_gettime(CLOCK_REALTIME, &tp)) + __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); + return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000)); +#else // !CLOCK_REALTIME timeval tv; gettimeofday(&tv, 0); return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec)); +#endif // CLOCK_REALTIME } time_t @@ -48,10 +62,26 @@ system_clock::from_time_t(time_t t) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK // steady_clock +// +// Warning: If this is not truly steady, then it is non-conforming. It is +// better for it to not exist and have the rest of libc++ use system_clock +// instead. const bool steady_clock::is_steady; -#ifdef __APPLE__ +#ifdef CLOCK_MONOTONIC + +steady_clock::time_point +steady_clock::now() _NOEXCEPT +{ + struct timespec tp; + if (0 != clock_gettime(CLOCK_MONOTONIC, &tp)) + __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed"); + return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); +} + +#elif defined(__APPLE__) + // mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of // nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom // are run time constants supplied by the OS. This clock has no relationship @@ -108,23 +138,9 @@ steady_clock::now() _NOEXCEPT return time_point(duration(fp())); } -#else // __APPLE__ -// FIXME: if _LIBCPP_HAS_NO_MONOTONIC_CLOCK, then clock_gettime isn't going to -// work. It may be possible to fall back on something else, depending on the system. - -// Warning: If this is not truly steady, then it is non-conforming. It is -// better for it to not exist and have the rest of libc++ use system_clock -// instead. - -steady_clock::time_point -steady_clock::now() _NOEXCEPT -{ - struct timespec tp; - if (0 != clock_gettime(CLOCK_MONOTONIC, &tp)) - __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed"); - return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); -} -#endif // __APPLE__ +#else +#error "Monotonic clock not implemented" +#endif #endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK diff --git a/src/config_elast.h b/src/config_elast.h new file mode 100644 index 000000000000..9d6a76b0c004 --- /dev/null +++ b/src/config_elast.h @@ -0,0 +1,36 @@ +//===----------------------- config_elast.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 _LIBCPP_CONFIG_ELAST +#define _LIBCPP_CONFIG_ELAST + +#if defined(_WIN32) +#include +#else +#include +#endif + +#if defined(ELAST) +#define _LIBCPP_ELAST ELAST +#elif defined(_NEWLIB_VERSION) +#define _LIBCPP_ELAST __ELASTERROR +#elif defined(__linux__) +#define _LIBCPP_ELAST 4095 +#elif defined(__APPLE__) +// No _LIBCPP_ELAST needed on Apple +#elif defined(__sun__) +#define _LIBCPP_ELAST ESTALE +#elif defined(_WIN32) +#define _LIBCPP_ELAST _sys_nerr +#else +// Warn here so that the person doing the libcxx port has an easier time: +#warning ELAST for this platform not yet implemented +#endif + +#endif // _LIBCPP_CONFIG_ELAST diff --git a/src/debug.cpp b/src/debug.cpp index 60694a3bdb0e..b1a16e6e72d4 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -214,10 +214,10 @@ __libcpp_db::__erase_i(void* __i) else q->__next_ = p->__next_; __c_node* c = p->__c_; - free(p); --__isz_; if (c != nullptr) c->__remove(p); + free(p); } } } diff --git a/src/exception.cpp b/src/exception.cpp index b5c46c0805ec..2c16060a7583 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -29,7 +29,7 @@ #define __terminate_handler __cxxabiapple::__cxa_terminate_handler #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler #endif // _LIBCPPABI_VERSION -#elif defined(LIBCXXRT) || __has_include() +#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) || __has_include() #include using namespace __cxxabiv1; #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION) @@ -90,14 +90,14 @@ terminate() _NOEXCEPT #endif // _LIBCPP_NO_EXCEPTIONS (*get_terminate())(); // handler should not return - printf("terminate_handler unexpectedly returned\n"); + fprintf(stderr, "terminate_handler unexpectedly returned\n"); ::abort(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { // handler should not throw exception - printf("terminate_handler unexpectedly threw an exception\n"); + fprintf(stderr, "terminate_handler unexpectedly threw an exception\n"); ::abort(); } #endif // _LIBCPP_NO_EXCEPTIONS @@ -106,18 +106,24 @@ terminate() _NOEXCEPT #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) #if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__) -bool uncaught_exception() _NOEXCEPT +bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; } + +int uncaught_exceptions() _NOEXCEPT { #if defined(__APPLE__) || defined(_LIBCPPABI_VERSION) - // on Darwin, there is a helper function so __cxa_get_globals is private - return __cxa_uncaught_exception(); + // on Darwin, there is a helper function so __cxa_get_globals is private +# if _LIBCPPABI_VERSION > 1101 + return __cxa_uncaught_exceptions(); +# else + return __cxa_uncaught_exception() ? 1 : 0; +# endif #else // __APPLE__ # if defined(_MSC_VER) && ! defined(__clang__) - _LIBCPP_WARNING("uncaught_exception not yet implemented") + _LIBCPP_WARNING("uncaught_exceptions not yet implemented") # else # warning uncaught_exception not yet implemented # endif - printf("uncaught_exception not yet implemented\n"); + fprintf(stderr, "uncaught_exceptions not yet implemented\n"); ::abort(); #endif // __APPLE__ } @@ -190,7 +196,7 @@ exception_ptr::~exception_ptr() _NOEXCEPT # else # warning exception_ptr not yet implemented # endif - printf("exception_ptr not yet implemented\n"); + fprintf(stderr, "exception_ptr not yet implemented\n"); ::abort(); #endif } @@ -209,7 +215,7 @@ exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT # else # warning exception_ptr not yet implemented # endif - printf("exception_ptr not yet implemented\n"); + fprintf(stderr, "exception_ptr not yet implemented\n"); ::abort(); #endif } @@ -234,7 +240,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT # else # warning exception_ptr not yet implemented # endif - printf("exception_ptr not yet implemented\n"); + fprintf(stderr, "exception_ptr not yet implemented\n"); ::abort(); #endif } @@ -278,7 +284,7 @@ exception_ptr current_exception() _NOEXCEPT # else # warning exception_ptr not yet implemented # endif - printf("exception_ptr not yet implemented\n"); + fprintf(stderr, "exception_ptr not yet implemented\n"); ::abort(); #endif } @@ -300,7 +306,7 @@ void rethrow_exception(exception_ptr p) # else # warning exception_ptr not yet implemented # endif - printf("exception_ptr not yet implemented\n"); + fprintf(stderr, "exception_ptr not yet implemented\n"); ::abort(); #endif } diff --git a/src/future.cpp b/src/future.cpp index 0c5c2c4488d2..3132b1861af2 100644 --- a/src/future.cpp +++ b/src/future.cpp @@ -98,7 +98,6 @@ __assoc_sub_state::set_value() #endif __state_ |= __constructed | ready; __cv_.notify_all(); - __lk.unlock(); } void @@ -111,7 +110,6 @@ __assoc_sub_state::set_value_at_thread_exit() #endif __state_ |= __constructed; __thread_local_data()->__make_ready_at_thread_exit(this); - __lk.unlock(); } void @@ -124,7 +122,6 @@ __assoc_sub_state::set_exception(exception_ptr __p) #endif __exception_ = __p; __state_ |= ready; - __lk.unlock(); __cv_.notify_all(); } @@ -138,7 +135,6 @@ __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p) #endif __exception_ = __p; __thread_local_data()->__make_ready_at_thread_exit(this); - __lk.unlock(); } void @@ -146,7 +142,6 @@ __assoc_sub_state::__make_ready() { unique_lock __lk(__mut_); __state_ |= ready; - __lk.unlock(); __cv_.notify_all(); } diff --git a/src/ios.cpp b/src/ios.cpp index d879beb3801f..90972c407d79 100644 --- a/src/ios.cpp +++ b/src/ios.cpp @@ -8,16 +8,20 @@ //===----------------------------------------------------------------------===// #include "__config" + #include "ios" -#include "streambuf" -#include "istream" -#include "string" + +#include + #include "__locale" #include "algorithm" +#include "config_elast.h" +#include "istream" +#include "limits" #include "memory" #include "new" -#include "limits" -#include +#include "streambuf" +#include "string" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/src/iostream.cpp b/src/iostream.cpp index 7102e4389e06..e073aec6ead5 100644 --- a/src/iostream.cpp +++ b/src/iostream.cpp @@ -13,55 +13,75 @@ _LIBCPP_BEGIN_NAMESPACE_STD -static mbstate_t state_types[6] = {}; - -_ALIGNAS_TYPE (__stdinbuf ) static char __cin [sizeof(__stdinbuf )]; -_ALIGNAS_TYPE (__stdoutbuf) static char __cout[sizeof(__stdoutbuf)]; -_ALIGNAS_TYPE (__stdoutbuf) static char __cerr[sizeof(__stdoutbuf)]; -_ALIGNAS_TYPE (__stdinbuf ) static char __wcin [sizeof(__stdinbuf )]; -_ALIGNAS_TYPE (__stdoutbuf) static char __wcout[sizeof(__stdoutbuf)]; -_ALIGNAS_TYPE (__stdoutbuf) static char __wcerr[sizeof(__stdoutbuf)]; - +#ifndef _LIBCPP_HAS_NO_STDIN _ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin [sizeof(istream)]; -_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]; +_ALIGNAS_TYPE (__stdinbuf ) static char __cin [sizeof(__stdinbuf )]; +static mbstate_t mb_cin; _ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)]; +_ALIGNAS_TYPE (__stdinbuf ) static char __wcin [sizeof(__stdinbuf )]; +static mbstate_t mb_wcin; +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]; +_ALIGNAS_TYPE (__stdoutbuf) static char __cout[sizeof(__stdoutbuf)]; +static mbstate_t mb_cout; _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]; +_ALIGNAS_TYPE (__stdoutbuf) static char __wcout[sizeof(__stdoutbuf)]; +static mbstate_t mb_wcout; +#endif + +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]; +_ALIGNAS_TYPE (__stdoutbuf) static char __cerr[sizeof(__stdoutbuf)]; +static mbstate_t mb_cerr; _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]; +_ALIGNAS_TYPE (__stdoutbuf) static char __wcerr[sizeof(__stdoutbuf)]; +static mbstate_t mb_wcerr; + +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]; _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]; ios_base::Init __start_std_streams; ios_base::Init::Init() { - istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf (stdin, state_types+0) ); - ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf(stdout, state_types+1)); - ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf(stderr, state_types+2)); +#ifndef _LIBCPP_HAS_NO_STDIN + istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf (stdin, &mb_cin)); + wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf (stdin, &mb_wcin)); +#endif +#ifndef _LIBCPP_HAS_NO_STDOUT + ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf(stdout, &mb_cout)); + wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf(stdout, &mb_wcout)); +#endif + ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf(stderr, &mb_cerr)); ::new(clog) ostream(cerr_ptr->rdbuf()); - cin_ptr->tie(cout_ptr); - _VSTD::unitbuf(*cerr_ptr); - cerr_ptr->tie(cout_ptr); - - wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf (stdin, state_types+3) ); - wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf(stdout, state_types+4)); - wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf(stderr, state_types+5)); + wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf(stderr, &mb_wcerr)); ::new(wclog) wostream(wcerr_ptr->rdbuf()); + +#if !defined(_LIBCPP_HAS_NO_STDIN) && !defined(_LIBCPP_HAS_NO_STDOUT) + cin_ptr->tie(cout_ptr); wcin_ptr->tie(wcout_ptr); +#endif + _VSTD::unitbuf(*cerr_ptr); _VSTD::unitbuf(*wcerr_ptr); +#ifndef _LIBCPP_HAS_NO_STDOUT + cerr_ptr->tie(cout_ptr); wcerr_ptr->tie(wcout_ptr); +#endif } ios_base::Init::~Init() { +#ifndef _LIBCPP_HAS_NO_STDOUT ostream* cout_ptr = reinterpret_cast(cout); - ostream* clog_ptr = reinterpret_cast(clog); - cout_ptr->flush(); - clog_ptr->flush(); - wostream* wcout_ptr = reinterpret_cast(wcout); - wostream* wclog_ptr = reinterpret_cast(wclog); + cout_ptr->flush(); wcout_ptr->flush(); +#endif + + ostream* clog_ptr = reinterpret_cast(clog); + wostream* wclog_ptr = reinterpret_cast(wclog); + clog_ptr->flush(); wclog_ptr->flush(); } diff --git a/src/locale.cpp b/src/locale.cpp index f21e35dd540a..bdc73e1d5379 100644 --- a/src/locale.cpp +++ b/src/locale.cpp @@ -27,7 +27,7 @@ #include "cwctype" #include "__sso_allocator" #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) -#include +#include "support/win32/locale_win32.h" #elif !defined(__ANDROID__) #include #endif @@ -575,8 +575,10 @@ locale::global(const locale& loc) locale& g = __global(); locale r = g; g = loc; +#ifndef __CloudABI__ if (g.name() != "*") setlocale(LC_ALL, g.name().c_str()); +#endif return r; } @@ -813,7 +815,7 @@ ctype::do_toupper(char_type c) const #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) return isascii(c) ? ctype::__classic_upper_table()[c] : c; #else - return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c; + return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c; #endif } @@ -827,7 +829,7 @@ ctype::do_toupper(char_type* low, const char_type* high) const *low = isascii(*low) ? ctype::__classic_upper_table()[*low] : *low; #else - *low = (isascii(*low) && islower_l(*low, __cloc())) ? (*low-L'a'+L'A') : *low; + *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low-L'a'+L'A') : *low; #endif return low; } @@ -840,7 +842,7 @@ ctype::do_tolower(char_type c) const #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) return isascii(c) ? ctype::__classic_lower_table()[c] : c; #else - return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c; + return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c; #endif } @@ -854,7 +856,7 @@ ctype::do_tolower(char_type* low, const char_type* high) const *low = isascii(*low) ? ctype::__classic_lower_table()[*low] : *low; #else - *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-L'A'+L'a' : *low; + *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-L'A'+L'a' : *low; #endif return low; } @@ -923,7 +925,7 @@ ctype::do_toupper(char_type c) const return isascii(c) ? static_cast(__classic_upper_table()[static_cast(c)]) : c; #else - return (isascii(c) && islower_l(c, __cloc())) ? c-'a'+'A' : c; + return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c; #endif } @@ -940,7 +942,7 @@ ctype::do_toupper(char_type* low, const char_type* high) const *low = isascii(*low) ? static_cast(__classic_upper_table()[static_cast(*low)]) : *low; #else - *low = (isascii(*low) && islower_l(*low, __cloc())) ? *low-'a'+'A' : *low; + *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'a'+'A' : *low; #endif return low; } @@ -957,7 +959,7 @@ ctype::do_tolower(char_type c) const return isascii(c) ? static_cast(__classic_lower_table()[static_cast(c)]) : c; #else - return (isascii(c) && isupper_l(c, __cloc())) ? c-'A'+'a' : c; + return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'A'+'a' : c; #endif } @@ -972,7 +974,7 @@ ctype::do_tolower(char_type* low, const char_type* high) const #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) *low = isascii(*low) ? static_cast(__classic_lower_table()[static_cast(*low)]) : *low; #else - *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-'A'+'a' : *low; + *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low; #endif return low; } @@ -1016,6 +1018,87 @@ extern "C" const int ** __ctype_tolower_loc(); extern "C" const int ** __ctype_toupper_loc(); #endif +#ifdef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE +const ctype::mask* +ctype::classic_table() _NOEXCEPT +{ + static _LIBCPP_CONSTEXPR const ctype::mask builtin_table[table_size] = { + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl | space | blank, + cntrl | space, cntrl | space, + cntrl | space, cntrl | space, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + cntrl, cntrl, + space | blank | print, punct | print, + punct | print, punct | print, + punct | print, punct | print, + punct | print, punct | print, + punct | print, punct | print, + punct | print, punct | print, + punct | print, punct | print, + punct | print, punct | print, + digit | print | xdigit, digit | print | xdigit, + digit | print | xdigit, digit | print | xdigit, + digit | print | xdigit, digit | print | xdigit, + digit | print | xdigit, digit | print | xdigit, + digit | print | xdigit, digit | print | xdigit, + punct | print, punct | print, + punct | print, punct | print, + punct | print, punct | print, + punct | print, upper | xdigit | print | alpha, + upper | xdigit | print | alpha, upper | xdigit | print | alpha, + upper | xdigit | print | alpha, upper | xdigit | print | alpha, + upper | xdigit | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, upper | print | alpha, + upper | print | alpha, punct | print, + punct | print, punct | print, + punct | print, punct | print, + punct | print, lower | xdigit | print | alpha, + lower | xdigit | print | alpha, lower | xdigit | print | alpha, + lower | xdigit | print | alpha, lower | xdigit | print | alpha, + lower | xdigit | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, lower | print | alpha, + lower | print | alpha, punct | print, + punct | print, punct | print, + punct | print, cntrl, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + return builtin_table; +} +#else const ctype::mask* ctype::classic_table() _NOEXCEPT { @@ -1024,7 +1107,7 @@ ctype::classic_table() _NOEXCEPT #elif defined(__NetBSD__) return _C_ctype_tab_ + 1; #elif defined(__GLIBC__) - return __cloc()->__ctype_b; + return _LIBCPP_GET_C_LOCALE->__ctype_b; #elif __sun__ return __ctype_mask; #elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) @@ -1033,10 +1116,11 @@ ctype::classic_table() _NOEXCEPT // going to end up dereferencing it later... #elif defined(__EMSCRIPTEN__) return *__ctype_b_loc(); +#elif defined(_NEWLIB_VERSION) + // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1]. + return _ctype_ + 1; #elif defined(_AIX) return (const unsigned int *)__lc_ctype_ptr->obj->mask; -#elif defined(__ANDROID__) - return reinterpret_cast(_ctype_) + 1; #else // Platform not supported: abort so the person doing the port knows what to // fix @@ -1046,18 +1130,19 @@ ctype::classic_table() _NOEXCEPT return NULL; #endif } +#endif #if defined(__GLIBC__) const int* ctype::__classic_lower_table() _NOEXCEPT { - return __cloc()->__ctype_tolower; + return _LIBCPP_GET_C_LOCALE->__ctype_tolower; } const int* ctype::__classic_upper_table() _NOEXCEPT { - return __cloc()->__ctype_toupper; + return _LIBCPP_GET_C_LOCALE->__ctype_toupper; } #elif __NetBSD__ const short* @@ -1180,16 +1265,16 @@ ctype_byname::do_is(mask m, char_type c) const #else bool result = false; wint_t ch = static_cast(c); - if (m & space) result |= (iswspace_l(ch, __l) != 0); - if (m & print) result |= (iswprint_l(ch, __l) != 0); - if (m & cntrl) result |= (iswcntrl_l(ch, __l) != 0); - if (m & upper) result |= (iswupper_l(ch, __l) != 0); - if (m & lower) result |= (iswlower_l(ch, __l) != 0); - if (m & alpha) result |= (iswalpha_l(ch, __l) != 0); - if (m & digit) result |= (iswdigit_l(ch, __l) != 0); - if (m & punct) result |= (iswpunct_l(ch, __l) != 0); - if (m & xdigit) result |= (iswxdigit_l(ch, __l) != 0); - if (m & blank) result |= (iswblank_l(ch, __l) != 0); + if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0); + if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0); + if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0); + if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0); + if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0); + if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0); + if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0); + if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0); + if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0); + if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0); return result; #endif } @@ -1207,22 +1292,32 @@ ctype_byname::do_is(const char_type* low, const char_type* high, mask* wint_t ch = static_cast(*low); if (iswspace_l(ch, __l)) *vec |= space; +#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT if (iswprint_l(ch, __l)) *vec |= print; +#endif if (iswcntrl_l(ch, __l)) *vec |= cntrl; if (iswupper_l(ch, __l)) *vec |= upper; if (iswlower_l(ch, __l)) *vec |= lower; +#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA if (iswalpha_l(ch, __l)) *vec |= alpha; +#endif if (iswdigit_l(ch, __l)) *vec |= digit; if (iswpunct_l(ch, __l)) *vec |= punct; +#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT if (iswxdigit_l(ch, __l)) *vec |= xdigit; +#endif +#if !defined(__sun__) + if (iswblank_l(ch, __l)) + *vec |= blank; +#endif } } return low; @@ -1238,16 +1333,16 @@ ctype_byname::do_scan_is(mask m, const char_type* low, const char_type* break; #else wint_t ch = static_cast(*low); - if (m & space && iswspace_l(ch, __l)) break; - if (m & print && iswprint_l(ch, __l)) break; - if (m & cntrl && iswcntrl_l(ch, __l)) break; - if (m & upper && iswupper_l(ch, __l)) break; - if (m & lower && iswlower_l(ch, __l)) break; - if (m & alpha && iswalpha_l(ch, __l)) break; - if (m & digit && iswdigit_l(ch, __l)) break; - if (m & punct && iswpunct_l(ch, __l)) break; - if (m & xdigit && iswxdigit_l(ch, __l)) break; - if (m & blank && iswblank_l(ch, __l)) break; + if ((m & space) == space && iswspace_l(ch, __l)) break; + if ((m & print) == print && iswprint_l(ch, __l)) break; + if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break; + if ((m & upper) == upper && iswupper_l(ch, __l)) break; + if ((m & lower) == lower && iswlower_l(ch, __l)) break; + if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break; + if ((m & digit) == digit && iswdigit_l(ch, __l)) break; + if ((m & punct) == punct && iswpunct_l(ch, __l)) break; + if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break; + if ((m & blank) == blank && iswblank_l(ch, __l)) break; #endif } return low; @@ -1263,16 +1358,16 @@ ctype_byname::do_scan_not(mask m, const char_type* low, const char_type break; #else wint_t ch = static_cast(*low); - if (m & space && iswspace_l(ch, __l)) continue; - if (m & print && iswprint_l(ch, __l)) continue; - if (m & cntrl && iswcntrl_l(ch, __l)) continue; - if (m & upper && iswupper_l(ch, __l)) continue; - if (m & lower && iswlower_l(ch, __l)) continue; - if (m & alpha && iswalpha_l(ch, __l)) continue; - if (m & digit && iswdigit_l(ch, __l)) continue; - if (m & punct && iswpunct_l(ch, __l)) continue; - if (m & xdigit && iswxdigit_l(ch, __l)) continue; - if (m & blank && iswblank_l(ch, __l)) continue; + if ((m & space) == space && iswspace_l(ch, __l)) continue; + if ((m & print) == print && iswprint_l(ch, __l)) continue; + if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue; + if ((m & upper) == upper && iswupper_l(ch, __l)) continue; + if ((m & lower) == lower && iswlower_l(ch, __l)) continue; + if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue; + if ((m & digit) == digit && iswdigit_l(ch, __l)) continue; + if ((m & punct) == punct && iswpunct_l(ch, __l)) continue; + if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue; + if ((m & blank) == blank && iswblank_l(ch, __l)) continue; break; #endif } @@ -1564,7 +1659,7 @@ codecvt::do_in(state_type& st, frm_nxt = frm; return frm_nxt == frm_end ? ok : partial; } - if (n == 0) + if (n == size_t(-1)) return error; to_nxt += n; if (to_nxt == to_end) @@ -1614,22 +1709,23 @@ codecvt::do_unshift(state_type& st, int codecvt::do_encoding() const _NOEXCEPT { +#ifndef __CloudABI__ #ifdef _LIBCPP_LOCALE__L_EXTENSIONS - if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0) + if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0) #else - if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0) + if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0) #endif - { - // stateless encoding + return -1; +#endif + + // stateless encoding #ifdef _LIBCPP_LOCALE__L_EXTENSIONS - if (__l == 0 || MB_CUR_MAX_L(__l) == 1) // there are no known constant length encodings + if (__l == 0 || MB_CUR_MAX_L(__l) == 1) // there are no known constant length encodings #else - if (__l == 0 || __mb_cur_max_l(__l) == 1) // there are no known constant length encodings + if (__l == 0 || __mb_cur_max_l(__l) == 1) // there are no known constant length encodings #endif - return 1; // which take more than 1 char to form a wchar_t - return 0; - } - return -1; + return 1; // which take more than 1 char to form a wchar_t + return 0; } bool diff --git a/src/memory.cpp b/src/memory.cpp index 8a4eb34811f2..66fb143c6a62 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -13,24 +13,28 @@ #include "mutex" #include "thread" #endif +#include "support/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD namespace { +// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) +// should be sufficient for thread safety. +// See https://llvm.org/bugs/show_bug.cgi?id=22803 template inline T increment(T& t) _NOEXCEPT { - return __sync_add_and_fetch(&t, 1); + return __libcpp_atomic_add(&t, 1, _AO_Relaxed); } template inline T decrement(T& t) _NOEXCEPT { - return __sync_add_and_fetch(&t, -1); + return __libcpp_atomic_add(&t, -1, _AO_Acq_Rel); } } // namespace @@ -99,14 +103,13 @@ __shared_weak_count::__release_weak() _NOEXCEPT __shared_weak_count* __shared_weak_count::lock() _NOEXCEPT { - long object_owners = __shared_owners_; + long object_owners = __libcpp_atomic_load(&__shared_owners_); while (object_owners != -1) { - if (__sync_bool_compare_and_swap(&__shared_owners_, - object_owners, - object_owners+1)) + if (__libcpp_atomic_compare_exchange(&__shared_owners_, + &object_owners, + object_owners+1)) return this; - object_owners = __shared_owners_; } return 0; } diff --git a/src/mutex.cpp b/src/mutex.cpp index e56271d308e6..5f8ba0a08266 100644 --- a/src/mutex.cpp +++ b/src/mutex.cpp @@ -12,6 +12,7 @@ #include "limits" #include "system_error" #include "cassert" +#include "support/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS @@ -220,6 +221,9 @@ static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cv = PTHREAD_COND_INITIALIZER; #endif +/// NOTE: Changes to flag are done via relaxed atomic stores +/// even though the accesses are protected by a mutex because threads +/// just entering 'call_once` concurrently read from flag. void __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) { @@ -252,11 +256,11 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) try { #endif // _LIBCPP_NO_EXCEPTIONS - flag = 1; + __libcpp_relaxed_store(&flag, 1ul); pthread_mutex_unlock(&mut); func(arg); pthread_mutex_lock(&mut); - flag = ~0ul; + __libcpp_relaxed_store(&flag, ~0ul); pthread_mutex_unlock(&mut); pthread_cond_broadcast(&cv); #ifndef _LIBCPP_NO_EXCEPTIONS @@ -264,7 +268,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) catch (...) { pthread_mutex_lock(&mut); - flag = 0ul; + __libcpp_relaxed_store(&flag, 0ul); pthread_mutex_unlock(&mut); pthread_cond_broadcast(&cv); throw; diff --git a/src/new.cpp b/src/new.cpp index a88d4cc7c249..c28fcb5917cf 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -131,11 +131,18 @@ operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT ::operator delete(ptr); } +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS +void +operator delete(void* ptr, size_t) _NOEXCEPT +{ + ::operator delete(ptr); +} + _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr) _NOEXCEPT { - ::operator delete (ptr); + ::operator delete(ptr); } _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS @@ -145,6 +152,13 @@ operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT ::operator delete[](ptr); } +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS +void +operator delete[] (void* ptr, size_t) _NOEXCEPT +{ + ::operator delete[](ptr); +} + #endif // !__GLIBCXX__ namespace std diff --git a/src/random.cpp b/src/random.cpp index 15ed65b58cf3..4ab424eaa6e5 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -7,11 +7,10 @@ // //===----------------------------------------------------------------------===// -#if defined(_WIN32) +#if defined(_LIBCPP_USING_WIN32_RANDOM) // Must be defined before including stdlib.h to enable rand_s(). #define _CRT_RAND_S -#include -#endif // defined(_WIN32) +#endif // defined(_LIBCPP_USING_WIN32_RANDOM) #include "random" #include "system_error" @@ -19,46 +18,27 @@ #if defined(__sun__) #define rename solaris_headers_are_broken #endif // defined(__sun__) -#if !defined(_WIN32) + +#include +#include +#include + +#if defined(_LIBCPP_USING_DEV_RANDOM) #include #include -#endif // !defined(_WIN32) -#include -#if defined(_LIBCPP_USING_NACL_RANDOM) +#elif defined(_LIBCPP_USING_NACL_RANDOM) #include -#endif // defined(_LIBCPP_USING_NACL_RANDOM) +#endif + _LIBCPP_BEGIN_NAMESPACE_STD -#if defined(_WIN32) - -random_device::random_device(const string&) -{ -} - -random_device::~random_device() -{ -} - -unsigned -random_device::operator()() -{ - unsigned r; - errno_t err = rand_s(&r); - if (err) - __throw_system_error(err, "random_device rand_s failed."); - return r; -} - -#elif defined(_LIBCPP_USING_NACL_RANDOM) +#if defined(_LIBCPP_USING_ARC4_RANDOM) random_device::random_device(const string& __token) { if (__token != "/dev/urandom") __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); - int error = nacl_secure_random_init(); - if (error) - __throw_system_error(error, ("random device failed to open " + __token).c_str()); } random_device::~random_device() @@ -68,19 +48,10 @@ random_device::~random_device() unsigned random_device::operator()() { - unsigned r; - size_t n = sizeof(r); - char* p = reinterpret_cast(&r); - size_t bytes_written; - int error = nacl_secure_random(&r, n, &bytes_written); - if (error != 0) - __throw_system_error(error, "random_device failed getting bytes"); - else if (bytes_written != n) - __throw_runtime_error("random_device failed to obtain enough bytes"); - return r; + return arc4random(); } -#else // !defined(_WIN32) && !defined(_LIBCPP_USING_NACL_RANDOM) +#elif defined(_LIBCPP_USING_DEV_RANDOM) random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) @@ -117,7 +88,60 @@ random_device::operator()() return r; } -#endif // defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM) +#elif defined(_LIBCPP_USING_NACL_RANDOM) + +random_device::random_device(const string& __token) +{ + if (__token != "/dev/urandom") + __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); + int error = nacl_secure_random_init(); + if (error) + __throw_system_error(error, ("random device failed to open " + __token).c_str()); +} + +random_device::~random_device() +{ +} + +unsigned +random_device::operator()() +{ + unsigned r; + size_t n = sizeof(r); + size_t bytes_written; + int error = nacl_secure_random(&r, n, &bytes_written); + if (error != 0) + __throw_system_error(error, "random_device failed getting bytes"); + else if (bytes_written != n) + __throw_runtime_error("random_device failed to obtain enough bytes"); + return r; +} + +#elif defined(_LIBCPP_USING_WIN32_RANDOM) + +random_device::random_device(const string& __token) +{ + if (__token != "/dev/urandom") + __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); +} + +random_device::~random_device() +{ +} + +unsigned +random_device::operator()() +{ + unsigned r; + errno_t err = rand_s(&r); + if (err) + __throw_system_error(err, "random_device rand_s failed."); + return r; +} + +#else +#error "Random device not implemented for this architecture" +#endif double random_device::entropy() const _NOEXCEPT diff --git a/src/shared_mutex.cpp b/src/shared_mutex.cpp index 2b78c1feb9f5..874aceb1b03a 100644 --- a/src/shared_mutex.cpp +++ b/src/shared_mutex.cpp @@ -15,7 +15,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD -shared_timed_mutex::shared_timed_mutex() +// Shared Mutex Base +__shared_mutex_base::__shared_mutex_base() : __state_(0) { } @@ -23,7 +24,7 @@ shared_timed_mutex::shared_timed_mutex() // Exclusive ownership void -shared_timed_mutex::lock() +__shared_mutex_base::lock() { unique_lock lk(__mut_); while (__state_ & __write_entered_) @@ -34,7 +35,7 @@ shared_timed_mutex::lock() } bool -shared_timed_mutex::try_lock() +__shared_mutex_base::try_lock() { unique_lock lk(__mut_); if (__state_ == 0) @@ -46,7 +47,7 @@ shared_timed_mutex::try_lock() } void -shared_timed_mutex::unlock() +__shared_mutex_base::unlock() { lock_guard _(__mut_); __state_ = 0; @@ -56,7 +57,7 @@ shared_timed_mutex::unlock() // Shared ownership void -shared_timed_mutex::lock_shared() +__shared_mutex_base::lock_shared() { unique_lock lk(__mut_); while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) @@ -67,7 +68,7 @@ shared_timed_mutex::lock_shared() } bool -shared_timed_mutex::try_lock_shared() +__shared_mutex_base::try_lock_shared() { unique_lock lk(__mut_); unsigned num_readers = __state_ & __n_readers_; @@ -82,7 +83,7 @@ shared_timed_mutex::try_lock_shared() } void -shared_timed_mutex::unlock_shared() +__shared_mutex_base::unlock_shared() { lock_guard _(__mut_); unsigned num_readers = (__state_ & __n_readers_) - 1; @@ -101,6 +102,16 @@ shared_timed_mutex::unlock_shared() } +// Shared Timed Mutex +// These routines are here for ABI stability +shared_timed_mutex::shared_timed_mutex() : __base() {} +void shared_timed_mutex::lock() { return __base.lock(); } +bool shared_timed_mutex::try_lock() { return __base.try_lock(); } +void shared_timed_mutex::unlock() { return __base.unlock(); } +void shared_timed_mutex::lock_shared() { return __base.lock_shared(); } +bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); } +void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); } + _LIBCPP_END_NAMESPACE_STD #endif // !_LIBCPP_HAS_NO_THREADS diff --git a/src/string.cpp b/src/string.cpp index febc53209972..d3f29df639f4 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -39,7 +39,7 @@ void throw_helper( const string& msg ) #ifndef _LIBCPP_NO_EXCEPTIONS throw T( msg ); #else - printf("%s\n", msg.c_str()); + fprintf(stderr, "%s\n", msg.c_str()); abort(); #endif } diff --git a/src/support/atomic_support.h b/src/support/atomic_support.h new file mode 100644 index 000000000000..e738a5154cd3 --- /dev/null +++ b/src/support/atomic_support.h @@ -0,0 +1,142 @@ +#ifndef ATOMIC_SUPPORT_H +#define ATOMIC_SUPPORT_H + +#include "__config" +#include "memory" // for __libcpp_relaxed_load + +#if defined(__clang__) && __has_builtin(__atomic_load_n) \ + && __has_builtin(__atomic_store_n) \ + && __has_builtin(__atomic_add_fetch) \ + && __has_builtin(__atomic_compare_exchange_n) \ + && defined(__ATOMIC_RELAXED) \ + && defined(__ATOMIC_CONSUME) \ + && defined(__ATOMIC_ACQUIRE) \ + && defined(__ATOMIC_RELEASE) \ + && defined(__ATOMIC_ACQ_REL) \ + && defined(__ATOMIC_SEQ_CST) +# define _LIBCPP_HAS_ATOMIC_BUILTINS +#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407 +# define _LIBCPP_HAS_ATOMIC_BUILTINS +#endif + +#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS) +# if defined(_MSC_VER) && !defined(__clang__) + _LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported") +# else +# warning Building libc++ without __atomic builtins is unsupported +# endif +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace { + +#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS) + +enum __libcpp_atomic_order { + _AO_Relaxed = __ATOMIC_RELAXED, + _AO_Consume = __ATOMIC_CONSUME, + _AO_Aquire = __ATOMIC_ACQUIRE, + _AO_Release = __ATOMIC_RELEASE, + _AO_Acq_Rel = __ATOMIC_ACQ_REL, + _AO_Seq = __ATOMIC_SEQ_CST +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +void __libcpp_atomic_store(_ValueType* __dest, _FromType __val, + int __order = _AO_Seq) +{ + __atomic_store_n(__dest, __val, __order); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val) +{ + __atomic_store_n(__dest, __val, _AO_Relaxed); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_ValueType __libcpp_atomic_load(_ValueType const* __val, + int __order = _AO_Seq) +{ + return __atomic_load_n(__val, __order); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a, + int __order = _AO_Seq) +{ + return __atomic_add_fetch(__val, __a, __order); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool __libcpp_atomic_compare_exchange(_ValueType* __val, + _ValueType* __expected, _ValueType __after, + int __success_order = _AO_Seq, + int __fail_order = _AO_Seq) +{ + return __atomic_compare_exchange_n(__val, __expected, __after, true, + __success_order, __fail_order); +} + +#else // _LIBCPP_HAS_NO_THREADS + +enum __libcpp_atomic_order { + _AO_Relaxed, + _AO_Consume, + _AO_Acquire, + _AO_Release, + _AO_Acq_Rel, + _AO_Seq +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +void __libcpp_atomic_store(_ValueType* __dest, _FromType __val, + int = 0) +{ + *__dest = __val; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_ValueType __libcpp_atomic_load(_ValueType const* __val, + int = 0) +{ + return *__val; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a, + int = 0) +{ + return *__val += __a; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool __libcpp_atomic_compare_exchange(_ValueType* __val, + _ValueType* __expected, _ValueType __after, + int = 0, int = 0) +{ + if (*__val == *__expected) { + *__val = __after; + return true; + } + *__expected = *__val; + return false; +} + +#endif // _LIBCPP_HAS_NO_THREADS + +} // end namespace + +_LIBCPP_END_NAMESPACE_STD + +#endif // ATOMIC_SUPPORT_H diff --git a/src/support/solaris/README b/src/support/solaris/README new file mode 100644 index 000000000000..89c887a3b4a3 --- /dev/null +++ b/src/support/solaris/README @@ -0,0 +1,4 @@ +This directory contains a partial implementation of the xlocale APIs for +Solaris. Some portions are lifted from FreeBSD libc, and so are covered by a +2-clause BSD license instead of the MIT/UUIC license that the rest of libc++ is +distributed under. diff --git a/src/support/solaris/mbsnrtowcs.inc b/src/support/solaris/mbsnrtowcs.inc new file mode 100644 index 000000000000..074045277ca1 --- /dev/null +++ b/src/support/solaris/mbsnrtowcs.inc @@ -0,0 +1,76 @@ + + +/*- + * As noted in the source, some portions of this implementation are copied from + * FreeBSD libc. These are covered by the following copyright: + * + * Copyright (c) 2002-2004 Tim J. Robbins. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +size_t +mbsnrtowcs_l(wchar_t * __restrict dst, const char ** __restrict src, + size_t nms, size_t len, mbstate_t * __restrict ps, locale_t loc) +{ + const char *s; + size_t nchr; + wchar_t wc; + size_t nb; + FIX_LOCALE(loc); + + s = *src; + nchr = 0; + + if (dst == NULL) { + for (;;) { + if ((nb = mbrtowc_l(&wc, s, nms, ps, loc)) == (size_t)-1) + /* Invalid sequence - mbrtowc() sets errno. */ + return ((size_t)-1); + else if (nb == 0 || nb == (size_t)-2) + return (nchr); + s += nb; + nms -= nb; + nchr++; + } + /*NOTREACHED*/ + } + + while (len-- > 0) { + if ((nb = mbrtowc_l(dst, s, nms, ps, loc)) == (size_t)-1) { + *src = s; + return ((size_t)-1); + } else if (nb == (size_t)-2) { + *src = s + nms; + return (nchr); + } else if (nb == 0) { + *src = NULL; + return (nchr); + } + s += nb; + nms -= nb; + nchr++; + dst++; + } + *src = s; + return (nchr); +} diff --git a/src/support/solaris/wcsnrtombs.inc b/src/support/solaris/wcsnrtombs.inc new file mode 100644 index 000000000000..67e7078f2d51 --- /dev/null +++ b/src/support/solaris/wcsnrtombs.inc @@ -0,0 +1,93 @@ +/*- + * Copyright (c) 2002-2004 Tim J. Robbins. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +size_t +wcsnrtombs_l(char * __restrict dst, const wchar_t ** __restrict src, + size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc) +{ + FIX_LOCALE(loc); + mbstate_t mbsbak; + char buf[MB_CUR_MAX_L(loc)]; + const wchar_t *s; + size_t nbytes; + size_t nb; + + s = *src; + nbytes = 0; + + if (dst == NULL) { + while (nwc-- > 0) { + if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1) + /* Invalid character - wcrtomb() sets errno. */ + return ((size_t)-1); + else if (*s == L'\0') + return (nbytes + nb - 1); + s++; + nbytes += nb; + } + return (nbytes); + } + + while (len > 0 && nwc-- > 0) { + if (len > (size_t)MB_CUR_MAX_L(loc)) { + /* Enough space to translate in-place. */ + if ((nb = wcrtomb_l(dst, *s, ps, loc)) == (size_t)-1) { + *src = s; + return ((size_t)-1); + } + } else { + /* + * May not be enough space; use temp. buffer. + * + * We need to save a copy of the conversion state + * here so we can restore it if the multibyte + * character is too long for the buffer. + */ + mbsbak = *ps; + if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1) { + *src = s; + return ((size_t)-1); + } + if (nb > (int)len) { + /* MB sequence for character won't fit. */ + *ps = mbsbak; + break; + } + memcpy(dst, buf, nb); + } + if (*s == L'\0') { + *src = NULL; + return (nbytes + nb - 1); + } + s++; + dst += nb; + len -= nb; + nbytes += nb; + } + *src = s; + return (nbytes); +} + diff --git a/src/support/solaris/xlocale.c b/src/support/solaris/xlocale.c new file mode 100644 index 000000000000..9125eea73777 --- /dev/null +++ b/src/support/solaris/xlocale.c @@ -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. +// +//===----------------------------------------------------------------------===// + +#ifdef __sun__ + +#include "support/solaris/xlocale.h" +#include +#include +#include + + +int isxdigit_l(int __c, locale_t __l) { + return isxdigit(__c); +} + +int iswxdigit_l(wchar_t __c, locale_t __l) { + return isxdigit(__c); +} + +// FIXME: This disregards the locale, which is Very Wrong +#define vsnprintf_l(__s, __n, __l, __format, __va) \ + vsnprintf(__s, __n, __format, __va) + +int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) +{ + va_list __va; + va_start(__va, __format); + int __res = vsnprintf_l(__s, __n , __l, __format, __va); + va_end(__va); + return __res; +} + +int asprintf_l(char **__s, locale_t __l, const char *__format, ...) { + va_list __va; + va_start(__va, __format); + // FIXME: + int __res = vasprintf(__s, __format, __va); + va_end(__va); + return __res; +} + +int sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { + va_list __va; + va_start(__va, __format); + // FIXME: + int __res = vsscanf(__s, __format, __va); + va_end(__va); + return __res; +} + +size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb, + size_t __max, mbstate_t *__ps, locale_t __loc) { + return mbrtowc(__pwc, __pmb, __max, __ps); +} + +struct lconv *localeconv_l(locale_t __l) { + return localeconv(); +} + +#endif // __sun__ diff --git a/src/support/win32/locale_win32.cpp b/src/support/win32/locale_win32.cpp new file mode 100644 index 000000000000..5a43743470d5 --- /dev/null +++ b/src/support/win32/locale_win32.cpp @@ -0,0 +1,105 @@ +// -*- C++ -*- +//===-------------------- support/win32/locale_win32.cpp ------------------===// +// +// The 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 +#include // va_start, va_end + +// FIXME: base currently unused. Needs manual work to construct the new locale +locale_t newlocale( int mask, const char * locale, locale_t /*base*/ ) +{ + return _create_locale( mask, locale ); +} +locale_t uselocale( locale_t newloc ) +{ + locale_t old_locale = _get_current_locale(); + if ( newloc == NULL ) + return old_locale; + // uselocale sets the thread's locale by definition, so unconditionally use thread-local locale + _configthreadlocale( _ENABLE_PER_THREAD_LOCALE ); + // uselocale sets all categories + setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale ); + // uselocale returns the old locale_t + return old_locale; +} +lconv *localeconv_l( locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return localeconv(); +} +size_t mbrlen_l( const char *__restrict s, size_t n, + mbstate_t *__restrict ps, locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return mbrlen( s, n, ps ); +} +size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t len, mbstate_t *__restrict ps, locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return mbsrtowcs( dst, src, len, ps ); +} +size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps, + locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return wcrtomb( s, wc, ps ); +} +size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s, + size_t n, mbstate_t *__restrict ps, locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return mbrtowc( pwc, s, n, ps ); +} +size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return mbsnrtowcs( dst, src, nms, len, ps ); +} +size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return wcsnrtombs( dst, src, nwc, len, ps ); +} +wint_t btowc_l( int c, locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return btowc( c ); +} +int wctob_l( wint_t c, locale_t loc ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return wctob( c ); +} + +int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...) +{ + __locale_raii __current( uselocale(loc), uselocale ); + va_list ap; + va_start( ap, format ); + int result = vsnprintf( ret, n, format, ap ); + va_end(ap); + return result; +} + +int asprintf_l( char **ret, locale_t loc, const char *format, ... ) +{ + va_list ap; + va_start( ap, format ); + int result = vasprintf_l( ret, loc, format, ap ); + va_end(ap); + return result; +} +int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap ) +{ + __locale_raii __current( uselocale(loc), uselocale ); + return vasprintf( ret, format, ap ); +} diff --git a/src/support/win32/support.cpp b/src/support/win32/support.cpp new file mode 100644 index 000000000000..e989681a6d5f --- /dev/null +++ b/src/support/win32/support.cpp @@ -0,0 +1,166 @@ +// -*- C++ -*- +//===----------------------- support/win32/support.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. +// +//===----------------------------------------------------------------------===// + +#include // va_start, va_end +#include // size_t +#include // malloc +#include // vsprintf, vsnprintf +#include // strcpy, wcsncpy +#include // mbstate_t + +// Some of these functions aren't standard or if they conform, the name does not. + +int asprintf(char **sptr, const char *__restrict format, ...) +{ + va_list ap; + va_start(ap, format); + int result; + result = vasprintf(sptr, format, ap); + va_end(ap); + return result; +} + +// Like sprintf, but when return value >= 0 it returns +// a pointer to a malloc'd string in *sptr. +// If return >= 0, use free to delete *sptr. +int vasprintf( char **sptr, const char *__restrict format, va_list ap ) +{ + *sptr = NULL; + // Query the count required. + int count = _vsnprintf( NULL, 0, format, ap ); + if (count < 0) + return count; + size_t buffer_size = static_cast(count) + 1; + char* p = static_cast(malloc(buffer_size)); + if ( ! p ) + return -1; + // If we haven't used exactly what was required, something is wrong. + // Maybe bug in vsnprintf. Report the error and return. + if (_vsnprintf(p, buffer_size, format, ap) != count) { + free(p); + return -1; + } + // All good. This is returning memory to the caller not freeing it. + *sptr = p; + return count; +} + +// Returns >= 0: the number of wide characters found in the +// multi byte sequence src (of src_size_bytes), that fit in the buffer dst +// (of max_dest_chars elements size). The count returned excludes the +// null terminator. When dst is NULL, no characters are copied +// and no "out" parameters are updated. +// Returns (size_t) -1: an incomplete sequence encountered. +// Leaves *src pointing the next character to convert or NULL +// if a null character was converted from *src. +size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src, + size_t src_size_bytes, size_t max_dest_chars, mbstate_t *__restrict ps ) +{ + const size_t terminated_sequence = static_cast(0); + //const size_t invalid_sequence = static_cast(-1); + const size_t incomplete_sequence = static_cast< size_t>(-2); + + size_t dest_converted = 0; + size_t source_converted = 0; + size_t source_remaining = src_size_bytes; + size_t result = 0; + bool have_result = false; + + while ( source_remaining ) { + if ( dst && dest_converted >= max_dest_chars ) + break; + // Converts one multi byte character. + // if result > 0, it's the size in bytes of that character. + // othewise if result is zero it indicates the null character has been found. + // otherwise it's an error and errno may be set. + size_t char_size = mbrtowc( dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps ); + // Don't do anything to change errno from here on. + if ( char_size > 0 ) { + source_remaining -= char_size; + source_converted += char_size; + ++dest_converted; + continue; + } + result = char_size; + have_result = true; + break; + } + if ( dst ) { + if ( have_result && result == terminated_sequence ) + *src = NULL; + else + *src += source_converted; + } + if ( have_result && result != terminated_sequence && result != incomplete_sequence ) + return static_cast(-1); + + return dest_converted; +} + +// Converts max_source_chars from the wide character buffer pointer to by *src, +// into the multi byte character sequence buffer stored at dst which must be +// dst_size_bytes bytes in size. +// Returns >= 0: the number of bytes in the sequence +// converted from *src, excluding the null terminator. +// Returns size_t(-1) if an error occurs, also sets errno. +// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst +// and no "out" parameters are updated. +size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src, + size_t max_source_chars, size_t dst_size_bytes, mbstate_t *__restrict ps ) +{ + //const size_t invalid_sequence = static_cast(-1); + + size_t source_converted = 0; + size_t dest_converted = 0; + size_t dest_remaining = dst_size_bytes; + size_t char_size = 0; + const errno_t no_error = ( errno_t) 0; + errno_t result = ( errno_t ) 0; + bool have_result = false; + bool terminator_found = false; + + while ( source_converted != max_source_chars ) { + if ( ! dest_remaining ) + break; + wchar_t c = (*src)[source_converted]; + if ( dst ) + result = wcrtomb_s( &char_size, dst + dest_converted, dest_remaining, c, ps); + else + result = wcrtomb_s( &char_size, NULL, 0, c, ps); + // If result is zero there is no error and char_size contains the + // size of the multi-byte-sequence converted. + // Otherwise result indicates an errno type error. + if ( result == no_error ) { + if ( c == L'\0' ) { + terminator_found = true; + break; + } + ++source_converted; + if ( dst ) + dest_remaining -= char_size; + dest_converted += char_size; + continue; + } + have_result = true; + break; + } + if ( dst ) { + if ( terminator_found ) + *src = NULL; + else + *src = *src + source_converted; + } + if ( have_result && result != no_error ) { + errno = result; + return static_cast(-1); + } + + return dest_converted; +} diff --git a/src/system_error.cpp b/src/system_error.cpp index 9c8adc4f323e..18f668f071cd 100644 --- a/src/system_error.cpp +++ b/src/system_error.cpp @@ -7,11 +7,14 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_BUILDING_SYSTEM_ERROR #include "__config" + +#define _LIBCPP_BUILDING_SYSTEM_ERROR #include "system_error" -#include "string" + +#include "config_elast.h" #include "cstring" +#include "string" _LIBCPP_BEGIN_NAMESPACE_STD @@ -149,7 +152,7 @@ system_error::__init(const error_code& ec, string what_arg) what_arg += ": "; what_arg += ec.message(); } - return _VSTD::move(what_arg); + return what_arg; } system_error::system_error(error_code ec, const string& what_arg) diff --git a/src/thread.cpp b/src/thread.cpp index 6aad558abaad..bd27f2878383 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -17,9 +17,9 @@ #include "limits" #include #if !defined(_WIN32) -# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) +# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__) # include -# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) +# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__) # include #endif // !_WIN32 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 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 +#include +#include "count_new.hpp" +#include "MoveOnly.h" + +int main() +{ + { + std::unordered_set 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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _LIBCPP_HAS_NO_THREADS +#include +#include +#include +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_ALGORITHM +# error " must include " +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +// dynarray(size_type c, const Alloc& alloc); +// template +// dynarray(size_type c, const T& v, const Alloc& alloc); +// template +// dynarray(const dynarray& d, const Alloc& alloc); +// template +// dynarray(initializer_list, const Alloc& alloc); + +// ~dynarray(); + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include +#include + +#include +#include +#include +#include "test_allocator.h" + +using std::experimental::dynarray; + +template +void check_allocator ( const dynarray &dyn, const Allocator &alloc ) { + for ( int i = 0; i < dyn.size (); ++i ) + assert ( dyn[i].get_allocator() == alloc ); +} + +template +void test ( const std::initializer_list &vals, const Allocator &alloc ) { + typedef dynarray 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 +void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) { + typedef dynarray 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 Alloc; +// typedef std::basic_string, 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); +// dynarray(const dynarray& d); + +// ~dynarray(); + + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void test ( const std::initializer_list &vals ) { + typedef dynarray dynA; + + dynA d1 ( vals ); + assert ( d1.size () == vals.size() ); + assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ())); + } + + +template +void test ( const T &val ) { + typedef dynarray 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 ( std::numeric_limits::max() / sizeof ( int ) + 1 ); } + catch ( std::bad_array_length & ) { return ; } + assert ( false ); + } + +void test_bad_alloc () { + try { dynarray ( std::numeric_limits::max() / sizeof ( int ) - 1 ); } + catch ( std::bad_alloc & ) { return ; } + assert ( false ); + } + +int main() +{ +// test ( 14 ); // ints don't get default initialized + test ( 0 ); + test ( 14.0 ); + test> ( std::complex ( 14, 0 )); + test ( "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 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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void dyn_test_const ( const dynarray &dyn ) { + const T *data = dyn.data (); + assert ( data != NULL ); + assert ( std::equal ( dyn.begin(), dyn.end(), data )); + } + +template +void dyn_test ( dynarray &dyn ) { + T *data = dyn.data (); + assert ( data != NULL ); + assert ( std::equal ( dyn.begin(), dyn.end(), data )); + } + + + +template +void test ( const T &val ) { + typedef dynarray 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 ( 14 ); + test ( 14.0 ); + test> ( std::complex ( 14, 0 )); + test ( "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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void test ( const T &val ) { + typedef dynarray 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 ( 14 ); + test ( 14.0 ); + test> ( std::complex ( 14, 0 )); + test ( "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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void dyn_at_fail ( dynarray &dyn, size_t sz ) { + try { dyn.at (sz); } + catch (const std::out_of_range &) { return; } + assert ( false ); + } + +template +void dyn_at_fail_const ( const dynarray &dyn, size_t sz ) { + try { dyn.at (sz); } + catch (const std::out_of_range &) { return; } + assert ( false ); + } + + +template +void dyn_test_const ( const dynarray &dyn, const std::initializer_list &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 +void dyn_test ( dynarray &dyn, const std::initializer_list &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 +void test ( std::initializer_list vals ) { + typedef dynarray 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 ( {} ); + test> ( {} ); + test ( {} ); +} +#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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void dyn_test_const ( const dynarray &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 +void dyn_test ( dynarray &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 +void test ( const T &val ) { + typedef dynarray 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 ( 14 ); + test ( 14.0 ); + test> ( std::complex ( 14, 0 )); + test ( "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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void dyn_test ( const dynarray &dyn, size_t sz ) { + assert ( dyn.size () == sz ); + assert ( dyn.max_size () == sz ); + assert ( dyn.empty () == ( sz == 0 )); + } + +template +void test ( std::initializer_list vals ) { + typedef dynarray 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 ( {} ); + test> ( {} ); + test ( {} ); +} +#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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void dyn_test_const ( const dynarray &dyn ) { + const T *data = dyn.data (); + assert ( *data == dyn.front ()); + assert ( *(data + dyn.size() - 1 ) == dyn.back ()); + } + +template +void dyn_test ( dynarray &dyn ) { + T *data = dyn.data (); + assert ( *data == dyn.front ()); + assert ( *(data + dyn.size() - 1 ) == dyn.back ()); + } + + +template +void test ( const T &val ) { + typedef dynarray 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 ( 14 ); + test ( 14.0 ); + test> ( std::complex ( 14, 0 )); + test ( "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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void dyn_test_const ( const dynarray &dyn, const std::initializer_list &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 +void dyn_test ( dynarray &dyn, const std::initializer_list &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 +void test ( std::initializer_list vals ) { + typedef dynarray 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 ( {} ); + test> ( {} ); + test ( {} ); +} +#else +int main() {} +#endif diff --git a/include/__tuple_03 b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp similarity index 51% rename from include/__tuple_03 rename to test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp index b91c2cd48a63..9b8240d4cd82 100644 --- a/include/__tuple_03 +++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp @@ -1,4 +1,3 @@ -// -*- C++ -*- //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure @@ -8,20 +7,25 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___TUPLE_03 -#define _LIBCPP___TUPLE_03 +// dynarray.data +// template +// struct uses_allocator, Alloc> : true_type { }; + + #include <__config> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header +#if _LIBCPP_STD_VER > 11 + +#include +#include "test_allocator.h" + +using std::experimental::dynarray; + +int main() +{ + static_assert ( std::uses_allocator, test_allocator>::value, "" ); +} +#else +int main() {} #endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class _LIBCPP_TYPE_VIS_ONLY tuple_size; -template class _LIBCPP_TYPE_VIS_ONLY tuple_element; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___TUPLE_03 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 +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void test ( ) { + typedef dynarray dynA; + + dynA d1 ( 0 ); + assert ( d1.size() == 0 ); + assert ( d1.begin() == d1.end ()); + } + +int main() +{ + test (); + test (); + test> (); + test (); +} +#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. +// +//===----------------------------------------------------------------------===// + +// + +// Test that is included. + +#include + +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_RATIO +# error " must include " +# 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_SYSTEM_ERROR +# error " must include " +# 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_CHRONO +# error " must include " +# 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_TUPLE +# error " must include " +# 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +struct is_same { enum { value = 0 }; }; + +template +struct is_same { 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::value), "is same"); +} + +void test_static_assert() +{ + TEST_STATIC_ASSERT((is_same::value), "is same"); + TEST_STATIC_ASSERT((!is_same::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 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 +#include +#include +#include + +#include "user_defined_integral.hpp" + +template +struct EnumType +{ + enum type : T {E_zero, E_one}; +}; + + +template +void check_integral_types() +{ + typedef std::numeric_limits 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::value, ""); + } + { + UserDefinedIntegral 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::value, ""); + } + { + typedef typename EnumType::type Enum; + Enum e(static_cast(max)); + auto ret = std::__convert_to_integral(e); + assert(ret == max); + e = static_cast(min); + ret = std::__convert_to_integral(min); + assert(ret == min); + static_assert(std::is_same::value, ""); + } +} + + +template +void check_enum_types() +{ + auto ret = std::__convert_to_integral((From)1); + assert(ret == 1); + static_assert(std::is_same::value, ""); +} + + +enum enum1 { zero = 0, one = 1 }; +enum enum2 { + value = std::numeric_limits::max() +}; + +int main() +{ + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); + check_integral_types(); +#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::type Enum1UT; + check_enum_types(); + typedef std::underlying_type::type Enum2UT; + check_enum_types(); +} 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 +// +// +// +// class shared_ptr +// +// This test attempts to create a race condition surrounding use_count() +// with the hope that TSAN will diagnose it. + +#include +#include +#include +#include + +typedef std::shared_ptr Ptr; +typedef std::weak_ptr 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(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 .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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter> +// OutIter +// copy(InIter first, InIter last, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// OutIter +// copy_backward(InIter first, InIter last, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test, random_access_iterator >(); + test, int*>(); + + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter, +// Predicate Pred> +// requires CopyConstructible +// OutIter +// copy_if(InIter first, InIter last, OutIter result, Pred pred); + +#include +#include + +#include "test_iterators.h" + +struct Pred +{ + bool operator()(int i) {return i % 3 == 0;} +}; + +template +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, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter> +// OutIter +// copy_n(InIter first, InIter::difference_type n, OutIter result); + +#include +#include + +#include "test_iterators.h" +#include "user_defined_integral.hpp" + +typedef UserDefinedIntegral UDI; + +template +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, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// void +// fill(Iter first, Iter last, const T& value); + +#include +#include + +#include "test_iterators.h" + +template +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 +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 >(); + test_char >(); + test_char >(); + test_char(); + + test_int >(); + test_int >(); + test_int >(); + test_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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// OutputIterator +// fill_n(Iter first, Size n, const T& value); + +#include +#include + +#include "test_iterators.h" +#include "user_defined_integral.hpp" + +typedef UserDefinedIntegral UDI; + +template +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 +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(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(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 >(); + test_char >(); + test_char >(); + test_char(); + + test_int >(); + test_int >(); + test_int >(); + test_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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && CopyConstructible +// void +// generate(Iter first, Iter last, Generator gen); + +#include +#include + +#include "test_iterators.h" + +struct gen_test +{ + int operator()() const {return 1;} +}; + +template +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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && CopyConstructible +// void +// generate_n(Iter first, Size n, Generator gen); + +#include +#include + +#include "test_iterators.h" +#include "user_defined_integral.hpp" + +typedef UserDefinedIntegral UDI; + +struct gen_test +{ + int operator()() const {return 2;} +}; + +template +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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator::type> +// OutIter +// move(InIter first, InIter last, OutIter result); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +template +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 +void +test1() +{ + const unsigned N = 100; + std::unique_ptr ia[N]; + for (unsigned i = 0; i < N; ++i) + ia[i].reset(new int(i)); + std::unique_ptr 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, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test1*>, output_iterator*> >(); + test1*>, input_iterator*> >(); + test1*>, forward_iterator*> >(); + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*>, output_iterator*> >(); + test1*>, input_iterator*> >(); + test1*>, forward_iterator*> >(); + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*>, output_iterator*> >(); + test1*>, input_iterator*> >(); + test1*>, forward_iterator*> >(); + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*>, output_iterator*> >(); + test1*>, input_iterator*> >(); + test1*>, forward_iterator*> >(); + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*, output_iterator*> >(); + test1*, input_iterator*> >(); + test1*, forward_iterator*> >(); + test1*, bidirectional_iterator*> >(); + test1*, random_access_iterator*> >(); + test1*, std::unique_ptr*>(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator::type> +// OutIter +// move_backward(InIter first, InIter last, OutIter result); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +template +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 +void +test1() +{ + const unsigned N = 100; + std::unique_ptr ia[N]; + for (unsigned i = 0; i < N; ++i) + ia[i].reset(new int(i)); + std::unique_ptr 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 >(); + test, random_access_iterator >(); + test, int*>(); + + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*, bidirectional_iterator*> >(); + test1*, random_access_iterator*> >(); + test1*, std::unique_ptr*>(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// is_partitioned(InputIterator first, InputIterator last, Predicate pred); + +#include +#include + +#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 pred((is_odd())); + assert(!std::is_partitioned(input_iterator(std::begin(ia)), + input_iterator(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 pred((is_odd())); + assert( std::is_partitioned(input_iterator(std::begin(ia)), + input_iterator(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 pred((is_odd())); + assert(!std::is_partitioned(input_iterator(std::begin(ia)), + input_iterator(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 pred((is_odd())); + assert(!std::is_partitioned(input_iterator(std::begin(ia)), + input_iterator(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 pred((is_odd())); + assert( std::is_partitioned(input_iterator(std::begin(ia)), + input_iterator(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 pred((is_odd())); + assert( std::is_partitioned(input_iterator(std::begin(ia)), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires ShuffleIterator +// && CopyConstructible +// Iter +// partition(Iter first, Iter last, Pred pred); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +struct is_odd +{ + bool operator()(const int& i) const {return i & 1;} +}; + +template +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 >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// pair +// partition_copy(InputIterator first, InputIterator last, +// OutputIterator1 out_true, OutputIterator2 out_false, +// Predicate pred); + +#include +#include + +#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, int*> P; + P p = std::partition_copy(input_iterator(std::begin(ia)), + input_iterator(std::end(ia)), + output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// ForwardIterator +// partition_point(ForwardIterator first, ForwardIterator last, Predicate pred); + +#include +#include + +#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(std::begin(ia)), + forward_iterator(std::end(ia)), + is_odd()) == forward_iterator(ia)); + } + { + const int ia[] = {1, 2, 4, 6, 8}; + assert(std::partition_point(forward_iterator(std::begin(ia)), + forward_iterator(std::end(ia)), + is_odd()) == forward_iterator(ia + 1)); + } + { + const int ia[] = {1, 3, 2, 4, 6}; + assert(std::partition_point(forward_iterator(std::begin(ia)), + forward_iterator(std::end(ia)), + is_odd()) == forward_iterator(ia + 2)); + } + { + const int ia[] = {1, 3, 5, 2, 4, 6}; + assert(std::partition_point(forward_iterator(std::begin(ia)), + forward_iterator(std::end(ia)), + is_odd()) == forward_iterator(ia + 3)); + } + { + const int ia[] = {1, 3, 5, 7, 2, 4}; + assert(std::partition_point(forward_iterator(std::begin(ia)), + forward_iterator(std::end(ia)), + is_odd()) == forward_iterator(ia + 4)); + } + { + const int ia[] = {1, 3, 5, 7, 9, 2}; + assert(std::partition_point(forward_iterator(std::begin(ia)), + forward_iterator(std::end(ia)), + is_odd()) == forward_iterator(ia + 5)); + } + { + const int ia[] = {1, 3, 5, 7, 9, 11}; + assert(std::partition_point(forward_iterator(std::begin(ia)), + forward_iterator(std::end(ia)), + is_odd()) == forward_iterator(ia + 6)); + } + { + const int ia[] = {1, 3, 5, 2, 4, 6, 7}; + assert(std::partition_point(forward_iterator(std::begin(ia)), + forward_iterator(std::begin(ia)), + is_odd()) == forward_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires ShuffleIterator +// && CopyConstructible +// Iter +// stable_partition(Iter first, Iter last, Pred pred); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#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& p) const + {return p.first & 1;} +}; + +template +void +test() +{ + { // check mixed + typedef std::pair 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 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 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 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 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 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 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 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 + bool operator()(const P& p) {return p == 0;} +}; + +template +void +test1() +{ + const unsigned size = 5; + std::unique_ptr array[size]; + Iter r = std::stable_partition(Iter(array), Iter(array+size), is_null()); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + test*> >(); + test*> >(); + test*>(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test1*> >(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// void +// random_shuffle(Iter first, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Rand> +// requires ShuffleIterator +// && Convertible +// void +// random_shuffle(Iter first, Iter last, Rand&& rand); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void shuffle(RandomAccessIterator first, RandomAccessIterator last, +// UniformRandomNumberGenerator& g); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator::type> +// && HasEqualTo +// Iter +// remove(Iter first, Iter last, const T& value); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +template +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 +void +test1() +{ + const unsigned sa = 9; + std::unique_ptr 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()); + 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 >(); + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1*> >(); + test1*> >(); + test1*> >(); + test1*>(); + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter, class T> +// requires HasEqualTo +// OutIter +// remove_copy(InIter first, InIter last, OutIter result, const T& value); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter, +// Predicate Pred> +// requires CopyConstructible +// OutIter +// remove_copy_if(InIter first, InIter last, OutIter result, Pred pred); + +#include +#include +#include + +#include "test_iterators.h" + +template +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(), 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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires OutputIterator::type> +// && CopyConstructible +// Iter +// remove_if(Iter first, Iter last, Pred pred); + +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" +#include "counting_predicates.hpp" + +bool equal2 ( int i ) { return i == 2; } + +template +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(), 2)); + unary_counting_predicate 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& i) {return *i == 2;} +}; + +template +void +test1() +{ + const unsigned sa = 9; + std::unique_ptr 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 >(); + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1*> >(); + test1*> >(); + test1*> >(); + test1*>(); + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && HasEqualTo +// void +// replace(Iter first, Iter last, const T& old_value, const T& new_value); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && HasEqualTo +// OutIter +// replace_copy(InIter first, InIter last, OutIter result, const T& old_value, +// const T& new_value); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred, class T> +// requires OutputIterator +// && OutputIterator +// && CopyConstructible +// OutIter +// replace_copy_if(InIter first, InIter last, OutIter result, Pred pred, const T& new_value); + +#include +#include +#include + +#include "test_iterators.h" + +template +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(), 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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred, class T> +// requires OutputIterator +// && OutputIterator +// && CopyConstructible +// void +// replace_if(Iter first, Iter last, Pred pred, const T& new_value); + +#include +#include +#include + +#include "test_iterators.h" + +template +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(), 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasSwap +// void +// reverse(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter> +// OutIter +// reverse_copy(InIter first, InIter last, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// Iter +// rotate(Iter first, Iter middle, Iter last); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +template +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 +void +test1() +{ + std::unique_ptr 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 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 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 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 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 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 >(); + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1*> >(); + test1*> >(); + test1*> >(); + test1*>(); + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter> +// OutIter +// rotate_copy(InIter first, InIter middle, InIter last, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasSwap +// void +// iter_swap(Iter1 a, Iter2 b); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasSwap +// Iter2 +// swap_ranges(Iter1 first1, Iter1 last1, Iter2 first2); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +template +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 +void +test1() +{ + std::unique_ptr i[3]; + for (int k = 0; k < 3; ++k) + i[k].reset(new int(k+1)); + std::unique_ptr 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 >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1*>, forward_iterator*> >(); + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*>, forward_iterator*> >(); + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*>, forward_iterator*> >(); + test1*>, bidirectional_iterator*> >(); + test1*>, random_access_iterator*> >(); + test1*>, std::unique_ptr*>(); + + test1*, forward_iterator*> >(); + test1*, bidirectional_iterator*> >(); + test1*, random_access_iterator*> >(); + test1*, std::unique_ptr*>(); + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template BinaryOp> +// requires OutputIterator && CopyConstructible +// OutIter +// transform(InIter1 first1, InIter1 last1, InIter2 first2, OutIter result, BinaryOp binary_op); + +#include +#include +#include + +#include "test_iterators.h" + +template +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()); + 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, output_iterator >(); + test, input_iterator, input_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, input_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, input_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, input_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, input_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, input_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, input_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, input_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, input_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, input_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, input_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, input_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, input_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, input_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, input_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, input_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, input_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, input_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, input_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, input_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Op> +// requires OutputIterator && CopyConstructible +// OutIter +// transform(InIter first, InIter last, OutIter result, Op op); + +#include +#include +#include + +#include "test_iterators.h" + +template +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(), 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, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && EqualityComparable +// Iter +// unique(Iter first, Iter last); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +template +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 Ptr; + +template +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 >(); + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1 >(); + test1 >(); + test1 >(); + test1(); + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator::type> +// && EqualityComparable +// && HasAssign +// && Constructible +// OutIter +// unique_copy(InIter first, InIter last, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires OutputIterator::type> +// && HasAssign +// && Constructible +// && CopyConstructible +// OutIter +// unique_copy(InIter first, InIter last, OutIter result, Pred pred); + +#include +#include + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires OutputIterator::type> +// && CopyConstructible +// Iter +// unique(Iter first, Iter last, Pred pred); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +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 Ptr; + +template +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 >(); + test >(); + test >(); + test(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1 >(); + test1 >(); + test1 >(); + test1(); + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires EqualityComparable +// Iter +// adjacent_find(Iter first, Iter last); + +#include +#include + +#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(ia), + forward_iterator(ia + sa)) == + forward_iterator(ia+2)); + assert(std::adjacent_find(forward_iterator(ia), + forward_iterator(ia)) == + forward_iterator(ia)); + assert(std::adjacent_find(forward_iterator(ia+3), + forward_iterator(ia + sa)) == + forward_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// Iter +// adjacent_find(Iter first, Iter last, Pred pred); + +#include +#include +#include + +#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(ia), + forward_iterator(ia + sa), + std::equal_to()) == + forward_iterator(ia+2)); + assert(std::adjacent_find(forward_iterator(ia), + forward_iterator(ia), + std::equal_to()) == + forward_iterator(ia)); + assert(std::adjacent_find(forward_iterator(ia+3), + forward_iterator(ia + sa), + std::equal_to()) == + forward_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// all_of(InputIterator first, InputIterator last, Predicate pred); + +#include +#include + +#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(ia), + input_iterator(ia + sa), test1()) == true); + assert(std::all_of(input_iterator(ia), + input_iterator(ia), test1()) == true); + } + { + const int ia[] = {2, 4, 5, 8}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::all_of(input_iterator(ia), + input_iterator(ia + sa), test1()) == false); + assert(std::all_of(input_iterator(ia), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// any_of(InputIterator first, InputIterator last, Predicate pred); + +#include +#include + +#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(ia), + input_iterator(ia + sa), test1()) == true); + assert(std::any_of(input_iterator(ia), + input_iterator(ia), test1()) == false); + } + { + const int ia[] = {2, 4, 5, 8}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::any_of(input_iterator(ia), + input_iterator(ia + sa), test1()) == true); + assert(std::any_of(input_iterator(ia), + input_iterator(ia), test1()) == false); + } + { + const int ia[] = {1, 3, 5, 7}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::any_of(input_iterator(ia), + input_iterator(ia + sa), test1()) == false); + assert(std::any_of(input_iterator(ia), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// Iter::difference_type +// count(Iter first, Iter last, const T& value); + +#include +#include + +#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(ia), + input_iterator(ia + sa), 2) == 3); + assert(std::count(input_iterator(ia), + input_iterator(ia + sa), 7) == 0); + assert(std::count(input_iterator(ia), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// Iter::difference_type +// count_if(Iter first, Iter last, Pred pred); + +#include +#include +#include + +#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(ia), + input_iterator(ia + sa), + std::bind2nd(std::equal_to(),2)) == 3); + assert(std::count_if(input_iterator(ia), + input_iterator(ia + sa), + std::bind2nd(std::equal_to(),7)) == 0); + assert(std::count_if(input_iterator(ia), + input_iterator(ia), + std::bind2nd(std::equal_to(),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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// bool +// equal(Iter1 first1, Iter1 last1, Iter2 first2); + +#include +#include + +#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(ia), + input_iterator(ia+s), + input_iterator(ia))); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s))); + assert(std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(ia+s))); +#endif + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ib))); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ib), + input_iterator(ib+s))); + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ib), + random_access_iterator(ib+s))); + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s-1))); + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// bool +// equal(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred); + +#include +#include +#include + +#include "test_iterators.h" + +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + +int comparison_count = 0; +template +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(ia), + input_iterator(ia+s), + input_iterator(ia), + std::equal_to())); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s), + std::equal_to())); + assert(std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(ia+s), + std::equal_to())); + + comparison_count = 0; + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ia), + input_iterator(ia+s-1), + counting_equals)); + assert(comparison_count > 0); + comparison_count = 0; + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ia), + random_access_iterator(ia+s-1), + counting_equals)); + assert(comparison_count == 0); +#endif + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ib), + std::equal_to())); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(!std::equal(input_iterator(ia), + input_iterator(ia+s), + input_iterator(ib), + input_iterator(ib+s), + std::equal_to())); + assert(!std::equal(random_access_iterator(ia), + random_access_iterator(ia+s), + random_access_iterator(ib), + random_access_iterator(ib+s), + std::equal_to())); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// Iter1 +// find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// Iter1 +// find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred); + +#include +#include + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +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 >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// Iter1 +// find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); + +#include +#include + +#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(ia), + input_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sb)) == + input_iterator(ia+1)); + int ic[] = {7}; + assert(std::find_first_of(input_iterator(ia), + input_iterator(ia + sa), + forward_iterator(ic), + forward_iterator(ic + 1)) == + input_iterator(ia+sa)); + assert(std::find_first_of(input_iterator(ia), + input_iterator(ia + sa), + forward_iterator(ic), + forward_iterator(ic)) == + input_iterator(ia+sa)); + assert(std::find_first_of(input_iterator(ia), + input_iterator(ia), + forward_iterator(ic), + forward_iterator(ic+1)) == + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// Iter1 +// find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred); + +#include +#include +#include + +#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(ia), + input_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sb), + std::equal_to()) == + input_iterator(ia+1)); + int ic[] = {7}; + assert(std::find_first_of(input_iterator(ia), + input_iterator(ia + sa), + forward_iterator(ic), + forward_iterator(ic + 1), + std::equal_to()) == + input_iterator(ia+sa)); + assert(std::find_first_of(input_iterator(ia), + input_iterator(ia + sa), + forward_iterator(ic), + forward_iterator(ic), + std::equal_to()) == + input_iterator(ia+sa)); + assert(std::find_first_of(input_iterator(ia), + input_iterator(ia), + forward_iterator(ic), + forward_iterator(ic+1), + std::equal_to()) == + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// Iter +// find(Iter first, Iter last, const T& value); + +#include +#include + +#include "test_iterators.h" + +int main() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned s = sizeof(ia)/sizeof(ia[0]); + input_iterator r = std::find(input_iterator(ia), + input_iterator(ia+s), 3); + assert(*r == 3); + r = std::find(input_iterator(ia), input_iterator(ia+s), 10); + assert(r == input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// Iter +// find_if(Iter first, Iter last, Pred pred); + +#include +#include +#include + +#include "test_iterators.h" + +int main() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned s = sizeof(ia)/sizeof(ia[0]); + input_iterator r = std::find_if(input_iterator(ia), + input_iterator(ia+s), + std::bind2nd(std::equal_to(), 3)); + assert(*r == 3); + r = std::find_if(input_iterator(ia), + input_iterator(ia+s), + std::bind2nd(std::equal_to(), 10)); + assert(r == input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// Iter +// find_if_not(Iter first, Iter last, Pred pred); + +#include +#include +#include + +#include "test_iterators.h" + +int main() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned s = sizeof(ia)/sizeof(ia[0]); + input_iterator r = std::find_if_not(input_iterator(ia), + input_iterator(ia+s), + std::bind2nd(std::not_equal_to(), 3)); + assert(*r == 3); + r = std::find_if_not(input_iterator(ia), + input_iterator(ia+s), + std::bind2nd(std::not_equal_to(), 10)); + assert(r == input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Function> +// requires CopyConstructible +// Function +// for_each(Iter first, Iter last, Function f); + +#include +#include + +#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(ia), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, +// ForwardIterator2 first2); + +#include +#include + +#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(ia), + forward_iterator(ia + 0), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + 0), + forward_iterator(ib), + forward_iterator(ib + 0)) == true); +#endif + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1), + forward_iterator(ib + sa)) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa)) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1 ), + forward_iterator(ib + sa)) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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(ia), + forward_iterator(ia + sa), + forward_iterator(ib)) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, +// ForwardIterator2 first2, BinaryPredicate pred); + +#include +#include +#include + +#include "test_iterators.h" + +#if _LIBCPP_STD_VER > 11 +#define HAS_FOUR_ITERATOR_VERSION +#endif + +int comparison_count = 0; +template +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(ia), + forward_iterator(ia + 0), + forward_iterator(ib), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); +#endif + } + { + const int ia[] = {0}; + const int ib[] = {1}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1), + forward_iterator(ib + sa), + std::equal_to()) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == true); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == true); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib + 1), + forward_iterator(ib + sa), + std::equal_to()) == false); + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + std::equal_to()) == false); + comparison_count = 0; + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa - 1), + counting_equals) == false); + assert ( comparison_count > 0 ); + comparison_count = 0; + assert(std::is_permutation(random_access_iterator(ia), + random_access_iterator(ia + sa), + random_access_iterator(ib), + random_access_iterator(ib + sa - 1), + counting_equals) == 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(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + std::equal_to()) == false); +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::is_permutation(forward_iterator(ia), + forward_iterator(ia + sa), + forward_iterator(ib), + forward_iterator(ib + sa), + std::equal_to()) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// none_of(InputIterator first, InputIterator last, Predicate pred); + +#include +#include + +#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(ia), + input_iterator(ia + sa), test1()) == false); + assert(std::none_of(input_iterator(ia), + input_iterator(ia), test1()) == true); + } + { + const int ia[] = {2, 4, 5, 8}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::none_of(input_iterator(ia), + input_iterator(ia + sa), test1()) == false); + assert(std::none_of(input_iterator(ia), + input_iterator(ia), test1()) == true); + } + { + const int ia[] = {1, 3, 5, 7}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + assert(std::none_of(input_iterator(ia), + input_iterator(ia + sa), test1()) == true); + assert(std::none_of(input_iterator(ia), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// Iter1 +// search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// ForwardIterator +// search_n(ForwardIterator first, ForwardIterator last, Size count, +// const T& value); + +#include +#include + +#include "test_iterators.h" +#include "user_defined_integral.hpp" + +template +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(0), 0); +} + +int main() +{ + test >(); + test >(); + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// ForwardIterator +// search_n(ForwardIterator first, ForwardIterator last, Size count, +// const T& value, BinaryPredicate pred); + +#include +#include + +#include "test_iterators.h" +#include "user_defined_integral.hpp" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + + +template +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(4), 0, count_equal()); + count_equal::count = 0; +} + +int main() +{ + test >(); + test >(); + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// Iter1 +// search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); + +#include +#include + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +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 >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasEqualTo +// pair +// mismatch(Iter1 first1, Iter1 last1, Iter2 first2); + +#include +#include + +#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 II; + typedef random_access_iterator RAI; + + assert(std::mismatch(II(ia), II(ia + sa), II(ib)) + == (std::pair(II(ia+3), II(ib+3)))); + + assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib)) + == (std::pair(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(ia+3), II(ib+3)))); + + assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib+sb)) + == (std::pair(RAI(ia+3), RAI(ib+3)))); + + + assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+2)) + == (std::pair(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. +// +//===----------------------------------------------------------------------===// + +// + +// template Pred> +// requires CopyConstructible +// pair +// mismatch(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred); + +#include +#include +#include + +#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 II; + typedef random_access_iterator RAI; + typedef std::equal_to EQ; + + assert(std::mismatch(II(ia), II(ia + sa), II(ib), EQ()) + == (std::pair(II(ia+3), II(ib+3)))); + assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), EQ()) + == (std::pair(RAI(ia+3), RAI(ib+3)))); + + binary_counting_predicate bcp((EQ())); + assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), std::ref(bcp)) + == (std::pair(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(ia+3), II(ib+3)))); + assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib + sb), EQ()) + == (std::pair(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(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(ia+3,ib+3))); + +#ifdef HAS_FOUR_ITERATOR_VERSION + assert(std::mismatch(ia, ia + sa, ib, ib + sb, EQ()) == + (std::pair(ia+3,ib+3))); + assert(std::mismatch(ia, ia + sa, ib, ib + 2, EQ()) == + (std::pair(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasLess +// && HasLess +// bool +// binary_search(Iter first, Iter last, const T& value); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, const T& value, bool x) +{ + assert(std::binary_search(first, last, value) == x); +} + +template +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires Predicate +// && Predicate +// bool +// binary_search(Iter first, Iter last, const T& value, Compare comp); + +#include +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, const T& value, bool x) +{ + assert(std::binary_search(first, last, value, std::greater()) == x); +} + +template +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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()); + 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasLess +// && HasLess +// pair +// equal_range(Iter first, Iter last, const T& value); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, const T& value) +{ + std::pair 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 +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires Predicate +// && Predicate +// pair +// equal_range(Iter first, Iter last, const T& value, Compare comp); + +#include +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, const T& value) +{ + std::pair i = std::equal_range(first, last, value, std::greater()); + for (Iter j = first; j != i.first; ++j) + assert(std::greater()(*j, value)); + for (Iter j = i.first; j != last; ++j) + assert(!std::greater()(*j, value)); + for (Iter j = first; j != i.second; ++j) + assert(!std::greater()(value, *j)); + for (Iter j = i.second; j != last; ++j) + assert(std::greater()(value, *j)); +} + +template +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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()); + 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasLess +// Iter +// lower_bound(Iter first, Iter last, const T& value); + +#include +#include +#include + +#include "test_iterators.h" + +template +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 +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasLess +// Iter +// lower_bound(Iter first, Iter last, const T& value); + +#include +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, const T& value) +{ + Iter i = std::lower_bound(first, last, value, std::greater()); + for (Iter j = first; j != i; ++j) + assert(std::greater()(*j, value)); + for (Iter j = i; j != last; ++j) + assert(!std::greater()(*j, value)); +} + +template +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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()); + 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasLess +// Iter +// upper_bound(Iter first, Iter last, const T& value); + +#include +#include +#include + +#include "test_iterators.h" + +template +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 +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires CopyConstructible +// Iter +// upper_bound(Iter first, Iter last, const T& value, Compare comp); + +#include +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, const T& value) +{ + Iter i = std::upper_bound(first, last, value, std::greater()); + for (Iter j = first; j != i; ++j) + assert(!std::greater()(value, *j)); + for (Iter j = i; j != last; ++j) + assert(std::greater()(value, *j)); +} + +template +void +test() +{ + const unsigned N = 1000; + const unsigned M = 10; + std::vector 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()); + 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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// bool +// is_heap(Iter first, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// bool +// is_heap(Iter first, Iter last); + +#include +#include +#include + +void test() +{ + int i1[] = {0, 0}; + assert(std::is_heap(i1, i1, std::greater())); + assert(std::is_heap(i1, i1+1, std::greater()) == (std::is_heap_until(i1, i1+1, std::greater()) == i1+1)); + int i2[] = {0, 1}; + int i3[] = {1, 0}; + assert(std::is_heap(i1, i1+2, std::greater()) == (std::is_heap_until(i1, i1+2, std::greater()) == i1+2)); + assert(std::is_heap(i2, i2+2, std::greater()) == (std::is_heap_until(i2, i2+2, std::greater()) == i2+2)); + assert(std::is_heap(i3, i3+2, std::greater()) == (std::is_heap_until(i3, i3+2, std::greater()) == 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()) == (std::is_heap_until(i4, i4+3, std::greater()) == i4+3)); + assert(std::is_heap(i5, i5+3, std::greater()) == (std::is_heap_until(i5, i5+3, std::greater()) == i5+3)); + assert(std::is_heap(i6, i6+3, std::greater()) == (std::is_heap_until(i6, i6+3, std::greater()) == i6+3)); + assert(std::is_heap(i7, i7+3, std::greater()) == (std::is_heap_until(i7, i7+3, std::greater()) == i7+3)); + assert(std::is_heap(i8, i8+3, std::greater()) == (std::is_heap_until(i8, i8+3, std::greater()) == i8+3)); + assert(std::is_heap(i9, i9+3, std::greater()) == (std::is_heap_until(i9, i9+3, std::greater()) == i9+3)); + assert(std::is_heap(i10, i10+3, std::greater()) == (std::is_heap_until(i10, i10+3, std::greater()) == 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()) == (std::is_heap_until(i11, i11+4, std::greater()) == i11+4)); + assert(std::is_heap(i12, i12+4, std::greater()) == (std::is_heap_until(i12, i12+4, std::greater()) == i12+4)); + assert(std::is_heap(i13, i13+4, std::greater()) == (std::is_heap_until(i13, i13+4, std::greater()) == i13+4)); + assert(std::is_heap(i14, i14+4, std::greater()) == (std::is_heap_until(i14, i14+4, std::greater()) == i14+4)); + assert(std::is_heap(i15, i15+4, std::greater()) == (std::is_heap_until(i15, i15+4, std::greater()) == i15+4)); + assert(std::is_heap(i16, i16+4, std::greater()) == (std::is_heap_until(i16, i16+4, std::greater()) == i16+4)); + assert(std::is_heap(i17, i17+4, std::greater()) == (std::is_heap_until(i17, i17+4, std::greater()) == i17+4)); + assert(std::is_heap(i18, i18+4, std::greater()) == (std::is_heap_until(i18, i18+4, std::greater()) == i18+4)); + assert(std::is_heap(i19, i19+4, std::greater()) == (std::is_heap_until(i19, i19+4, std::greater()) == i19+4)); + assert(std::is_heap(i20, i20+4, std::greater()) == (std::is_heap_until(i20, i20+4, std::greater()) == i20+4)); + assert(std::is_heap(i21, i21+4, std::greater()) == (std::is_heap_until(i21, i21+4, std::greater()) == i21+4)); + assert(std::is_heap(i22, i22+4, std::greater()) == (std::is_heap_until(i22, i22+4, std::greater()) == i22+4)); + assert(std::is_heap(i23, i23+4, std::greater()) == (std::is_heap_until(i23, i23+4, std::greater()) == i23+4)); + assert(std::is_heap(i24, i24+4, std::greater()) == (std::is_heap_until(i24, i24+4, std::greater()) == i24+4)); + assert(std::is_heap(i25, i25+4, std::greater()) == (std::is_heap_until(i25, i25+4, std::greater()) == 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()) == (std::is_heap_until(i26, i26+5, std::greater()) == i26+5)); + assert(std::is_heap(i27, i27+5, std::greater()) == (std::is_heap_until(i27, i27+5, std::greater()) == i27+5)); + assert(std::is_heap(i28, i28+5, std::greater()) == (std::is_heap_until(i28, i28+5, std::greater()) == i28+5)); + assert(std::is_heap(i29, i29+5, std::greater()) == (std::is_heap_until(i29, i29+5, std::greater()) == i29+5)); + assert(std::is_heap(i30, i30+5, std::greater()) == (std::is_heap_until(i30, i30+5, std::greater()) == i30+5)); + assert(std::is_heap(i31, i31+5, std::greater()) == (std::is_heap_until(i31, i31+5, std::greater()) == i31+5)); + assert(std::is_heap(i32, i32+5, std::greater()) == (std::is_heap_until(i32, i32+5, std::greater()) == i32+5)); + assert(std::is_heap(i33, i33+5, std::greater()) == (std::is_heap_until(i33, i33+5, std::greater()) == i33+5)); + assert(std::is_heap(i34, i34+5, std::greater()) == (std::is_heap_until(i34, i34+5, std::greater()) == i34+5)); + assert(std::is_heap(i35, i35+5, std::greater()) == (std::is_heap_until(i35, i35+5, std::greater()) == i35+5)); + assert(std::is_heap(i36, i36+5, std::greater()) == (std::is_heap_until(i36, i36+5, std::greater()) == i36+5)); + assert(std::is_heap(i37, i37+5, std::greater()) == (std::is_heap_until(i37, i37+5, std::greater()) == i37+5)); + assert(std::is_heap(i38, i38+5, std::greater()) == (std::is_heap_until(i38, i38+5, std::greater()) == i38+5)); + assert(std::is_heap(i39, i39+5, std::greater()) == (std::is_heap_until(i39, i39+5, std::greater()) == i39+5)); + assert(std::is_heap(i40, i40+5, std::greater()) == (std::is_heap_until(i40, i40+5, std::greater()) == i40+5)); + assert(std::is_heap(i41, i41+5, std::greater()) == (std::is_heap_until(i41, i41+5, std::greater()) == i41+5)); + assert(std::is_heap(i42, i42+5, std::greater()) == (std::is_heap_until(i42, i42+5, std::greater()) == i42+5)); + assert(std::is_heap(i43, i43+5, std::greater()) == (std::is_heap_until(i43, i43+5, std::greater()) == i43+5)); + assert(std::is_heap(i44, i44+5, std::greater()) == (std::is_heap_until(i44, i44+5, std::greater()) == i44+5)); + assert(std::is_heap(i45, i45+5, std::greater()) == (std::is_heap_until(i45, i45+5, std::greater()) == i45+5)); + assert(std::is_heap(i46, i46+5, std::greater()) == (std::is_heap_until(i46, i46+5, std::greater()) == i46+5)); + assert(std::is_heap(i47, i47+5, std::greater()) == (std::is_heap_until(i47, i47+5, std::greater()) == i47+5)); + assert(std::is_heap(i48, i48+5, std::greater()) == (std::is_heap_until(i48, i48+5, std::greater()) == i48+5)); + assert(std::is_heap(i49, i49+5, std::greater()) == (std::is_heap_until(i49, i49+5, std::greater()) == i49+5)); + assert(std::is_heap(i50, i50+5, std::greater()) == (std::is_heap_until(i50, i50+5, std::greater()) == i50+5)); + assert(std::is_heap(i51, i51+5, std::greater()) == (std::is_heap_until(i51, i51+5, std::greater()) == i51+5)); + assert(std::is_heap(i52, i52+5, std::greater()) == (std::is_heap_until(i52, i52+5, std::greater()) == i52+5)); + assert(std::is_heap(i53, i53+5, std::greater()) == (std::is_heap_until(i53, i53+5, std::greater()) == i53+5)); + assert(std::is_heap(i54, i54+5, std::greater()) == (std::is_heap_until(i54, i54+5, std::greater()) == i54+5)); + assert(std::is_heap(i55, i55+5, std::greater()) == (std::is_heap_until(i55, i55+5, std::greater()) == i55+5)); + assert(std::is_heap(i56, i56+5, std::greater()) == (std::is_heap_until(i56, i56+5, std::greater()) == 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()) == (std::is_heap_until(i57, i57+6, std::greater()) == i57+6)); + assert(std::is_heap(i58, i58+6, std::greater()) == (std::is_heap_until(i58, i58+6, std::greater()) == i58+6)); + assert(std::is_heap(i59, i59+6, std::greater()) == (std::is_heap_until(i59, i59+6, std::greater()) == i59+6)); + assert(std::is_heap(i60, i60+6, std::greater()) == (std::is_heap_until(i60, i60+6, std::greater()) == i60+6)); + assert(std::is_heap(i61, i61+6, std::greater()) == (std::is_heap_until(i61, i61+6, std::greater()) == i61+6)); + assert(std::is_heap(i62, i62+6, std::greater()) == (std::is_heap_until(i62, i62+6, std::greater()) == i62+6)); + assert(std::is_heap(i63, i63+6, std::greater()) == (std::is_heap_until(i63, i63+6, std::greater()) == i63+6)); + assert(std::is_heap(i64, i64+6, std::greater()) == (std::is_heap_until(i64, i64+6, std::greater()) == i64+6)); + assert(std::is_heap(i65, i65+6, std::greater()) == (std::is_heap_until(i65, i65+6, std::greater()) == i65+6)); + assert(std::is_heap(i66, i66+6, std::greater()) == (std::is_heap_until(i66, i66+6, std::greater()) == i66+6)); + assert(std::is_heap(i67, i67+6, std::greater()) == (std::is_heap_until(i67, i67+6, std::greater()) == i67+6)); + assert(std::is_heap(i68, i68+6, std::greater()) == (std::is_heap_until(i68, i68+6, std::greater()) == i68+6)); + assert(std::is_heap(i69, i69+6, std::greater()) == (std::is_heap_until(i69, i69+6, std::greater()) == i69+6)); + assert(std::is_heap(i70, i70+6, std::greater()) == (std::is_heap_until(i70, i70+6, std::greater()) == i70+6)); + assert(std::is_heap(i71, i71+6, std::greater()) == (std::is_heap_until(i71, i71+6, std::greater()) == i71+6)); + assert(std::is_heap(i72, i72+6, std::greater()) == (std::is_heap_until(i72, i72+6, std::greater()) == i72+6)); + assert(std::is_heap(i73, i73+6, std::greater()) == (std::is_heap_until(i73, i73+6, std::greater()) == i73+6)); + assert(std::is_heap(i74, i74+6, std::greater()) == (std::is_heap_until(i74, i74+6, std::greater()) == i74+6)); + assert(std::is_heap(i75, i75+6, std::greater()) == (std::is_heap_until(i75, i75+6, std::greater()) == i75+6)); + assert(std::is_heap(i76, i76+6, std::greater()) == (std::is_heap_until(i76, i76+6, std::greater()) == i76+6)); + assert(std::is_heap(i77, i77+6, std::greater()) == (std::is_heap_until(i77, i77+6, std::greater()) == i77+6)); + assert(std::is_heap(i78, i78+6, std::greater()) == (std::is_heap_until(i78, i78+6, std::greater()) == i78+6)); + assert(std::is_heap(i79, i79+6, std::greater()) == (std::is_heap_until(i79, i79+6, std::greater()) == i79+6)); + assert(std::is_heap(i80, i80+6, std::greater()) == (std::is_heap_until(i80, i80+6, std::greater()) == i80+6)); + assert(std::is_heap(i81, i81+6, std::greater()) == (std::is_heap_until(i81, i81+6, std::greater()) == i81+6)); + assert(std::is_heap(i82, i82+6, std::greater()) == (std::is_heap_until(i82, i82+6, std::greater()) == i82+6)); + assert(std::is_heap(i83, i83+6, std::greater()) == (std::is_heap_until(i83, i83+6, std::greater()) == i83+6)); + assert(std::is_heap(i84, i84+6, std::greater()) == (std::is_heap_until(i84, i84+6, std::greater()) == i84+6)); + assert(std::is_heap(i85, i85+6, std::greater()) == (std::is_heap_until(i85, i85+6, std::greater()) == i85+6)); + assert(std::is_heap(i86, i86+6, std::greater()) == (std::is_heap_until(i86, i86+6, std::greater()) == i86+6)); + assert(std::is_heap(i87, i87+6, std::greater()) == (std::is_heap_until(i87, i87+6, std::greater()) == i87+6)); + assert(std::is_heap(i88, i88+6, std::greater()) == (std::is_heap_until(i88, i88+6, std::greater()) == i88+6)); + assert(std::is_heap(i89, i89+6, std::greater()) == (std::is_heap_until(i89, i89+6, std::greater()) == i89+6)); + assert(std::is_heap(i90, i90+6, std::greater()) == (std::is_heap_until(i90, i90+6, std::greater()) == i90+6)); + assert(std::is_heap(i91, i91+6, std::greater()) == (std::is_heap_until(i91, i91+6, std::greater()) == i91+6)); + assert(std::is_heap(i92, i92+6, std::greater()) == (std::is_heap_until(i92, i92+6, std::greater()) == i92+6)); + assert(std::is_heap(i93, i93+6, std::greater()) == (std::is_heap_until(i93, i93+6, std::greater()) == i93+6)); + assert(std::is_heap(i94, i94+6, std::greater()) == (std::is_heap_until(i94, i94+6, std::greater()) == i94+6)); + assert(std::is_heap(i95, i95+6, std::greater()) == (std::is_heap_until(i95, i95+6, std::greater()) == i95+6)); + assert(std::is_heap(i96, i96+6, std::greater()) == (std::is_heap_until(i96, i96+6, std::greater()) == i96+6)); + assert(std::is_heap(i97, i97+6, std::greater()) == (std::is_heap_until(i97, i97+6, std::greater()) == i97+6)); + assert(std::is_heap(i98, i98+6, std::greater()) == (std::is_heap_until(i98, i98+6, std::greater()) == i98+6)); + assert(std::is_heap(i99, i99+6, std::greater()) == (std::is_heap_until(i99, i99+6, std::greater()) == i99+6)); + assert(std::is_heap(i100, i100+6, std::greater()) == (std::is_heap_until(i100, i100+6, std::greater()) == i100+6)); + assert(std::is_heap(i101, i101+6, std::greater()) == (std::is_heap_until(i101, i101+6, std::greater()) == i101+6)); + assert(std::is_heap(i102, i102+6, std::greater()) == (std::is_heap_until(i102, i102+6, std::greater()) == i102+6)); + assert(std::is_heap(i103, i103+6, std::greater()) == (std::is_heap_until(i103, i103+6, std::greater()) == i103+6)); + assert(std::is_heap(i104, i104+6, std::greater()) == (std::is_heap_until(i104, i104+6, std::greater()) == i104+6)); + assert(std::is_heap(i105, i105+6, std::greater()) == (std::is_heap_until(i105, i105+6, std::greater()) == i105+6)); + assert(std::is_heap(i106, i106+6, std::greater()) == (std::is_heap_until(i106, i106+6, std::greater()) == i106+6)); + assert(std::is_heap(i107, i107+6, std::greater()) == (std::is_heap_until(i107, i107+6, std::greater()) == i107+6)); + assert(std::is_heap(i108, i108+6, std::greater()) == (std::is_heap_until(i108, i108+6, std::greater()) == i108+6)); + assert(std::is_heap(i109, i109+6, std::greater()) == (std::is_heap_until(i109, i109+6, std::greater()) == i109+6)); + assert(std::is_heap(i110, i110+6, std::greater()) == (std::is_heap_until(i110, i110+6, std::greater()) == i110+6)); + assert(std::is_heap(i111, i111+6, std::greater()) == (std::is_heap_until(i111, i111+6, std::greater()) == i111+6)); + assert(std::is_heap(i112, i112+6, std::greater()) == (std::is_heap_until(i112, i112+6, std::greater()) == i112+6)); + assert(std::is_heap(i113, i113+6, std::greater()) == (std::is_heap_until(i113, i113+6, std::greater()) == i113+6)); + assert(std::is_heap(i114, i114+6, std::greater()) == (std::is_heap_until(i114, i114+6, std::greater()) == i114+6)); + assert(std::is_heap(i115, i115+6, std::greater()) == (std::is_heap_until(i115, i115+6, std::greater()) == i115+6)); + assert(std::is_heap(i116, i116+6, std::greater()) == (std::is_heap_until(i116, i116+6, std::greater()) == i116+6)); + assert(std::is_heap(i117, i117+6, std::greater()) == (std::is_heap_until(i117, i117+6, std::greater()) == i117+6)); + assert(std::is_heap(i118, i118+6, std::greater()) == (std::is_heap_until(i118, i118+6, std::greater()) == i118+6)); + assert(std::is_heap(i119, i119+6, std::greater()) == (std::is_heap_until(i119, i119+6, std::greater()) == 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()) == (std::is_heap_until(i120, i120+7, std::greater()) == i120+7)); + assert(std::is_heap(i121, i121+7, std::greater()) == (std::is_heap_until(i121, i121+7, std::greater()) == i121+7)); + assert(std::is_heap(i122, i122+7, std::greater()) == (std::is_heap_until(i122, i122+7, std::greater()) == i122+7)); + assert(std::is_heap(i123, i123+7, std::greater()) == (std::is_heap_until(i123, i123+7, std::greater()) == i123+7)); + assert(std::is_heap(i124, i124+7, std::greater()) == (std::is_heap_until(i124, i124+7, std::greater()) == i124+7)); + assert(std::is_heap(i125, i125+7, std::greater()) == (std::is_heap_until(i125, i125+7, std::greater()) == i125+7)); + assert(std::is_heap(i126, i126+7, std::greater()) == (std::is_heap_until(i126, i126+7, std::greater()) == i126+7)); + assert(std::is_heap(i127, i127+7, std::greater()) == (std::is_heap_until(i127, i127+7, std::greater()) == i127+7)); + assert(std::is_heap(i128, i128+7, std::greater()) == (std::is_heap_until(i128, i128+7, std::greater()) == i128+7)); + assert(std::is_heap(i129, i129+7, std::greater()) == (std::is_heap_until(i129, i129+7, std::greater()) == i129+7)); + assert(std::is_heap(i130, i130+7, std::greater()) == (std::is_heap_until(i130, i130+7, std::greater()) == i130+7)); + assert(std::is_heap(i131, i131+7, std::greater()) == (std::is_heap_until(i131, i131+7, std::greater()) == i131+7)); + assert(std::is_heap(i132, i132+7, std::greater()) == (std::is_heap_until(i132, i132+7, std::greater()) == i132+7)); + assert(std::is_heap(i133, i133+7, std::greater()) == (std::is_heap_until(i133, i133+7, std::greater()) == i133+7)); + assert(std::is_heap(i134, i134+7, std::greater()) == (std::is_heap_until(i134, i134+7, std::greater()) == i134+7)); + assert(std::is_heap(i135, i135+7, std::greater()) == (std::is_heap_until(i135, i135+7, std::greater()) == i135+7)); + assert(std::is_heap(i136, i136+7, std::greater()) == (std::is_heap_until(i136, i136+7, std::greater()) == i136+7)); + assert(std::is_heap(i137, i137+7, std::greater()) == (std::is_heap_until(i137, i137+7, std::greater()) == i137+7)); + assert(std::is_heap(i138, i138+7, std::greater()) == (std::is_heap_until(i138, i138+7, std::greater()) == i138+7)); + assert(std::is_heap(i139, i139+7, std::greater()) == (std::is_heap_until(i139, i139+7, std::greater()) == i139+7)); + assert(std::is_heap(i140, i140+7, std::greater()) == (std::is_heap_until(i140, i140+7, std::greater()) == i140+7)); + assert(std::is_heap(i141, i141+7, std::greater()) == (std::is_heap_until(i141, i141+7, std::greater()) == i141+7)); + assert(std::is_heap(i142, i142+7, std::greater()) == (std::is_heap_until(i142, i142+7, std::greater()) == i142+7)); + assert(std::is_heap(i143, i143+7, std::greater()) == (std::is_heap_until(i143, i143+7, std::greater()) == i143+7)); + assert(std::is_heap(i144, i144+7, std::greater()) == (std::is_heap_until(i144, i144+7, std::greater()) == i144+7)); + assert(std::is_heap(i145, i145+7, std::greater()) == (std::is_heap_until(i145, i145+7, std::greater()) == i145+7)); + assert(std::is_heap(i146, i146+7, std::greater()) == (std::is_heap_until(i146, i146+7, std::greater()) == i146+7)); + assert(std::is_heap(i147, i147+7, std::greater()) == (std::is_heap_until(i147, i147+7, std::greater()) == i147+7)); + assert(std::is_heap(i148, i148+7, std::greater()) == (std::is_heap_until(i148, i148+7, std::greater()) == i148+7)); + assert(std::is_heap(i149, i149+7, std::greater()) == (std::is_heap_until(i149, i149+7, std::greater()) == i149+7)); + assert(std::is_heap(i150, i150+7, std::greater()) == (std::is_heap_until(i150, i150+7, std::greater()) == i150+7)); + assert(std::is_heap(i151, i151+7, std::greater()) == (std::is_heap_until(i151, i151+7, std::greater()) == i151+7)); + assert(std::is_heap(i152, i152+7, std::greater()) == (std::is_heap_until(i152, i152+7, std::greater()) == i152+7)); + assert(std::is_heap(i153, i153+7, std::greater()) == (std::is_heap_until(i153, i153+7, std::greater()) == i153+7)); + assert(std::is_heap(i154, i154+7, std::greater()) == (std::is_heap_until(i154, i154+7, std::greater()) == i154+7)); + assert(std::is_heap(i155, i155+7, std::greater()) == (std::is_heap_until(i155, i155+7, std::greater()) == i155+7)); + assert(std::is_heap(i156, i156+7, std::greater()) == (std::is_heap_until(i156, i156+7, std::greater()) == i156+7)); + assert(std::is_heap(i157, i157+7, std::greater()) == (std::is_heap_until(i157, i157+7, std::greater()) == i157+7)); + assert(std::is_heap(i158, i158+7, std::greater()) == (std::is_heap_until(i158, i158+7, std::greater()) == i158+7)); + assert(std::is_heap(i159, i159+7, std::greater()) == (std::is_heap_until(i159, i159+7, std::greater()) == i159+7)); + assert(std::is_heap(i160, i160+7, std::greater()) == (std::is_heap_until(i160, i160+7, std::greater()) == i160+7)); + assert(std::is_heap(i161, i161+7, std::greater()) == (std::is_heap_until(i161, i161+7, std::greater()) == i161+7)); + assert(std::is_heap(i162, i162+7, std::greater()) == (std::is_heap_until(i162, i162+7, std::greater()) == i162+7)); + assert(std::is_heap(i163, i163+7, std::greater()) == (std::is_heap_until(i163, i163+7, std::greater()) == i163+7)); + assert(std::is_heap(i164, i164+7, std::greater()) == (std::is_heap_until(i164, i164+7, std::greater()) == i164+7)); + assert(std::is_heap(i165, i165+7, std::greater()) == (std::is_heap_until(i165, i165+7, std::greater()) == i165+7)); + assert(std::is_heap(i166, i166+7, std::greater()) == (std::is_heap_until(i166, i166+7, std::greater()) == i166+7)); + assert(std::is_heap(i167, i167+7, std::greater()) == (std::is_heap_until(i167, i167+7, std::greater()) == i167+7)); + assert(std::is_heap(i168, i168+7, std::greater()) == (std::is_heap_until(i168, i168+7, std::greater()) == i168+7)); + assert(std::is_heap(i169, i169+7, std::greater()) == (std::is_heap_until(i169, i169+7, std::greater()) == i169+7)); + assert(std::is_heap(i170, i170+7, std::greater()) == (std::is_heap_until(i170, i170+7, std::greater()) == i170+7)); + assert(std::is_heap(i171, i171+7, std::greater()) == (std::is_heap_until(i171, i171+7, std::greater()) == i171+7)); + assert(std::is_heap(i172, i172+7, std::greater()) == (std::is_heap_until(i172, i172+7, std::greater()) == i172+7)); + assert(std::is_heap(i173, i173+7, std::greater()) == (std::is_heap_until(i173, i173+7, std::greater()) == i173+7)); + assert(std::is_heap(i174, i174+7, std::greater()) == (std::is_heap_until(i174, i174+7, std::greater()) == i174+7)); + assert(std::is_heap(i175, i175+7, std::greater()) == (std::is_heap_until(i175, i175+7, std::greater()) == i175+7)); + assert(std::is_heap(i176, i176+7, std::greater()) == (std::is_heap_until(i176, i176+7, std::greater()) == i176+7)); + assert(std::is_heap(i177, i177+7, std::greater()) == (std::is_heap_until(i177, i177+7, std::greater()) == i177+7)); + assert(std::is_heap(i178, i178+7, std::greater()) == (std::is_heap_until(i178, i178+7, std::greater()) == i178+7)); + assert(std::is_heap(i179, i179+7, std::greater()) == (std::is_heap_until(i179, i179+7, std::greater()) == i179+7)); + assert(std::is_heap(i180, i180+7, std::greater()) == (std::is_heap_until(i180, i180+7, std::greater()) == i180+7)); + assert(std::is_heap(i181, i181+7, std::greater()) == (std::is_heap_until(i181, i181+7, std::greater()) == i181+7)); + assert(std::is_heap(i182, i182+7, std::greater()) == (std::is_heap_until(i182, i182+7, std::greater()) == i182+7)); + assert(std::is_heap(i183, i183+7, std::greater()) == (std::is_heap_until(i183, i183+7, std::greater()) == i183+7)); + assert(std::is_heap(i184, i184+7, std::greater()) == (std::is_heap_until(i184, i184+7, std::greater()) == i184+7)); + assert(std::is_heap(i185, i185+7, std::greater()) == (std::is_heap_until(i185, i185+7, std::greater()) == i185+7)); + assert(std::is_heap(i186, i186+7, std::greater()) == (std::is_heap_until(i186, i186+7, std::greater()) == i186+7)); + assert(std::is_heap(i187, i187+7, std::greater()) == (std::is_heap_until(i187, i187+7, std::greater()) == i187+7)); + assert(std::is_heap(i188, i188+7, std::greater()) == (std::is_heap_until(i188, i188+7, std::greater()) == i188+7)); + assert(std::is_heap(i189, i189+7, std::greater()) == (std::is_heap_until(i189, i189+7, std::greater()) == i189+7)); + assert(std::is_heap(i190, i190+7, std::greater()) == (std::is_heap_until(i190, i190+7, std::greater()) == i190+7)); + assert(std::is_heap(i191, i191+7, std::greater()) == (std::is_heap_until(i191, i191+7, std::greater()) == i191+7)); + assert(std::is_heap(i192, i192+7, std::greater()) == (std::is_heap_until(i192, i192+7, std::greater()) == i192+7)); + assert(std::is_heap(i193, i193+7, std::greater()) == (std::is_heap_until(i193, i193+7, std::greater()) == i193+7)); + assert(std::is_heap(i194, i194+7, std::greater()) == (std::is_heap_until(i194, i194+7, std::greater()) == i194+7)); + assert(std::is_heap(i195, i195+7, std::greater()) == (std::is_heap_until(i195, i195+7, std::greater()) == i195+7)); + assert(std::is_heap(i196, i196+7, std::greater()) == (std::is_heap_until(i196, i196+7, std::greater()) == i196+7)); + assert(std::is_heap(i197, i197+7, std::greater()) == (std::is_heap_until(i197, i197+7, std::greater()) == i197+7)); + assert(std::is_heap(i198, i198+7, std::greater()) == (std::is_heap_until(i198, i198+7, std::greater()) == i198+7)); + assert(std::is_heap(i199, i199+7, std::greater()) == (std::is_heap_until(i199, i199+7, std::greater()) == i199+7)); + assert(std::is_heap(i200, i200+7, std::greater()) == (std::is_heap_until(i200, i200+7, std::greater()) == i200+7)); + assert(std::is_heap(i201, i201+7, std::greater()) == (std::is_heap_until(i201, i201+7, std::greater()) == i201+7)); + assert(std::is_heap(i202, i202+7, std::greater()) == (std::is_heap_until(i202, i202+7, std::greater()) == i202+7)); + assert(std::is_heap(i203, i203+7, std::greater()) == (std::is_heap_until(i203, i203+7, std::greater()) == i203+7)); + assert(std::is_heap(i204, i204+7, std::greater()) == (std::is_heap_until(i204, i204+7, std::greater()) == i204+7)); + assert(std::is_heap(i205, i205+7, std::greater()) == (std::is_heap_until(i205, i205+7, std::greater()) == i205+7)); + assert(std::is_heap(i206, i206+7, std::greater()) == (std::is_heap_until(i206, i206+7, std::greater()) == i206+7)); + assert(std::is_heap(i207, i207+7, std::greater()) == (std::is_heap_until(i207, i207+7, std::greater()) == i207+7)); + assert(std::is_heap(i208, i208+7, std::greater()) == (std::is_heap_until(i208, i208+7, std::greater()) == i208+7)); + assert(std::is_heap(i209, i209+7, std::greater()) == (std::is_heap_until(i209, i209+7, std::greater()) == i209+7)); + assert(std::is_heap(i210, i210+7, std::greater()) == (std::is_heap_until(i210, i210+7, std::greater()) == i210+7)); + assert(std::is_heap(i211, i211+7, std::greater()) == (std::is_heap_until(i211, i211+7, std::greater()) == i211+7)); + assert(std::is_heap(i212, i212+7, std::greater()) == (std::is_heap_until(i212, i212+7, std::greater()) == i212+7)); + assert(std::is_heap(i213, i213+7, std::greater()) == (std::is_heap_until(i213, i213+7, std::greater()) == i213+7)); + assert(std::is_heap(i214, i214+7, std::greater()) == (std::is_heap_until(i214, i214+7, std::greater()) == i214+7)); + assert(std::is_heap(i215, i215+7, std::greater()) == (std::is_heap_until(i215, i215+7, std::greater()) == i215+7)); + assert(std::is_heap(i216, i216+7, std::greater()) == (std::is_heap_until(i216, i216+7, std::greater()) == i216+7)); + assert(std::is_heap(i217, i217+7, std::greater()) == (std::is_heap_until(i217, i217+7, std::greater()) == i217+7)); + assert(std::is_heap(i218, i218+7, std::greater()) == (std::is_heap_until(i218, i218+7, std::greater()) == i218+7)); + assert(std::is_heap(i219, i219+7, std::greater()) == (std::is_heap_until(i219, i219+7, std::greater()) == i219+7)); + assert(std::is_heap(i220, i220+7, std::greater()) == (std::is_heap_until(i220, i220+7, std::greater()) == i220+7)); + assert(std::is_heap(i221, i221+7, std::greater()) == (std::is_heap_until(i221, i221+7, std::greater()) == i221+7)); + assert(std::is_heap(i222, i222+7, std::greater()) == (std::is_heap_until(i222, i222+7, std::greater()) == i222+7)); + assert(std::is_heap(i223, i223+7, std::greater()) == (std::is_heap_until(i223, i223+7, std::greater()) == i223+7)); + assert(std::is_heap(i224, i224+7, std::greater()) == (std::is_heap_until(i224, i224+7, std::greater()) == i224+7)); + assert(std::is_heap(i225, i225+7, std::greater()) == (std::is_heap_until(i225, i225+7, std::greater()) == i225+7)); + assert(std::is_heap(i226, i226+7, std::greater()) == (std::is_heap_until(i226, i226+7, std::greater()) == i226+7)); + assert(std::is_heap(i227, i227+7, std::greater()) == (std::is_heap_until(i227, i227+7, std::greater()) == i227+7)); + assert(std::is_heap(i228, i228+7, std::greater()) == (std::is_heap_until(i228, i228+7, std::greater()) == i228+7)); + assert(std::is_heap(i229, i229+7, std::greater()) == (std::is_heap_until(i229, i229+7, std::greater()) == i229+7)); + assert(std::is_heap(i230, i230+7, std::greater()) == (std::is_heap_until(i230, i230+7, std::greater()) == i230+7)); + assert(std::is_heap(i231, i231+7, std::greater()) == (std::is_heap_until(i231, i231+7, std::greater()) == i231+7)); + assert(std::is_heap(i232, i232+7, std::greater()) == (std::is_heap_until(i232, i232+7, std::greater()) == i232+7)); + assert(std::is_heap(i233, i233+7, std::greater()) == (std::is_heap_until(i233, i233+7, std::greater()) == i233+7)); + assert(std::is_heap(i234, i234+7, std::greater()) == (std::is_heap_until(i234, i234+7, std::greater()) == i234+7)); + assert(std::is_heap(i235, i235+7, std::greater()) == (std::is_heap_until(i235, i235+7, std::greater()) == i235+7)); + assert(std::is_heap(i236, i236+7, std::greater()) == (std::is_heap_until(i236, i236+7, std::greater()) == i236+7)); + assert(std::is_heap(i237, i237+7, std::greater()) == (std::is_heap_until(i237, i237+7, std::greater()) == i237+7)); + assert(std::is_heap(i238, i238+7, std::greater()) == (std::is_heap_until(i238, i238+7, std::greater()) == i238+7)); + assert(std::is_heap(i239, i239+7, std::greater()) == (std::is_heap_until(i239, i239+7, std::greater()) == i239+7)); + assert(std::is_heap(i240, i240+7, std::greater()) == (std::is_heap_until(i240, i240+7, std::greater()) == i240+7)); + assert(std::is_heap(i241, i241+7, std::greater()) == (std::is_heap_until(i241, i241+7, std::greater()) == i241+7)); + assert(std::is_heap(i242, i242+7, std::greater()) == (std::is_heap_until(i242, i242+7, std::greater()) == i242+7)); + assert(std::is_heap(i243, i243+7, std::greater()) == (std::is_heap_until(i243, i243+7, std::greater()) == i243+7)); + assert(std::is_heap(i244, i244+7, std::greater()) == (std::is_heap_until(i244, i244+7, std::greater()) == i244+7)); + assert(std::is_heap(i245, i245+7, std::greater()) == (std::is_heap_until(i245, i245+7, std::greater()) == i245+7)); + assert(std::is_heap(i246, i246+7, std::greater()) == (std::is_heap_until(i246, i246+7, std::greater()) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// Iter +// is_heap_until(Iter first, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires CopyConstructible +// Iter +// is_heap_until(Iter first, Iter last, Compare comp); + +#include +#include +#include + +void test() +{ + int i1[] = {0, 0}; + assert(std::is_heap_until(i1, i1, std::greater()) == i1); + assert(std::is_heap_until(i1, i1+1, std::greater()) == i1+1); + int i2[] = {0, 1}; + int i3[] = {1, 0}; + assert(std::is_heap_until(i1, i1+2, std::greater()) == i1+2); + assert(std::is_heap_until(i2, i2+2, std::greater()) == i2+2); + assert(std::is_heap_until(i3, i3+2, std::greater()) == 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()) == i4+3); + assert(std::is_heap_until(i5, i5+3, std::greater()) == i5+3); + assert(std::is_heap_until(i6, i6+3, std::greater()) == i6+3); + assert(std::is_heap_until(i7, i7+3, std::greater()) == i7+3); + assert(std::is_heap_until(i8, i8+3, std::greater()) == i8+1); + assert(std::is_heap_until(i9, i9+3, std::greater()) == i9+1); + assert(std::is_heap_until(i10, i10+3, std::greater()) == 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()) == i11+4); + assert(std::is_heap_until(i12, i12+4, std::greater()) == i12+4); + assert(std::is_heap_until(i13, i13+4, std::greater()) == i13+4); + assert(std::is_heap_until(i14, i14+4, std::greater()) == i14+4); + assert(std::is_heap_until(i15, i15+4, std::greater()) == i15+3); + assert(std::is_heap_until(i16, i16+4, std::greater()) == i16+4); + assert(std::is_heap_until(i17, i17+4, std::greater()) == i17+3); + assert(std::is_heap_until(i18, i18+4, std::greater()) == i18+4); + assert(std::is_heap_until(i19, i19+4, std::greater()) == i19+1); + assert(std::is_heap_until(i20, i20+4, std::greater()) == i20+1); + assert(std::is_heap_until(i21, i21+4, std::greater()) == i21+1); + assert(std::is_heap_until(i22, i22+4, std::greater()) == i22+1); + assert(std::is_heap_until(i23, i23+4, std::greater()) == i23+2); + assert(std::is_heap_until(i24, i24+4, std::greater()) == i24+2); + assert(std::is_heap_until(i25, i25+4, std::greater()) == 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()) == i26+5); + assert(std::is_heap_until(i27, i27+5, std::greater()) == i27+5); + assert(std::is_heap_until(i28, i28+5, std::greater()) == i28+5); + assert(std::is_heap_until(i29, i29+5, std::greater()) == i29+5); + assert(std::is_heap_until(i30, i30+5, std::greater()) == i30+5); + assert(std::is_heap_until(i31, i31+5, std::greater()) == i31+5); + assert(std::is_heap_until(i32, i32+5, std::greater()) == i32+5); + assert(std::is_heap_until(i33, i33+5, std::greater()) == i33+5); + assert(std::is_heap_until(i34, i34+5, std::greater()) == i34+3); + assert(std::is_heap_until(i35, i35+5, std::greater()) == i35+3); + assert(std::is_heap_until(i36, i36+5, std::greater()) == i36+4); + assert(std::is_heap_until(i37, i37+5, std::greater()) == i37+5); + assert(std::is_heap_until(i38, i38+5, std::greater()) == i38+3); + assert(std::is_heap_until(i39, i39+5, std::greater()) == i39+3); + assert(std::is_heap_until(i40, i40+5, std::greater()) == i40+4); + assert(std::is_heap_until(i41, i41+5, std::greater()) == i41+5); + assert(std::is_heap_until(i42, i42+5, std::greater()) == i42+1); + assert(std::is_heap_until(i43, i43+5, std::greater()) == i43+1); + assert(std::is_heap_until(i44, i44+5, std::greater()) == i44+1); + assert(std::is_heap_until(i45, i45+5, std::greater()) == i45+1); + assert(std::is_heap_until(i46, i46+5, std::greater()) == i46+1); + assert(std::is_heap_until(i47, i47+5, std::greater()) == i47+1); + assert(std::is_heap_until(i48, i48+5, std::greater()) == i48+1); + assert(std::is_heap_until(i49, i49+5, std::greater()) == i49+1); + assert(std::is_heap_until(i50, i50+5, std::greater()) == i50+2); + assert(std::is_heap_until(i51, i51+5, std::greater()) == i51+2); + assert(std::is_heap_until(i52, i52+5, std::greater()) == i52+2); + assert(std::is_heap_until(i53, i53+5, std::greater()) == i53+2); + assert(std::is_heap_until(i54, i54+5, std::greater()) == i54+3); + assert(std::is_heap_until(i55, i55+5, std::greater()) == i55+3); + assert(std::is_heap_until(i56, i56+5, std::greater()) == 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()) == i57+6); + assert(std::is_heap_until(i58, i58+6, std::greater()) == i58+6); + assert(std::is_heap_until(i59, i59+6, std::greater()) == i59+6); + assert(std::is_heap_until(i60, i60+6, std::greater()) == i60+6); + assert(std::is_heap_until(i61, i61+6, std::greater()) == i61+6); + assert(std::is_heap_until(i62, i62+6, std::greater()) == i62+6); + assert(std::is_heap_until(i63, i63+6, std::greater()) == i63+6); + assert(std::is_heap_until(i64, i64+6, std::greater()) == i64+6); + assert(std::is_heap_until(i65, i65+6, std::greater()) == i65+5); + assert(std::is_heap_until(i66, i66+6, std::greater()) == i66+6); + assert(std::is_heap_until(i67, i67+6, std::greater()) == i67+5); + assert(std::is_heap_until(i68, i68+6, std::greater()) == i68+6); + assert(std::is_heap_until(i69, i69+6, std::greater()) == i69+5); + assert(std::is_heap_until(i70, i70+6, std::greater()) == i70+6); + assert(std::is_heap_until(i71, i71+6, std::greater()) == i71+5); + assert(std::is_heap_until(i72, i72+6, std::greater()) == i72+6); + assert(std::is_heap_until(i73, i73+6, std::greater()) == i73+3); + assert(std::is_heap_until(i74, i74+6, std::greater()) == i74+3); + assert(std::is_heap_until(i75, i75+6, std::greater()) == i75+3); + assert(std::is_heap_until(i76, i76+6, std::greater()) == i76+3); + assert(std::is_heap_until(i77, i77+6, std::greater()) == i77+4); + assert(std::is_heap_until(i78, i78+6, std::greater()) == i78+4); + assert(std::is_heap_until(i79, i79+6, std::greater()) == i79+6); + assert(std::is_heap_until(i80, i80+6, std::greater()) == i80+6); + assert(std::is_heap_until(i81, i81+6, std::greater()) == i81+3); + assert(std::is_heap_until(i82, i82+6, std::greater()) == i82+3); + assert(std::is_heap_until(i83, i83+6, std::greater()) == i83+3); + assert(std::is_heap_until(i84, i84+6, std::greater()) == i84+3); + assert(std::is_heap_until(i85, i85+6, std::greater()) == i85+4); + assert(std::is_heap_until(i86, i86+6, std::greater()) == i86+4); + assert(std::is_heap_until(i87, i87+6, std::greater()) == i87+5); + assert(std::is_heap_until(i88, i88+6, std::greater()) == i88+6); + assert(std::is_heap_until(i89, i89+6, std::greater()) == i89+1); + assert(std::is_heap_until(i90, i90+6, std::greater()) == i90+1); + assert(std::is_heap_until(i91, i91+6, std::greater()) == i91+1); + assert(std::is_heap_until(i92, i92+6, std::greater()) == i92+1); + assert(std::is_heap_until(i93, i93+6, std::greater()) == i93+1); + assert(std::is_heap_until(i94, i94+6, std::greater()) == i94+1); + assert(std::is_heap_until(i95, i95+6, std::greater()) == i95+1); + assert(std::is_heap_until(i96, i96+6, std::greater()) == i96+1); + assert(std::is_heap_until(i97, i97+6, std::greater()) == i97+1); + assert(std::is_heap_until(i98, i98+6, std::greater()) == i98+1); + assert(std::is_heap_until(i99, i99+6, std::greater()) == i99+1); + assert(std::is_heap_until(i100, i100+6, std::greater()) == i100+1); + assert(std::is_heap_until(i101, i101+6, std::greater()) == i101+1); + assert(std::is_heap_until(i102, i102+6, std::greater()) == i102+1); + assert(std::is_heap_until(i103, i103+6, std::greater()) == i103+1); + assert(std::is_heap_until(i104, i104+6, std::greater()) == i104+1); + assert(std::is_heap_until(i105, i105+6, std::greater()) == i105+2); + assert(std::is_heap_until(i106, i106+6, std::greater()) == i106+2); + assert(std::is_heap_until(i107, i107+6, std::greater()) == i107+2); + assert(std::is_heap_until(i108, i108+6, std::greater()) == i108+2); + assert(std::is_heap_until(i109, i109+6, std::greater()) == i109+2); + assert(std::is_heap_until(i110, i110+6, std::greater()) == i110+2); + assert(std::is_heap_until(i111, i111+6, std::greater()) == i111+2); + assert(std::is_heap_until(i112, i112+6, std::greater()) == i112+2); + assert(std::is_heap_until(i113, i113+6, std::greater()) == i113+3); + assert(std::is_heap_until(i114, i114+6, std::greater()) == i114+3); + assert(std::is_heap_until(i115, i115+6, std::greater()) == i115+3); + assert(std::is_heap_until(i116, i116+6, std::greater()) == i116+3); + assert(std::is_heap_until(i117, i117+6, std::greater()) == i117+4); + assert(std::is_heap_until(i118, i118+6, std::greater()) == i118+4); + assert(std::is_heap_until(i119, i119+6, std::greater()) == 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()) == i120+7); + assert(std::is_heap_until(i121, i121+7, std::greater()) == i121+7); + assert(std::is_heap_until(i122, i122+7, std::greater()) == i122+7); + assert(std::is_heap_until(i123, i123+7, std::greater()) == i123+7); + assert(std::is_heap_until(i124, i124+7, std::greater()) == i124+7); + assert(std::is_heap_until(i125, i125+7, std::greater()) == i125+7); + assert(std::is_heap_until(i126, i126+7, std::greater()) == i126+7); + assert(std::is_heap_until(i127, i127+7, std::greater()) == i127+7); + assert(std::is_heap_until(i128, i128+7, std::greater()) == i128+7); + assert(std::is_heap_until(i129, i129+7, std::greater()) == i129+7); + assert(std::is_heap_until(i130, i130+7, std::greater()) == i130+7); + assert(std::is_heap_until(i131, i131+7, std::greater()) == i131+7); + assert(std::is_heap_until(i132, i132+7, std::greater()) == i132+7); + assert(std::is_heap_until(i133, i133+7, std::greater()) == i133+7); + assert(std::is_heap_until(i134, i134+7, std::greater()) == i134+7); + assert(std::is_heap_until(i135, i135+7, std::greater()) == i135+7); + assert(std::is_heap_until(i136, i136+7, std::greater()) == i136+5); + assert(std::is_heap_until(i137, i137+7, std::greater()) == i137+5); + assert(std::is_heap_until(i138, i138+7, std::greater()) == i138+6); + assert(std::is_heap_until(i139, i139+7, std::greater()) == i139+7); + assert(std::is_heap_until(i140, i140+7, std::greater()) == i140+5); + assert(std::is_heap_until(i141, i141+7, std::greater()) == i141+5); + assert(std::is_heap_until(i142, i142+7, std::greater()) == i142+6); + assert(std::is_heap_until(i143, i143+7, std::greater()) == i143+7); + assert(std::is_heap_until(i144, i144+7, std::greater()) == i144+5); + assert(std::is_heap_until(i145, i145+7, std::greater()) == i145+5); + assert(std::is_heap_until(i146, i146+7, std::greater()) == i146+6); + assert(std::is_heap_until(i147, i147+7, std::greater()) == i147+7); + assert(std::is_heap_until(i148, i148+7, std::greater()) == i148+5); + assert(std::is_heap_until(i149, i149+7, std::greater()) == i149+5); + assert(std::is_heap_until(i150, i150+7, std::greater()) == i150+6); + assert(std::is_heap_until(i151, i151+7, std::greater()) == i151+7); + assert(std::is_heap_until(i152, i152+7, std::greater()) == i152+3); + assert(std::is_heap_until(i153, i153+7, std::greater()) == i153+3); + assert(std::is_heap_until(i154, i154+7, std::greater()) == i154+3); + assert(std::is_heap_until(i155, i155+7, std::greater()) == i155+3); + assert(std::is_heap_until(i156, i156+7, std::greater()) == i156+3); + assert(std::is_heap_until(i157, i157+7, std::greater()) == i157+3); + assert(std::is_heap_until(i158, i158+7, std::greater()) == i158+3); + assert(std::is_heap_until(i159, i159+7, std::greater()) == i159+3); + assert(std::is_heap_until(i160, i160+7, std::greater()) == i160+4); + assert(std::is_heap_until(i161, i161+7, std::greater()) == i161+4); + assert(std::is_heap_until(i162, i162+7, std::greater()) == i162+4); + assert(std::is_heap_until(i163, i163+7, std::greater()) == i163+4); + assert(std::is_heap_until(i164, i164+7, std::greater()) == i164+7); + assert(std::is_heap_until(i165, i165+7, std::greater()) == i165+7); + assert(std::is_heap_until(i166, i166+7, std::greater()) == i166+7); + assert(std::is_heap_until(i167, i167+7, std::greater()) == i167+7); + assert(std::is_heap_until(i168, i168+7, std::greater()) == i168+3); + assert(std::is_heap_until(i169, i169+7, std::greater()) == i169+3); + assert(std::is_heap_until(i170, i170+7, std::greater()) == i170+3); + assert(std::is_heap_until(i171, i171+7, std::greater()) == i171+3); + assert(std::is_heap_until(i172, i172+7, std::greater()) == i172+3); + assert(std::is_heap_until(i173, i173+7, std::greater()) == i173+3); + assert(std::is_heap_until(i174, i174+7, std::greater()) == i174+3); + assert(std::is_heap_until(i175, i175+7, std::greater()) == i175+3); + assert(std::is_heap_until(i176, i176+7, std::greater()) == i176+4); + assert(std::is_heap_until(i177, i177+7, std::greater()) == i177+4); + assert(std::is_heap_until(i178, i178+7, std::greater()) == i178+4); + assert(std::is_heap_until(i179, i179+7, std::greater()) == i179+4); + assert(std::is_heap_until(i180, i180+7, std::greater()) == i180+5); + assert(std::is_heap_until(i181, i181+7, std::greater()) == i181+5); + assert(std::is_heap_until(i182, i182+7, std::greater()) == i182+6); + assert(std::is_heap_until(i183, i183+7, std::greater()) == i183+7); + assert(std::is_heap_until(i184, i184+7, std::greater()) == i184+1); + assert(std::is_heap_until(i185, i185+7, std::greater()) == i185+1); + assert(std::is_heap_until(i186, i186+7, std::greater()) == i186+1); + assert(std::is_heap_until(i187, i187+7, std::greater()) == i187+1); + assert(std::is_heap_until(i188, i188+7, std::greater()) == i188+1); + assert(std::is_heap_until(i189, i189+7, std::greater()) == i189+1); + assert(std::is_heap_until(i190, i190+7, std::greater()) == i190+1); + assert(std::is_heap_until(i191, i191+7, std::greater()) == i191+1); + assert(std::is_heap_until(i192, i192+7, std::greater()) == i192+1); + assert(std::is_heap_until(i193, i193+7, std::greater()) == i193+1); + assert(std::is_heap_until(i194, i194+7, std::greater()) == i194+1); + assert(std::is_heap_until(i195, i195+7, std::greater()) == i195+1); + assert(std::is_heap_until(i196, i196+7, std::greater()) == i196+1); + assert(std::is_heap_until(i197, i197+7, std::greater()) == i197+1); + assert(std::is_heap_until(i198, i198+7, std::greater()) == i198+1); + assert(std::is_heap_until(i199, i199+7, std::greater()) == i199+1); + assert(std::is_heap_until(i200, i200+7, std::greater()) == i200+1); + assert(std::is_heap_until(i201, i201+7, std::greater()) == i201+1); + assert(std::is_heap_until(i202, i202+7, std::greater()) == i202+1); + assert(std::is_heap_until(i203, i203+7, std::greater()) == i203+1); + assert(std::is_heap_until(i204, i204+7, std::greater()) == i204+1); + assert(std::is_heap_until(i205, i205+7, std::greater()) == i205+1); + assert(std::is_heap_until(i206, i206+7, std::greater()) == i206+1); + assert(std::is_heap_until(i207, i207+7, std::greater()) == i207+1); + assert(std::is_heap_until(i208, i208+7, std::greater()) == i208+1); + assert(std::is_heap_until(i209, i209+7, std::greater()) == i209+1); + assert(std::is_heap_until(i210, i210+7, std::greater()) == i210+1); + assert(std::is_heap_until(i211, i211+7, std::greater()) == i211+1); + assert(std::is_heap_until(i212, i212+7, std::greater()) == i212+1); + assert(std::is_heap_until(i213, i213+7, std::greater()) == i213+1); + assert(std::is_heap_until(i214, i214+7, std::greater()) == i214+1); + assert(std::is_heap_until(i215, i215+7, std::greater()) == i215+1); + assert(std::is_heap_until(i216, i216+7, std::greater()) == i216+2); + assert(std::is_heap_until(i217, i217+7, std::greater()) == i217+2); + assert(std::is_heap_until(i218, i218+7, std::greater()) == i218+2); + assert(std::is_heap_until(i219, i219+7, std::greater()) == i219+2); + assert(std::is_heap_until(i220, i220+7, std::greater()) == i220+2); + assert(std::is_heap_until(i221, i221+7, std::greater()) == i221+2); + assert(std::is_heap_until(i222, i222+7, std::greater()) == i222+2); + assert(std::is_heap_until(i223, i223+7, std::greater()) == i223+2); + assert(std::is_heap_until(i224, i224+7, std::greater()) == i224+2); + assert(std::is_heap_until(i225, i225+7, std::greater()) == i225+2); + assert(std::is_heap_until(i226, i226+7, std::greater()) == i226+2); + assert(std::is_heap_until(i227, i227+7, std::greater()) == i227+2); + assert(std::is_heap_until(i228, i228+7, std::greater()) == i228+2); + assert(std::is_heap_until(i229, i229+7, std::greater()) == i229+2); + assert(std::is_heap_until(i230, i230+7, std::greater()) == i230+2); + assert(std::is_heap_until(i231, i231+7, std::greater()) == i231+2); + assert(std::is_heap_until(i232, i232+7, std::greater()) == i232+3); + assert(std::is_heap_until(i233, i233+7, std::greater()) == i233+3); + assert(std::is_heap_until(i234, i234+7, std::greater()) == i234+3); + assert(std::is_heap_until(i235, i235+7, std::greater()) == i235+3); + assert(std::is_heap_until(i236, i236+7, std::greater()) == i236+3); + assert(std::is_heap_until(i237, i237+7, std::greater()) == i237+3); + assert(std::is_heap_until(i238, i238+7, std::greater()) == i238+3); + assert(std::is_heap_until(i239, i239+7, std::greater()) == i239+3); + assert(std::is_heap_until(i240, i240+7, std::greater()) == i240+4); + assert(std::is_heap_until(i241, i241+7, std::greater()) == i241+4); + assert(std::is_heap_until(i242, i242+7, std::greater()) == i242+4); + assert(std::is_heap_until(i243, i243+7, std::greater()) == i243+4); + assert(std::is_heap_until(i244, i244+7, std::greater()) == i244+5); + assert(std::is_heap_until(i245, i245+7, std::greater()) == i245+5); + assert(std::is_heap_until(i246, i246+7, std::greater()) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator && LessThanComparable +// void +// make_heap(Iter first, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator && CopyConstructible +// void +// make_heap(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "counting_predicates.hpp" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + 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()); + assert(std::is_heap(ia, ia+N, std::greater())); + } + +// Ascending + { + binary_counting_predicate, int, int> pred ((std::greater())); + 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, int, int> pred ((std::greater())); + 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, int, int> pred ((std::greater())); + 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* ia = new std::unique_ptr [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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator && LessThanComparable +// void +// pop_heap(Iter first, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator && CopyConstructible +// void +// pop_heap(Iter first, Iter last, Compare comp); + +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + 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()); + for (int i = N; i > 0; --i) + { + std::pop_heap(ia, ia+i, std::greater()); + assert(std::is_heap(ia, ia+i-1, std::greater())); + } + std::pop_heap(ia, ia, std::greater()); + delete [] ia; +} + +int main() +{ + test(1000); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + const int N = 1000; + std::unique_ptr* ia = new std::unique_ptr [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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// void +// push_heap(Iter first, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// void +// push_heap(Iter first, Iter last); + +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + 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()); + assert(std::is_heap(ia, ia+i, std::greater())); + } + delete [] ia; +} + +int main() +{ + test(1000); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + const int N = 1000; + std::unique_ptr* ia = new std::unique_ptr [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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator && LessThanComparable +// void +// sort_heap(Iter first, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator && CopyConstructible +// void +// sort_heap(Iter first, Iter last, Compare comp); + +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + 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()); + std::sort_heap(ia, ia+N, std::greater()); + assert(std::is_sorted(ia, ia+N, std::greater())); + 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* ia = new std::unique_ptr [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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasLess +// && HasLess +// bool +// lexicographical_compare(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires Predicate +// && Predicate +// bool +// lexicographical_compare(Iter1 first1, Iter1 last1, +// Iter2 first2, Iter2 last2, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test() +{ + int ia[] = {1, 2, 3, 4}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + int ib[] = {1, 2, 3}; + typedef std::greater 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 >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// void +// inplace_merge(Iter first, Iter middle, Iter last); + +#include +#include + +#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 +void +test_one(unsigned N, unsigned M) +{ + typedef typename std::iterator_traits::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 +void +test(unsigned N) +{ + test_one(N, 0); + test_one(N, N/4); + test_one(N, N/2); + test_one(N, 3*N/4); + test_one(N, N); +} + +template +void +test() +{ + test_one(0, 0); + test_one(1, 0); + test_one(1, 1); + test_one(2, 0); + test_one(2, 1); + test_one(2, 2); + test_one(3, 0); + test_one(3, 1); + test_one(3, 2); + test_one(3, 3); + test(4); + test(100); + test(1000); +} + +int main() +{ + test >(); + test >(); + test(); + +#if TEST_STD_VER >= 11 + test >(); + test >(); + test(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator +// && CopyConstructible +// void +// inplace_merge(Iter first, Iter middle, Iter last, Compare comp); + +#include +#include +#include + +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +#include + +struct indirect_less +{ + template + 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 +void +test_one(unsigned N, unsigned M) +{ + assert(M <= N); + typedef typename std::iterator_traits::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()); + std::sort(ia+M, ia+N, std::greater()); + binary_counting_predicate, value_type, value_type> pred((std::greater())); + 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())); + assert(pred.count() <= (N-1)); + } + delete [] ia; +} + +template +void +test(unsigned N) +{ + test_one(N, 0); + test_one(N, N/4); + test_one(N, N/2); + test_one(N, 3*N/4); + test_one(N, N); +} + +template +void +test() +{ + test_one(0, 0); + test_one(1, 0); + test_one(1, 1); + test_one(2, 0); + test_one(2, 1); + test_one(2, 2); + test_one(3, 0); + test_one(3, 1); + test_one(3, 2); + test_one(3, 3); + test(4); + test(20); + test(100); + test(1000); +} + +int main() +{ + test >(); + test >(); + test(); + +#if TEST_STD_VER >= 11 + test >(); + test >(); + test(); + + { + unsigned N = 100; + unsigned M = 50; + std::unique_ptr* ia = new std::unique_ptr[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 + +// + +// template +// requires OutputIterator +// && OutputIterator +// && HasLess +// OutIter +// merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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 + +// + +// template Compare> +// requires OutputIterator +// && OutputIterator +// && CopyConstructible +// OutIter +// merge(InIter1 first1, InIter1 last1, +// InIter2 first2, InIter2 last2, OutIter result, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" +#include "counting_predicates.hpp" + +template +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, int, int> pred((std::greater())); + 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())); + 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()); + std::sort(ib, ib+N, std::greater()); + binary_counting_predicate, int, int> pred((std::greater())); + 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())); + assert(pred.count() <= (N + N - 1)); + delete [] ic; + delete [] ib; + delete [] ia; + } +} + +int main() +{ + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// const T& +// max(const T& a, const T& b); + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires !SameType && CopyConstructible +// const T& +// max(const T& a, const T& b, Compare comp); + +#include +#include +#include + +template +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(), x); + test(y, x, std::greater(), y); + } + { + int x = 0; + int y = 1; + test(x, y, std::greater(), x); + test(y, x, std::greater(), x); + } + { + int x = 1; + int y = 0; + test(x, y, std::greater(), y); + test(y, x, std::greater(), y); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr int x = 1; + constexpr int y = 0; + static_assert(std::max(x, y, std::greater()) == y, "" ); + static_assert(std::max(y, x, std::greater()) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// Iter +// max_element(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +template +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 +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 +void +test() +{ + test(0); + test(1); + test(2); + test(3); + test(10); + test(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 >(); + test >(); + test >(); + test(); + + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires CopyConstructible +// Iter +// max_element(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last) +{ + Iter i = std::max_element(first, last, std::greater()); + if (first != last) + { + for (Iter j = first; j != last; ++j) + assert(!std::greater()(*i, *j)); + } + else + assert(i == last); +} + +template +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 +void +test() +{ + test(0); + test(1); + test(2); + test(3); + test(10); + test(1000); +} + +template +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()); + test_eq0(a, a+N, std::greater()); + 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 >(); + test >(); + test >(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// max(initializer_list t); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// max(initializer_list t, Compare comp); + +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + int i = std::max({2, 3, 1}, std::greater()); + assert(i == 1); + i = std::max({2, 1, 3}, std::greater()); + assert(i == 1); + i = std::max({3, 1, 2}, std::greater()); + assert(i == 1); + i = std::max({3, 2, 1}, std::greater()); + assert(i == 1); + i = std::max({1, 2, 3}, std::greater()); + assert(i == 1); + i = std::max({1, 3, 2}, std::greater()); + assert(i == 1); +#if _LIBCPP_STD_VER > 11 + { + static_assert(std::max({1, 3, 2}, std::greater()) == 1, ""); + static_assert(std::max({2, 1, 3}, std::greater()) == 1, ""); + static_assert(std::max({3, 2, 1}, std::greater()) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// const T& +// min(const T& a, const T& b); + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires !SameType && CopyConstructible +// const T& +// min(const T& a, const T& b, Compare comp); + +#include +#include +#include + +template +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(), x); + test(y, x, std::greater(), y); + } + { + int x = 0; + int y = 1; + test(x, y, std::greater(), y); + test(y, x, std::greater(), y); + } + { + int x = 1; + int y = 0; + test(x, y, std::greater(), x); + test(y, x, std::greater(), x); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr int x = 1; + constexpr int y = 0; + static_assert(std::min(x, y, std::greater()) == x, "" ); + static_assert(std::min(y, x, std::greater()) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// Iter +// min_element(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +template +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 +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 +void +test() +{ + test(0); + test(1); + test(2); + test(3); + test(10); + test(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 >(); + test >(); + test >(); + test(); + + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires CopyConstructible +// Iter +// min_element(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last) +{ + Iter i = std::min_element(first, last, std::greater()); + if (first != last) + { + for (Iter j = first; j != last; ++j) + assert(!std::greater()(*j, *i)); + } + else + assert(i == last); +} + +template +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 +void +test() +{ + test(0); + test(1); + test(2); + test(3); + test(10); + test(1000); +} + +template +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()); + test_eq0(a, a+N, std::greater()); + 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 >(); + test >(); + test >(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// min(initializer_list t); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// min(initializer_list t, Compare comp); + +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + int i = std::min({2, 3, 1}, std::greater()); + assert(i == 3); + i = std::min({2, 1, 3}, std::greater()); + assert(i == 3); + i = std::min({3, 1, 2}, std::greater()); + assert(i == 3); + i = std::min({3, 2, 1}, std::greater()); + assert(i == 3); + i = std::min({1, 2, 3}, std::greater()); + assert(i == 3); + i = std::min({1, 3, 2}, std::greater()); + assert(i == 3); +#if _LIBCPP_STD_VER > 11 + { + static_assert(std::min({1, 3, 2}, std::greater()) == 3, ""); + static_assert(std::min({2, 1, 3}, std::greater()) == 3, ""); + static_assert(std::min({3, 2, 1}, std::greater()) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// pair +// minmax(const T& a, const T& b); + +#include +#include + +template +void +test(const T& a, const T& b, const T& x, const T& y) +{ + std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires !SameType && CopyConstructible +// pair +// minmax(const T& a, const T& b, Compare comp); + +#include +#include +#include + +template +void +test(const T& a, const T& b, C c, const T& x, const T& y) +{ + std::pair 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(), x, y); + test(y, x, std::greater(), y, x); + } + { + int x = 0; + int y = 1; + test(x, y, std::greater(), y, x); + test(y, x, std::greater(), y, x); + } + { + int x = 1; + int y = 0; + test(x, y, std::greater(), x, y); + test(y, x, std::greater(), 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// pair +// minmax_element(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last) +{ + std::pair 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 +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 +void +test() +{ + test(0); + test(1); + test(2); + test(3); + test(10); + test(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 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 >(); + test >(); + test >(); + test(); + + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires CopyConstructible +// pair +// minmax_element(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last) +{ + typedef std::greater Compare; + Compare comp; + std::pair 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 +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 +void +test() +{ + test(0); + test(1); + test(2); + test(3); + test(10); + test(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 Compare; + Compare comp; + std::pair 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 >(); + test >(); + test >(); + test(); + + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// pair +// minmax(initializer_list t); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + assert((std::minmax({1, 2, 3}) == std::pair(1, 3))); + assert((std::minmax({1, 3, 2}) == std::pair(1, 3))); + assert((std::minmax({2, 1, 3}) == std::pair(1, 3))); + assert((std::minmax({2, 3, 1}) == std::pair(1, 3))); + assert((std::minmax({3, 1, 2}) == std::pair(1, 3))); + assert((std::minmax({3, 2, 1}) == std::pair(1, 3))); +#if _LIBCPP_STD_VER > 11 + { + static_assert((std::minmax({1, 2, 3}) == std::pair(1, 3)), ""); + static_assert((std::minmax({1, 3, 2}) == std::pair(1, 3)), ""); + static_assert((std::minmax({2, 1, 3}) == std::pair(1, 3)), ""); + static_assert((std::minmax({2, 3, 1}) == std::pair(1, 3)), ""); + static_assert((std::minmax({3, 1, 2}) == std::pair(1, 3)), ""); + static_assert((std::minmax({3, 2, 1}) == std::pair(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// pair +// minmax(initializer_list t, Compare comp); +// +// Complexity: At most (3/2) * t.size() applications of the corresponding predicate. + +#include +#include +#include + +#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 il) +{ + binary_counting_predicate pred (all_equal); + std::pair 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()) == std::pair(3, 1))); + assert((std::minmax({1, 3, 2}, std::greater()) == std::pair(3, 1))); + assert((std::minmax({2, 1, 3}, std::greater()) == std::pair(3, 1))); + assert((std::minmax({2, 3, 1}, std::greater()) == std::pair(3, 1))); + assert((std::minmax({3, 1, 2}, std::greater()) == std::pair(3, 1))); + assert((std::minmax({3, 2, 1}, std::greater()) == std::pair(3, 1))); + assert((std::minmax({1, 2, 3}, all_equal ) == std::pair(1, 3))); + + binary_counting_predicate, int, int> pred ((std::greater())); + assert((std::minmax({1, 2, 2, 3, 3, 3, 5, 5, 5, 5, 5, 3}, std::ref(pred)) == std::pair(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()) == std::pair(3, 1)), ""); + static_assert((std::minmax({1, 3, 2}, std::greater()) == std::pair(3, 1)), ""); + static_assert((std::minmax({2, 1, 3}, std::greater()) == std::pair(3, 1)), ""); + static_assert((std::minmax({2, 3, 1}, std::greater()) == std::pair(3, 1)), ""); + static_assert((std::minmax({3, 1, 2}, std::greater()) == std::pair(3, 1)), ""); + static_assert((std::minmax({3, 2, 1}, std::greater()) == std::pair(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// void +// nth_element(Iter first, Iter nth, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator +// && CopyConstructible +// void +// nth_element(Iter first, Iter nth, Iter last, Compare comp); + +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + 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()); + assert(array[M] == N-M-1); + std::nth_element(array, array+N, array+N, std::greater()); // 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 > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// bool +// next_permutation(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +#include + +int factorial(int x) +{ + int r = 1; + for (; x; --x) + r *= x; + return r; +} + +template +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 >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator +// && CopyConstructible +// bool +// next_permutation(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +#include + +int factorial(int x) +{ + int r = 1; + for (; x; --x) + r *= x; + return r; +} + +template +void +test() +{ + typedef std::greater 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 >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// bool +// prev_permutation(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +#include + +int factorial(int x) +{ + int r = 1; + for (; x; --x) + r *= x; + return r; +} + +template +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 >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator +// && CopyConstructible +// bool +// prev_permutation(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +#include + +int factorial(int x) +{ + int r = 1; + for (; x; --x) + r *= x; + return r; +} + +template +void +test() +{ + typedef std::greater 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 >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasLess +// && HasLess +// bool +// includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires Predicate +// && Predicate +// bool +// includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +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())); + assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1), std::less())); + assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib), std::less())); + assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), std::less())); + + assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb), std::less())); + assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa), std::less())); + + assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2), std::less())); + assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(ib+2), std::less())); + + assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+1), std::less())); + assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+2), std::less())); + assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+3), std::less())); + assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4), std::less())); +} + +int main() +{ + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && HasLess +// && HasLess +// OutIter +// set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, +// OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && Predicate +// && Predicate +// OutIter +// set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, +// OutIter result, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +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()); + 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()); + assert(base(ce) - ic == srr); + assert(std::lexicographical_compare(ic, base(ce), irr, irr+srr) == 0); +} + +int main() +{ + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && HasLess +// && HasLess +// OutIter +// set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, +// OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && Predicate +// && Predicate +// OutIter +// set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, +// OutIter result, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +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()); + 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()); + assert(base(ce) - ic == sr); + assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0); +} + +int main() +{ + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && HasLess +// && HasLess +// OutIter +// set_symmetric_difference(InIter1 first1, InIter1 last1, +// InIter2 first2, InIter2 last2, +// OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && Predicate +// && Predicate +// OutIter +// set_symmetric_difference(InIter1 first1, InIter1 last1, +// InIter2 first2, InIter2 last2, +// OutIter result, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +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()); + 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()); + assert(base(ce) - ic == sr); + assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0); +} + +int main() +{ + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && HasLess +// && HasLess +// OutIter +// set_union(InIter1 first1, InIter1 last1, +// InIter2 first2, InIter2 last2, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires OutputIterator +// && OutputIterator +// && Predicate +// && Predicate +// OutIter +// set_union(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, +// OutIter result, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +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()); + 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()); + assert(base(ce) - ic == sr); + assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0); +} + +int main() +{ + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, forward_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, input_iterator, output_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, bidirectional_iterator >(); + test, input_iterator, random_access_iterator >(); + test, input_iterator, int*>(); + + test, forward_iterator, output_iterator >(); + test, forward_iterator, forward_iterator >(); + test, forward_iterator, bidirectional_iterator >(); + test, forward_iterator, random_access_iterator >(); + test, forward_iterator, int*>(); + + test, bidirectional_iterator, output_iterator >(); + test, bidirectional_iterator, forward_iterator >(); + test, bidirectional_iterator, bidirectional_iterator >(); + test, bidirectional_iterator, random_access_iterator >(); + test, bidirectional_iterator, int*>(); + + test, random_access_iterator, output_iterator >(); + test, random_access_iterator, forward_iterator >(); + test, random_access_iterator, bidirectional_iterator >(); + test, random_access_iterator, random_access_iterator >(); + test, random_access_iterator, int*>(); + + test, const int*, output_iterator >(); + test, const int*, forward_iterator >(); + test, const int*, bidirectional_iterator >(); + test, const int*, random_access_iterator >(); + test, const int*, int*>(); + + test, output_iterator >(); + test, bidirectional_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// bool +// is_sorted(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires CopyConstructible +// bool +// is_sorted(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +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 a[] = {0, 0}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {0, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {1, 0}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {1, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + + { + int a[] = {0, 0, 0}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {0, 0, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {0, 1, 0}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {0, 1, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {1, 0, 0}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {1, 0, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {1, 1, 0}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + int a[] = {1, 1, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + + { + 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 a[] = {0, 0, 0, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + 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 a[] = {0, 0, 1, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + 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 a[] = {0, 1, 0, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + 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 a[] = {0, 1, 1, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + 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 a[] = {1, 0, 0, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + 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 a[] = {1, 0, 1, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + 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 a[] = {1, 1, 0, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } + { + 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 a[] = {1, 1, 1, 1}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater())); + } +} + +int main() +{ + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires LessThanComparable +// Iter +// is_sorted_until(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires CopyConstructible +// Iter +// is_sorted_until(Iter first, Iter last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test() +{ + { + int a[] = {0}; + unsigned sa = sizeof(a) / sizeof(a[0]); + assert(std::is_sorted_until(Iter(a), Iter(a), std::greater()) == Iter(a)); + assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == 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()) == Iter(a+sa)); + } +} + +int main() +{ + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && OutputIterator +// && HasLess +// && LessThanComparable +// RAIter +// partial_sort_copy(InIter first, InIter last, RAIter result_first, RAIter result_last); + +#include +#include + +#include "test_iterators.h" + +template +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 +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); + test_larger_sorts(N, N+1000); +} + +template +void +test() +{ + test_larger_sorts(0, 100); + 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); +} + +int main() +{ + int i = 0; + std::partial_sort_copy(&i, &i, &i, &i+5); + assert(i == 0); + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && OutputIterator +// && Predicate +// && StrictWeakOrder} +// && CopyConstructible +// RAIter +// partial_sort_copy(InIter first, InIter last, +// RAIter result_first, RAIter result_last, Compare comp); + +#include +#include +#include + +#include "test_iterators.h" + +template +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* 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 +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); + test_larger_sorts(N, N+1000); +} + +template +void +test() +{ + test_larger_sorts(0, 100); + 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); +} + +int main() +{ + int i = 0; + std::partial_sort_copy(&i, &i, &i, &i+5); + assert(i == 0); + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// void +// partial_sort(Iter first, Iter middle, Iter last); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator +// && CopyConstructible +// void +// partial_sort(Iter first, Iter middle, Iter last, Compare comp); + +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + 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()); + 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 > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// void +// sort(Iter first, Iter last); + +#include +#include + +template +void +test_sort_helper(RI f, RI l) +{ + typedef typename std::iterator_traits::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 +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 +void +test_sort_driver(RI f, RI l, int start) +{ + test_sort_driver_driver(f, l, start, l); +} + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator +// && CopyConstructible +// void +// sort(Iter first, Iter last, Compare comp); + +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + bool operator()(const P& x, const P& y) + {return *x < *y;} +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + std::vector v(1000); + for (int i = 0; i < v.size(); ++i) + v[i] = i; + std::sort(v.begin(), v.end(), std::greater()); + std::reverse(v.begin(), v.end()); + assert(std::is_sorted(v.begin(), v.end())); + } + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::vector > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires ShuffleIterator +// && LessThanComparable +// void +// stable_sort(Iter first, Iter last); + +#include +#include + +template +void +test_sort_helper(RI f, RI l) +{ + typedef typename std::iterator_traits::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 +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 +void +test_sort_driver(RI f, RI l, int start) +{ + test_sort_driver_driver(f, l, start, l); +} + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template Compare> +// requires ShuffleIterator +// && CopyConstructible +// void +// stable_sort(Iter first, Iter last, Compare comp); + +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include + +struct indirect_less +{ + template + 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& x, const std::pair& y) + { + return x.first < y.first; + } +}; + +void test() +{ + typedef std::pair P; + const int N = 1000; + const int M = 10; + std::vector

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 > 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +// + +// void atomic_signal_fence(memory_order m); + +#include + +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 + +// + +// void atomic_thread_fence(memory_order m); + +#include + +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 + +// + +// struct atomic_flag + +// void atomic_flag_clear(volatile atomic_flag*); +// void atomic_flag_clear(atomic_flag*); + +#include +#include + +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 + +// + +// struct atomic_flag + +// void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order); +// void atomic_flag_clear_explicit(atomic_flag*, memory_order); + +#include +#include + +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 + +// + +// struct atomic_flag + +// bool atomic_flag_test_and_set(volatile atomic_flag*); +// bool atomic_flag_test_and_set(atomic_flag*); + +#include +#include + +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 + +// + +// 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 +#include + +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 + +// + +// struct atomic_flag + +// void clear(memory_order = memory_order_seq_cst); +// void clear(memory_order = memory_order_seq_cst) volatile; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// struct atomic_flag + +// atomic_flag& operator=(const atomic_flag&) = delete; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// struct atomic_flag + +// atomic_flag(const atomic_flag&) = delete; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// struct atomic_flag + +// atomic_flag& operator=(const atomic_flag&) = delete; + +#include +#include + +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 + +// + +// struct atomic_flag + +// atomic_flag() = default; + +#include +#include +#include + +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 + +// + +// struct atomic_flag + +// atomic_flag() = ATOMIC_FLAG_INIT; + +#include +#include + +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 + +// + +// 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 +#include + +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 + +int main() { + std::atomic i; + volatile std::atomic 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 + +// + +// #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 +#include + +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 + +// + +// template T kill_dependency(T y); + +#include +#include + +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 + +// + +// 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 +#include + +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. + +// + +// template +// 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); +// 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 +#include +#include +#include + +#include + +template +void +do_test() +{ + typedef typename std::remove_pointer::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 +void test() +{ + do_test(); + do_test(); +} + +int main() +{ + test, 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 + +// + +// template +// 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 atomic_bool; + +#include +#include +#include + +#include + +int main() +{ + { + volatile std::atomic _; + volatile std::atomic 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 _; + std::atomic 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 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 + +// + +// typedef atomic atomic_int_least8_t; +// typedef atomic atomic_uint_least8_t; +// typedef atomic atomic_int_least16_t; +// typedef atomic atomic_uint_least16_t; +// typedef atomic atomic_int_least32_t; +// typedef atomic atomic_uint_least32_t; +// typedef atomic atomic_int_least64_t; +// typedef atomic atomic_uint_least64_t; +// +// typedef atomic atomic_int_fast8_t; +// typedef atomic atomic_uint_fast8_t; +// typedef atomic atomic_int_fast16_t; +// typedef atomic atomic_uint_fast16_t; +// typedef atomic atomic_int_fast32_t; +// typedef atomic atomic_uint_fast32_t; +// typedef atomic atomic_int_fast64_t; +// typedef atomic atomic_uint_fast64_t; +// +// typedef atomic atomic_intptr_t; +// typedef atomic atomic_uintptr_t; +// typedef atomic atomic_size_t; +// typedef atomic atomic_ptrdiff_t; +// typedef atomic atomic_intmax_t; +// typedef atomic atomic_uintmax_t; + +#include +#include +#include + +int main() +{ + static_assert((std::is_same, std::atomic_int_least8_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_least8_t>::value), ""); + static_assert((std::is_same, std::atomic_int_least16_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_least16_t>::value), ""); + static_assert((std::is_same, std::atomic_int_least32_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_least32_t>::value), ""); + static_assert((std::is_same, std::atomic_int_least64_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_least64_t>::value), ""); + + static_assert((std::is_same, std::atomic_int_fast8_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_fast8_t>::value), ""); + static_assert((std::is_same, std::atomic_int_fast16_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_fast16_t>::value), ""); + static_assert((std::is_same, std::atomic_int_fast32_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_fast32_t>::value), ""); + static_assert((std::is_same, std::atomic_int_fast64_t>::value), ""); + static_assert((std::is_same, std::atomic_uint_fast64_t>::value), ""); + + static_assert((std::is_same, std::atomic_intptr_t>::value), ""); + static_assert((std::is_same, std::atomic_uintptr_t>::value), ""); + static_assert((std::is_same, std::atomic_size_t>::value), ""); + static_assert((std::is_same, std::atomic_ptrdiff_t>::value), ""); + static_assert((std::is_same, std::atomic_intmax_t>::value), ""); + static_assert((std::is_same, 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 + +// + +// template <> +// struct atomic +// { +// 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 +#include +#include + +#include + +template +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 +void test() +{ + do_test(); + do_test(); +} + + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); +} 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 + +// + +// typedef atomic atomic_char; +// typedef atomic atomic_schar; +// typedef atomic atomic_uchar; +// typedef atomic atomic_short; +// typedef atomic atomic_ushort; +// typedef atomic atomic_int; +// typedef atomic atomic_uint; +// typedef atomic atomic_long; +// typedef atomic atomic_ulong; +// typedef atomic atomic_llong; +// typedef atomic atomic_ullong; +// typedef atomic atomic_char16_t; +// typedef atomic atomic_char32_t; +// typedef atomic atomic_wchar_t; + +#include +#include + +int main() +{ + static_assert((std::is_same, std::atomic_char>::value), ""); + static_assert((std::is_same, std::atomic_schar>::value), ""); + static_assert((std::is_same, std::atomic_uchar>::value), ""); + static_assert((std::is_same, std::atomic_short>::value), ""); + static_assert((std::is_same, std::atomic_ushort>::value), ""); + static_assert((std::is_same, std::atomic_int>::value), ""); + static_assert((std::is_same, std::atomic_uint>::value), ""); + static_assert((std::is_same, std::atomic_long>::value), ""); + static_assert((std::is_same, std::atomic_ulong>::value), ""); + static_assert((std::is_same, std::atomic_llong>::value), ""); + static_assert((std::is_same, std::atomic_ullong>::value), ""); + static_assert((std::is_same, std::atomic_wchar_t>::value), ""); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert((std::is_same, std::atomic_char16_t>::value), ""); + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include +#include // for thread_id +#include // for nanoseconds + +struct NotTriviallyCopyable { + NotTriviallyCopyable ( int i ) : i_(i) {} + NotTriviallyCopyable ( const NotTriviallyCopyable &rhs) : i_(rhs.i_) {} + int i_; + }; + +template +void test ( T t ) { + std::atomic 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 + +// + +// template +// 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 +#include +#include +#include // for thread_id +#include // for nanoseconds + +struct TriviallyCopyable { + TriviallyCopyable ( int i ) : i_(i) {} + int i_; + }; + +template +void test ( T t ) { + std::atomic 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 + +// + +// template +// bool +// atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr); +// +// template +// bool +// atomic_compare_exchange_strong(atomic* obj, T* expc, T desr); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// bool +// atomic_compare_exchange_strong_explicit(volatile atomic* obj, T* expc, +// T desr, +// memory_order s, memory_order f); +// +// template +// bool +// atomic_compare_exchange_strong_explicit(atomic* obj, T* expc, T desr, +// memory_order s, memory_order f); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// bool +// atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr); +// +// template +// bool +// atomic_compare_exchange_weak(atomic* obj, T* expc, T desr); + +#include +#include +#include + +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// bool +// atomic_compare_exchange_weak_explicit(volatile atomic* obj, T* expc, +// T desr, +// memory_order s, memory_order f); +// +// template +// bool +// atomic_compare_exchange_weak_explicit(atomic* obj, T* expc, T desr, +// memory_order s, memory_order f); + +#include +#include +#include + +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// T +// atomic_exchange(volatile atomic* obj, T desr); +// +// template +// T +// atomic_exchange(atomic* obj, T desr); + +#include +#include +#include + +template +void +test() +{ + typedef std::atomic 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// T +// atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m); +// +// template +// T +// atomic_exchange_explicit(atomic* obj, T desr, memory_order m); + +#include +#include +#include + +template +void +test() +{ + typedef std::atomic 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// Integral +// atomic_fetch_add(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_add(atomic* obj, Integral op); +// +// template +// T* +// atomic_fetch_add(volatile atomic* obj, ptrdiff_t op); +// +// template +// T* +// atomic_fetch_add(atomic* obj, ptrdiff_t op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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 +void +testp() +{ + { + typedef std::atomic A; + typedef typename std::remove_pointer::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 A; + typedef typename std::remove_pointer::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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + testp(); + testp(); +} 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 + +// + +// template +// Integral +// atomic_fetch_add_explicit(volatile atomic* obj, Integral op, +// memory_order m); +// template +// Integral +// atomic_fetch_add_explicit(atomic* obj, Integral op, +// memory_order m); +// template +// T* +// atomic_fetch_add_explicit(volatile atomic* obj, ptrdiff_t op, +// memory_order m); +// template +// T* +// atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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 +void +testp() +{ + { + typedef std::atomic A; + typedef typename std::remove_pointer::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 A; + typedef typename std::remove_pointer::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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + testp(); + testp(); +} 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 + +// + +// template +// Integral +// atomic_fetch_and(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_and(atomic* obj, Integral op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#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 + +// + +// template +// Integral +// atomic_fetch_and_explicit(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_and_explicit(atomic* obj, Integral op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#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 + +// + +// template +// Integral +// atomic_fetch_or(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_or(atomic* obj, Integral op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#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 + +// + +// template +// Integral +// atomic_fetch_or_explicit(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_or_explicit(atomic* obj, Integral op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#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 + +// + +// template +// Integral +// atomic_fetch_sub(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_sub(atomic* obj, Integral op); +// +// template +// T* +// atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op); +// +// template +// T* +// atomic_fetch_sub(atomic* obj, ptrdiff_t op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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 +void +testp() +{ + { + typedef std::atomic A; + typedef typename std::remove_pointer::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 A; + typedef typename std::remove_pointer::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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + testp(); + testp(); +} 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 + +// + +// template +// Integral +// atomic_fetch_sub_explicit(volatile atomic* obj, Integral op, +// memory_order m); +// template +// Integral +// atomic_fetch_sub_explicit(atomic* obj, Integral op, +// memory_order m); +// +// template +// T* +// atomic_fetch_sub_explicit(volatile atomic* obj, ptrdiff_t op, +// memory_order m); +// template +// T* +// atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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 +void +testp() +{ + { + typedef std::atomic A; + typedef typename std::remove_pointer::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 A; + typedef typename std::remove_pointer::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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + testp(); + testp(); +} 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 + +// + +// template +// Integral +// atomic_fetch_xor(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_xor(atomic* obj, Integral op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#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 + +// + +// template +// Integral +// atomic_fetch_xor_explicit(volatile atomic* obj, Integral op); +// +// template +// Integral +// atomic_fetch_xor_explicit(atomic* obj, Integral op); + +#include +#include +#include + +template +void +test() +{ + { + typedef std::atomic 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 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#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 + +// + +// template +// void +// atomic_init(volatile atomic* obj, T desr); +// +// template +// void +// atomic_init(atomic* obj, T desr); + +#include +#include +#include + +template +void +test() +{ + typedef std::atomic 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// bool +// atomic_is_lock_free(const volatile atomic* obj); +// +// template +// bool +// atomic_is_lock_free(const atomic* obj); + +#include + +template +void +test() +{ + typedef std::atomic A; + A t; + bool b1 = std::atomic_is_lock_free(static_cast(&t)); + volatile A vt; + bool b2 = std::atomic_is_lock_free(static_cast(&vt)); +} + +struct A +{ + char _[4]; +}; + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// T +// atomic_load(const volatile atomic* obj); +// +// template +// T +// atomic_load(const atomic* obj); + +#include +#include +#include + +template +void +test() +{ + typedef std::atomic 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// T +// atomic_load_explicit(const volatile atomic* obj, memory_order m); +// +// template +// T +// atomic_load_explicit(const atomic* obj, memory_order m); + +#include +#include +#include + +template +void +test() +{ + typedef std::atomic 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// void +// atomic_store(volatile atomic* obj, T desr); +// +// template +// void +// atomic_store(atomic* obj, T desr); + +#include +#include +#include + +template +void +test() +{ + typedef std::atomic 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// template +// void +// atomic_store_explicit(volatile atomic* obj, T desr, memory_order m); +// +// template +// void +// atomic_store_explicit(atomic* obj, T desr, memory_order m); + +#include +#include +#include + +template +void +test() +{ + typedef std::atomic 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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +} 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 + +// + +// #define ATOMIC_VAR_INIT(value) + +#include +#include +#include + +int main() +{ + std::atomic 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 + +// + +// constexpr atomic::atomic(T value) + +#include +#include +#include + +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 +void test() { + typedef std::atomic Atomic; + static_assert(std::is_literal_type::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(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// Test that including fails to compile when _LIBCPP_HAS_NO_THREADS +// is defined. + +#ifndef _LIBCPP_HAS_NO_THREADS +#define _LIBCPP_HAS_NO_THREADS +#endif + +#include + +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 + +// + +#include + +#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 + : public std::unary_function +{ + 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 + +class NotConstructible +{ + NotConstructible(const NotConstructible&); + NotConstructible& operator=(const NotConstructible&); +public: +}; + +inline +bool +operator==(const NotConstructible&, const NotConstructible&) +{return true;} + +namespace std +{ + +template <> +struct hash + : public std::unary_function +{ + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Allocator = allocator>> +// class map + +// http://llvm.org/bugs/show_bug.cgi?id=16538 +// http://llvm.org/bugs/show_bug.cgi?id=16549 + +#include + +struct Key { + template Key(const T&) {} + bool operator< (const Key&) const { return false; } +}; + +int +main() +{ + std::map::iterator it = std::map().find(Key(0)); + std::pair::iterator, bool> result = + std::map().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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// mapped_type& at(const key_type& k); +// const mapped_type& at(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 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 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 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 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, min_allocator> 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 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// bool empty() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// mapped_type& operator[](const key_type& k); + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef std::pair 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 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 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, min_allocator> 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 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// mapped_type& operator[](key_type&& k); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::pair V; + std::map 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 V; + std::map, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// mapped_type& operator[](const key_type& k); + +// http://llvm.org/bugs/show_bug.cgi?id=16542 + +#include + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +#include + +#endif + +int main() +{ +#ifndef _LIBCPP_HAS_NO_VARIADICS + using namespace std; + map, 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 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::iterator i; + i = m.begin(); + std::map::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 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 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::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 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, min_allocator> 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, min_allocator>::iterator i; + i = m.begin(); + std::map, min_allocator>::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 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, min_allocator> 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, min_allocator>::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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map M; + M m; + assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// size_type size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// explicit map(const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::less C; + typedef test_allocator > A; + std::map m(A(5)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef std::less C; + typedef min_allocator > A; + std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map& operator=(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::pair V; + std::map 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 V; + std::map, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// explicit map(const key_compare& comp); + +#include +#include + +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_compare > C; + std::map m(C(3)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(3)); + } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + std::map>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(const key_compare& comp, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_compare > C; + typedef test_allocator > A; + std::map 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 > C; + typedef min_allocator > A; + std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(const map& m); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::map 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 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 > C; + typedef other_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::map 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 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 > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(const map& m, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::map 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 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 > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map& operator=(const map& m); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::map 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 V; + const V ar[] = + { + V(1, 1), + V(2, 1), + V(3, 1), + }; + std::map m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::map *p = &m; + m = *p; + + assert(m.size() == 3); + assert(std::equal(m.begin(), m.end(), ar)); + } + { + typedef std::pair 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 > C; + typedef other_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::map 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 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 > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map 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 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 > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::map m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::map, min_allocator>> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } + { + std::map 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() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::map, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::map, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::map> C; + static_assert(!std::is_nothrow_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(); + +#include + +struct X +{ + std::map m; + std::map::iterator i; + std::map::const_iterator ci; + std::map::reverse_iterator ri; + std::map::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::map, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::map, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::map> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::pair V; + std::map 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 V; + std::map, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(initializer_list il, const key_compare& comp); + +#include +#include +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::pair V; + typedef test_compare > C; + std::map 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 V; + typedef test_compare > C; + std::map>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(initializer_list il, const key_compare& comp, const allocator_type& a); + +#include +#include +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::pair V; + typedef test_compare > C; + typedef test_allocator > A; + std::map 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 V; + typedef test_compare > C; + typedef min_allocator > A; + std::map 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 V; + typedef min_allocator A; + typedef test_compare > C; + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// map(InputIterator first, InputIterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 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 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// map(InputIterator first, InputIterator last, const key_compare& comp); + +#include +#include + +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + std::map 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 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 > C; + std::map>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// map(InputIterator first, InputIterator last, +// const key_compare& comp, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::map 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 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 > C; + typedef min_allocator A; + std::map 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 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 V; + typedef min_allocator A; + typedef test_compare > C; + A a; + std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(map&& m); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + typedef std::pair V; + { + typedef test_compare > C; + typedef test_allocator A; + std::map mo(C(5), A(7)); + std::map 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 > C; + typedef test_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::map 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 > C; + typedef min_allocator A; + std::map mo(C(5), A()); + std::map 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 > C; + typedef min_allocator A; + std::map mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map(map&& m, const allocator_type& a); + +#include +#include + +#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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::map M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::map M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef other_allocator A; + typedef std::map M; + typedef std::move_iterator 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 T; + typedef std::pair V; + typedef std::pair VC; + typedef test_allocator A; + typedef std::less C; + typedef std::map 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::map M; + typedef std::move_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// map& operator=(map&& m); + +#include +#include + +#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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::map M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::map M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef other_allocator A; + typedef std::map M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::map M; + typedef std::move_iterator 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& operator=(map&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::map, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::map, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::map> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::map C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::map, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::map, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::map> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// void clear(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// pair emplace(Args&&... args); + +#include +#include +#include + +#include "../../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::map M; + typedef std::pair 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 M; + typedef std::pair 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 M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// iterator emplace_hint(const_iterator position, Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::map 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 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 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, min_allocator>> 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, min_allocator>> 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// iterator erase(const_iterator position); + +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + TemplateConstructor (const T&) {} +}; + +bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; } + +int main() +{ + { + typedef std::map M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// size_type erase(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// pair insert(const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// void insert(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::pair V; + std::map 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 V; + std::map, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// iterator insert(const_iterator position, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::map M; + typedef std::pair 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(ar), input_iterator(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, min_allocator>> M; + typedef std::pair 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(ar), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// iterator insert(const_iterator position, P&& p); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::map M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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 + +// + +// class map + +// template +// pair insert_or_assign(const key_type& k, M&& obj); // C++17 +// template +// pair insert_or_assign(key_type&& k, M&& obj); // C++17 +// template +// iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 +// template +// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 + +#include <__config> +#include +#include +#include + +#include + +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 insert_or_assign(const key_type& k, M&& obj); + typedef std::map M; + typedef std::pair 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 insert_or_assign(key_type&& k, M&& obj); + typedef std::map M; + typedef std::pair 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// pair insert(P&& p); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::map M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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 + +// + +// class map + +// template +// pair try_emplace(const key_type& k, Args&&... args); // C++17 +// template +// pair try_emplace(key_type&& k, Args&&... args); // C++17 +// template +// iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 +// template +// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 + +#include <__config> +#include +#include +#include + +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 try_emplace(const key_type& k, Args&&... args); + typedef std::map M; + typedef std::pair 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 try_emplace(key_type&& k, Args&&... args); + typedef std::map M; + typedef std::pair 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// size_type count(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + { + typedef std::pair V; + typedef std::map 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 V; + typedef std::map, min_allocator> 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 V; + typedef std::map> 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> 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// pair equal_range(const key_type& k); +// pair equal_range(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + { + typedef std::pair V; + typedef std::map M; + { + typedef std::pair 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 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 V; + typedef std::map, min_allocator> M; + { + typedef std::pair 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 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 V; + typedef std::map> M; + typedef std::pair 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> M; + typedef std::pair 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + { + typedef std::pair V; + typedef std::map 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 V; + typedef std::map, min_allocator> 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 V; + typedef std::map> 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> 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + { + typedef std::pair V; + typedef std::map 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 V; + typedef std::map, min_allocator> 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 V; + typedef std::map> 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> 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef std::pair V; + typedef std::map 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 V; + typedef std::map, min_allocator> 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 V; + typedef std::map> 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> 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// void swap(map& m); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + typedef std::pair V; + { + typedef std::map 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// template +// void +// swap(map& x, map& y); + +#include +#include +#include "test_allocator.h" +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ + typedef std::pair V; + { + typedef std::map 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 A; + typedef test_compare > C; + typedef std::map 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 A; + typedef test_compare > C; + typedef std::map 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, min_allocator> 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 A; + typedef test_compare > C; + typedef std::map 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(map& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// noexcept(swap(declval(), declval()))); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +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 +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::map, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::map, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::map> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + +#if TEST_STD_VER >= 14 + { // POCS allocator, throwable swap for comp + typedef std::map, some_alloc > C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, throwable swap for comp + typedef std::map, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for comp + typedef std::map, some_alloc > C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, nothrow swap for comp + typedef std::map, some_alloc2> C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + + { // NOT always equal allocator, nothrow swap for comp + typedef std::map, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Allocator = allocator>> +// class map +// { +// public: +// // types: +// typedef Key key_type; +// typedef T mapped_type; +// typedef pair 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::map C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same > >::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same*>::value), ""); + static_assert((std::is_same*>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::map, min_allocator>> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same > >::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same>>::value), ""); + static_assert((std::is_same>>::value), ""); +// min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// bool empty() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 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::iterator i; + i = m.begin(); + std::multimap::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 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 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::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 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, min_allocator> 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, min_allocator>::iterator i; + i = m.begin(); + std::multimap, min_allocator>::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 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, min_allocator> 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, min_allocator>::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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap M; + M m; + assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// explicit multimap(const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::less C; + typedef test_allocator > A; + std::multimap m(A(5)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.get_allocator() == A(5)); + } +#if __cplusplus >= 201103L + { + typedef std::less C; + typedef min_allocator > A; + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap& operator=(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// explicit multimap(const key_compare& comp); + +#include +#include + +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_compare > C; + std::multimap m(C(3)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(3)); + } +#if __cplusplus >= 201103L + { + typedef test_compare > C; + std::multimap>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(const key_compare& comp, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_compare > C; + typedef test_allocator > A; + std::multimap 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 > C; + typedef min_allocator > A; + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(const multimap& m); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multimap 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 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 > C; + typedef other_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multimap 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 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 > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(const multimap& m, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multimap 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 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 > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap& operator=(const multimap& m); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::multimap 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 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 m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::multimap *p = &m; + m = *p; + assert(m.size() == sizeof(ar)/sizeof(ar[0])); + assert(std::equal(m.begin(), m.end(), ar)); + } + { + typedef std::pair 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 > C; + typedef other_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::multimap 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 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 > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::multimap m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::multimap, min_allocator>> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } + { + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// multimap() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multimap, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multimap, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multimap> C; + static_assert(!std::is_nothrow_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(); + +#include + +struct X +{ + std::multimap m; + std::multimap::iterator i; + std::multimap::const_iterator ci; + std::multimap::reverse_iterator ri; + std::multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// ~multimap() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multimap, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multimap, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multimap> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(initializer_list il, const key_compare& comp = key_compare()); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(initializer_list il, const key_compare& comp = key_compare()); + +#include +#include +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef test_compare > Cmp; + typedef std::multimap 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 > Cmp; + typedef std::multimap>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(initializer_list il, const key_compare& comp, const allocator_type& a); + +#include +#include +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef test_compare > Cmp; + typedef test_allocator > A; + typedef std::multimap 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 > Cmp; + typedef min_allocator > A; + typedef std::multimap 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 > C; + typedef std::pair V; + typedef min_allocator A; + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// multimap(InputIterator first, InputIterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 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 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, min_allocator> 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 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> A; + A a; + std::multimap, 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// multimap(InputIterator first, InputIterator last, +// const key_compare& comp); + +#include +#include + +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + std::multimap 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 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 > C; + std::multimap> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// multimap(InputIterator first, InputIterator last, +// const key_compare& comp, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::pair 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 > C; + typedef test_allocator A; + std::multimap 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 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 > C; + typedef min_allocator A; + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(multimap&& m); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + typedef std::pair V; + { + typedef test_compare > C; + typedef test_allocator A; + std::multimap mo(C(5), A(7)); + std::multimap 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 > C; + typedef test_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multimap 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 > C; + typedef min_allocator A; + std::multimap mo(C(5), A()); + std::multimap 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 > C; + typedef min_allocator A; + std::multimap mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap(multimap&& m, const allocator_type& a); + +#include +#include + +#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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef other_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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 T; + typedef std::pair V; + typedef std::pair VC; + typedef test_allocator A; + typedef std::less C; + typedef std::multimap 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// multimap& operator=(multimap&& m); + +#include +#include + +#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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef test_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef other_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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 V; + typedef std::pair VC; + typedef test_compare > C; + typedef min_allocator A; + typedef std::multimap M; + typedef std::move_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// multimap& operator=(multimap&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multimap, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multimap, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multimap> C; + static_assert(!std::is_nothrow_move_assignable::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. +// +//===----------------------------------------------------------------------===// + +// + +// multimap(multimap&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multimap C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multimap, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multimap, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multimap> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// void clear(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// iterator emplace(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multimap 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 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 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, min_allocator>> 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, min_allocator>> 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// iterator emplace_hint(const_iterator position, Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multimap 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 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 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, min_allocator>> 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, min_allocator>> 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// iterator erase(const_iterator position); + +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + TemplateConstructor (const T&) {} +}; + +bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; } + +int main() +{ + { + typedef std::multimap M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// size_type erase(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// iterator insert(const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// void insert(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// iterator insert(const_iterator position, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap M; + typedef std::pair 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(ar), input_iterator(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, min_allocator>> M; + typedef std::pair 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(ar), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// iterator insert(const_iterator position, P&& p); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multimap M; + typedef std::pair 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, min_allocator>> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// iterator insert(P&& p); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// size_type count(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair V; + { + typedef std::multimap 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, min_allocator>> 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> 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> M; + typedef M::size_type R; + + M m; + m.insert ( std::make_pair ( PC::make(5), 1 )); + m.insert ( std::make_pair ( PC::make(5), 2 )); + m.insert ( std::make_pair ( PC::make(5), 3 )); + m.insert ( std::make_pair ( PC::make(7), 1 )); + m.insert ( std::make_pair ( PC::make(7), 2 )); + m.insert ( std::make_pair ( PC::make(7), 3 )); + m.insert ( std::make_pair ( PC::make(9), 1 )); + m.insert ( std::make_pair ( PC::make(9), 2 )); + m.insert ( std::make_pair ( 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// pair equal_range(const key_type& k); +// pair equal_range(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair V; + { + typedef std::multimap M; + { + typedef std::pair 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 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, min_allocator>> M; + { + typedef std::pair 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 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 V; + typedef std::multimap> M; + + typedef std::pair 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> M; + typedef std::pair R; + + M m; + m.insert ( std::make_pair ( PC::make(5), 1 )); + m.insert ( std::make_pair ( PC::make(5), 2 )); + m.insert ( std::make_pair ( PC::make(5), 3 )); + m.insert ( std::make_pair ( PC::make(7), 1 )); + m.insert ( std::make_pair ( PC::make(7), 2 )); + m.insert ( std::make_pair ( PC::make(7), 3 )); + m.insert ( std::make_pair ( PC::make(9), 1 )); + m.insert ( std::make_pair ( PC::make(9), 2 )); + m.insert ( std::make_pair ( 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair V; + { + typedef std::multimap 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, min_allocator>> 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 V; + typedef std::multimap> 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> M; + typedef M::iterator R; + + M m; + m.insert ( std::make_pair ( PC::make(5), 1 )); + m.insert ( std::make_pair ( PC::make(5), 2 )); + m.insert ( std::make_pair ( PC::make(5), 3 )); + m.insert ( std::make_pair ( PC::make(7), 1 )); + m.insert ( std::make_pair ( PC::make(7), 2 )); + m.insert ( std::make_pair ( PC::make(7), 3 )); + m.insert ( std::make_pair ( PC::make(9), 1 )); + m.insert ( std::make_pair ( PC::make(9), 2 )); + m.insert ( std::make_pair ( 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair V; + { + typedef std::multimap 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, min_allocator>> 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 V; + typedef std::multimap> 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> M; + typedef M::iterator R; + + M m; + m.insert ( std::make_pair ( PC::make(5), 1 )); + m.insert ( std::make_pair ( PC::make(5), 2 )); + m.insert ( std::make_pair ( PC::make(5), 3 )); + m.insert ( std::make_pair ( PC::make(7), 1 )); + m.insert ( std::make_pair ( PC::make(7), 2 )); + m.insert ( std::make_pair ( PC::make(7), 3 )); + m.insert ( std::make_pair ( PC::make(9), 1 )); + m.insert ( std::make_pair ( PC::make(9), 2 )); + m.insert ( std::make_pair ( 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair V; + { + typedef std::multimap 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, min_allocator>> 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 V; + typedef std::multimap> 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> M; + typedef M::iterator R; + + M m; + m.insert ( std::make_pair ( PC::make(5), 1 )); + m.insert ( std::make_pair ( PC::make(5), 2 )); + m.insert ( std::make_pair ( PC::make(5), 3 )); + m.insert ( std::make_pair ( PC::make(7), 1 )); + m.insert ( std::make_pair ( PC::make(7), 2 )); + m.insert ( std::make_pair ( PC::make(7), 3 )); + m.insert ( std::make_pair ( PC::make(9), 1 )); + m.insert ( std::make_pair ( PC::make(9), 2 )); + m.insert ( std::make_pair ( 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 + +// + +// 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 +#include + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// void swap(multimap& m); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + typedef std::pair V; + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// template +// void +// swap(multimap& x, multimap& y); + +#include +#include +#include "test_allocator.h" +#include "../../../test_compare.h" +#include "min_allocator.h" + +int main() +{ + typedef std::pair V; + { + typedef std::multimap 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 A; + typedef test_compare > C; + typedef std::multimap 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 A; + typedef test_compare > C; + typedef std::multimap 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, min_allocator>> 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 A; + typedef test_compare > C; + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(multimap& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// noexcept(swap(declval(), declval()))); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +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 +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multimap, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multimap, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multimap> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + +#if TEST_STD_VER >= 14 + { // POCS allocator, throwable swap for comp + typedef std::multimap, some_alloc > C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, throwable swap for comp + typedef std::multimap, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for comp + typedef std::multimap, some_alloc > C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, nothrow swap for comp + typedef std::multimap, some_alloc2> C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + + { // NOT always equal allocator, nothrow swap for comp + typedef std::map, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class map class multimap + +// Extension: SCARY/N2913 iterator compatibility between map and multimap + +#include + +int main() +{ + typedef std::map M1; + typedef std::multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multimap + +// size_type size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap 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, min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Allocator = allocator>> +// class multimap +// { +// public: +// // types: +// typedef Key key_type; +// typedef T mapped_type; +// typedef pair 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multimap C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same > >::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same*>::value), ""); + static_assert((std::is_same*>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::multimap, min_allocator>> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same > >::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same>>::value), ""); + static_assert((std::is_same>>::value), ""); +// min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// void clear(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// size_type count(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::multiset 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// template +// iterator emplace(Args&&... args); + +#include +#include + +#include "../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multiset 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 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 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// template +// iterator emplace_hint(const_iterator position, Args&&... args); + +#include +#include + +#include "../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multiset 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 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 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// bool empty() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// pair equal_range(const key_type& k); +// pair equal_range(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::multiset M; + { + typedef std::pair 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 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, min_allocator> M; + { + typedef std::pair 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 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> M; + typedef std::pair 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> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator erase(const_iterator position); + +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + TemplateConstructor (const T&) {} +}; + +bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; } + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// size_type erase(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::multiset 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator insert(const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// void insert(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator insert(const_iterator position, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset M; + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + M m; + m.insert(input_iterator(ar), + input_iterator(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, min_allocator> M; + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + M m; + m.insert(input_iterator(ar), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator insert(const_iterator position, value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator insert(value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 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::iterator i; + i = m.begin(); + std::multiset::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 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::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, min_allocator> 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, min_allocator>::iterator i; + i = m.begin(); + std::multiset, min_allocator>::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, min_allocator> 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, min_allocator>::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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::multiset 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset M; + M m; + assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(const allocator_type& a); + +#include +#include + +#include "test_allocator.h" + +int main() +{ + typedef std::less C; + typedef test_allocator A; + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset& operator=(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// explicit multiset(const value_compare& comp); + +#include +#include + +#include "../../../test_compare.h" + +int main() +{ + typedef test_compare > C; + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(const value_compare& comp, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" + +int main() +{ + typedef test_compare > C; + typedef test_allocator A; + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(const multiset& m); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset 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 > C; + typedef other_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(const multiset& m, const allocator_type& a); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset& operator=(const multiset& s); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::multiset 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 m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::multiset *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 > C; + typedef other_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::multiset m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::multiset, min_allocator> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } + { + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// multiset() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// ~multiset() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(initializer_list il, const key_compare& comp = key_compare()); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::multiset 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, min_allocator> 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, min_allocator> C; + typedef C::value_type V; + min_allocator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(initializer_list il, const key_compare& comp = key_compare()); + +#include +#include +#include "../../../test_compare.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + typedef test_compare > Cmp; + typedef std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(initializer_list il, const key_compare& comp, const allocator_type& a); + +#include +#include +#include "../../../test_compare.h" +#include "test_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + typedef test_compare > Cmp; + typedef test_allocator A; + typedef std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// template +// multiset(InputIterator first, InputIterator last); + +#include +#include + +#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 m(input_iterator(ar), + input_iterator(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, min_allocator> m(input_iterator(ar), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// template +// multiset(InputIterator first, InputIterator last, +// const value_compare& comp, const allocator_type& a); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::multiset m(input_iterator(ar), + input_iterator(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 A; + typedef test_compare > C; + A a; + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// template +// multiset(InputIterator first, InputIterator last, const value_compare& comp); + +#include +#include + +#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 > C; + std::multiset m(input_iterator(ar), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(multiset&& s); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::multiset mo(C(5), A(7)); + std::multiset 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 > C; + typedef test_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset 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 > C; + typedef min_allocator A; + std::multiset mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset(multiset&& s, const allocator_type& a); + +#include +#include + +#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 > C; + typedef test_allocator A; + typedef std::multiset M; + typedef std::move_iterator 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 > C; + typedef test_allocator A; + typedef std::multiset M; + typedef std::move_iterator 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 > C; + typedef other_allocator A; + typedef std::multiset M; + typedef std::move_iterator 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 V; + typedef std::less C; + typedef test_allocator A; + typedef std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// multiset& operator=(multiset&& s); + +#include +#include + +#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 > C; + typedef test_allocator A; + typedef std::multiset M; + typedef std::move_iterator 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 > C; + typedef test_allocator A; + typedef std::multiset M; + typedef std::move_iterator 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 > C; + typedef other_allocator A; + typedef std::multiset M; + typedef std::move_iterator 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 > C; + typedef min_allocator A; + typedef std::multiset M; + typedef std::move_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// multiset& operator=(multiset&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_move_assignable::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. +// +//===----------------------------------------------------------------------===// + +// + +// multiset(multiset&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::multiset C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multiset, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multiset, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::multiset> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// void swap(multiset& m); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int V; + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// void swap(multiset& m); + +#include +#include +#include "test_allocator.h" +#include "../../../test_compare.h" + +int main() +{ + typedef int V; + typedef std::multiset 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 A; + typedef test_compare > C; + typedef std::set 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 A; + typedef test_compare > C; + typedef std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(multiset& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// noexcept(swap(declval(), declval()))); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +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 +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multiset, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multiset, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::multiset> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + +#if TEST_STD_VER >= 14 + { // POCS allocator, throwable swap for comp + typedef std::multiset, some_alloc > C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, throwable swap for comp + typedef std::multiset, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for comp + typedef std::multiset, some_alloc > C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, nothrow swap for comp + typedef std::multiset, some_alloc2> C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + + { // NOT always equal allocator, nothrow swap for comp + typedef std::multiset, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set class multiset + +// Extension: SCARY/N2913 iterator compatibility between set and multiset + +#include + +int main() +{ + typedef std::set M1; + typedef std::multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// size_type size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Allocator = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::multiset C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::multiset, min_allocator> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); +// min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class multiset + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::multiset 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// void clear(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// size_type count(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::set 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// template +// pair emplace(Args&&... args); + +#include +#include + +#include "../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::set M; + typedef std::pair 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 M; + typedef std::pair 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 M; + typedef std::pair 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, min_allocator> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// template +// iterator emplace_hint(const_iterator position, Args&&... args); + +#include +#include + +#include "../../Emplaceable.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::set 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 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 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// bool empty() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// pair equal_range(const key_type& k); +// pair equal_range(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::set M; + { + typedef std::pair 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 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, min_allocator> M; + typedef std::pair 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> M; + { + typedef std::pair 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> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// iterator erase(const_iterator position); + +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + TemplateConstructor (const T&) {} +}; + +bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; } + +int main() +{ + { + typedef std::set 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, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// size_type erase(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::set 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// pair insert(const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set M; + typedef std::pair 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, min_allocator> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// void insert(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// iterator insert(const_iterator position, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::set M; + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + M m; + m.insert(input_iterator(ar), + input_iterator(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, min_allocator> M; + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + M m; + m.insert(input_iterator(ar), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// iterator insert(const_iterator position, value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// pair insert(value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::set M; + typedef std::pair 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, min_allocator> M; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 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::iterator i; + i = m.begin(); + std::set::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 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::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, min_allocator> 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, min_allocator>::iterator i; + i = m.begin(); + std::set, min_allocator>::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, min_allocator> 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, min_allocator>::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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::set 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set M; + M m; + assert(m.max_size() != 0); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(const allocator_type& a); + +#include +#include + +#include "test_allocator.h" + +int main() +{ + typedef std::less C; + typedef test_allocator A; + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set& operator=(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// explicit set(const value_compare& comp); + +#include +#include + +#include "../../../test_compare.h" + +int main() +{ + typedef test_compare > C; + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(const value_compare& comp, const allocator_type& a); + +#include +#include + +#include "../../../test_compare.h" +#include "test_allocator.h" + +int main() +{ + typedef test_compare > C; + typedef test_allocator A; + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(const set& m); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::set 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 > C; + typedef other_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(const set& m, const allocator_type& a); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set& operator=(const set& s); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::set 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 m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::set *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 > C; + typedef other_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::set m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::set, min_allocator> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } + { + std::set 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() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +#endif + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(initializer_list il, const key_compare& comp = key_compare()); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(initializer_list il, const key_compare& comp = key_compare()); + +#include +#include +#include "../../../test_compare.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + typedef test_compare > Cmp; + typedef std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(initializer_list il, const key_compare& comp, const allocator_type& a); +// set(initializer_list il, const allocator_type& a); + +#include +#include +#include "../../../test_compare.h" +#include "test_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef test_compare > Cmp; + typedef test_allocator A; + typedef std::set 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 > Cmp; + typedef test_allocator A; + typedef std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// template +// set(InputIterator first, InputIterator last); + +#include +#include + +#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 m(input_iterator(ar), + input_iterator(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, min_allocator> m(input_iterator(ar), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// template +// set(InputIterator first, InputIterator last, +// const value_compare& comp, const allocator_type& a); +// +// template +// set(InputIterator first, InputIterator last, +// const allocator_type& a); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::set m(input_iterator(ar), + input_iterator(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 A; + typedef test_compare > C; + A a(7); + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// template +// set(InputIterator first, InputIterator last, const value_compare& comp); + +#include +#include + +#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 > C; + std::set m(input_iterator(ar), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(set&& s); + +#include +#include + +#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 > C; + typedef test_allocator A; + std::set mo(C(5), A(7)); + std::set 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 > C; + typedef test_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::set 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 > C; + typedef min_allocator A; + std::set mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set(set&& s, const allocator_type& a); + +#include +#include + +#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 > C; + typedef test_allocator A; + typedef std::set M; + typedef std::move_iterator 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 > C; + typedef test_allocator A; + typedef std::set M; + typedef std::move_iterator 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 > C; + typedef other_allocator A; + typedef std::set M; + typedef std::move_iterator 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 V; + typedef std::less C; + typedef test_allocator A; + typedef std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// set& operator=(set&& s); + +#include +#include + +#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 > C; + typedef test_allocator A; + typedef std::set M; + typedef std::move_iterator 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 > C; + typedef test_allocator A; + typedef std::set M; + typedef std::move_iterator 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 > C; + typedef other_allocator A; + typedef std::set M; + typedef std::move_iterator 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 > C; + typedef min_allocator A; + typedef std::set M; + typedef std::move_iterator 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& operator=(set&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::set C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::set, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::set, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::set> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// void swap(set& m); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int V; + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// void swap(set& m); + +#include +#include +#include "test_allocator.h" +#include "../../../test_compare.h" + +int main() +{ + typedef int V; + typedef std::set 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 A; + typedef test_compare > C; + typedef std::set 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 A; + typedef test_compare > C; + typedef std::set 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(set& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// noexcept(swap(declval(), declval()))); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +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 +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::set, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::set, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::set> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + +#if TEST_STD_VER >= 14 + { // POCS allocator, throwable swap for comp + typedef std::set, some_alloc > C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, throwable swap for comp + typedef std::set, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for comp + typedef std::set, some_alloc > C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + { // always equal allocator, nothrow swap for comp + typedef std::set, some_alloc2> C; + C c1, c2; + static_assert( noexcept(swap(c1, c2)), ""); + } + + { // NOT always equal allocator, nothrow swap for comp + typedef std::set, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// size_type size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Allocator = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::set C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::set, min_allocator> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); +// min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class set + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" +#include "private_constructor.hpp" + +int main() +{ + { + typedef int V; + typedef std::set 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, min_allocator> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +// void +// __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) + +#include <__tree> +#include + +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 +// void +// __tree_left_rotate(_NodePtr __x); + +#include <__tree> +#include + +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 +// void +// __tree_remove(_NodePtr __root, _NodePtr __z) + +#include <__tree> +#include + +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 +// void +// __tree_right_rotate(_NodePtr __x); + +#include <__tree> +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// explicit priority_queue(const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +struct test + : public std::priority_queue > > +{ + typedef std::priority_queue > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator& a) : base(a) {} + test(const value_compare& comp, const test_allocator& a) + : base(comp, c, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + test q((test_allocator(3))); + assert(q.c.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(const Compare& comp, const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +struct test + : public std::priority_queue > > +{ + typedef std::priority_queue > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator& a) : base(a) {} + test(const value_compare& comp, const test_allocator& a) + : base(comp, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + test q(std::less(), test_allocator(3)); + assert(q.c.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(const Compare& comp, const container_type& c, +// const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +template +struct test + : public std::priority_queue > > +{ + typedef std::priority_queue > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator& a) : base(a) {} + test(const value_compare& comp, const test_allocator& a) + : base(comp, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + typedef std::vector > C; + C v = make(5); + test q(std::less(), v, test_allocator(3)); + assert(q.c.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(const Compare& comp, container_type&& c, +// const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +template +struct test + : public std::priority_queue > > +{ + typedef std::priority_queue > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator& a) : base(a) {} + test(const value_compare& comp, const test_allocator& a) + : base(comp, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator& a) : base(comp, c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(const value_compare& comp, container_type&& c, + const test_allocator& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + typedef std::vector > C; + test q(std::less(), make(5), test_allocator(3)); + assert(q.c.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(const priority_queue& q, const Alloc& a); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +#include "test_allocator.h" + +template +struct test + : public std::priority_queue > > +{ + typedef std::priority_queue > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator& a) : base(a) {} + test(const value_compare& comp, const test_allocator& a) + : base(comp, c, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator& a) : base(comp, c, a) {} + test(const test& q, const test_allocator& a) : base(q, a) {} + test_allocator get_allocator() {return c.get_allocator();} + + using base::c; +}; + +int main() +{ + test qo(std::less(), + make > >(5), + test_allocator(2)); + test q(qo, test_allocator(6)); + assert(q.size() == 5); + assert(q.c.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(priority_queue&& q, const Alloc& a); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 +struct test + : public std::priority_queue > > +{ + typedef std::priority_queue > > base; + typedef typename base::container_type container_type; + typedef typename base::value_compare value_compare; + + explicit test(const test_allocator& a) : base(a) {} + test(const value_compare& comp, const test_allocator& a) + : base(comp, c, a) {} + test(const value_compare& comp, const container_type& c, + const test_allocator& a) : base(comp, c, a) {} + test(const value_compare& comp, container_type&& c, + const test_allocator& a) : base(comp, std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} + test_allocator get_allocator() {return c.get_allocator();} + + using base::c; +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test qo(std::less(), + make > >(5), + test_allocator(2)); + test q(std::move(qo), test_allocator(6)); + assert(q.size() == 5); + assert(q.c.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue& operator=(const priority_queue&) = default; + +#include +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::vector v = make >(5); + std::priority_queue, std::greater > qo(std::greater(), v); + std::priority_queue, std::greater > 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue& operator=(priority_queue&& q); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 qo(std::less(), make >(5)); + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit priority_queue(const Compare& comp); + +#include +#include + +#include "../../../stack_allocator.h" + +int main() +{ + std::priority_queue > > q((std::less())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit priority_queue(const Compare& comp, const container_type& c); + +#include +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::vector v = make >(5); + std::priority_queue, std::greater > q(std::greater(), 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit priority_queue(const Compare& comp, container_type&& c); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 q(std::less(), make >(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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(const priority_queue&) = default; + +#include +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::vector v = make >(5); + std::priority_queue, std::greater > qo(std::greater(), v); + std::priority_queue, std::greater > 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +#include +#include + +#include "../../../stack_allocator.h" + +int main() +{ + std::priority_queue > > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(InputIterator first, InputIterator last); + +#include +#include + +int main() +{ + int a[] = {3, 5, 2, 0, 6, 8, 1}; + int* an = a + sizeof(a)/sizeof(a[0]); + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(InputIterator first, InputIterator last, const Compare& comp); + +#include +#include +#include + +int main() +{ + int a[] = {3, 5, 2, 0, 6, 8, 1}; + int* an = a + sizeof(a)/sizeof(a[0]); + std::priority_queue, std::greater > + q(a, an, std::greater()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(InputIterator first, InputIterator last, +// const Compare& comp, const container_type& c); + +#include +#include + +int main() +{ + int a[] = {3, 5, 2, 0, 6, 8, 1}; + const int n = sizeof(a)/sizeof(a[0]); + std::vector v(a, a+n/2); + std::priority_queue q(a+n/2, a+n, std::less(), 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// priority_queue(InputIterator first, InputIterator last, +// const Compare& comp, container_type&& c); + +#include +#include + +#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 q(a+n/2, a+n, + std::less(), + std::vector(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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(priority_queue&& q); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 qo(std::less(), make >(5)); + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue() +// noexcept(is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::priority_queue C; + static_assert(std::is_nothrow_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// ~priority_queue() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::priority_queue C; + static_assert(std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue& operator=(priority_queue&& c) +// noexcept(is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::priority_queue C; + static_assert(std::is_nothrow_move_assignable::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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(priority_queue&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::priority_queue C; + static_assert(std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// template void emplace(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// bool empty() const; + +#include +#include + +int main() +{ + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// void pop(); + +#include +#include + +int main() +{ + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// void push(const value_type& v); + +#include +#include + +int main() +{ + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// void push(value_type&& v); + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// size_type size() const; + +#include +#include + +int main() +{ + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// void swap(priority_queue& q); + +#include +#include + +int main() +{ + std::priority_queue q1; + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// const_reference top() const; + +#include +#include + +int main() +{ + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// priority_queue(); + +// template +// void swap(priority_queue& x, +// priority_queue& y); + +#include +#include + +int main() +{ + std::priority_queue q1; + std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(priority_queue& c) +// noexcept(__is_nothrow_swappable::value && +// __is_nothrow_swappable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::priority_queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Compare = less> +// 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 +#include +#include + +struct test + : private std::priority_queue +{ + 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::container_type, std::vector >::value), ""); + static_assert((std::is_same >::container_type, std::deque >::value), ""); + static_assert((std::is_same >::value_type, int>::value), ""); + static_assert((std::is_same::reference, std::vector::reference>::value), ""); + static_assert((std::is_same::const_reference, std::vector::const_reference>::value), ""); + static_assert((std::is_same::size_type, std::vector::size_type>::value), ""); + static_assert((std::uses_allocator, std::allocator >::value), ""); + static_assert((!std::uses_allocator, std::allocator >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// explicit queue(const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +struct test + : private std::queue > > +{ + typedef std::queue > > base; + + explicit test(const test_allocator& a) : base(a) {} + test(const container_type& c, const test_allocator& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} +}; + +int main() +{ + test q(test_allocator(3)); + assert(q.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// queue(const container_type& c, const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +typedef std::deque > C; + +struct test + : public std::queue +{ + typedef std::queue base; + + explicit test(const test_allocator& a) : base(a) {} + test(const container_type& c, const test_allocator& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} +}; + +int main() +{ + C d = make(5); + test q(d, test_allocator(4)); + assert(q.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// queue(const queue& q, const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +typedef std::deque > C; + +template +struct test + : public std::queue +{ + typedef std::queue base; + typedef test_allocator 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 q(make(5), test_allocator(4)); + test q2(q, test_allocator(5)); + assert(q2.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// queue(const container_type& c, const Alloc& a); + +#include +#include + +#include "test_allocator.h" +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(MoveOnly(i)); + return c; +} + +typedef std::deque > C; + +template +struct test + : public std::queue +{ + typedef std::queue base; + typedef test_allocator 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 q(make(5), test_allocator(4)); + assert(q.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// queue(queue&& q, const Alloc& a); + +#include +#include + +#include "test_allocator.h" +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(MoveOnly(i)); + return c; +} + +typedef std::deque > C; + +template +struct test + : public std::queue +{ + typedef std::queue base; + typedef test_allocator 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 q(make(5), test_allocator(4)); + test q2(std::move(q), test_allocator(5)); + assert(q2.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit queue(const container_type& c); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::deque d = make >(5); + std::queue 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(const queue&) = default; + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::queue q(make >(5)); + std::queue 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(); + +#include +#include + +#include "../../../stack_allocator.h" + +int main() +{ + std::queue > > 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&& q); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 q(make >(5)); + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit queue(container_type&& c); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 q(make >(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() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue C; + static_assert(std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue C; + static_assert(std::is_nothrow_destructible::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& operator=(queue&& c) +// noexcept(is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue C; + static_assert(std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue C; + static_assert(std::is_nothrow_move_constructible::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& operator=(const queue& q); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::queue q(make >(5)); + std::queue 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& operator=(queue&& q); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 q(make >(5)); + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference back(); + +#include +#include + +int main() +{ + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_reference back() const; + +#include +#include + +int main() +{ + std::queue q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + const std::queue& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// bool empty() const; + +#include +#include + +int main() +{ + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference front(); + +#include +#include + +int main() +{ + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_reference front() const; + +#include +#include + +int main() +{ + std::queue q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + const std::queue& 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop(); + +#include +#include + +int main() +{ + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push(const value_type& v); + +#include +#include + +int main() +{ + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push(value_type&& v); + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type size() const; + +#include +#include + +int main() +{ + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(queue& q); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::queue q1 = make >(5); + std::queue q2 = make >(10); + std::queue q1_save = q1; + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include + +struct test + : private std::queue +{ + 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::container_type, std::deque >::value), ""); + static_assert((std::is_same >::container_type, std::vector >::value), ""); + static_assert((std::is_same >::value_type, int>::value), ""); + static_assert((std::is_same::reference, std::deque::reference>::value), ""); + static_assert((std::is_same::const_reference, std::deque::const_reference>::value), ""); + static_assert((std::is_same::size_type, std::deque::size_type>::value), ""); + static_assert((std::uses_allocator, std::allocator >::value), ""); + static_assert((!std::uses_allocator, std::allocator >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator==(const queue& x,const queue& y); +// +// template +// bool operator!=(const queue& x,const queue& y); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::queue q1 = make >(5); + std::queue q2 = make >(10); + std::queue q1_save = q1; + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator< (const queue& x,const queue& y); +// +// template +// bool operator> (const queue& x,const queue& y); +// +// template +// bool operator>=(const queue& x,const queue& y); +// +// template +// bool operator<=(const queue& x,const queue& y); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::queue q1 = make >(5); + std::queue q2 = make >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(queue& x, queue& y); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::queue q1 = make >(5); + std::queue q2 = make >(10); + std::queue q1_save = q1; + std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(queue& c) +// noexcept(__is_nothrow_swappable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::queue 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// explicit stack(const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +struct test + : private std::stack > > +{ + typedef std::stack > > base; + + explicit test(const test_allocator& a) : base(a) {} + test(const container_type& c, const test_allocator& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} +}; + +int main() +{ + test q(test_allocator(3)); + assert(q.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// stack(const container_type& c, const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +typedef std::deque > C; + +struct test + : public std::stack +{ + typedef std::stack base; + + explicit test(const test_allocator& a) : base(a) {} + test(const container_type& c, const test_allocator& a) : base(c, a) {} +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(container_type&& c, const test_allocator& a) : base(std::move(c), a) {} + test(test&& q, const test_allocator& a) : base(std::move(q), a) {} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_allocator get_allocator() {return c.get_allocator();} +}; + +int main() +{ + C d = make(5); + test q(d, test_allocator(4)); + assert(q.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// stack(const stack& q, const Alloc& a); + +#include +#include + +#include "test_allocator.h" + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(int(i)); + return c; +} + +typedef std::deque > C; + +template +struct test + : public std::stack +{ + typedef std::stack base; + typedef test_allocator 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 q(make(5), test_allocator(4)); + test q2(q, test_allocator(5)); + assert(q2.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// stack(const container_type& c, const Alloc& a); + +#include +#include + +#include "test_allocator.h" +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(MoveOnly(i)); + return c; +} + +typedef std::deque > C; + +template +struct test + : public std::stack +{ + typedef std::stack base; + typedef test_allocator 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 q(make(5), test_allocator(4)); + assert(q.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// stack(stack&& q, const Alloc& a); + +#include +#include + +#include "test_allocator.h" +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(MoveOnly(i)); + return c; +} + +typedef std::deque > C; + +template +struct test + : public std::stack +{ + typedef std::stack base; + typedef test_allocator 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 q(make(5), test_allocator(4)); + test q2(std::move(q), test_allocator(5)); + assert(q2.get_allocator() == test_allocator(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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit stack(const container_type& c); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::deque d = make >(5); + std::stack 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(const stack&) = default; + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::stack q(make >(5)); + std::stack 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(); + +#include +#include +#include + +#include "../../../stack_allocator.h" + +int main() +{ + std::stack > > 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&& q); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 q(make >(5)); + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit stack(container_type&& c); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 q(make >(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() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_destructible::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& operator=(stack&& c) +// noexcept(is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack C; + static_assert(std::is_nothrow_move_constructible::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& operator=(const stack& q); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push_back(i); + return c; +} + +int main() +{ + std::stack q(make >(5)); + std::stack 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& operator=(stack&& q); + +#include +#include + +#include "MoveOnly.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 q(make >(5)); + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// bool empty() const; + +#include +#include + +int main() +{ + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop(); + +#include +#include + +int main() +{ + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push(const value_type& v); + +#include +#include + +int main() +{ + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push(value_type&& v); + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type size() const; + +#include +#include + +int main() +{ + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(stack& q); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::stack q1 = make >(5); + std::stack q2 = make >(10); + std::stack q1_save = q1; + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference top(); + +#include +#include + +int main() +{ + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_reference top() const; + +#include +#include + +int main() +{ + std::stack q; + assert(q.size() == 0); + q.push(1); + q.push(2); + q.push(3); + const std::stack& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include +#include + +struct test + : private std::stack +{ + 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::container_type, std::deque >::value), ""); + static_assert((std::is_same >::container_type, std::vector >::value), ""); + static_assert((std::is_same >::value_type, int>::value), ""); + static_assert((std::is_same::reference, std::deque::reference>::value), ""); + static_assert((std::is_same::const_reference, std::deque::const_reference>::value), ""); + static_assert((std::is_same::size_type, std::deque::size_type>::value), ""); + static_assert((std::uses_allocator, std::allocator >::value), ""); + static_assert((!std::uses_allocator, std::allocator >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator==(const stack& x,const stack& y); +// +// template +// bool operator!=(const stack& x,const stack& y); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::stack q1 = make >(5); + std::stack q2 = make >(10); + std::stack q1_save = q1; + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator< (const stack& x,const stack& y); +// +// template +// bool operator> (const stack& x,const stack& y); +// +// template +// bool operator>=(const stack& x,const stack& y); +// +// template +// bool operator<=(const stack& x,const stack& y); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::stack q1 = make >(5); + std::stack q2 = make >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(stack& x, stack& y); + +#include +#include + +template +C +make(int n) +{ + C c; + for (int i = 0; i < n; ++i) + c.push(i); + return c; +} + +int main() +{ + std::stack q1 = make >(5); + std::stack q2 = make >(10); + std::stack q1_save = q1; + std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(stack& c) +// noexcept(__is_nothrow_swappable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::stack 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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(); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array C; + C c; + assert(c.size() == 3); + } + { + typedef double T; + typedef std::array 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. +// +//===----------------------------------------------------------------------===// + +// + +// Construct with initizializer list + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// T *data(); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// const T* data() const; + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void fill(const T& u); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr size_type array::size(); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void swap(array& x, array& y); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(array& a); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T& get(array& a); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T& get(array& a); + +#include +#include + +#if __cplusplus > 201103L +struct S { + std::array a; + int k; + constexpr S() : a{1,2,3}, k(std::get<2>(a)) {} + }; + +constexpr std::array getArr () { return { 3, 4 }; } +#endif + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template const T& get(const array& a); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T&& get(array&& a); + +#include +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unique_ptr T; + typedef std::array C; + C c = {std::unique_ptr(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. +// +//===----------------------------------------------------------------------===// + +// + +// tuple_element >::type + +#include +#include + +template +void test() +{ + { + typedef T Exp; + typedef std::array C; + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + } + { + typedef T const Exp; + typedef std::array const C; + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + } + { + typedef T volatile Exp; + typedef std::array volatile C; + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + } + { + typedef T const volatile Exp; + typedef std::array const volatile C; + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + static_assert((std::is_same::type, Exp>::value), ""); + } +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// tuple_size >::value + +#include + +template +void test() +{ + { + typedef std::array C; + static_assert((std::tuple_size::value == N), ""); + } + { + typedef std::array C; + static_assert((std::tuple_size::value == N), ""); + } + { + typedef std::array C; + static_assert((std::tuple_size::value == N), ""); + } + { + typedef std::array C; + static_assert((std::tuple_size::value == N), ""); + } +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// support for zero-sized array + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator begin(); + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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. +// +//===----------------------------------------------------------------------===// + +// + +// An array is a contiguous container + +#include +#include + +template +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference front(); +// reference back(); +// const_reference front(); // constexpr in C++14 +// const_reference back(); // constexpr in C++14 + +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +int main() +{ + { + typedef double T; + typedef std::array 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator, const_iterator + +#include +#include +#include + +int main() +{ + { + typedef std::array C; + C c; + C::iterator i; + i = c.begin(); + C::const_iterator j; + j = c.cbegin(); + assert(i == j); + } + { + typedef std::array 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 reverse_iterator; +// typedef std::reverse_iterator const_reverse_iterator; + +#include +#include +#include + +int main() +{ + { + typedef double T; + typedef std::array C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + } + { + typedef int* T; + typedef std::array C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "min_allocator.h" + +template +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 c = make >(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 c = make >(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> c = make> >(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> c = make> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type n); + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +void +testN(int start, int N, int M) +{ + typedef typename C::const_iterator CI; + C c1 = make(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 >(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>>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type n, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +void +testN(int start, int N, int M) +{ + typedef typename C::const_iterator CI; + C c1 = make(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 >(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>>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void shrink_to_fit(); + +#include +#include + +#include "min_allocator.h" + +template +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 +void +test(C& c1) +{ + C s = c1; + c1.shrink_to_fit(); + assert(c1 == s); +} + +template +void +testN(int start, int N) +{ + typedef typename C::const_iterator CI; + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit deque(const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "../../../NotConstructible.h" +#include "min_allocator.h" + +template +void +test(const Allocator& a) +{ + std::deque d(a); + assert(d.size() == 0); + assert(d.get_allocator() == a); +} + +int main() +{ + test(std::allocator()); + test(test_allocator(3)); +#if __cplusplus >= 201103L + test(min_allocator()); + test(min_allocator{}); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::deque 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void assign(InputIterator f, InputIterator l); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 +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 +void +testN(int start, int N, int M) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + C c1 = make(N, start); + C c2 = make(M); + test(c1, c2); +} + +template +void +testI(C& c1, const C& c2) +{ + typedef typename C::const_iterator CI; + typedef input_iterator 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 +void +testNI(int start, int N, int M) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + C c1 = make(N, start); + C c2 = make(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 >(rng[i], rng[j], rng[k]); + testNI >(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> >(rng[i], rng[j], rng[k]); + testNI> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(size_type n, const value_type& v); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 +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 +void +testN(int start, int N, int M) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + C c1 = make(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 >(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> >(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(const deque&); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +template +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(ab, an)); + } + { + std::deque > v(3, 2, test_allocator(5)); + std::deque > v2 = v; + assert(v2 == v); + assert(v2.get_allocator() == v.get_allocator()); + } +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + { + std::deque > v(3, 2, other_allocator(5)); + std::deque > v2 = v; + assert(v2 == v); + assert(v2.get_allocator() == other_allocator(-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>(ab, an)); + } + { + std::deque > v(3, 2, min_allocator()); + std::deque > 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(const deque& c, const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 >(ab, an, test_allocator(3)), + test_allocator(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 >(ab, an, other_allocator(3)), + other_allocator(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 >(ab, an, min_allocator()), + min_allocator()); + } +#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() + +#include +#include + +#include "../../../stack_allocator.h" +#include "../../../NotConstructible.h" +#include "min_allocator.h" + +template +void +test() +{ + std::deque d; + assert(d.size() == 0); +#if __cplusplus >= 201103L + std::deque d1 = {}; + assert(d1.size() == 0); +#endif +} + +int main() +{ + test >(); + test >(); +#if __cplusplus >= 201103L + test >(); + test >(); +#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() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::deque C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::deque> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::deque> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::deque> C; + static_assert(!std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::deque> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::deque> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::deque> C; + static_assert(!std::is_nothrow_destructible::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(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::deque 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> 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(initializer_list il, const Allocator& a = allocator_type()); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::deque> d({3, 4, 5, 6}, test_allocator(3)); + assert(d.get_allocator() == test_allocator(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> d({3, 4, 5, 6}, min_allocator()); + assert(d.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template deque(InputIterator f, InputIterator l); + +#include +#include + +#include "../../../stack_allocator.h" +#include "test_iterators.h" +#include "min_allocator.h" + +template +void +test(InputIterator f, InputIterator l) +{ + typedef typename std::iterator_traits::value_type T; + typedef std::allocator Allocator; + typedef std::deque 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 +void +test(InputIterator f, InputIterator l) +{ + typedef typename std::iterator_traits::value_type T; + typedef std::deque 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(ab), input_iterator(an)); + test(forward_iterator(ab), forward_iterator(an)); + test(bidirectional_iterator(ab), bidirectional_iterator(an)); + test(random_access_iterator(ab), random_access_iterator(an)); + test >(ab, an); +#if __cplusplus >= 201103L + test >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// deque(InputIterator f, InputIterator l, const allocator_type& a); + +#include +#include + +#include "test_iterators.h" +#include "test_allocator.h" +#include "min_allocator.h" + +template +void +test(InputIterator f, InputIterator l, const Allocator& a) +{ + typedef typename std::iterator_traits::value_type T; + typedef std::deque 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(ab), input_iterator(an), test_allocator(3)); + test(forward_iterator(ab), forward_iterator(an), test_allocator(4)); + test(bidirectional_iterator(ab), bidirectional_iterator(an), test_allocator(5)); + test(random_access_iterator(ab), random_access_iterator(an), test_allocator(6)); +#if __cplusplus >= 201103L + test(input_iterator(ab), input_iterator(an), min_allocator()); + test(forward_iterator(ab), forward_iterator(an), min_allocator()); + test(bidirectional_iterator(ab), bidirectional_iterator(an), min_allocator()); + test(random_access_iterator(ab), random_access_iterator(an), min_allocator()); +#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&&); + +#include +#include + +#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 A; + std::deque c1(A(1)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(2)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A(1)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(2)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A{}); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A{}); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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&& c, const allocator_type& a); + +#include +#include + +#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 A; + std::deque c1(A(1)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(1)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A(1)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(1)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A(1)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(1)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A{}); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A{}); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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& operator=(deque&& c); + +#include +#include + +#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 A; + std::deque c1(A(5)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(5)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A(5)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(5)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A(5)); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A(5)); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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 A; + std::deque c1(A{}); + for (int* p = ab; p < an; ++p) + c1.push_back(MoveOnly(*p)); + std::deque c2(A{}); + for (int* p = ab; p < an; ++p) + c2.push_back(MoveOnly(*p)); + std::deque 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& operator=(deque&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::deque C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::deque> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::deque> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::deque> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::deque C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::deque> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::deque> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::deque> C; + static_assert(!std::is_nothrow_move_constructible::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& operator=(const deque& c); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +template +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(ab, an)); + } + { + std::deque > l(3, 2, test_allocator(5)); + std::deque > l2(l, test_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == test_allocator(3)); + } + { + std::deque > l(3, 2, other_allocator(5)); + std::deque > l2(l, other_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(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>(ab, an)); + } + { + std::deque > l(3, 2, min_allocator()); + std::deque > l2(l, min_allocator()); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#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& operator=(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::deque 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit deque(size_type n); + +#include +#include + +#include "../../../stack_allocator.h" +#include "DefaultOnly.h" +#include "min_allocator.h" + +template +void +test2(unsigned n) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::deque 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 +void +test1(unsigned n) +{ + typedef std::deque 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 +void +test3(unsigned n, Allocator const &alloc = Allocator()) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::deque C; + typedef typename C::const_iterator const_iterator; + { + C d(n, alloc); + assert(d.size() == n); + assert(d.get_allocator() == alloc); + } +#endif +} + +template +void +test(unsigned n) +{ + test1 ( n ); + test2 ( n ); +} + +int main() +{ + test >(0); + test >(1); + test >(10); + test >(1023); + test >(1024); + test >(1025); + test >(2047); + test >(2048); + test >(2049); + test >(4095); + test >(4096); + test >(4097); + + test1 >(4095); + +#if __cplusplus >= 201103L + test >(4095); +#endif + +#if _LIBCPP_STD_VER > 11 + test3> (1023); + test3>(1); + test3> (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(size_type n, const value_type& v); + +#include +#include + +#include "../../../stack_allocator.h" +#include "min_allocator.h" + +template +void +test(unsigned n, const T& x) +{ + typedef std::deque 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 >(0, 5); + test >(1, 10); + test >(10, 11); + test >(1023, -11); + test >(1024, 25); + test >(1025, 0); + test >(2047, 110); + test >(2048, -500); + test >(2049, 654); + test >(4095, 78); + test >(4096, 1165); + test >(4097, 157); + test >(4095, 90); +#if __cplusplus >= 201103L + test >(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(size_type n, const value_type& v, const allocator_type& a); + +#include +#include + +#include "min_allocator.h" + +template +void +test(unsigned n, const T& x, const Allocator& a) +{ + typedef std::deque 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template iterator emplace(const_iterator p, Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 +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 +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(N, start); + test(i, c1); + } + } + for (int i = N/2-1; i <= N/2+1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + test(i, c1); + } + } + for (int i = N - 3; i <= N; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace_back(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 +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 +void +testN(int start, int N) +{ + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace_front(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 +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 +void +testN(int start, int N) +{ + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +template +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 +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase(const_iterator p) + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +template +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 +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 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 + +// + +// iterator erase(const_iterator f, const_iterator l) + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert(const_iterator p, initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::deque d(10, 1); + std::deque::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> d(10, 1); + std::deque>::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 + +// + +// template +// iterator insert (const_iterator p, InputIterator f, InputIterator l); + +#include +#include + +#include "test_iterators.h" +#include "MoveOnly.h" +#include "../../../stack_allocator.h" +#include "min_allocator.h" + +template +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 +void +test(int P, const C& c0, const C& c2) +{ + { + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + typedef input_iterator 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 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 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 +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(N, start); + C c2 = make(M); + test(i, c1, c2); + } + } + for (int i = M-1; i <= M+1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + test(i, c1, c2); + } + } + for (int i = N/2-1; i <= N/2+1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + test(i, c1, c2); + } + } + for (int i = N - M - 1; i <= N - M + 1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + test(i, c1, c2); + } + } + for (int i = N - M - 1; i <= N - M + 1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + test(i, c1, c2); + } + } + for (int i = N - 3; i <= N; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + test(i, c1, c2); + } + } +} + +template +void +testI(int P, C& c1, const C& c2) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + typedef input_iterator 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 +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(N, start); + C c2 = make(M); + testI(i, c1, c2); + } + } + for (int i = M-1; i <= M+1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + testI(i, c1, c2); + } + } + for (int i = N/2-1; i <= N/2+1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + testI(i, c1, c2); + } + } + for (int i = N - M - 1; i <= N - M + 1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + testI(i, c1, c2); + } + } + for (int i = N - 3; i <= N; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + C c2 = make(M); + testI(i, c1, c2); + } + } +} + +template +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(&mo), std::move_iterator(&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 I; + c.insert(c.end(), std::move_iterator(I(&mo)), std::move_iterator(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 >(rng[i], rng[j], rng[k]); + testNI >(1500, 2000, 1000); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_move > >(); +#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> >(rng[i], rng[j], rng[k]); + testNI >(1500, 2000, 1000); + test_move > >(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert (const_iterator p, value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 +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 +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(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(N, start); + test(i, c1, -10); + } + } + for (int i = N - 3; i <= N; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(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 >(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> >(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 + +// + +// iterator insert (const_iterator p, size_type n, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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(N, start); + test(i, c1, M, -10); + } + } + for (int i = M-1; i <= M+1; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(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(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(N, start); + test(i, c1, M, -10); + } + } + for (int i = N - 3; i <= N; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + test(i, c1, M, -10); + } + } +} + +template +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(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 >(rng[i], rng[j], rng[k]); + self_reference_test >(); + } +#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> >(rng[i], rng[j], rng[k]); + self_reference_test> >(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert (const_iterator p, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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(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(N, start); + test(i, c1, -10); + } + } + for (int i = N - 3; i <= N; ++i) + { + if (0 <= i && i <= N) + { + C c1 = make(N, start); + test(i, c1, -10); + } + } +} + +template +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(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 >(rng[i], rng[j]); + self_reference_test >(); + } +#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> >(rng[i], rng[j]); + self_reference_test> >(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +template +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop_back() + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +void +testN(int start, int N) +{ + if (N != 0) + { + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +template +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop_front() + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +void +testN(int start, int N) +{ + if (N != 0) + { + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(const value_type& v); +// void pop_back(); +// void pop_front(); + +#include +#include + +#include "min_allocator.h" + +template +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 +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(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(const value_type& x); + +#include +#include "test_allocator.h" +#include + +// 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 vec; + + vec.push_back(instance); + std::deque vec2(vec); + + gCopyConstructorShouldThow = true; + try { + vec.push_back(instance); + assert(false); + } + catch (...) { + gCopyConstructorShouldThow = false; + assert(vec==vec2); + } + } + + { + typedef std::deque > 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(value_type&& v); +// void pop_back(); +// void pop_front(); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 +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(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(const value_type& v); + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +void +testN(int start, int N) +{ + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(const value_type& x); + +#include +#include +#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 vec; + + vec.push_front(instance); + std::deque vec2(vec); + + gCopyConstructorShouldThow = true; + try { + vec.push_front(instance); + assert(false); + } + catch (...) { + gCopyConstructorShouldThow = false; + assert(vec==vec2); + } + } + + { + typedef std::deque > 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 +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 +void +testN(int start, int N) +{ + C c1 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// Optimization for deque::iterators + +// template +// OutputIterator +// copy(InputIterator first, InputIterator last, OutputIterator result); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 +void testN(int start, int N) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + typedef random_access_iterator RAI; + typedef random_access_iterator RACI; + typedef input_iterator ICI; + C c1 = make(N, start); + C c2 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// Optimization for deque::iterators + +// template +// OutputIterator +// copy_backward(InputIterator first, InputIterator last, OutputIterator result); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 +void testN(int start, int N) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + typedef random_access_iterator RAI; + typedef random_access_iterator RACI; + C c1 = make(N, start); + C c2 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// Optimization for deque::iterators + +// template +// OutputIterator +// move(InputIterator first, InputIterator last, OutputIterator result); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 +void testN(int start, int N) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + typedef random_access_iterator RAI; + typedef random_access_iterator RACI; + C c1 = make(N, start); + C c2 = make(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 >(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> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// Optimization for deque::iterators + +// template +// OutputIterator +// move_backward(InputIterator first, InputIterator last, OutputIterator result); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 +void testN(int start, int N) +{ + typedef typename C::iterator I; + typedef typename C::const_iterator CI; + typedef random_access_iterator RAI; + typedef random_access_iterator RACI; + C c1 = make(N, start); + C c2 = make(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 >(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 > >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(deque& x, deque& y); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 +void testN(int start, int N, int M) +{ + C c1 = make(N, start); + C c2 = make(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 >(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 A; + std::deque c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); + std::deque c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); + swap(c1, c2); + assert((c1 == std::deque(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A(1)); + assert((c2 == std::deque(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 A; + std::deque c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); + std::deque c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); + swap(c1, c2); + assert((c1 == std::deque(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A(2)); + assert((c2 == std::deque(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> >(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 A; + std::deque c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A()); + std::deque c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A()); + swap(c1, c2); + assert((c1 == std::deque(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A()); + assert((c2 == std::deque(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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(deque& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::deque> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::deque> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::deque> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Test nested types and default template args: + +// template > +// class deque; + +// iterator, const_iterator + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::deque 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> 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::iterator ii1{}, ii2{}; + std::deque::iterator ii4 = ii1; + std::deque::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 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. +// +//===----------------------------------------------------------------------===// + +// + +// Test nested types and default template args: + +// template > +// 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 reverse_iterator; +// typedef std::reverse_iterator const_reverse_iterator; +// }; + +#include +#include +#include + +#include "test_allocator.h" +#include "../../Copyable.h" +#include "min_allocator.h" + +template +void +test() +{ + typedef std::deque C; + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename C::reverse_iterator, + std::reverse_iterator >::value), ""); + static_assert((std::is_same< + typename C::const_reverse_iterator, + std::reverse_iterator >::value), ""); +} + +int main() +{ + test >(); + test >(); + test >(); + static_assert((std::is_same::allocator_type, + std::allocator >::value), ""); +#if __cplusplus >= 201103L + { + typedef std::deque> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); +// min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// reference front(); +// const_reference front() const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit forward_list(const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "../../../NotConstructible.h" + +int main() +{ + { + typedef test_allocator A; + typedef A::value_type T; + typedef std::forward_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit forward_list(const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "../../../NotConstructible.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_allocator A; + typedef A::value_type T; + typedef std::forward_list C; + C c(A(12)); + assert(c.get_allocator() == A(12)); + assert(c.empty()); + } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef A::value_type T; + typedef std::forward_list 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& operator=(const forward_list& x); + +#include +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef test_allocator A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(initializer_list il); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef int T; + typedef std::forward_list 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 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> 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> 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& operator=(forward_list&& x); + +#include +#include +#include + +#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 A; + typedef std::forward_list C; + T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + T t1[] = {10, 11, 12, 13}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + T t1[] = {10, 11, 12, 13}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {10, 11, 12, 13}; + T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {10, 11, 12, 13}; + T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + T t1[] = {10, 11, 12, 13}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + T t1[] = {10, 11, 12, 13}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {10, 11, 12, 13}; + T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {10, 11, 12, 13}; + T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + T t1[] = {10, 11, 12, 13}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t0[] = {10, 11, 12, 13}; + T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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& operator=(initializer_list il); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef int T; + typedef std::forward_list 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 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void assign(InputIterator first, InputIterator last); + +#include +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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 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 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 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> 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 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> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(size_type n, const value_type& v); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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 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> 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> 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(const forward_list& x); + +#include +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef test_allocator A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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(const forward_list& x, const allocator_type& a); + +#include +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef test_allocator A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list C; + C c; + assert(c.empty()); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> C; + C c; + assert(c.empty()); + } + { + typedef int T; + typedef std::forward_list 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() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(!std::is_nothrow_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// class forward_list + +// forward_list(); + +#include + +struct X +{ + std::forward_list 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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(!std::is_nothrow_destructible::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(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef int T; + typedef std::forward_list 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> 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(initializer_list il, const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef int T; + typedef test_allocator A; + typedef std::forward_list 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 A; + typedef std::forward_list 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&& x); + +#include +#include +#include + +#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 A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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&& x, const allocator_type& a); + +#include +#include +#include + +#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 A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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 A; + typedef std::forward_list C; + T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + typedef std::move_iterator 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& operator=(forward_list&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::forward_list> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::forward_list> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::forward_list> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::forward_list C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::forward_list> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// forward_list(InputIterator first, InputIterator last); + +#include +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list C; + typedef input_iterator 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> C; + typedef input_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// forward_list(InputIterator first, InputIterator last, +// const allocator_type& a); + +#include +#include +#include + +#include "test_allocator.h" +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef test_allocator A; + typedef std::forward_list C; + typedef input_iterator 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 A; + typedef std::forward_list C; + typedef input_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit forward_list(size_type n); + +#include +#include + +#include "DefaultOnly.h" + +int main() +{ + { + typedef DefaultOnly T; + typedef std::forward_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit forward_list(size_type n); +// explicit forward_list(size_type n, const Alloc& a); + +#include +#include + +#include "DefaultOnly.h" +#include "min_allocator.h" + +template +void check_allocator(unsigned n, Allocator const &alloc = Allocator()) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::forward_list 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 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> 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> ( 0 ); + check_allocator> ( 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(size_type n, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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(size_type n, const value_type& v, const allocator_type& a); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_allocator A; + typedef A::value_type T; + typedef std::forward_list 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 A; + typedef A::value_type T; + typedef std::forward_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator before_begin(); +// const_iterator before_begin() const; +// const_iterator cbefore_begin() const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list C; + C c; + C::iterator i = c.before_begin(); + assert(std::distance(i, c.end()) == 1); + } + { + typedef int T; + typedef std::forward_list 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 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 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 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> C; + C c; + C::iterator i = c.before_begin(); + assert(std::distance(i, c.end()) == 1); + } + { + typedef int T; + typedef std::forward_list> 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> 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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 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 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 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 C; + C::iterator i; + C::const_iterator j; + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> 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> 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> 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> 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> C; + C::iterator i; + C::const_iterator j; + } +#endif +#if _LIBCPP_STD_VER > 11 + { // N3644 testing + std::forward_list::iterator ii1{}, ii2{}; + std::forward_list::iterator ii4 = ii1; + std::forward_list::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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void clear(); + +#include +#include + +#include "../../../NotConstructible.h" +#include "min_allocator.h" + +int main() +{ + { + typedef NotConstructible T; + typedef std::forward_list C; + C c; + c.clear(); + assert(distance(c.begin(), c.end()) == 0); + } + { + typedef int T; + typedef std::forward_list 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> C; + C c; + c.clear(); + assert(distance(c.begin(), c.end()) == 0); + } + { + typedef int T; + typedef std::forward_list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// iterator emplace_after(const_iterator p, Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef Emplaceable T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace_front(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef Emplaceable T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase_after(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase_after(const_iterator p); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert_after(const_iterator p, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert_after(const_iterator p, initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// iterator insert_after(const_iterator p, +// InputIterator first, InputIterator last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list C; + typedef C::iterator I; + typedef input_iterator 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> C; + typedef C::iterator I; + typedef input_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert_after(const_iterator p, value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef MoveOnly T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert_after(const_iterator p, size_type n, const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop_front(); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list C; + typedef std::forward_list 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 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> C; + typedef std::forward_list> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(const value_type& v); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(const value_type& x); + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(value_type&& v); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef MoveOnly T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type n); + +#include +#include + +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef DefaultOnly T; + typedef std::forward_list 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 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type n, const value_type& v); + +#include +#include + +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void merge(forward_list&& x); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void merge(forward_list&& x, Compare comp); + +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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()); + C c3(std::begin(t3), std::end(t3)); + assert(c1 == c3); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> 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()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// void remove(const value_type& v); + +#include +#include +#include + +#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 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 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 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 C; + C c1; + C c2; + c1.remove(0); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list 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 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 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> 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> 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> 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> C; + C c1; + C c2; + c1.remove(0); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void remove_if(Predicate pred); + +#include +#include +#include + +#include "min_allocator.h" +#include "counting_predicates.hpp" + + +bool g(int i) +{ + return i < 3; +} + +int main() +{ + { + typedef int T; + typedef unary_counting_predicate Predicate; + typedef std::forward_list 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 Predicate; + typedef std::forward_list 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 Predicate; + typedef std::forward_list 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 Predicate; + typedef std::forward_list 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 Predicate; + typedef std::forward_list 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 Predicate; + typedef std::forward_list> 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 Predicate; + typedef std::forward_list> 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 Predicate; + typedef std::forward_list> 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 Predicate; + typedef std::forward_list> 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 Predicate; + typedef std::forward_list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void reverse(); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 >(i); +#if __cplusplus >= 201103L + for (int i = 0; i < 10; ++i) + test> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void sort(); + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +template +void test(int N) +{ + typedef typename C::value_type T; + typedef std::vector 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 >(i); +#if __cplusplus >= 201103L + for (int i = 0; i < 40; ++i) + test> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template void sort(Compare comp); + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +template +void test(int N) +{ + typedef typename C::value_type T; + typedef std::vector 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()); + 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 >(i); +#if __cplusplus >= 201103L + for (int i = 0; i < 40; ++i) + test> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void splice_after(const_iterator p, forward_list&& x); + +#include +#include +#include + +#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 +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 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void splice_after(const_iterator p, forward_list&& x, const_iterator i); + +#include +#include +#include + +#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 +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 +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 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void splice_after(const_iterator p, forward_list&& x, +// const_iterator first, const_iterator last); + +#include +#include +#include + +#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 +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 +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 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void unique(); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list 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 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 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 C; + C c1; + C c2; + c1.unique(); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list 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> 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> 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> 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> C; + C c1; + C c2; + c1.unique(); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void unique(BinaryPredicate binary_pred); + +#include +#include +#include + +#include "min_allocator.h" + +bool g(int x, int y) +{ + return x == y; +} + +int main() +{ + { + typedef int T; + typedef std::forward_list 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 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 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 C; + C c1; + C c2; + c1.unique(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list 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> 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> 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> 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> C; + C c1; + C c2; + c1.unique(g); + assert(c1 == c2); + } + { + typedef int T; + typedef std::forward_list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator==(const forward_list& x, +// const forward_list& y); +// +// template +// bool operator!=(const forward_list& x, +// const forward_list& y); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 >(i, j); +#if __cplusplus >= 201103L + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + test> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(forward_list& x); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef test_allocator A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(forward_list& x, forward_list& y); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef test_allocator A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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 A; + typedef std::forward_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator< (const forward_list& x, +// const forward_list& y); +// +// template +// bool operator> (const forward_list& x, +// const forward_list& y); +// +// template +// bool operator>=(const forward_list& x, +// const forward_list& y); +// +// template +// bool operator<=(const forward_list& x, +// const forward_list& y); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 >(i, j); +#if __cplusplus >= 201103L + for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) + test> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(forward_list& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(is_always_equal::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::forward_list> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::forward_list> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::forward_list> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::forward_list C; + C c; + assert(c.max_size() > 0); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::forward_list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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::pointer pointer; +// typedef typename allocator_traits::const_pointer const_pointer; +// typedef typename allocator_traits::size_type size_type; +// typedef typename allocator_traits::difference_type difference_type; +// ... +// }; + +#include +#include + +#include "min_allocator.h" + +struct A { std::forward_list v; }; // incomplete type support + +int main() +{ + { + typedef std::forward_list C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::forward_list> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); +// min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// Call back() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call back() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::list C; + const C c; + assert(c.back() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call front() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::list C; + const C c; + assert(c.front() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call front() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Decrement iterator prior to begin. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::list C; + C c(1); + C::iterator i = c.end(); + T j = *i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Operations on "NULL" iterators + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0) + +#include +#include +#include +#include +#include + +struct S { int val; }; + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + unsigned lib_asserts; + + typedef S T; + typedef std::list 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include +#include +#include + +#include "min_allocator.h" + +struct A +{ + int first; + int second; +}; + +int main() +{ + { + typedef int T; + typedef std::list 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 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 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 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 C; + C::iterator i; + C::const_iterator j; + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::list> 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> 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> 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> 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> C; + C::iterator i; + C::const_iterator j; + } + { + typedef A T; + typedef std::list> 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 c; + std::list::iterator ii1{}, ii2{}; + std::list::iterator ii4 = ii1; + std::list::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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type sz); + +#include +#include +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ + { + std::list l(5, 2); + l.resize(2); + assert(l.size() == 2); + assert(std::distance(l.begin(), l.end()) == 2); + assert(l == std::list(2, 2)); + } + { + std::list 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 l(10); + l.resize(5); + assert(l.size() == 5); + assert(std::distance(l.begin(), l.end()) == 5); + } + { + std::list 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> l(5, 2); + l.resize(2); + assert(l.size() == 2); + assert(std::distance(l.begin(), l.end()) == 2); + assert((l == std::list>(2, 2))); + } + { + std::list> 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> l(10); + l.resize(5); + assert(l.size() == 5); + assert(std::distance(l.begin(), l.end()) == 5); + } + { + std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type sz, const value_type& x); + +#include +#include +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ + { + std::list l(5, 2); + l.resize(2, 3.5); + assert(l.size() == 2); + assert(std::distance(l.begin(), l.end()) == 2); + assert(l == std::list(2, 2)); + } + { + std::list 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> l(5, 2); + l.resize(2, 3.5); + assert(l.size() == 2); + assert(std::distance(l.begin(), l.end()) == 2); + assert((l == std::list>(2, 2))); + } + { + std::list> 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& operator=(const list& c); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::list > l(3, 2, test_allocator(5)); + std::list > l2(l, test_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == test_allocator(3)); + } + { + std::list > l(3, 2, other_allocator(5)); + std::list > l2(l, other_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(5)); + } +#if __cplusplus >= 201103L + { + std::list > l(3, 2, min_allocator()); + std::list > l2(l, min_allocator()); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::list d; + d.assign({3, 4, 5, 6}); + assert(d.size() == 4); + std::list::iterator i = d.begin(); + assert(*i++ == 3); + assert(*i++ == 4); + assert(*i++ == 5); + assert(*i++ == 6); + } +#if __cplusplus >= 201103L + { + std::list> d; + d.assign({3, 4, 5, 6}); + assert(d.size() == 4); + std::list>::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& operator=(list&& c); + +#include +#include +#include "MoveOnly.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list > l(test_allocator(5)); + std::list > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(test_allocator(5)); + l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } + { + std::list > l(test_allocator(5)); + std::list > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(test_allocator(6)); + l2 = std::move(l); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == test_allocator(6)); + } + { + std::list > l(other_allocator(5)); + std::list > lo(other_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(other_allocator(6)); + l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#if __cplusplus >= 201103L + { + std::list > l(min_allocator{}); + std::list > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(min_allocator{}); + 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(const list& c); + +#include +#include +#include "DefaultOnly.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::list l(3, 2); + std::list l2 = l; + assert(l2 == l); + } + { + std::list > l(3, 2, test_allocator(5)); + std::list > l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == l.get_allocator()); + } +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + { + std::list > l(3, 2, other_allocator(5)); + std::list > l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(-2)); + } +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if __cplusplus >= 201103L + { + std::list> l(3, 2); + std::list> l2 = l; + assert(l2 == l); + } + { + std::list > l(3, 2, min_allocator()); + std::list > 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(const list& c, const allocator_type& a); + +#include +#include +#include "DefaultOnly.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::list > l(3, 2, test_allocator(5)); + std::list > l2(l, test_allocator(3)); + assert(l2 == l); + assert(l2.get_allocator() == test_allocator(3)); + } + { + std::list > l(3, 2, other_allocator(5)); + std::list > l2(l, other_allocator(3)); + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(3)); + } +#if __cplusplus >= 201103L + { + std::list > l(3, 2, min_allocator()); + std::list > l2(l, min_allocator()); + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit list(const Alloc& = Alloc()); + +#include +#include +#include "DefaultOnly.h" +#include "min_allocator.h" + +int main() +{ + { + std::list l; + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list l; + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list l((std::allocator())); + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } +#if __cplusplus >= 201103L + { + std::list> l; + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list> l; + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list> l((min_allocator())); + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list 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() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::list C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::list> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::list> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::list> C; + static_assert(!std::is_nothrow_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit list(const Alloc& = Alloc()); + +#include +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::list l; + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list l((std::allocator())); + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list > l; + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } +#if __cplusplus >= 201103L + { + std::list> l; + assert(l.size() == 0); + assert(std::distance(l.begin(), l.end()) == 0); + } + { + std::list> l((min_allocator())); + 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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::list> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::list> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::list> C; + static_assert(!std::is_nothrow_destructible::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(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::list d = {3, 4, 5, 6}; + assert(d.size() == 4); + std::list::iterator i = d.begin(); + assert(*i++ == 3); + assert(*i++ == 4); + assert(*i++ == 5); + assert(*i++ == 6); + } +#if __cplusplus >= 201103L + { + std::list> d = {3, 4, 5, 6}; + assert(d.size() == 4); + std::list>::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(initializer_list il, const Allocator& a = allocator_type()); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::list> d({3, 4, 5, 6}, test_allocator(3)); + assert(d.get_allocator() == test_allocator(3)); + assert(d.size() == 4); + std::list::iterator i = d.begin(); + assert(*i++ == 3); + assert(*i++ == 4); + assert(*i++ == 5); + assert(*i++ == 6); + } +#if __cplusplus >= 201103L + { + std::list> d({3, 4, 5, 6}, min_allocator()); + assert(d.get_allocator() == min_allocator()); + assert(d.size() == 4); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// list(InputIterator first, InputIterator last, const Allocator& = Allocator()); + +#include +#include +#include "test_iterators.h" +#include "../../../stack_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + int a[] = {0, 1, 2, 3}; + std::list l(input_iterator(a), + input_iterator(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::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j) + assert(*i == j); + } + { + int a[] = {0, 1, 2, 3}; + std::list l(input_iterator(a), + input_iterator(a + sizeof(a)/sizeof(a[0])), + std::allocator()); + 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::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j) + assert(*i == j); + } + { + int a[] = {0, 1, 2, 3}; + std::list > l(input_iterator(a), + input_iterator(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::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> l(input_iterator(a), + input_iterator(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>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j) + assert(*i == j); + } + { + int a[] = {0, 1, 2, 3}; + std::list> l(input_iterator(a), + input_iterator(a + sizeof(a)/sizeof(a[0])), + min_allocator()); + 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>::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&& c); + +#include +#include +#include "MoveOnly.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list > l(test_allocator(5)); + std::list > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } + { + std::list > l(other_allocator(5)); + std::list > lo(other_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#if __cplusplus >= 201103L + { + std::list > l(min_allocator{}); + std::list > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#endif +#if _LIBCPP_DEBUG >= 1 + { + std::list l1 = {1, 2, 3}; + std::list::iterator i = l1.begin(); + std::list 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&& c, const allocator_type& a); + +#include +#include +#include "MoveOnly.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list > l(test_allocator(5)); + std::list > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(std::move(l), test_allocator(6)); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == test_allocator(6)); + } + { + std::list > l(test_allocator(5)); + std::list > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(std::move(l), test_allocator(5)); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == test_allocator(5)); + } + { + std::list > l(other_allocator(5)); + std::list > lo(other_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(std::move(l), other_allocator(4)); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == other_allocator(4)); + } +#if __cplusplus >= 201103L + { + std::list > l(min_allocator{}); + std::list > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::list > l2(std::move(l), min_allocator()); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == min_allocator()); + } +#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& operator=(list&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::list C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::list> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::list> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::list> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::list C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::list> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::list> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::list> C; + static_assert(!std::is_nothrow_move_constructible::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& operator=(initializer_list il); + +#include +#include +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::list d; + d = {3, 4, 5, 6}; + assert(d.size() == 4); + std::list::iterator i = d.begin(); + assert(*i++ == 3); + assert(*i++ == 4); + assert(*i++ == 5); + assert(*i++ == 6); + } +#if __cplusplus >= 201103L + { + std::list> d; + d = {3, 4, 5, 6}; + assert(d.size() == 4); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit list(size_type n); + +#include +#include +#include "DefaultOnly.h" +#include "../../../stack_allocator.h" +#include "min_allocator.h" + +template +void +test3(unsigned n, Allocator const &alloc = Allocator()) +{ +#if _LIBCPP_STD_VER > 11 + typedef std::list 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 l(3); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list::const_iterator i = l.begin(); + assert(*i == 0); + ++i; + assert(*i == 0); + ++i; + assert(*i == 0); + } + { + std::list > l(3); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list::const_iterator i = l.begin(); + assert(*i == 0); + ++i; + assert(*i == 0); + ++i; + assert(*i == 0); + } +#if _LIBCPP_STD_VER > 11 + { + typedef std::list > C; + C l(3, min_allocator ()); + 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> (3); + } +#endif +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list 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> l(3); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list>::const_iterator i = l.begin(); + assert(*i == 0); + ++i; + assert(*i == 0); + ++i; + assert(*i == 0); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list> 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(size_type n, const T& value, const Allocator& = Allocator()); + +#include +#include +#include "DefaultOnly.h" +#include "../../../stack_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::list l(3, 2); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list::const_iterator i = l.begin(); + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + } + { + std::list l(3, 2, std::allocator()); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list::const_iterator i = l.begin(); + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + } + { + std::list > l(3, 2); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list::const_iterator i = l.begin(); + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + } +#if __cplusplus >= 201103L + { + std::list> l(3, 2); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list>::const_iterator i = l.begin(); + assert(*i == 2); + ++i; + assert(*i == 2); + ++i; + assert(*i == 2); + } + { + std::list> l(3, 2, min_allocator()); + assert(l.size() == 3); + assert(std::distance(l.begin(), l.end()) == 3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// void clear(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a[] = {1, 2, 3}; + std::list c(a, a+3); + c.clear(); + assert(c.empty()); + } +#if __cplusplus >= 201103L + { + int a[] = {1, 2, 3}; + std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace(const_iterator p, Args&&... args); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#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 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 c1; + std::list c2; + std::list::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> 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> c1; + std::list> c2; + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace_back(Args&&... args); + +#include +#include + +#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 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace_front(Args&&... args); + +#include +#include + +#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 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase(const_iterator position); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list::const_iterator i = l1.begin(); + ++i; + std::list::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> l1(a1, a1+3); + std::list>::const_iterator i = l1.begin(); + ++i; + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list::const_iterator i = l1.end(); + l1.erase(i); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::list> l1(a1, a1+3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list l2(a1, a1+3); + std::list::const_iterator i = l2.begin(); + l1.erase(i); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::list> l1(a1, a1+3); + std::list> l2(a1, a1+3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + int a1[] = {1, 2, 3}; + { + std::list l1(a1, a1+3); + std::list::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 l1(a1, a1+3); + std::list::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(a1+1, a1+3)); + } + { + std::list l1(a1, a1+3); + std::list::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(a1+2, a1+3)); + } + { + std::list l1(a1, a1+3); + std::list::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> l1(a1, a1+3); + std::list>::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> l1(a1, a1+3); + std::list>::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>(a1+1, a1+3))); + } + { + std::list> l1(a1, a1+3); + std::list>::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>(a1+2, a1+3))); + } + { + std::list> l1(a1, a1+3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list l2(a1, a1+3); + std::list::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin())); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::list> l1(a1, a1+3); + std::list> l2(a1, a1+3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list l2(a1, a1+3); + std::list::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin())); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::list> l1(a1, a1+3); + std::list> l2(a1, a1+3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list l2(a1, a1+3); + std::list::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin())); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::list> l1(a1, a1+3); + std::list> l2(a1, a1+3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin()); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::list> l1(a1, a1+3); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert(const_iterator p, initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::list d(10, 1); + std::list::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> d(10, 1); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include +#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 l1; + std::list::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 v(100); + std::list v2(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::list::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator(a), + input_iterator(a+N)); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::list> l1; + std::list>::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> v(100); + std::list> v2(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::list>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator(a), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list 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 v1(3); + std::list v2(3); + v1.insert(v2.begin(), 4); + assert(false); + } +#endif +#if __cplusplus >= 201103L +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list> 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> v1(3); + std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#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 l1(a1, a1+3); + std::list::iterator i = l1.insert(next(l1.cbegin()), 5, 4); + assert(i == next(l1.begin())); + assert(l1 == std::list(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(a2, a2+8)); + } +#if _LIBCPP_DEBUG >= 1 + { + std::list c1(100); + std::list c2; + std::list::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> l1(a1, a1+3); + std::list>::iterator i = l1.insert(next(l1.cbegin()), 5, 4); + assert(i == next(l1.begin())); + assert((l1 == std::list>(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>(a2, a2+8))); + } +#if _LIBCPP_DEBUG >= 1 + { + std::list> c1(100); + std::list> c2; + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#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 l1(a1, a1+3); + std::list::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(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(a2, a2+4)); + } +#if _LIBCPP_DEBUG >= 1 + { + std::list v1(3); + std::list 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> l1(a1, a1+3); + std::list>::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>(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>(a2, a2+4))); + } +#if _LIBCPP_DEBUG >= 1 + { + std::list> v1(3); + std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop_back(); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a[] = {1, 2, 3}; + std::list c(a, a+3); + c.pop_back(); + assert(c == std::list(a, a+2)); + c.pop_back(); + assert(c == std::list(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> c(a, a+3); + c.pop_back(); + assert((c == std::list>(a, a+2))); + c.pop_back(); + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop_front(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a[] = {1, 2, 3}; + std::list c(a, a+3); + c.pop_front(); + assert(c == std::list(a+1, a+3)); + c.pop_front(); + assert(c == std::list(a+2, a+3)); + c.pop_front(); + assert(c.empty()); + } +#if __cplusplus >= 201103L + { + int a[] = {1, 2, 3}; + std::list> c(a, a+3); + c.pop_front(); + assert((c == std::list>(a+1, a+3))); + c.pop_front(); + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::list c; + for (int i = 0; i < 5; ++i) + c.push_back(i); + int a[] = {0, 1, 2, 3, 4}; + assert(c == std::list(a, a+5)); + } +#if __cplusplus >= 201103L + { + std::list> c; + for (int i = 0; i < 5; ++i) + c.push_back(i); + int a[] = {0, 1, 2, 3, 4}; + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(const value_type& x); + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(value_type&& x); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::list c; + for (int i = 0; i < 5; ++i) + c.push_front(i); + int a[] = {4, 3, 2, 1, 0}; + assert(c == std::list(a, a+5)); + } +#if __cplusplus >= 201103L + { + std::list> c; + for (int i = 0; i < 5; ++i) + c.push_front(i); + int a[] = {4, 3, 2, 1, 0}; + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(const value_type& x); + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_front(value_type&& x); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::list 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void merge(list& x); + +#include +#include + +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + c1.merge(c2); + assert(c1 == std::list(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + c1.merge(c2); + assert((c1 == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// template void merge(list& x, Compare comp); + +#include +#include +#include + +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + c1.merge(c2, std::greater()); + assert(c1 == std::list(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + c1.merge(c2, std::greater()); + assert((c1 == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void remove(const value_type& value); + +#include +#include + +#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 c(a1, a1+4); + c.remove(3); + assert(c == std::list(a2, a2+3)); + } + { // LWG issue #526 + int a1[] = {1, 2, 1, 3, 5, 8, 11}; + int a2[] = { 2, 3, 5, 8, 11}; + std::list c(a1, a1+7); + c.remove(c.front()); + assert(c == std::list(a2, a2+5)); + } + { + int a1[] = {1, 2, 1, 3, 5, 8, 11, 1}; + int a2[] = { 2, 3, 5, 8, 11 }; + std::list c; + for(int *ip = a1; ip < a1+8; ++ip) + c.push_back(S(*ip)); + c.remove(c.front()); + std::list::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> c(a1, a1+4); + c.remove(3); + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// template void remove_if(Pred pred); + +#include +#include +#include + +#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 Predicate; + +int main() +{ + { + int a1[] = {1, 2, 3, 4}; + int a2[] = {3, 4}; + std::list c(a1, a1+4); + Predicate cp(g); + c.remove_if(std::ref(cp)); + assert(c == std::list(a2, a2+2)); + assert(cp.count() == 4); + } + { + int a1[] = {1, 2, 3, 4}; + int a2[] = {1, 3}; + std::list c(a1, a1+4); + Predicate cp(even); + c.remove_if(std::ref(cp)); + assert(c == std::list(a2, a2+2)); + assert(cp.count() == 4); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3, 4}; + int a2[] = {3, 4}; + std::list> c(a1, a1+4); + Predicate cp(g); + c.remove_if(std::ref(cp)); + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void reverse(); + +#include +#include + +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.reverse(); + assert(c1 == std::list(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.reverse(); + assert((c1 == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void sort(); + +#include +#include + +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.sort(); + assert(c1 == std::list(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.sort(); + assert((c1 == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// template sort(Compare comp); + +#include +#include +#include + +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.sort(std::greater()); + assert(c1 == std::list(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + c1.sort(std::greater()); + assert((c1 == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// void splice(const_iterator position, list& x); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#include "min_allocator.h" + +int main() +{ + int a1[] = {1, 2, 3}; + int a2[] = {4, 5, 6}; + { + std::list l1; + std::list 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 l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + } + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 6); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 1); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 1); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 6); + ++i; + assert(*i == 1); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 6); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 2); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 4); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 2); + } + { + std::list l1(a1, a1+2); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list l1(a1, a1+3); + std::list 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::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 l1(a1, a1+3); + std::list 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::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 l1(a1, a1+3); + std::list 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::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 l1(a1, a1+3); + std::list 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::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 v1(3); + std::list v2(3); + v1.splice(v2.begin(), v2); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::list> l1; + std::list> 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> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + } + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 6); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 1); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 1); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 6); + ++i; + assert(*i == 1); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 6); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 2); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 4); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + ++i; + assert(*i == 2); + } + { + std::list> l1(a1, a1+2); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list> l1(a1, a1+3); + std::list> 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>::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> l1(a1, a1+3); + std::list> 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>::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> l1(a1, a1+3); + std::list> 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>::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> l1(a1, a1+3); + std::list> 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>::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> v1(3); + std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void splice(const_iterator position, list& x, iterator i); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#include "min_allocator.h" + +int main() +{ + int a1[] = {1, 2, 3}; + int a2[] = {4, 5, 6}; + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + } + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + i = l2.begin(); + assert(*i == 5); + } + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 5); + i = l2.begin(); + assert(*i == 4); + } + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + i = l2.begin(); + assert(*i == 5); + ++i; + assert(*i == 6); + } + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 5); + i = l2.begin(); + assert(*i == 4); + ++i; + assert(*i == 6); + } + { + std::list l1; + std::list 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::const_iterator i = l1.begin(); + assert(*i == 6); + i = l2.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list l1(a1, a1+1); + l1.splice(l1.begin(), l1, l1.begin()); + assert(l1.size() == 1); + assert(distance(l1.begin(), l1.end()) == 1); + std::list::const_iterator i = l1.begin(); + assert(*i == 1); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 1); + } + { + std::list l1(a1, a1+1); + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + } + { + std::list l1(a1, a1+2); + l1.splice(l1.begin(), l1, l1.begin()); + assert(l1.size() == 2); + assert(distance(l1.begin(), l1.end()) == 2); + std::list::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list 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::const_iterator i = l1.begin(); + assert(*i == 2); + ++i; + assert(*i == 1); + } + { + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } +#if _LIBCPP_DEBUG >= 1 + { + std::list v1(3); + std::list v2(3); + v1.splice(v1.begin(), v2, v1.begin()); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + } + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + i = l2.begin(); + assert(*i == 5); + } + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 5); + i = l2.begin(); + assert(*i == 4); + } + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + i = l2.begin(); + assert(*i == 5); + ++i; + assert(*i == 6); + } + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 5); + i = l2.begin(); + assert(*i == 4); + ++i; + assert(*i == 6); + } + { + std::list> l1; + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 6); + i = l2.begin(); + assert(*i == 4); + ++i; + assert(*i == 5); + } + { + std::list> l1(a1, a1+1); + l1.splice(l1.begin(), l1, l1.begin()); + assert(l1.size() == 1); + assert(distance(l1.begin(), l1.end()) == 1); + std::list>::const_iterator i = l1.begin(); + assert(*i == 1); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 4); + ++i; + assert(*i == 1); + } + { + std::list> l1(a1, a1+1); + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 4); + } + { + std::list> l1(a1, a1+2); + l1.splice(l1.begin(), l1, l1.begin()); + assert(l1.size() == 2); + assert(distance(l1.begin(), l1.end()) == 2); + std::list>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 2); + ++i; + assert(*i == 1); + } + { + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } + { + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + } +#if _LIBCPP_DEBUG >= 1 + { + std::list> v1(3); + std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + int a1[] = {1, 2, 3}; + int a2[] = {4, 5, 6}; + { + std::list 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::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 3); + } + { + std::list 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::const_iterator i = l1.begin(); + assert(*i == 2); + ++i; + assert(*i == 1); + ++i; + assert(*i == 3); + } + { + std::list 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::const_iterator i = l1.begin(); + assert(*i == 2); + ++i; + assert(*i == 3); + ++i; + assert(*i == 1); + } + { + std::list l1(a1, a1+3); + std::list 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::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 l1(a1, a1+3); + std::list 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::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 l1(a1, a1+3); + std::list 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::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 v1(3); + std::list v2(3); + v1.splice(v1.begin(), v2, v2.begin(), v1.end()); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 1); + ++i; + assert(*i == 2); + ++i; + assert(*i == 3); + } + { + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 2); + ++i; + assert(*i == 1); + ++i; + assert(*i == 3); + } + { + std::list> 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>::const_iterator i = l1.begin(); + assert(*i == 2); + ++i; + assert(*i == 3); + ++i; + assert(*i == 1); + } + { + std::list> l1(a1, a1+3); + std::list> 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>::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> l1(a1, a1+3); + std::list> 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>::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> l1(a1, a1+3); + std::list> 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>::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> v1(3); + std::list> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void unique(); + +#include +#include + +#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 c(a1, a1+sizeof(a1)/sizeof(a1[0])); + c.unique(); + assert(c == std::list(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> c(a1, a1+sizeof(a1)/sizeof(a1[0])); + c.unique(); + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// template void unique(BinaryPred pred); + +#include +#include + +#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 c(a1, a1+sizeof(a1)/sizeof(a1[0])); + c.unique(g); + assert(c == std::list(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> c(a1, a1+sizeof(a1)/sizeof(a1[0])); + c.unique(g); + assert((c == std::list>(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(list& x, list& y); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::list::iterator i1 = c1.begin(); + std::list::iterator i2 = c2.begin(); + swap(c1, c2); + c1.erase(i2); + c2.erase(i1); + std::list::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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::list>::iterator i1 = c1.begin(); + std::list>::iterator i2 = c2.begin(); + swap(c1, c2); + c1.erase(i2); + c2.erase(i1); + std::list>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(list& x, list& y); + +#include +#include +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + swap(c1, c2); + assert(c1 == std::list(a2, a2+sizeof(a2)/sizeof(a2[0]))); + assert(c2 == std::list(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 c1(a1, a1); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + swap(c1, c2); + assert(c1 == std::list(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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list c2(a2, a2); + swap(c1, c2); + assert(c1.empty()); + assert(distance(c1.begin(), c1.end()) == 0); + assert(c2 == std::list(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 c1(a1, a1); + std::list 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 A; + std::list c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); + swap(c1, c2); + assert((c1 == std::list(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A(1)); + assert((c2 == std::list(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 A; + std::list c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); + swap(c1, c2); + assert((c1 == std::list(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A(2)); + assert((c2 == std::list(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + swap(c1, c2); + assert((c1 == std::list>(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert((c2 == std::list>(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> c1(a1, a1); + std::list> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + swap(c1, c2); + assert((c1 == std::list>(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::list> c2(a2, a2); + swap(c1, c2); + assert(c1.empty()); + assert(distance(c1.begin(), c1.end()) == 0); + assert((c2 == std::list>(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> c1(a1, a1); + std::list> 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 A; + std::list c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A()); + std::list c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A()); + swap(c1, c2); + assert((c1 == std::list(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A()); + assert((c2 == std::list(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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(list& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::list> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::list> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::list> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include + +#include "min_allocator.h" + +struct A { std::list v; }; // incomplete type support + +int main() +{ + static_assert((std::is_same::value_type, int>::value), ""); + static_assert((std::is_same::allocator_type, std::allocator >::value), ""); + static_assert((std::is_same::reference, std::allocator::reference>::value), ""); + static_assert((std::is_same::const_reference, std::allocator::const_reference>::value), ""); + static_assert((std::is_same::pointer, std::allocator::pointer>::value), ""); + static_assert((std::is_same::const_pointer, std::allocator::const_pointer>::value), ""); +#if __cplusplus >= 201103L + static_assert((std::is_same>::value_type, int>::value), ""); + static_assert((std::is_same>::allocator_type, min_allocator >::value), ""); + static_assert((std::is_same>::reference, int&>::value), ""); + static_assert((std::is_same>::const_reference, const int&>::value), ""); + static_assert((std::is_same>::pointer, min_pointer>::value), ""); + static_assert((std::is_same>::const_pointer, min_pointer>::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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& operator=(const vector& c); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::vector > l(3, 2, test_allocator(5)); + std::vector > l2(l, test_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == test_allocator(3)); + } + { + std::vector > l(3, 2, other_allocator(5)); + std::vector > l2(l, other_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(5)); + } +#if __cplusplus >= 201103L + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector 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> 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& operator=(vector&& c); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::vector > l(test_allocator(5)); + std::vector > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(test_allocator(5)); + l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } + { + std::vector > l(test_allocator(5)); + std::vector > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(test_allocator(6)); + l2 = std::move(l); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == test_allocator(6)); + } + { + std::vector > l(other_allocator(5)); + std::vector > lo(other_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(other_allocator(6)); + l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(min_allocator{}); + 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 + +// size_type capacity() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::vector v; + assert(v.capacity() == 0); + } + { + std::vector v(100); + assert(v.capacity() >= 100); + v.push_back(0); + assert(v.capacity() >= 101); + } +#if __cplusplus >= 201103L + { + std::vector> v; + assert(v.capacity() == 0); + } + { + std::vector> 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(const Alloc& = Alloc()); + +#include +#include + +#include "test_macros.h" +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 +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::value), "" ); +#endif + C c(a); + assert(c.__invariants()); + assert(c.empty()); + assert(c.get_allocator() == a); +} + +int main() +{ + { + test0 >(); + test1 > >(test_allocator(3)); + } +#if TEST_STD_VER >= 11 + { + test0> >(); + test1 > >(min_allocator()); + } +#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 + +// template vector(InputIter first, InputIter last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 >(input_iterator(a), input_iterator(an)); + test >(forward_iterator(a), forward_iterator(an)); + test >(bidirectional_iterator(a), bidirectional_iterator(an)); + test >(random_access_iterator(a), random_access_iterator(an)); + test >(a, an); +#if __cplusplus >= 201103L + test> >(input_iterator(a), input_iterator(an)); + test> >(forward_iterator(a), forward_iterator(an)); + test> >(bidirectional_iterator(a), bidirectional_iterator(an)); + test> >(random_access_iterator(a), random_access_iterator(an)); + test> >(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 + +// template vector(InputIter first, InputIter last, +// const allocator_type& a); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +template +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 alloc; + test >(input_iterator(a), input_iterator(an), alloc); + test >(forward_iterator(a), forward_iterator(an), alloc); + test >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + test >(random_access_iterator(a), random_access_iterator(an), alloc); + test >(a, an, alloc); + } +#if __cplusplus >= 201103L + { + min_allocator alloc; + test> >(input_iterator(a), input_iterator(an), alloc); + test> >(forward_iterator(a), forward_iterator(an), alloc); + test> >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + test> >(random_access_iterator(a), random_access_iterator(an), alloc); + test> >(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 + +// explicit vector(size_type n); + +#include +#include + +#include "min_allocator.h" +#include "test_allocator.h" + +template +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 +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 +void +test(typename C::size_type n) +{ + test1 ( n ); + test2 ( n ); +} + +int main() +{ + test >(50); +#if __cplusplus >= 201103L + test> >(50); + test2> >( 100, test_allocator(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(size_type n, const value_type& x); + +#include +#include + +#include "min_allocator.h" + +template +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 >(50, 3); +#if __cplusplus >= 201103L + test> >(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(size_type n, const value_type& x, const allocator_type& a); + +#include +#include + +#include "min_allocator.h" + +template +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 >(50, 3, std::allocator()); +#if __cplusplus >= 201103L + test> >(50, 3, min_allocator()); +#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(const vector& v); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +template +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(a, an)); + } + { + std::vector > v(3, 2, test_allocator(5)); + std::vector > v2 = v; + assert(v2 == v); + assert(v2.get_allocator() == v.get_allocator()); + } +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + { + std::vector > v(3, 2, other_allocator(5)); + std::vector > v2 = v; + assert(v2 == v); + assert(v2.get_allocator() == other_allocator(-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>(a, an)); + } + { + std::vector > v(3, 2, min_allocator()); + std::vector > 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(const vector& v, const allocator_type& a); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +template +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(a, an), std::allocator()); + } + { + std::vector > l(3, 2, test_allocator(5)); + std::vector > l2(l, test_allocator(3)); + assert(l2 == l); + assert(l2.get_allocator() == test_allocator(3)); + } + { + std::vector > l(3, 2, other_allocator(5)); + std::vector > l2(l, other_allocator(3)); + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(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>(a, an), min_allocator()); + } + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#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() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::vector C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_destructible::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 + +// template iterator emplace(const_iterator pos, Args&&... args); + +#include +#include +#include "min_allocator.h" + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef std::vector 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> 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.bool + +// template void emplace_back(Args&&... args); + +#include +#include +#include "min_allocator.h" + + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + typedef std::vector 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> 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 + +// iterator erase(const_iterator position); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + bool a1[] = {1, 0, 1}; + { + std::vector l1(a1, a1+3); + std::vector::const_iterator i = l1.begin(); + ++i; + std::vector::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> l1(a1, a1+3); + std::vector>::const_iterator i = l1.begin(); + ++i; + std::vector>::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 + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + bool a1[] = {1, 0, 1}; + { + std::vector l1(a1, a1+3); + std::vector::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 l1(a1, a1+3); + std::vector::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(a1+1, a1+3)); + } + { + std::vector l1(a1, a1+3); + std::vector::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(a1+2, a1+3)); + } + { + std::vector l1(a1, a1+3); + std::vector::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> l1(a1, a1+3); + std::vector>::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> l1(a1, a1+3); + std::vector>::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>(a1+1, a1+3))); + } + { + std::vector> l1(a1, a1+3); + std::vector>::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>(a1+2, a1+3))); + } + { + std::vector> l1(a1, a1+3); + std::vector>::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 + +// std::find with vector::iterator + +// http://llvm.org/bugs/show_bug.cgi?id=16816 + +#include +#include + +int main() +{ + { + for (unsigned i = 1; i < 256; ++i) + { + std::vector b(i,true); + std::vector::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 b(i,false); + std::vector::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(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector 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> 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(initializer_list il, const Allocator& a = allocator_type()); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector> d({true, false, false, true}, test_allocator(3)); + assert(d.get_allocator() == test_allocator(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> d({true, false, false, true}, min_allocator()); + assert(d.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert(const_iterator p, initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector d(10, true); + std::vector::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> d(10, true); + std::vector>::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 + +// template +// iterator insert(const_iterator position, Iter first, Iter last); + +#include +#include +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + std::vector v(100); + bool a[] = {1, 0, 0, 1, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::vector::iterator i = v.insert(v.cbegin() + 10, input_iterator(a), + input_iterator(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 v(100); + bool a[] = {1, 0, 0, 1, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::vector::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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 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::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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 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::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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> v(100); + bool a[] = {1, 0, 0, 1, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, input_iterator(a), + input_iterator(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> v(100); + bool a[] = {1, 0, 0, 1, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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 + +// iterator insert(const_iterator position, size_type n, const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::vector v(100); + std::vector::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 v(100); + while(v.size() < v.capacity()) v.push_back(false); + size_t sz = v.size(); + std::vector::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 v(100); + while(v.size() < v.capacity()) v.push_back(false); + v.pop_back(); v.pop_back(); + size_t sz = v.size(); + std::vector::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> v(100); + std::vector>::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 + +// iterator insert(const_iterator position, const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::vector v(100); + std::vector::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 v(100); + while(v.size() < v.capacity()) v.push_back(false); + size_t sz = v.size(); + std::vector::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 v(100); + while(v.size() < v.capacity()) v.push_back(false); + v.pop_back(); v.pop_back(); + size_t sz = v.size(); + std::vector::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> v(100); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef bool T; + typedef std::vector 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 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 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 C; + C::iterator i; + C::const_iterator j; + } +#if __cplusplus >= 201103L + { + typedef bool T; + typedef std::vector> 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> 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> 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> C; + C::iterator i; + C::const_iterator j; + } +#endif +#if _LIBCPP_STD_VER > 11 + { // N3644 testing + std::vector::iterator ii1{}, ii2{}; + std::vector::iterator ii4 = ii1; + std::vector::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&& c); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::vector > l(test_allocator(5)); + std::vector > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } + { + std::vector > l(other_allocator(5)); + std::vector > lo(other_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2 = std::move(l); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == lo.get_allocator()); + } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > 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&& c, const allocator_type& a); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::vector > l(test_allocator(5)); + std::vector > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(std::move(l), test_allocator(6)); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == test_allocator(6)); + } + { + std::vector > l(test_allocator(5)); + std::vector > lo(test_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(std::move(l), test_allocator(5)); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == test_allocator(5)); + } + { + std::vector > l(other_allocator(5)); + std::vector > lo(other_allocator(5)); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(std::move(l), other_allocator(4)); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == other_allocator(4)); + } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + for (int i = 1; i <= 3; ++i) + { + l.push_back(i); + lo.push_back(i); + } + std::vector > l2(std::move(l), min_allocator()); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == min_allocator()); + } +#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& operator=(vector&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::vector C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::vector C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::vector> 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::value, ""); +#else + static_assert(!std::is_nothrow_move_constructible::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& operator=(initializer_list il); + +#include +#include + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector 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> 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 + +// void push_back(const value_type& x); + +#include +#include + +#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 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> 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 + +// void reserve(size_type n); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::vector v; + v.reserve(10); + assert(v.capacity() >= 10); + } + { + std::vector 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> v; + v.reserve(10); + assert(v.capacity() >= 10); + } + { + std::vector> 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 + +// void resize(size_type sz); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::vector 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> 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 + +// void resize(size_type sz, const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::vector v(100); + v.resize(50, 1); + assert(v.size() == 50); + assert(v.capacity() >= 100); + assert(v == std::vector(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> v(100); + v.resize(50, 1); + assert(v.size() == 50); + assert(v.capacity() >= 100); + assert((v == std::vector>(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 + +// void shrink_to_fit(); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::vector v(100); + v.push_back(1); + v.shrink_to_fit(); + assert(v.capacity() >= 101); + assert(v.size() >= 101); + } +#if __cplusplus >= 201103L + { + std::vector> 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 + +// void swap(vector& x); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::vector v1(100); + std::vector v2(200); + v1.swap(v2); + assert(v1.size() == 200); + assert(v1.capacity() >= 200); + assert(v2.size() == 100); + assert(v2.capacity() >= 100); + } + { + typedef test_allocator A; + std::vector v1(100, true, A(1)); + std::vector 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 A; + std::vector v1(100, true, A(1)); + std::vector 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 v(2); + std::vector::reference r1 = v[0]; + std::vector::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> v1(100); + std::vector> v2(200); + v1.swap(v2); + assert(v1.size() == 200); + assert(v1.capacity() >= 200); + assert(v2.size() == 100); + assert(v2.capacity() >= 100); + } + { + typedef min_allocator A; + std::vector v1(100, true, A()); + std::vector 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> v(2); + std::vector>::reference r1 = v[0]; + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(vector& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::propagate_on_container_swap::value || +// allocator_traits::is_always_equal::value); + +// This tests a conforming extension + +#include +#include + +#include "test_allocator.h" + +template +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::vector> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::vector> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::vector> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Test nested types and default template args: + +// template +// class vector reverse_iterator; +// typedef std::reverse_iterator const_reverse_iterator; +// }; + +#include +#include +#include + +#include "test_allocator.h" +#include "../../Copyable.h" +#include "min_allocator.h" + +template +void +test() +{ + typedef std::vector C; + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::size_type>::value), ""); + static_assert((std::is_same::difference_type>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename C::reverse_iterator, + std::reverse_iterator >::value), ""); + static_assert((std::is_same< + typename C::const_reverse_iterator, + std::reverse_iterator >::value), ""); +} + +int main() +{ + test >(); + test >(); + static_assert((std::is_same::allocator_type, + std::allocator >::value), ""); +#if __cplusplus >= 201103L + test >(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::vector T; + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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> T; + typedef std::hash H; + static_assert((std::is_base_of, + 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference operator[](size_type n); + +#include +#include +#include + +#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> 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 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 +#include + +#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 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 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 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 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 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 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 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 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 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 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 v; // an extension + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// An vector is a contiguous container + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 C; + test_contiguous(C()); + test_contiguous(C(3, 5)); + } + + { + typedef double T; + typedef test_allocator A; + typedef std::vector C; + test_contiguous(C(A(3))); + test_contiguous(C(7, 9.0, A(5))); + } +#if __cplusplus >= 201103L + { + typedef double T; + typedef min_allocator A; + typedef std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call back() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call back() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector C; + const C c; + assert(c.back() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call front() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector C; + const C c; + assert(c.front() == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Index const vector out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector C; + const C c(1); + assert(c[0] == 0); + assert(c[1] == 0); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call front() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Index vector out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Compare iterators from different containers with <. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector C; + C c1; + C c2; + bool b = c1.begin() < c2.begin(); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Subtract iterators from different containers. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector C; + C c1; + C c2; + int i = c1.begin() - c2.begin(); + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Index iterator out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Add to iterator out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Decrement iterator prior to begin. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::vector C; + C c(1); + C::iterator i = c.end(); + T j = *i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include +#include +#include + +#include "min_allocator.h" + +struct A +{ + int first; + int second; +}; + +int main() +{ + { + typedef int T; + typedef std::vector 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 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 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 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 C; + C::iterator i; + C::const_iterator j; + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::vector> 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> 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> 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> 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> C; + C::iterator i; + C::const_iterator j; + } + { + typedef A T; + typedef std::vector> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// Test nested types and default template args: + +// template > +// 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 reverse_iterator; +// typedef std::reverse_iterator const_reverse_iterator; +// }; + +#include +#include +#include + +#include "test_allocator.h" +#include "../../Copyable.h" +#include "min_allocator.h" + +struct A { std::vector v; }; // incomplete type support + +template +void +test() +{ + typedef std::vector C; + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename C::reverse_iterator, + std::reverse_iterator >::value), ""); + static_assert((std::is_same< + typename C::const_reverse_iterator, + std::reverse_iterator >::value), ""); +} + +int main() +{ + test >(); + test >(); + test >(); + static_assert((std::is_same::allocator_type, + std::allocator >::value), ""); +#if __cplusplus >= 201103L + static_assert((std::is_same>::value_type, int>::value), ""); + static_assert((std::is_same>::allocator_type, min_allocator >::value), ""); + static_assert((std::is_same>::reference, int&>::value), ""); + static_assert((std::is_same>::const_reference, const int&>::value), ""); + static_assert((std::is_same>::pointer, min_pointer>::value), ""); + static_assert((std::is_same>::const_pointer, min_pointer>::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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type capacity() const; + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v; + assert(v.capacity() == 0); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector 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> v; + assert(v.capacity() == 0); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void reserve(size_type n); + +#include +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v; + v.reserve(10); + assert(v.capacity() >= 10); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector 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 > 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> v; + v.reserve(10); + assert(v.capacity() >= 10); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type sz); + +#include +#include +#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 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 > 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 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 > 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type sz, const value_type& x); + +#include +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v(100); + v.resize(50, 1); + assert(v.size() == 50); + assert(v.capacity() == 100); + assert(v == std::vector(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 > 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> 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>(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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void shrink_to_fit(); + +#include +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector 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 > 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 > 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(vector& x); + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v1(100); + std::vector 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> v1(100); + std::vector> 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& operator=(const vector& c); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + std::vector > l(3, 2, test_allocator(5)); + std::vector > l2(l, test_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == test_allocator(3)); + } + { + std::vector > l(3, 2, other_allocator(5)); + std::vector > l2(l, other_allocator(3)); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(5)); + } +#if __cplusplus >= 201103L + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + l2 = l; + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(initializer_list il); + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +template +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 V; + V d1; + V d2; + d2.reserve(10); // no reallocation during assign. + test(d1); + test(d2); + } + +#if __cplusplus >= 201103L + { + typedef std::vector> 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& operator=(vector&& c); + +#include +#include +#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 > l(test_allocator(5)); + std::vector > lo(test_allocator(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 > l2(test_allocator(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 > l(test_allocator(5)); + std::vector > lo(test_allocator(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 > l2(test_allocator(6)); + l2 = std::move(l); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == test_allocator(6)); + assert(is_contiguous_container_asan_correct(l2)); + } + { + std::vector > l(other_allocator(5)); + std::vector > lo(other_allocator(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 > l2(other_allocator(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 > l(min_allocator{}); + std::vector > lo(min_allocator{}); + 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 > l2(min_allocator{}); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// void assign(size_type n, const_reference v); + +#include +#include +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +bool is6(int x) { return x == 6; } + +template +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 V; + V d1; + V d2; + d2.reserve(10); // no reallocation during assign. + test(d1); + test(d2); + } + +#if __cplusplus >= 201103L + { + typedef std::vector> 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(const Alloc&); + +#include +#include + +#include "test_macros.h" +#include "test_allocator.h" +#include "../../../NotConstructible.h" +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +template +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 +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::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 >(); + test0 >(); + test1 > >(test_allocator(3)); + test1 > > + (test_allocator(5)); + } + { + std::vector > v; + assert(v.empty()); + } +#if TEST_STD_VER >= 11 + { + test0> >(); + test0> >(); + test1 > >(min_allocator{}); + test1 > > + (min_allocator{}); + } + { + std::vector > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template vector(InputIter first, InputIter last); + +#include +#include + +#include "test_iterators.h" +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +template +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 >(input_iterator(a), input_iterator(an)); + test >(forward_iterator(a), forward_iterator(an)); + test >(bidirectional_iterator(a), bidirectional_iterator(an)); + test >(random_access_iterator(a), random_access_iterator(an)); + test >(a, an); + + test > >(input_iterator(a), input_iterator(an)); + test > >(forward_iterator(a), forward_iterator(an)); + test > >(bidirectional_iterator(a), bidirectional_iterator(an)); + test > >(random_access_iterator(a), random_access_iterator(an)); + test > >(a, an); +#if __cplusplus >= 201103L + test> >(input_iterator(a), input_iterator(an)); + test> >(forward_iterator(a), forward_iterator(an)); + test> >(bidirectional_iterator(a), bidirectional_iterator(an)); + test> >(random_access_iterator(a), random_access_iterator(an)); + test >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template vector(InputIter first, InputIter last, +// const allocator_type& a); + +#include +#include + +#include "test_iterators.h" +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +template +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 +struct implicit_conv_allocator : min_allocator +{ + 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 alloc; + test >(input_iterator(a), input_iterator(an), alloc); + test >(forward_iterator(a), forward_iterator(an), alloc); + test >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + test >(random_access_iterator(a), random_access_iterator(an), alloc); + test >(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 alloc; + test> >(input_iterator(a), input_iterator(an), alloc); + test> >(forward_iterator(a), forward_iterator(an), alloc); + test> >(bidirectional_iterator(a), bidirectional_iterator(an), alloc); + test> >(random_access_iterator(a), random_access_iterator(an), alloc); + test> >(a, an, alloc); + test> >(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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit vector(size_type n); + +#include +#include + +#include "DefaultOnly.h" +#include "min_allocator.h" +#include "test_allocator.h" +#include "asan_testing.h" + +template +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 +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 +void +test(typename C::size_type n) +{ + test1 ( n ); + test2 ( n ); +} + +int main() +{ + test >(50); + test >(500); + assert(DefaultOnly::count == 0); +#if __cplusplus >= 201103L + test> >(50); + test> >(500); + test2> >( 100, test_allocator(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(size_type n, const value_type& x); + +#include +#include + +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +template +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 >(50, 3); + test > >(50, 5); +#if __cplusplus >= 201103L + test> >(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(size_type n, const value_type& x, const allocator_type& a); + +#include +#include +#include "min_allocator.h" +#include "asan_testing.h" + +template +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 >(50, 3, std::allocator()); +#if __cplusplus >= 201103L + test> >(50, 3, min_allocator()); +#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(const vector& v); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +template +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(a, an)); + } + { + std::vector > v(3, 2, test_allocator(5)); + std::vector > 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 > v(3, 2, other_allocator(5)); + std::vector > 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(-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>(a, an)); + } + { + std::vector > v(3, 2, min_allocator()); + std::vector > 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(const vector& v, const allocator_type& a); + +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +template +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(a, an), std::allocator()); + } + { + std::vector > l(3, 2, test_allocator(5)); + std::vector > l2(l, test_allocator(3)); + assert(l2 == l); + assert(l2.get_allocator() == test_allocator(3)); + } + { + std::vector > l(3, 2, other_allocator(5)); + std::vector > l2(l, other_allocator(3)); + assert(l2 == l); + assert(l2.get_allocator() == other_allocator(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>(a, an), min_allocator()); + } + { + std::vector > l(3, 2, min_allocator()); + std::vector > l2(l, min_allocator()); + assert(l2 == l); + assert(l2.get_allocator() == min_allocator()); + } +#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. +// +//===----------------------------------------------------------------------===// + +// +// class vector +// vector(); + +#include + +struct X +{ + std::vector 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() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "test_macros.h" +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::vector C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_destructible::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(initializer_list il); + +#include +#include +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector 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> 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(initializer_list il, const Allocator& a = allocator_type()); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector> d({3, 4, 5, 6}, test_allocator(3)); + assert(d.get_allocator() == test_allocator(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> d({3, 4, 5, 6}, min_allocator()); + assert(d.get_allocator() == min_allocator()); + 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&& c); + +#include +#include +#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 > l(test_allocator(5)); + std::vector > lo(test_allocator(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 > 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 > l(other_allocator(5)); + std::vector > lo(other_allocator(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 > 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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + assert(is_contiguous_container_asan_correct(c1)); + std::vector::const_iterator i = c1.begin(); + std::vector c2 = std::move(c1); + assert(is_contiguous_container_asan_correct(c2)); + std::vector::iterator j = c2.erase(i); + assert(*j == 3); + assert(is_contiguous_container_asan_correct(c2)); + } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + 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 > 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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + assert(is_contiguous_container_asan_correct(c1)); + std::vector>::const_iterator i = c1.begin(); + std::vector> c2 = std::move(c1); + assert(is_contiguous_container_asan_correct(c2)); + std::vector>::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&& c, const allocator_type& a); + +#include +#include +#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 > l(test_allocator(5)); + std::vector > lo(test_allocator(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 > l2(std::move(l), test_allocator(6)); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == test_allocator(6)); + assert(is_contiguous_container_asan_correct(l2)); + } + { + std::vector > l(test_allocator(5)); + std::vector > lo(test_allocator(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 > l2(std::move(l), test_allocator(5)); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == test_allocator(5)); + assert(is_contiguous_container_asan_correct(l2)); + } + { + std::vector > l(other_allocator(5)); + std::vector > lo(other_allocator(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 > l2(std::move(l), other_allocator(4)); + assert(l2 == lo); + assert(!l.empty()); + assert(l2.get_allocator() == other_allocator(4)); + assert(is_contiguous_container_asan_correct(l2)); + } +#if __cplusplus >= 201103L + { + std::vector > l(min_allocator{}); + std::vector > lo(min_allocator{}); + 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 > l2(std::move(l), min_allocator()); + assert(l2 == lo); + assert(l.empty()); + assert(l2.get_allocator() == min_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/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& operator=(vector&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::vector C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::vector> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_alloc +{ + typedef T value_type; + some_alloc(const some_alloc&); +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::vector C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::vector> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::vector> 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::value, ""); +#else + static_assert(!std::is_nothrow_move_constructible::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& operator=(initializer_list il); + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// pointer data(); + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v; + assert(v.data() == 0); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector v(100); + assert(v.data() == &v.front()); + assert(is_contiguous_container_asan_correct(v)); + } +#if __cplusplus >= 201103L + { + std::vector> v; + assert(v.data() == 0); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_pointer data() const; + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + const std::vector v; + assert(v.data() == 0); + assert(is_contiguous_container_asan_correct(v)); + } + { + const std::vector v(100); + assert(v.data() == &v.front()); + assert(is_contiguous_container_asan_correct(v)); + } +#if __cplusplus >= 201103L + { + const std::vector> v; + assert(v.data() == 0); + assert(is_contiguous_container_asan_correct(v)); + } + { + const std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template iterator emplace(const_iterator pos, Args&&... args); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include +#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 c; + std::vector::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 > c; + std::vector >::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 c1; + std::vector c2; + std::vector::iterator i = c1.emplace(c2.cbegin(), 2, 3.5); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::vector> c; + std::vector>::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> c1; + std::vector> c2; + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template void emplace_back(Args&&... args); + +#include +#include +#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 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 > 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template iterator emplace(const_iterator pos, Args&&... args); + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector 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 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> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase(const_iterator position); + +#include +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::vector l1(a1, a1+3); + std::vector::const_iterator i = l1.begin(); + assert(is_contiguous_container_asan_correct(l1)); + ++i; + std::vector::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> l1(a1, a1+3); + std::vector>::const_iterator i = l1.begin(); + assert(is_contiguous_container_asan_correct(l1)); + ++i; + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::vector l1(a1, a1+3); + std::vector::const_iterator i = l1.end(); + l1.erase(i); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::vector l1(a1, a1+3); + std::vector l2(a1, a1+3); + std::vector::const_iterator i = l2.begin(); + l1.erase(i); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + int a1[] = {1, 2, 3}; + { + std::vector l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector::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 l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector::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(a1+1, a1+3)); + assert(is_contiguous_container_asan_correct(l1)); + } + { + std::vector l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector::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(a1+2, a1+3)); + assert(is_contiguous_container_asan_correct(l1)); + } + { + std::vector l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector::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 > outer(2, std::vector(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> l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector>::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> l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector>::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>(a1+1, a1+3))); + assert(is_contiguous_container_asan_correct(l1)); + } + { + std::vector> l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector>::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>(a1+2, a1+3))); + assert(is_contiguous_container_asan_correct(l1)); + } + { + std::vector> l1(a1, a1+3); + assert(is_contiguous_container_asan_correct(l1)); + std::vector>::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>, min_allocator>>> outer(2, std::vector>(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::vector l1(a1, a1+3); + std::vector l2(a1, a1+3); + std::vector::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::vector l1(a1, a1+3); + std::vector l2(a1, a1+3); + std::vector::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::vector l1(a1, a1+3); + std::vector l2(a1, a1+3); + std::vector::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector> l2(a1, a1+3); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::vector l1(a1, a1+3); + std::vector::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin()); + assert(false); + } +#if __cplusplus >= 201103L + { + int a1[] = {1, 2, 3}; + std::vector> l1(a1, a1+3); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert(const_iterator p, initializer_list il); + +#include +#include + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::vector d(10, 1); + std::vector::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> d(10, 1); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include "../../../stack_allocator.h" +#include "test_iterators.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector::iterator i = v.insert(v.cbegin() + 10, input_iterator(a), + input_iterator(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 v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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 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::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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 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::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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 > v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector::iterator i = v.insert(v.cbegin() + 10, input_iterator(a), + input_iterator(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 > v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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 v(100); + std::vector v2(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector::iterator i = v.insert(v2.cbegin() + 10, input_iterator(a), + input_iterator(a+N)); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, input_iterator(a), + input_iterator(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> v(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v.cbegin() + 10, forward_iterator(a), + forward_iterator(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> v(100); + std::vector> v2(100); + int a[] = {1, 2, 3, 4, 5}; + const int N = sizeof(a)/sizeof(a[0]); + std::vector>::iterator i = v.insert(v2.cbegin() + 10, input_iterator(a), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#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 v(100); + std::vector::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 > v(100); + std::vector >::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 v1(3); + std::vector v2(3); + v1.insert(v2.begin(), 4); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::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> v1(3); + std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v(100); + std::vector::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 v(100); + while(v.size() < v.capacity()) v.push_back(0); // force reallocation + size_t sz = v.size(); + std::vector::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 v(100); + v.reserve(128); // force no reallocation + size_t sz = v.size(); + std::vector::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 > v(100); + std::vector >::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 c1(100); + std::vector c2; + std::vector::iterator i = c1.insert(c2.cbegin() + 10, 5, 1); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::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> v(100); + std::vector>::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> c1(100); + std::vector> c2; + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector v(100); + std::vector::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 v(100); + while(v.size() < v.capacity()) v.push_back(0); // force reallocation + size_t sz = v.size(); + std::vector::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 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::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 > v(100); + std::vector >::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 v1(3); + std::vector v2(3); + int i = 4; + v1.insert(v2.begin(), i); + assert(false); + } +#endif +#if __cplusplus >= 201103L + { + std::vector> v(100); + std::vector>::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> v1(3); + std::vector> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop_back(); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" + +#if _LIBCPP_DEBUG >= 1 +#include +#include + +#endif + +int main() +{ + { + std::vector 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(const value_type& x); + +#include +#include +#include "../../../stack_allocator.h" +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + std::vector 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 > 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(const value_type& x); + +#include +#include + +#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 vec; + + vec.push_back(instance); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(value_type&& x); + +#include +#include +#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 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 > 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(vector& x, vector& y); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::vector::iterator i1 = c1.begin(); + std::vector::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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::vector>::iterator i1 = c1.begin(); + std::vector>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(vector& x, vector& y); + +#include +#include +#include +#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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector 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(a2, a2+sizeof(a2)/sizeof(a2[0]))); + assert(c2 == std::vector(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 c1(a1, a1); + std::vector 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(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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector 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(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 c1(a1, a1); + std::vector 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 A; + std::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); + std::vector c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); + swap(c1, c2); + assert((c1 == std::vector(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A(1)); + assert((c2 == std::vector(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 A; + std::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); + std::vector 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(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A(2)); + assert((c2 == std::vector(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector> 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>(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert((c2 == std::vector>(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> c1(a1, a1); + std::vector> 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>(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> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::vector> 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>(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> c1(a1, a1); + std::vector> 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 A; + std::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A()); + std::vector 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(a2, a2+sizeof(a2)/sizeof(a2[0])))); + assert(c1.get_allocator() == A()); + assert((c2 == std::vector(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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(vector& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::propagate_on_container_swap::value || +// allocator_traits::is_always_equal::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::vector> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::vector> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::vector> 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include + +template +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 struct rebind {typedef stack_allocator 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 +inline +void +swap(stack_allocator& x, stack_allocator& 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 +#include +#include +#include +#include + +template +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::type x, + typename std::add_lvalue_reference::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 +#include + +template +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::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 + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// size_type bucket_count() const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_map C; + typedef C::const_iterator I; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// http://llvm.org/bugs/show_bug.cgi?id=16538 +// http://llvm.org/bugs/show_bug.cgi?id=16549 + +#include + +struct Key { + template Key(const T&) {} + bool operator== (const Key&) const { return true; } +}; + +namespace std +{ + template <> + struct hash + { + size_t operator()(Key const &) const {return 0;} + }; +} + +int +main() +{ + std::unordered_map::iterator it = + std::unordered_map().find(Key(0)); + std::pair::iterator, bool> result = + std::unordered_map().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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// size_type count(const key_type& k) const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + C c(1); + C::local_iterator i = c.begin(0); + ++i; + ++i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator==(const unordered_map& x, +// const unordered_map& y); +// +// template +// bool +// operator!=(const unordered_map& x, +// const unordered_map& y); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// pair equal_range(const key_type& k) const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef C::const_iterator I; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// pair equal_range(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef C::iterator I; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef C::iterator I; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// const_iterator find(const key_type& k) const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// iterator find(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// float load_factor() const + +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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 C; + typedef std::pair P; + const C c; + assert(c.load_factor() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// size_type max_bucket_count() const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.max_bucket_count() > 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::unordered_map u; + assert(u.max_size() > 0); + } +#if __cplusplus >= 201103L + { + std::unordered_map, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// void rehash(size_type n); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// void reserve(size_type n); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// void swap(unordered_map& __u); + +#include +#include +#include + +#include "../../test_compare.h" +#include "../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 value_type; +// typedef value_type& reference; +// typedef const value_type& const_reference; +// typedef typename allocator_traits::pointer pointer; +// typedef typename allocator_traits::const_pointer const_pointer; +// typedef typename allocator_traits::size_type size_type; +// typedef typename allocator_traits::difference_type difference_type; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_map, std::equal_to, + min_allocator>> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + // min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// explicit unordered_map(const allocator_type& __a); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(test_allocator >(10)); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + C c(min_allocator >{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_map 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> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_map 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map& operator=(const unordered_map& u); + +#include +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_allocator > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 C; + typedef std::pair 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 > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map& operator=(initializer_list il); + +#include +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::allocator > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map& operator=(unordered_map&& u); + +#include +#include +#include +#include + +#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 > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 > A; + typedef std::unordered_map >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 s1 = {{1, 1}, {2, 2}, {3, 3}}; + std::unordered_map::iterator i = s1.begin(); + std::pair k = *i; + std::unordered_map 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(const unordered_map& u); + +#include +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + other_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + other_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (other_allocator >(-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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(const unordered_map& u, const allocator_type& a); + +#include +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(10) + ); + C c(c0, test_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + C c(c0, min_allocator >()); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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 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() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" +#include "../../../test_hash.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, test_allocator>> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, other_allocator>> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_map> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_map, + some_comp> C; + static_assert(!std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, test_allocator>> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, other_allocator>> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_map> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_map, + some_comp> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(initializer_list il); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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 P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_map 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 >()); + assert(c.key_eq() == test_compare >()); + 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 P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_map 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 >())); + assert(c.key_eq() == test_compare >()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(initializer_list il, size_type n); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(initializer_list il, size_type n, const hasher& hf); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9), + test_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(unordered_map&& u); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(10) + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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 s1 = {{1, 1}, {2, 2}, {3, 3}}; + std::unordered_map::iterator i = s1.begin(); + std::pair k = *i; + std::unordered_map 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(unordered_map&& u, const allocator_type& a); + +#include +#include +#include +#include + +#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 P; + typedef test_allocator> A; + typedef std::unordered_map >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 P; + typedef test_allocator> A; + typedef std::unordered_map >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 P; + typedef min_allocator> A; + typedef std::unordered_map >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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& operator=(unordered_map&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, test_allocator>> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, other_allocator>> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_map> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_map, + some_comp> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, test_allocator>> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_map, + std::equal_to, other_allocator>> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_map> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_map, + some_comp> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// unordered_map(InputIterator first, InputIterator last); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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 P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_map 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(arr), input_iterator(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 P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_map 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(arr), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// unordered_map(InputIterator first, InputIterator last, size_type n); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// unordered_map(InputIterator first, InputIterator last, size_type n, +// const hasher& hf); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// unordered_map(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// unordered_map(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql, +// const allocator_type& a); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + test_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(size_type n); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(size_type n); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(size_type n, const hasher& hf); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(size_type n, const hasher& hf, const key_equal& eql); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9), + test_allocator >(10) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// mapped_type& at(const key_type& k); +// const mapped_type& at(const key_type& k) const; + +#include +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// mapped_type& operator[](const key_type& k); + +#include +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// mapped_type& operator[](const key_type& k); + +// http://llvm.org/bugs/show_bug.cgi?id=16542 + +#include + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +#include + +using namespace std; + +struct my_hash +{ + size_t operator()(const tuple&) const {return 0;} +}; + +#endif + +int main() +{ +#ifndef _LIBCPP_HAS_NO_VARIADICS + unordered_map, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include + +int main() +{ +#if _LIBCPP_DEBUG >= 1 + { + typedef std::pair 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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::unordered_map c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::unordered_map::iterator i1 = c1.begin(); + std::unordered_map::iterator i2 = c2.begin(); + swap(c1, c2); + c1.erase(i2); + c2.erase(i1); + std::unordered_map::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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(unordered_map& c) +// noexcept( +// (!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value) && +// __is_nothrow_swappable::value && +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// noexcept(swap(declval(), declval())) && +// noexcept(swap(declval(), declval()))); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + + some_comp() {} + some_comp(const some_comp&) {} +}; + +template +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +struct some_hash +{ + typedef T value_type; + some_hash() {} + some_hash(const some_hash&); +}; + +template +struct some_hash2 +{ + typedef T value_type; + some_hash2() {} + some_hash2(const some_hash2&); +}; + +#if TEST_STD_VER >= 14 +template +void swap(some_hash2&, some_hash2&) noexcept {} +#endif + +template +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 +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 +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 MapType; + { + typedef std::unordered_map C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_map, + std::equal_to, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_map, + std::equal_to, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_map> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_map, + some_comp> 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, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, throwable swap for hash, nothrow swap for comp + typedef std::unordered_map, some_comp2, some_alloc > 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, some_comp2, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, throwable swap for comp + typedef std::unordered_map, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, nothrow swap for comp + typedef std::unordered_map, some_comp2, some_alloc > 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, some_comp2, some_alloc2> 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, some_comp2, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// void swap(unordered_map& __u); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_map C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// void clear() + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// pair emplace(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_map C; + typedef std::pair 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(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, std::equal_to, + min_allocator>> C; + typedef std::pair 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(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// 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 +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_map 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(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, std::equal_to, + min_allocator>> 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(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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// iterator erase(const_iterator p) + +#include +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map l2(a1, a1+3); + std::unordered_map::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map l2(a1, a1+3); + std::unordered_map::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map l2(a1, a1+3); + std::unordered_map::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map l2(a1, a1+3); + std::unordered_map::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// size_type erase(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +#if __cplusplus >= 201103L +template +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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// iterator erase(const_iterator first, const_iterator last) + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// pair insert(const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template ::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 +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef C::iterator R; + typedef std::pair 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 C; + typedef C::iterator R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// void insert(initializer_list il); + +#include +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::unordered_map C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 + +// + +// class unordered_map + +// template +// pair insert_or_assign(const key_type& k, M&& obj); // C++17 +// template +// pair insert_or_assign(key_type&& k, M&& obj); // C++17 +// template +// iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 +// template +// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 + +#include <__config> +#include +#include +#include + +#include + +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_) + std::hash()(double_); } + + int get() const {return int_;} + bool moved() const {return int_ == -1;} +}; + +namespace std { + template <> struct hash { + size_t operator () (const Moveable &m) const { return m.hash(); } + }; +} + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_HAS_NO_VARIADICS + + { // pair insert_or_assign(const key_type& k, M&& obj); + typedef std::unordered_map M; + typedef std::pair 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 insert_or_assign(key_type&& k, M&& obj); + typedef std::unordered_map M; + typedef std::pair 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair 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(a), input_iterator(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, std::equal_to, + min_allocator>> C; + typedef std::pair 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(a), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// template ::value>::type> +// pair insert(P&& x); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_map C; + typedef std::pair R; + typedef std::pair 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 C; + typedef std::pair R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair R; + typedef std::pair 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 + +// + +// class unordered_map + +// template +// pair try_emplace(const key_type& k, Args&&... args); // C++17 +// template +// pair try_emplace(key_type&& k, Args&&... args); // C++17 +// template +// iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 +// template +// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 + +#include <__config> +#include +#include +#include + +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_) + std::hash()(double_); } + + int get() const {return int_;} + bool moved() const {return int_ == -1;} +}; + +namespace std { + template <> struct hash { + size_t operator () (const Moveable &m) const { return m.hash(); } + }; +} + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_HAS_NO_VARIADICS + + { // pair try_emplace(const key_type& k, Args&&... args); + typedef std::unordered_map M; + typedef std::pair 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 try_emplace(key_type&& k, Args&&... args); + typedef std::unordered_map M; + typedef std::pair 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// size_type bucket_count() const; + +#include +#include +#include + +int main() +{ + { + typedef std::unordered_multimap C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_multimap C; + typedef C::const_iterator I; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// size_type count(const key_type& k) const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + C c(1); + C::local_iterator i = c.begin(0); + ++i; + ++i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator==(const unordered_multimap& x, +// const unordered_multimap& y); +// +// template +// bool +// operator!=(const unordered_multimap& x, +// const unordered_multimap& y); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// pair equal_range(const key_type& k) const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef C::const_iterator I; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// pair equal_range(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef C::iterator I; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef C::iterator I; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// const_iterator find(const key_type& k) const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// iterator find(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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 C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// float load_factor() const + +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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 C; + typedef std::pair P; + const C c; + assert(c.load_factor() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// size_type max_bucket_count() const; + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef C::const_iterator I; + typedef std::pair P; + const C c; + assert(c.max_bucket_count() > 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef C::const_iterator I; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_multimap C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::unordered_multimap u; + assert(u.max_size() > 0); + } +#if __cplusplus >= 201103L + { + std::unordered_multimap, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// void rehash(size_type n); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +void test(const C& c) +{ + assert(c.size() == 6); + typedef std::pair 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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// void rehash(size_type n); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// class unordered_map class unordered_multimap + +// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap + +#include + +int main() +{ + typedef std::unordered_map M1; + typedef std::unordered_multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// void swap(unordered_multimap& __u); + +#include +#include +#include + +#include "../../test_compare.h" +#include "../../test_hash.h" +#include "test_allocator.h" + +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 value_type; +// typedef value_type& reference; +// typedef const value_type& const_reference; +// typedef typename allocator_traits::pointer pointer; +// typedef typename allocator_traits::const_pointer const_pointer; +// typedef typename allocator_traits::size_type size_type; +// typedef typename allocator_traits::difference_type difference_type; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap, std::equal_to, + min_allocator>> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + // min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// explicit unordered_multimap(const allocator_type& __a); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(test_allocator >(10)); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + C c(min_allocator >{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_multimap 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> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap& operator=(const unordered_multimap& u); + +#include +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_allocator > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 C; + typedef std::pair 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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap& operator=(initializer_list il); + +#include +#include +#include +#include + +#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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap& operator=(unordered_multimap&& u); + +#include +#include +#include +#include + +#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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A(4) + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A(10) + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A(4) + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 > A; + typedef std::unordered_multimap >, + test_compare >, + A + > C; + typedef std::pair 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(3), + A() + ); + c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 s1 = {{1, 1}, {2, 2}, {3, 3}}; + std::unordered_multimap::iterator i = s1.begin(); + std::pair k = *i; + std::unordered_multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(const unordered_multimap& u); + +#include +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + other_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + other_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (other_allocator >(-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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(const unordered_multimap& u, const allocator_type& a); + +#include +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(10) + ); + C c(c0, test_allocator >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + C c(c0, min_allocator >()); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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 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_multimap() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" +#include "../../../test_hash.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, test_allocator>> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, other_allocator>> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multimap> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multimap, + some_comp> C; + static_assert(!std::is_nothrow_default_constructible::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_multimap() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, test_allocator>> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, other_allocator>> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multimap> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multimap, + some_comp> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(initializer_list il); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_multimap 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 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 P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_multimap 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(initializer_list il, size_type n); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(initializer_list il, size_type n, const hasher& hf); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9), + test_allocator >(10) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == test_allocator >(10))); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair P; + C c({ + P(1, "one"), + P(2, "two"), + P(3, "three"), + P(4, "four"), + P(1, "four"), + P(2, "four"), + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(unordered_multimap&& u); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(10) + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + test_allocator >(10) + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == test_allocator >(10))); + + assert(c0.empty()); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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 >(8), + test_compare >(9), + min_allocator >() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + + assert(c0.empty()); + } +#endif +#if _LIBCPP_DEBUG >= 1 + { + std::unordered_multimap s1 = {{1, 1}, {2, 2}, {3, 3}}; + std::unordered_multimap::iterator i = s1.begin(); + std::pair k = *i; + std::unordered_multimap 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(unordered_multimap&& u, const allocator_type& a); + +#include + +#include +#include +#include +#include + +#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 P; + typedef test_allocator> A; + typedef std::unordered_multimap >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(std::move(c0), A(12)); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == test_allocator >(12))); + + assert(c0.empty()); + } + { + typedef std::pair P; + typedef test_allocator> A; + typedef std::unordered_multimap >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(std::move(c0), A(10)); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == test_allocator >(10))); + + assert(c0.empty()); + } +#if __cplusplus >= 201103L + { + typedef std::pair P; + typedef min_allocator> A; + typedef std::unordered_multimap >, + test_compare >, + 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 >(8), + test_compare >(9), + A() + ); + C c(std::move(c0), A()); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + + 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_multimap& operator=(unordered_multimap&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, test_allocator>> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, other_allocator>> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multimap> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multimap, + some_comp> C; + static_assert(!std::is_nothrow_move_assignable::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_multimap(unordered_multimap&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, test_allocator>> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multimap, + std::equal_to, other_allocator>> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multimap> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multimap, + some_comp> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// unordered_multimap(InputIterator first, InputIterator last); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.bucket_count() >= 7); + assert(c.size() == 6); + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_multimap 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(arr), input_iterator(arr + sizeof(arr)/sizeof(arr[0])), 14, a); + assert(c.bucket_count() >= 14); + assert(c.size() == 6); + typedef std::pair 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 P; + typedef test_allocator> A; + typedef test_hash> HF; + typedef test_compare> Comp; + typedef std::unordered_multimap 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(arr), input_iterator(arr + sizeof(arr)/sizeof(arr[0])), 12, hf, a ); + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// unordered_multimap(InputIterator first, InputIterator last, size_type n); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 10 + ); + assert(c.bucket_count() == 11); + assert(c.size() == 6); + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 10 + ); + assert(c.bucket_count() == 11); + assert(c.size() == 6); + typedef std::pair 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 >()); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// unordered_multimap(InputIterator first, InputIterator last, size_type n, +// const hasher& hf); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >()); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// unordered_multimap(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == test_allocator >())); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// unordered_multimap(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql, +// const allocator_type& a); + +#include +#include +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + test_allocator >(10) + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == test_allocator >(10))); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multimap >, + test_compare >, + min_allocator > + > C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.size() == 6); + typedef std::pair 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert((c.get_allocator() == min_allocator >())); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(size_type n); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(size_type n); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(size_type n, const hasher& hf); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >())); + 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 >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include + +#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 >, + test_compare >, + test_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9), + test_allocator >(10) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (test_allocator >(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 >, + test_compare >, + min_allocator > + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == + (min_allocator >())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// void clear() + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// iterator emplace(Args&&... args); + +#include +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multimap 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(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, std::equal_to, + min_allocator>> 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(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// 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 +#include + +#include "../../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multimap 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(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, std::equal_to, + min_allocator>> 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(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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// iterator erase(const_iterator p) + +#include +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + 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 C; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap l2(a1, a1+3); + std::unordered_multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap l2(a1, a1+3); + std::unordered_multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap l2(a1, a1+3); + std::unordered_multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap l2(a1, a1+3); + std::unordered_multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// size_type erase(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +#if __cplusplus >= 201103L +template +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 C; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// iterator erase(const_iterator first, const_iterator last) + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// iterator insert(const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template ::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 +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef C::iterator R; + typedef std::pair 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 C; + typedef C::iterator R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// void insert(initializer_list il); + +#include +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::unordered_multimap C; + typedef std::pair 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 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.size() == 6); + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef std::pair 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(a), input_iterator(a + sizeof(a)/sizeof(a[0]))); + assert(c.size() == 6); + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// template ::value>::type> +// iterator insert(P&& x); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multimap C; + typedef C::iterator R; + typedef std::pair 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 C; + typedef C::iterator R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair 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, std::equal_to, + min_allocator>> C; + typedef C::iterator R; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// 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 +#include + +int main() +{ +#if _LIBCPP_DEBUG >= 1 + { + typedef std::pair 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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::unordered_multimap c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::unordered_multimap::iterator i1 = c1.begin(); + std::unordered_multimap::iterator i2 = c2.begin(); + swap(c1, c2); + c1.erase(i2); + c2.erase(i1); + std::unordered_multimap::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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(unordered_multimap& c) +// noexcept( +// (!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value) && +// __is_nothrow_swappable::value && +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// __is_nothrow_swappable::value && +// __is_nothrow_swappable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + + some_comp() {} + some_comp(const some_comp&) {} +}; + +template +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +struct some_hash +{ + typedef T value_type; + some_hash() {} + some_hash(const some_hash&); +}; + +template +struct some_hash2 +{ + typedef T value_type; + some_hash2() {} + some_hash2(const some_hash2&); +}; + +#if TEST_STD_VER >= 14 +template +void swap(some_hash2&, some_hash2&) noexcept {} +#endif + +template +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 +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 +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 MapType; + { + typedef std::unordered_multimap C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multimap, + std::equal_to, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multimap, + std::equal_to, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multimap> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multimap, + some_comp> 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, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, throwable swap for hash, nothrow swap for comp + typedef std::unordered_multimap, some_comp2, some_alloc > 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, some_comp2, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, throwable swap for comp + typedef std::unordered_multimap, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, nothrow swap for comp + typedef std::unordered_multimap, some_comp2, some_alloc > 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, some_comp2, some_alloc2> 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, some_comp2, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_multimap + +// void swap(unordered_multimap& __u); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator > Alloc; + typedef std::unordered_multimap C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// size_type bucket_count() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset C; + typedef C::const_iterator I; + typedef int P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// void clear() + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// size_type count(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_multiset 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_multiset C; + C c(1); + C::iterator i = c.end(); + T j = *i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::unordered_multiset> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_multiset 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_multiset 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// iterator emplace(Args&&... args); + +#include +#include + +#include "../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// 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 +#include + +#include "../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator==(const unordered_multiset& x, +// const unordered_multiset& y); +// +// template +// bool +// operator!=(const unordered_multiset& x, +// const unordered_multiset& y); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// pair equal_range(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// pair equal_range(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// iterator erase(const_iterator p) + +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + 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 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset l2(a1, a1+3); + std::unordered_multiset::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset l2(a1, a1+3); + std::unordered_multiset::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset l2(a1, a1+3); + std::unordered_multiset::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset l2(a1, a1+3); + std::unordered_multiset::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// size_type erase(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +#if __cplusplus >= 201103L +template +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 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// iterator erase(const_iterator first, const_iterator last) + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// const_iterator find(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// iterator find(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// iterator insert(const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// void insert(initializer_list il); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c; + c.insert(input_iterator(a), input_iterator(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, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c; + c.insert(input_iterator(a), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// iterator insert(value_type&& x); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +int main() +{ + { + typedef std::unordered_multiset 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// float load_factor() const + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 C; + typedef int P; + const C c; + assert(c.load_factor() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +int main() +{ + { + typedef std::unordered_multiset 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset 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 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 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// size_type max_bucket_count() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset C; + const C c; + assert(c.max_bucket_count() > 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset C; + typedef int P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_multiset 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, + std::equal_to, min_allocator> C; + typedef int P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::unordered_multiset u; + assert(u.max_size() > 0); + } +#if __cplusplus >= 201103L + { + std::unordered_multiset, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// void rehash(size_type n); + +#include +#include + +#include "min_allocator.h" + +template +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 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// void reserve(size_type n); + +#include +#include + +#include "min_allocator.h" + +template +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 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// class unordered_set class unordered_multiset + +// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset + +#include + +int main() +{ + typedef std::unordered_set M1; + typedef std::unordered_multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// void swap(unordered_multiset& __u); + +#include +#include + +#include "../../test_compare.h" +#include "../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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::pointer pointer; +// typedef typename allocator_traits::const_pointer const_pointer; +// typedef typename allocator_traits::size_type size_type; +// typedef typename allocator_traits::difference_type difference_type; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_multiset, + std::equal_to, min_allocator> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + // min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// explicit unordered_multiset(const allocator_type& __a); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(test_allocator(10)); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + C c(min_allocator{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_multiset 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset& operator=(const unordered_multiset& u); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_allocator A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset& operator=(initializer_list il); + +#include +#include +#include + +#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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 A; + typedef std::unordered_multiset >, + test_compare >, + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset& operator=(unordered_multiset&& u); + +#include +#include +#include + +#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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 s1 = {1, 2, 3}; + std::unordered_multiset::iterator i = s1.begin(); + int k = *i; + std::unordered_multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(const unordered_multiset& u); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset >, + test_compare >, + test_allocator + > 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 >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + other_allocator + > 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 >(8), + test_compare >(9), + other_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == other_allocator(-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 >, + test_compare >, + min_allocator + > 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 >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(const unordered_multiset& u, const allocator_type& a); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_multiset >, + test_compare >, + test_allocator + > 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 >(8), + test_compare >(9), + test_allocator(10) + ); + C c(c0, test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > 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 >(8), + test_compare >(9), + min_allocator() + ); + C c(c0, min_allocator()); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + 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 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_multiset() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" +#include "../../../test_hash.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_default_constructible::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_multiset() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(initializer_list il); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_multiset 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(initializer_list il, size_type n); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(initializer_list il, size_type n, +// const hasher& hf); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(unordered_multiset&& u); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(7, + test_hash >(8), + test_compare >(9), + test_allocator(10) + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + test_allocator + > 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 >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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 >, + test_compare >, + min_allocator + > 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 >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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 s1 = {1, 2, 3}; + std::unordered_multiset::iterator i = s1.begin(); + int k = *i; + std::unordered_multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(unordered_multiset&& u, const allocator_type& a); + +#include +#include +#include + +#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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_multiset >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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_multiset& operator=(unordered_multiset&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_move_assignable::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_multiset(unordered_multiset&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_multiset, + some_comp> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// unordered_multiset(InputIterator first, InputIterator last); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_multiset C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator(arr), input_iterator(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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_multiset 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(arr), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// unordered_multiset(InputIterator first, InputIterator last, size_type n); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// unordered_multiset(InputIterator first, InputIterator last, size_type n, +// const hasher& hf); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// unordered_multiset(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// template +// unordered_multiset(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql, +// const allocator_type& a); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// explicit unordered_multiset(size_type n); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// explicit unordered_multiset(size_type n); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(size_type n, const hasher& hf); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9), + test_allocator >(10) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (test_allocator(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 >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator >() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::unordered_multiset c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::unordered_multiset::iterator i1 = c1.begin(); + std::unordered_multiset::iterator i2 = c2.begin(); + swap(c1, c2); + c1.erase(i2); + c2.erase(i1); + std::unordered_multiset::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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(unordered_multiset& c) +// noexcept( +// (!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value) && +// __is_nothrow_swappable::value && +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// noexcept(swap(declval(), declval())) && +// noexcept(swap(declval(), declval()))); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + + some_comp() {} + some_comp(const some_comp&) {} +}; + +template +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +struct some_hash +{ + typedef T value_type; + some_hash() {} + some_hash(const some_hash&); +}; + +template +struct some_hash2 +{ + typedef T value_type; + some_hash2() {} + some_hash2(const some_hash2&); +}; + +#if TEST_STD_VER >= 14 +template +void swap(some_hash2&, some_hash2&) noexcept {} +#endif + +template +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 +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset, + std::equal_to, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset, + std::equal_to, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_multiset, + some_comp> 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, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, throwable swap for hash, nothrow swap for comp + typedef std::unordered_multiset, some_comp2, some_alloc > 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, some_comp2, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, throwable swap for comp + typedef std::unordered_multiset, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, nothrow swap for comp + typedef std::unordered_multiset, some_comp2, some_alloc > 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, some_comp2, some_alloc2> 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, some_comp2, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_multiset + +// void swap(unordered_multiset& x, unordered_multiset& y); + +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_multiset 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// size_type bucket_count() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set C; + typedef C::const_iterator I; + typedef int P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_set 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, std::equal_to, min_allocator> C; + typedef C::const_iterator I; + typedef int P; + const C c; + assert(c.bucket_count() == 0); + } + { + typedef std::unordered_set, std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// void clear() + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// size_type count(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_set 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_set C; + C c(1); + C::iterator i = c.end(); + T j = *i; + assert(false); + } +#if __cplusplus >= 201103L + { + typedef int T; + typedef std::unordered_set> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_set 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef int T; + typedef std::unordered_set 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// pair emplace(Args&&... args); + +#include +#include + +#include "../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_set C; + typedef std::pair 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, + std::equal_to, min_allocator> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// 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 +#include + +#include "../../Emplaceable.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_set 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator==(const unordered_set& x, +// const unordered_set& y); +// +// template +// bool +// operator!=(const unordered_set& x, +// const unordered_set& y); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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 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 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, std::equal_to, min_allocator> 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, std::equal_to, min_allocator> 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, std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// pair equal_range(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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 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, std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// pair equal_range(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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 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, std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// iterator erase(const_iterator p) + +#include +#include + +#include "min_allocator.h" + +struct TemplateConstructor +{ + template + 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 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, std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set l2(a1, a1+3); + std::unordered_set::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set l2(a1, a1+3); + std::unordered_set::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set l2(a1, a1+3); + std::unordered_set::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set l2(a1, a1+3); + std::unordered_set::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +int main() +{ + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// size_type erase(const key_type& k); + +#include +#include +#include + +#include "min_allocator.h" + +#if __cplusplus >= 201103L +template +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 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, std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// iterator erase(const_iterator first, const_iterator last) + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// const_iterator find(const key_type& k) const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// iterator find(const key_type& k); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// pair insert(const value_type& x); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set C; + typedef std::pair 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, + std::equal_to, min_allocator> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// void insert(initializer_list il); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::unordered_set 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// void insert(InputIterator first, InputIterator last); + +#include +#include + +#include "test_iterators.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c; + c.insert(input_iterator(a), input_iterator(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, + std::equal_to, min_allocator> C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c; + c.insert(input_iterator(a), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// pair insert(value_type&& x); + +#include +#include + +#include "MoveOnly.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set C; + typedef std::pair 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 C; + typedef std::pair 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, + std::equal_to, min_allocator> C; + typedef std::pair 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, + std::equal_to, min_allocator> C; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +int main() +{ + { + typedef std::unordered_set 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// float load_factor() const + +#include +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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 C; + typedef int P; + const C c; + assert(c.load_factor() == 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +int main() +{ + { + typedef std::unordered_set 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set 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 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 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 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// size_type max_bucket_count() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set C; + const C c; + assert(c.max_bucket_count() > 0); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set C; + typedef int P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_set 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, + std::equal_to, min_allocator> C; + typedef int P; + const C c; + assert(c.max_load_factor() == 1); + } + { + typedef std::unordered_set, + std::equal_to, min_allocator> 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::unordered_set u; + assert(u.max_size() > 0); + } +#if __cplusplus >= 201103L + { + std::unordered_set, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// void rehash(size_type n); + +#include +#include + +#include "min_allocator.h" + +template +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 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// void reserve(size_type n); + +#include +#include + +#include "min_allocator.h" + +template +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 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, + std::equal_to, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// void swap(unordered_set& u); + +#include +#include + +#include "../../test_compare.h" +#include "../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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::pointer pointer; +// typedef typename allocator_traits::const_pointer const_pointer; +// typedef typename allocator_traits::size_type size_type; +// typedef typename allocator_traits::difference_type difference_type; + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + } +#if __cplusplus >= 201103L + { + typedef std::unordered_set, + std::equal_to, min_allocator> C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same>::value), ""); + static_assert((std::is_same>::value), ""); + // min_allocator doesn't have a size_type, so one gets synthesized + static_assert((std::is_same::type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// explicit unordered_set(const allocator_type& __a); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(test_allocator(10)); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + C c(min_allocator{}); + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_set 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_set 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set& operator=(const unordered_set& u); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_allocator A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set& operator=(initializer_list il); + +#include +#include +#include + +#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 A; + typedef std::unordered_set >, + test_compare >, + 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 A; + typedef std::unordered_set >, + test_compare >, + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set& operator=(unordered_set&& u); + +#include +#include +#include + +#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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(9), + A(10) + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(9), + A() + ); + C c(a, a + 2, + 7, + test_hash >(2), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 s1 = {1, 2, 3}; + std::unordered_set::iterator i = s1.begin(); + int k = *i; + std::unordered_set 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(const unordered_set& u); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set >, + test_compare >, + test_allocator + > 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 >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + other_allocator + > 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 >(8), + test_compare >(9), + other_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == other_allocator(-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 >, + test_compare >, + min_allocator + > 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 >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(const unordered_set& u, const allocator_type& a); + +#include +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef std::unordered_set >, + test_compare >, + test_allocator + > 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 >(8), + test_compare >(9), + test_allocator(10) + ); + C c(c0, test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > 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 >(8), + test_compare >(9), + min_allocator() + ); + C c(c0, min_allocator()); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c; + assert(c.bucket_count() == 0); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + 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 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() +// noexcept( +// is_nothrow_default_constructible::value && +// is_nothrow_default_constructible::value && +// is_nothrow_copy_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" +#include "../../../test_hash.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(); + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_default_constructible::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() // implied noexcept; + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +struct some_comp +{ + typedef T value_type; + ~some_comp() noexcept(false); +}; + +template +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 C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_destructible::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(initializer_list il); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_set 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_set 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(initializer_list il, size_type n); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > 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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(initializer_list il, size_type n, +// const hasher& hf); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(initializer_list il, size_type n, +// const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + typedef int P; + C c({ + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }, + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(unordered_set&& u); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(7, + test_hash >(8), + test_compare >(9), + test_allocator(10) + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + test_allocator + > 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 >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c0(7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + C c = std::move(c0); + assert(c.bucket_count() == 7); + assert(c.size() == 0); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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 >, + test_compare >, + min_allocator + > 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 >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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 s1 = {1, 2, 3}; + std::unordered_set::iterator i = s1.begin(); + int k = *i; + std::unordered_set 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(unordered_set&& u, const allocator_type& a); + +#include +#include +#include + +#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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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 A; + typedef std::unordered_set >, + test_compare >, + 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 >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(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& operator=(unordered_set&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp& operator=(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_move_assignable::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&&) +// noexcept(is_nothrow_move_constructible::value && +// is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + some_comp(const some_comp&); +}; + +template +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 C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set> C; + static_assert(!std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::unordered_set, + some_comp> C; + static_assert(!std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// unordered_set(InputIterator first, InputIterator last); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_set C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator(arr), input_iterator(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> HF; + typedef test_compare> Comp; + typedef test_allocator A; + typedef std::unordered_set 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(arr), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// unordered_set(InputIterator first, InputIterator last, size_type n); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(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 >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// unordered_set(InputIterator first, InputIterator last, size_type n, +// const hasher& hf); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(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 >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// unordered_set(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator()); + 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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// template +// unordered_set(InputIterator first, InputIterator last, size_type n, +// const hasher& hf, const key_equal& eql, +// const allocator_type& a); + +#include +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + test_allocator(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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == test_allocator(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 >, + test_compare >, + min_allocator + > C; + typedef int P; + P a[] = + { + P(1), + P(2), + P(3), + P(4), + P(1), + P(2) + }; + C c(input_iterator(a), input_iterator(a + sizeof(a)/sizeof(a[0])), + 7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + 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 >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == min_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// explicit unordered_set(size_type n); + +#include +#include + +#include "../../../NotConstructible.h" +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" + +int main() +{ + { + typedef std::unordered_set >, + test_compare >, + test_allocator + > C; + C c = 7; + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// explicit unordered_set(size_type n); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c(7); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >()); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(size_type n, const hasher& hf); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >()); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(size_type n, const hasher& hf, const key_equal& eql); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (test_allocator())); + 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 >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// unordered_set(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a); + +#include +#include + +#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 >, + test_compare >, + test_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9), + test_allocator(10) + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (test_allocator(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 >, + test_compare >, + min_allocator + > C; + C c(7, + test_hash >(8), + test_compare >(9), + min_allocator() + ); + assert(c.bucket_count() == 7); + assert(c.hash_function() == test_hash >(8)); + assert(c.key_eq() == test_compare >(9)); + assert(c.get_allocator() == (min_allocator())); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// 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 +#include + +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 c1(a1, a1+sizeof(a1)/sizeof(a1[0])); + std::unordered_set c2(a2, a2+sizeof(a2)/sizeof(a2[0])); + std::unordered_set::iterator i1 = c1.begin(); + std::unordered_set::iterator i2 = c2.begin(); + swap(c1, c2); + c1.erase(i2); + c2.erase(i1); + std::unordered_set::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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(unordered_set& c) +// noexcept( +// (!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value) && +// __is_nothrow_swappable::value && +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::is_always_equal::value && +// noexcept(swap(declval(), declval())) && +// noexcept(swap(declval(), declval()))); + +// This tests a conforming extension + +#include +#include + +#include "MoveOnly.h" +#include "test_allocator.h" + +template +struct some_comp +{ + typedef T value_type; + + some_comp() {} + some_comp(const some_comp&) {} +}; + +template +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 +void swap(some_comp2&, some_comp2&) noexcept {} +#endif + +template +struct some_hash +{ + typedef T value_type; + some_hash() {} + some_hash(const some_hash&); +}; + +template +struct some_hash2 +{ + typedef T value_type; + some_hash2() {} + some_hash2(const some_hash2&); +}; + +#if TEST_STD_VER >= 14 +template +void swap(some_hash2&, some_hash2&) noexcept {} +#endif + +template +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 +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 +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 C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set, + std::equal_to, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set, + std::equal_to, other_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { + typedef std::unordered_set, + some_comp> 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, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, throwable swap for hash, nothrow swap for comp + typedef std::unordered_set, some_comp2, some_alloc > 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, some_comp2, some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, throwable swap for comp + typedef std::unordered_set, some_comp , some_alloc > 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, some_comp , some_alloc2> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } + { // POCS allocator, nothrow swap for hash, nothrow swap for comp + typedef std::unordered_set, some_comp2, some_alloc > 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, some_comp2, some_alloc2> 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, some_comp2, some_alloc3> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator> +// class unordered_set + +// void swap(unordered_set& x, unordered_set& y); + +#include +#include + +#include "../../../test_compare.h" +#include "../../../test_hash.h" +#include "test_allocator.h" +#include "min_allocator.h" + +int main() +{ + { + typedef test_hash > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef test_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef other_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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 > Hash; + typedef test_compare > Compare; + typedef min_allocator Alloc; + typedef std::unordered_set 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +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 + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr& operator=(auto_ptr& a) throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p1 = new A(1); + const std::auto_ptr ap1(p1); + A* p2 = new A(2); + std::auto_ptr ap2(p2); + assert(A::count == 2); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr& operator=(auto_ptr& a) throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p1 = new A(1); + std::auto_ptr ap1(p1); + A* p2 = new A(2); + std::auto_ptr ap2(p2); + assert(A::count == 2); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include +#include + +#include "../AB.h" + +void +test() +{ + { + B* p = new B(1); + const std::auto_ptr ap1(p); + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include +#include + +#include "../AB.h" + +void +test() +{ + { + B* p = new B(1); + std::auto_ptr ap1(p); + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// template auto_ptr& operator=(auto_ptr& a) throw(); + +#include +#include + +#include "../AB.h" + +void +test() +{ + { + B* p1 = new B(1); + const std::auto_ptr ap1(p1); + A* p2 = new A(2); + std::auto_ptr ap2(p2); + assert(A::count == 2); + assert(B::count == 1); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// template auto_ptr& operator=(auto_ptr& a) throw(); + +#include +#include + +#include "../AB.h" + +void +test() +{ + { + B* p1 = new B(1); + std::auto_ptr ap1(p1); + A* p2 = new A(2); + std::auto_ptr ap2(p2); + assert(A::count == 2); + assert(B::count == 1); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + const std::auto_ptr ap1(p); + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr ap1(p); + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// explicit auto_ptr(X* p =0) throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr ap = p; + assert(ap.get() == p); + assert(A::count == 1); + } + assert(A::count == 0); + { + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// explicit auto_ptr(X* p =0) throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr ap(p); + assert(ap.get() == p); + assert(A::count == 1); + } + assert(A::count == 0); + { + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr& operator=(auto_ptr_ref r) throw() + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p1 = new A(1); + std::auto_ptr ap1(p1); + std::auto_ptr_ref apr = ap1; + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// auto_ptr(auto_ptr_ref r) throw(); + +#include +#include + +#include "../AB.h" + +void +test() +{ + { + B* p1 = new B(1); + std::auto_ptr ap1(p1); + std::auto_ptr_ref apr = ap1; + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// template operator auto_ptr() throw(); + +#include +#include + +#include "../AB.h" + +std::auto_ptr +source() +{ + return std::auto_ptr(new B(1)); +} + +void +test() +{ + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// template operator auto_ptr_ref() throw(); + +#include +#include + +#include "../AB.h" + +void +test() +{ + B* p1 = new B(1); + std::auto_ptr ap1(p1); + std::auto_ptr_ref 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// X& operator*() const throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// X& operator*() const throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + const std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// X* release() throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class auto_ptr; + +// void reset(X* p=0) throw(); + +#include +#include + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr ap(p); + ap.reset(); + assert(ap.get() == 0); + assert(A::count == 0); + } + assert(A::count == 0); + { + A* p = new A(1); + std::auto_ptr 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class auto_ptr +// { +// public: +// typedef X element_type; +// ... +// }; + +#include +#include + +template +void +test() +{ + static_assert((std::is_same::element_type, T>::value), ""); +} + +int main() +{ + test(); + test(); + test(); + std::auto_ptr 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 + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +#include + +#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 + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +#include + +#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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +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 + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// XFAIL: linux + +#include +#include +#include + +#include "hexfloat.h" + +void test_acos() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(acos(1) == 0); +} + +void test_asin() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(asin(0) == 0); +} + +void test_atan() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(atan(0) == 0); +} + +void test_atan2() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(atan2(0,1) == 0); +} + +void test_ceil() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(ceil(0) == 0); +} + +void test_cos() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(cos(0) == 1); +} + +void test_cosh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(cosh(0) == 1); +} + +void test_exp() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(exp(0) == 1); +} + +void test_fabs() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fabs(-1.f) == 1); +} + +void test_floor() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(floor(1) == 1); +} + +void test_fmod() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fmod(1.5,1) == .5); +} + +void test_frexp() +{ + int ip; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(frexp(0, &ip) == 0); +} + +void test_ldexp() +{ + int ip = 1; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(ldexp(1, ip) == 2); +} + +void test_log() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(log(1) == 0); +} + +void test_log10() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(log10(1) == 0); +} + +void test_modf() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + double i; + assert(modf(1., &i) == 0); +} + +void test_pow() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(pow(1,1) == 1); +} + +void test_sin() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(sin(0) == 0); +} + +void test_sinh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(sinh(0) == 0); +} + +void test_sqrt() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(sqrt(4) == 2); +} + +void test_tan() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(tan(0) == 0); +} + +void test_tanh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(tanh(0) == 0); +} + +void test_signbit() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(signbit(-1.0) == true); +} + +void test_fpclassify() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fpclassify(-1.0) == FP_NORMAL); +} + +void test_isfinite() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isfinite(-1.0) == true); +} + +void test_isinf() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isinf(-1.0) == false); +} + +void test_isnan() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isnan(-1.0) == false); +} + +void test_isnormal() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isnormal(-1.0) == true); +} + +void test_isgreater() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isgreater(-1.0, 0.F) == false); +} + +void test_isgreaterequal() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isgreaterequal(-1.0, 0.F) == false); +} + +void test_isless() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isless(-1.0, 0.F) == true); +} + +void test_islessequal() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(islessequal(-1.0, 0.F) == true); +} + +void test_islessgreater() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(islessgreater(-1.0, 0.F) == true); +} + +void test_isunordered() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isunordered(-1.0, 0.F) == false); +} + +void test_acosh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(acosh(1) == 0); +} + +void test_asinh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(asinh(0) == 0); +} + +void test_atanh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(atanh(0) == 0); +} + +void test_cbrt() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(cbrt(1) == 1); +} + +void test_copysign() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(copysign(1,1) == 1); +} + +void test_erf() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(erf(0) == 0); +} + +void test_erfc() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(erfc(0) == 1); +} + +void test_exp2() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(exp2(1) == 2); +} + +void test_expm1() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(expm1(0) == 0); +} + +void test_fdim() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fdim(1,0) == 1); +} + +void test_fma() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fma(1,1,1) == 2); +} + +void test_fmax() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fmax(1,0) == 1); +} + +void test_fmin() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fmin(1,0) == 0); +} + +void test_hypot() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(hypot(3,4) == 5); +} + +void test_ilogb() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(ilogb(1) == 0); +} + +void test_lgamma() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(lgamma(1) == 0); +} + +void test_llrint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(llrint(1) == 1LL); +} + +void test_llround() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(llround(1) == 1LL); +} + +void test_log1p() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(log1p(0) == 0); +} + +void test_log2() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(log2(1) == 0); +} + +void test_logb() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(logb(1) == 0); +} + +void test_lrint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(lrint(1) == 1L); +} + +void test_lround() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(lround(1) == 1L); +} + +void test_nan() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +void test_nearbyint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(nearbyint(1) == 1); +} + +void test_nextafter() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(nextafter(0,1) == hexfloat(0x1, 0, -1074)); +} + +void test_nexttoward() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(nexttoward(0, 1) == hexfloat(0x1, 0, -1074)); +} + +void test_remainder() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(remainder(0.5,1) == 0.5); +} + +void test_remquo() +{ + int ip; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(remquo(0.5,1, &ip) == 0.5); +} + +void test_rint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(rint(1) == 1); +} + +void test_round() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(round(1) == 1); +} + +void test_scalbln() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(scalbln(1, 1) == 2); +} + +void test_scalbn() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(scalbn(1, 1) == 2); +} + +void test_tgamma() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(tgamma(1) == 1); +} + +void test_trunc() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +#include +#include + +int main() +{ + jmp_buf jb; + static_assert((std::is_same::value), + "std::is_same::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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::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 + +#include + +#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 + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value, + "std::is_unsigned::value"); + static_assert(std::is_integral::value, + "std::is_integral::value"); + static_assert(sizeof(ptrdiff_t) == sizeof(void*), + "sizeof(ptrdiff_t) == sizeof(void*)"); + static_assert(std::is_signed::value, + "std::is_signed::value"); + static_assert(std::is_integral::value, + "std::is_integral::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 + +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + // typedef int8_t + static_assert(sizeof(int8_t)*CHAR_BIT == 8, + "sizeof(int8_t)*CHAR_BIT == 8"); + static_assert(std::is_signed::value, + "std::is_signed::value"); + // typedef int16_t + static_assert(sizeof(int16_t)*CHAR_BIT == 16, + "sizeof(int16_t)*CHAR_BIT == 16"); + static_assert(std::is_signed::value, + "std::is_signed::value"); + // typedef int32_t + static_assert(sizeof(int32_t)*CHAR_BIT == 32, + "sizeof(int32_t)*CHAR_BIT == 32"); + static_assert(std::is_signed::value, + "std::is_signed::value"); + // typedef int64_t + static_assert(sizeof(int64_t)*CHAR_BIT == 64, + "sizeof(int64_t)*CHAR_BIT == 64"); + static_assert(std::is_signed::value, + "std::is_signed::value"); + + // typedef uint8_t + static_assert(sizeof(uint8_t)*CHAR_BIT == 8, + "sizeof(uint8_t)*CHAR_BIT == 8"); + static_assert(std::is_unsigned::value, + "std::is_unsigned::value"); + // typedef uint16_t + static_assert(sizeof(uint16_t)*CHAR_BIT == 16, + "sizeof(uint16_t)*CHAR_BIT == 16"); + static_assert(std::is_unsigned::value, + "std::is_unsigned::value"); + // typedef uint32_t + static_assert(sizeof(uint32_t)*CHAR_BIT == 32, + "sizeof(uint32_t)*CHAR_BIT == 32"); + static_assert(std::is_unsigned::value, + "std::is_unsigned::value"); + // typedef uint64_t + static_assert(sizeof(uint64_t)*CHAR_BIT == 64, + "sizeof(uint64_t)*CHAR_BIT == 64"); + static_assert(std::is_unsigned::value, + "std::is_unsigned::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::value"); + + // typedef intptr_t + static_assert(sizeof(intptr_t) >= sizeof(void*), + "sizeof(intptr_t) >= sizeof(void*)"); + static_assert(std::is_signed::value, + "std::is_signed::value"); + // typedef uintptr_t + static_assert(sizeof(uintptr_t) >= sizeof(void*), + "sizeof(uintptr_t) >= sizeof(void*)"); + static_assert(std::is_unsigned::value, + "std::is_unsigned::value"); + + // typedef intmax_t + static_assert(sizeof(intmax_t) >= sizeof(long long), + "sizeof(intmax_t) >= sizeof(long long)"); + static_assert(std::is_signed::value, + "std::is_signed::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::value, + "std::is_unsigned::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::min()); + + // INTPTR_MAX + assert(INTPTR_MAX == std::numeric_limits::max()); + + // UINTPTR_MAX + assert(UINTPTR_MAX == std::numeric_limits::max()); + + // INTMAX_MIN + assert(INTMAX_MIN == std::numeric_limits::min()); + + // INTMAX_MAX + assert(INTMAX_MAX == std::numeric_limits::max()); + + // UINTMAX_MAX + assert(UINTMAX_MAX == std::numeric_limits::max()); + + // PTRDIFF_MIN + assert(PTRDIFF_MIN == std::numeric_limits::min()); + + // PTRDIFF_MAX + assert(PTRDIFF_MAX == std::numeric_limits::max()); + + // SIG_ATOMIC_MIN + assert(SIG_ATOMIC_MIN == std::numeric_limits::min()); + + // SIG_ATOMIC_MAX + assert(SIG_ATOMIC_MAX == std::numeric_limits::max()); + + // SIZE_MAX + assert(SIZE_MAX == std::numeric_limits::max()); + + // WCHAR_MIN + assert(WCHAR_MIN == std::numeric_limits::min()); + + // WCHAR_MAX + assert(WCHAR_MAX == std::numeric_limits::max()); + + // WINT_MIN + assert(WINT_MIN == std::numeric_limits::min()); + + // WINT_MAX + assert(WINT_MAX == std::numeric_limits::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 + +#include +#include + +#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 + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#if _LIBCPP_STD_VER < 14 + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ + std::complex 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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + char* c1 = 0; + const char* c2 = 0; + static_assert((std::is_same::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 + +// + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// pointer_to_binary_function + +#include +#include +#include + +double binary_f(int i, short j) {return i - j + .75;} + +int main() +{ + typedef std::pointer_to_binary_function F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// pointer_to_unary_function + +#include +#include +#include + +double unary_f(int i) {return 0.5 - i;} + +int main() +{ + typedef std::pointer_to_unary_function F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// pointer_to_unary_function +// ptr_fun(Result (*f)(Arg)); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// pointer_to_binary_function +// ptr_fun(Result (*f)(Arg1, Arg2)); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// const_mem_fun_t +// mem_fun(S (T::*f)() const); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// const_mem_fun1_t +// mem_fun(S (T::*f)(A) const); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// const_mem_fun1_ref_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_mem_fun1_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// const_mem_fun_ref_t +// mem_fun_ref(S (T::*f)() const); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// const_mem_fun1_ref_t +// mem_fun_ref(S (T::*f)(A) const); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// const_mem_fun_ref_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_mem_fun_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// mem_fun_t +// mem_fun(S (T::*f)()); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// mem_fun1_t +// mem_fun(S (T::*f)(A)); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// mem_fun1_ref_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// mem_fun1_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// mem_fun_ref_t +// mem_fun_ref(S (T::*f)()); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// mem_fun1_ref_t +// mem_fun_ref(S (T::*f)(A)); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// mem_fun_ref_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// mem_fun_t + +#include +#include +#include + +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 F; + static_assert((std::is_base_of, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct binary_function +// { +// typedef Arg1 first_argument_type; +// typedef Arg2 second_argument_type; +// typedef Result result_type; +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::first_argument_type, int>::value), ""); + static_assert((std::is_same::second_argument_type, unsigned>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct unary_function +// { +// typedef Arg argument_type; +// typedef Result result_type; +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::argument_type, unsigned>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// +// +// class ios_base +// { +// public: +// typedef T1 io_state; +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// +// +// class ios_base +// { +// public: +// typedef T2 open_mode; +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// +// +// class ios_base +// { +// public: +// typedef T3 seek_dir; +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// +// +// class ios_base +// { +// public: +// typedef OFF_T streamoff; +// }; + +#include +#include + +int main() +{ + static_assert((std::is_integral::value), ""); + static_assert((std::is_signed::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. +// +//===----------------------------------------------------------------------===// + +// +// +// class ios_base +// { +// public: +// typedef POS_T streampos; +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// binder1st +// bind1st(const Fn& fn, const T& x); + +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// binder2nd +// bind2nd(const Fn& op, const T& x); + +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binder1st +// : public unary_function +// { +// 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 +#include +#include + +#include "../test_func.h" + +class test + : public std::binder1st +{ + typedef std::binder1st base; +public: + test() : std::binder1st(test_func(2), 30) {} + + void do_test() + { + static_assert((std::is_base_of< + std::unary_function, + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binder2nd +// : public unary_function +// { +// 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 +#include +#include + +#include "../test_func.h" + +class test + : public std::binder2nd +{ + typedef std::binder2nd base; +public: + test() : std::binder2nd(test_func(3), 4.5) {} + + void do_test() + { + static_assert((std::is_base_of< + std::unary_function, + 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istrstream + +// explicit istrstream(const char* s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class istrstream + +// explicit istrstream(const char* s, streamsize n); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class istrstream + +// explicit istrstream(char* s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class istrstream + +// explicit istrstream(char* s, streamsize n); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class istrstream + +// strstreambuf* rdbuf() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class istrstream + +// char* str(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class istrstream +// : public basic_istream +// { +// ... + +#include +#include + +int main() +{ + static_assert((std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostrstream + +// ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostrstream + +// ostrstream(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostrstream + +// void freeze(bool freezefl = true); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostrstream + +// int pcount() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostrstream + +// strstreambuf* rdbuf() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostrstream + +// char* str(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostrstream +// : public basic_ostream +// { +// ... + +#include +#include + +int main() +{ + static_assert((std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstream + +// strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstream + +// strstream(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstream + +// strstreambuf* rdbuf() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstream + +// void freeze(bool freezefl = true); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstream + +// int pcount() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstream + +// char* str(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstream +// : public basic_iostream +// { +// public: +// // Types +// typedef char char_type; +// typedef char_traits::int_type int_type; +// typedef char_traits::pos_type pos_type; +// typedef char_traits::off_type off_type; + +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::int_type>::value), ""); + static_assert((std::is_same::pos_type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// strstreambuf(const char* gnext_arg, streamsize n); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// strstreambuf(const signed char* gnext_arg, streamsize n); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// strstreambuf(const unsigned char* gnext_arg, streamsize n); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*)); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// explicit strstreambuf(streamsize alsize_arg = 0); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// void freeze(bool freezefl = true); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// int pcount() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// char* str(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// int_type overflow(int_type c = EOF); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// int_type pbackfail(int_type c = EOF); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// pos_type seekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// streambuf* setbuf(char* s, streamsize n); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf + +// int_type underflow(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class strstreambuf +// : public basic_streambuf + +#include +#include + +int main() +{ + static_assert((std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include +#include + +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 +#include +#include + +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 + +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 +#include +#include + +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 + +#include + +#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 + +#include + +#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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// enum errc {...} + +#include + +int main() +{ + static_assert(static_cast(std::errc::address_family_not_supported) == EAFNOSUPPORT, ""); + static_assert(static_cast(std::errc::address_in_use) == EADDRINUSE, ""); + static_assert(static_cast(std::errc::address_not_available) == EADDRNOTAVAIL, ""); + static_assert(static_cast(std::errc::already_connected) == EISCONN, ""); + static_assert(static_cast(std::errc::argument_list_too_long) == E2BIG, ""); + static_assert(static_cast(std::errc::argument_out_of_domain) == EDOM, ""); + static_assert(static_cast(std::errc::bad_address) == EFAULT, ""); + static_assert(static_cast(std::errc::bad_file_descriptor) == EBADF, ""); + static_assert(static_cast(std::errc::bad_message) == EBADMSG, ""); + static_assert(static_cast(std::errc::broken_pipe) == EPIPE, ""); + static_assert(static_cast(std::errc::connection_aborted) == ECONNABORTED, ""); + static_assert(static_cast(std::errc::connection_already_in_progress) == EALREADY, ""); + static_assert(static_cast(std::errc::connection_refused) == ECONNREFUSED, ""); + static_assert(static_cast(std::errc::connection_reset) == ECONNRESET, ""); + static_assert(static_cast(std::errc::cross_device_link) == EXDEV, ""); + static_assert(static_cast(std::errc::destination_address_required) == EDESTADDRREQ, ""); + static_assert(static_cast(std::errc::device_or_resource_busy) == EBUSY, ""); + static_assert(static_cast(std::errc::directory_not_empty) == ENOTEMPTY, ""); + static_assert(static_cast(std::errc::executable_format_error) == ENOEXEC, ""); + static_assert(static_cast(std::errc::file_exists) == EEXIST, ""); + static_assert(static_cast(std::errc::file_too_large) == EFBIG, ""); + static_assert(static_cast(std::errc::filename_too_long) == ENAMETOOLONG, ""); + static_assert(static_cast(std::errc::function_not_supported) == ENOSYS, ""); + static_assert(static_cast(std::errc::host_unreachable) == EHOSTUNREACH, ""); + static_assert(static_cast(std::errc::identifier_removed) == EIDRM, ""); + static_assert(static_cast(std::errc::illegal_byte_sequence) == EILSEQ, ""); + static_assert(static_cast(std::errc::inappropriate_io_control_operation) == ENOTTY, ""); + static_assert(static_cast(std::errc::interrupted) == EINTR, ""); + static_assert(static_cast(std::errc::invalid_argument) == EINVAL, ""); + static_assert(static_cast(std::errc::invalid_seek) == ESPIPE, ""); + static_assert(static_cast(std::errc::io_error) == EIO, ""); + static_assert(static_cast(std::errc::is_a_directory) == EISDIR, ""); + static_assert(static_cast(std::errc::message_size) == EMSGSIZE, ""); + static_assert(static_cast(std::errc::network_down) == ENETDOWN, ""); + static_assert(static_cast(std::errc::network_reset) == ENETRESET, ""); + static_assert(static_cast(std::errc::network_unreachable) == ENETUNREACH, ""); + static_assert(static_cast(std::errc::no_buffer_space) == ENOBUFS, ""); + static_assert(static_cast(std::errc::no_child_process) == ECHILD, ""); + static_assert(static_cast(std::errc::no_link) == ENOLINK, ""); + static_assert(static_cast(std::errc::no_lock_available) == ENOLCK, ""); +#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1) + static_assert(static_cast(std::errc::no_message_available) == ENODATA, ""); +#endif + static_assert(static_cast(std::errc::no_message) == ENOMSG, ""); + static_assert(static_cast(std::errc::no_protocol_option) == ENOPROTOOPT, ""); + static_assert(static_cast(std::errc::no_space_on_device) == ENOSPC, ""); +#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1) + static_assert(static_cast(std::errc::no_stream_resources) == ENOSR, ""); +#endif + static_assert(static_cast(std::errc::no_such_device_or_address) == ENXIO, ""); + static_assert(static_cast(std::errc::no_such_device) == ENODEV, ""); + static_assert(static_cast(std::errc::no_such_file_or_directory) == ENOENT, ""); + static_assert(static_cast(std::errc::no_such_process) == ESRCH, ""); + static_assert(static_cast(std::errc::not_a_directory) == ENOTDIR, ""); + static_assert(static_cast(std::errc::not_a_socket) == ENOTSOCK, ""); +#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1) + static_assert(static_cast(std::errc::not_a_stream) == ENOSTR, ""); +#endif + static_assert(static_cast(std::errc::not_connected) == ENOTCONN, ""); + static_assert(static_cast(std::errc::not_enough_memory) == ENOMEM, ""); + static_assert(static_cast(std::errc::not_supported) == ENOTSUP, ""); + static_assert(static_cast(std::errc::operation_canceled) == ECANCELED, ""); + static_assert(static_cast(std::errc::operation_in_progress) == EINPROGRESS, ""); + static_assert(static_cast(std::errc::operation_not_permitted) == EPERM, ""); + static_assert(static_cast(std::errc::operation_not_supported) == EOPNOTSUPP, ""); + static_assert(static_cast(std::errc::operation_would_block) == EWOULDBLOCK, ""); + static_assert(static_cast(std::errc::owner_dead) == EOWNERDEAD, ""); + static_assert(static_cast(std::errc::permission_denied) == EACCES, ""); + static_assert(static_cast(std::errc::protocol_error) == EPROTO, ""); + static_assert(static_cast(std::errc::protocol_not_supported) == EPROTONOSUPPORT, ""); + static_assert(static_cast(std::errc::read_only_file_system) == EROFS, ""); + static_assert(static_cast(std::errc::resource_deadlock_would_occur) == EDEADLK, ""); + static_assert(static_cast(std::errc::resource_unavailable_try_again) == EAGAIN, ""); + static_assert(static_cast(std::errc::result_out_of_range) == ERANGE, ""); + static_assert(static_cast(std::errc::state_not_recoverable) == ENOTRECOVERABLE, ""); +#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1) + static_assert(static_cast(std::errc::stream_timeout) == ETIME, ""); +#endif + static_assert(static_cast(std::errc::text_file_busy) == ETXTBSY, ""); + static_assert(static_cast(std::errc::timed_out) == ETIMEDOUT, ""); + static_assert(static_cast(std::errc::too_many_files_open_in_system) == ENFILE, ""); + static_assert(static_cast(std::errc::too_many_files_open) == EMFILE, ""); + static_assert(static_cast(std::errc::too_many_links) == EMLINK, ""); + static_assert(static_cast(std::errc::too_many_symbolic_link_levels) == ELOOP, ""); + static_assert(static_cast(std::errc::value_too_large) == EOVERFLOW, ""); + static_assert(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// virtual string message(int ev) const = 0; + +#include +#include +#include + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// constexpr error_category() noexcept; + +#include +#include +#include +#include + +#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::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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// bool operator==(const error_category& rhs) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// bool operator<(const error_category& rhs) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// bool operator!=(const error_category& rhs) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// const error_category& generic_category(); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// const error_category& system_category(); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// virtual error_condition default_error_condition(int ev) const; + +#include +#include + +int main() +{ + const std::error_category& e_cat = std::generic_category(); + std::error_condition e_cond = e_cat.default_error_condition(static_cast(std::errc::not_a_directory)); + assert(e_cond.category() == e_cat); + assert(e_cond.value() == static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// virtual bool equivalent(const error_code& code, int condition) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_category + +// virtual bool equivalent(int code, const error_condition& condition) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// template error_code(E e); + +#include +#include + +enum testing +{ + zero, one, two +}; + +namespace std +{ + +template <> struct is_error_code_enum : public std::true_type {}; + +} + +std::error_code +make_error_code(testing x) +{ + return std::error_code(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// error_code(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// error_code(int val, const error_category& cat); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// template error_code& operator=(E e); + +#include +#include + +enum testing +{ + zero, one, two +}; + +namespace std +{ + +template <> struct is_error_code_enum : public std::true_type {}; + +} + +std::error_code +make_error_code(testing x) +{ + return std::error_code(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// void assign(int val, const error_category& cat); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// void clear(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// bool operator<(const error_code& lhs, const error_code& rhs); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// error_code make_error_code(errc e); + +#include +#include + +int main() +{ + { + std::error_code ec = make_error_code(std::errc::operation_canceled); + assert(ec.value() == static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// template +// basic_ostream& +// operator<<(basic_ostream& os, const error_code& ec); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// explicit operator bool() const; + +#include +#include +#include + +int main() +{ + { + const std::error_code ec(6, std::generic_category()); + assert(static_cast(ec)); + } + { + const std::error_code ec(0, std::generic_category()); + assert(!static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// const error_category& category() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// error_condition default_error_condition() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// string message() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// int value() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// template error_condition(E e); + +#include +#include + +int main() +{ + { + std::error_condition ec(std::errc::not_a_directory); + assert(ec.value() == static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// error_condition(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// error_condition(int val, const error_category& cat); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// template error_condition& operator=(E e); + +#include +#include + +int main() +{ + { + std::error_condition ec; + ec = std::errc::not_enough_memory; + assert(ec.value() == static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// void assign(int val, const error_category& cat); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// void clear(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// bool operator<(const error_condition& lhs, const error_condition& rhs); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// error_condition make_error_condition(errc e); + +#include +#include + +int main() +{ + { + const std::error_condition ec1 = std::make_error_condition(std::errc::message_size); + assert(ec1.value() == static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// explicit operator bool() const; + +#include +#include +#include + +int main() +{ + { + const std::error_condition ec(6, std::generic_category()); + assert(static_cast(ec)); + } + { + const std::error_condition ec(0, std::generic_category()); + assert(!static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// const error_category& category() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// string message() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// int value() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include + +void +test(int i) +{ + typedef std::error_code T; + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class system_error + +// system_error(error_code ec); + +// Test is slightly non-portable + +#include +#include +#include + +int main() +{ + std::system_error se(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class system_error + +// system_error(error_code ec, const char* what_arg); + +// Test is slightly non-portable + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class system_error + +// system_error(error_code ec, const string& what_arg); + +// Test is slightly non-portable + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class system_error + +// system_error(int ev, const error_category& ecat); + +// Test is slightly non-portable + +#include +#include +#include + +int main() +{ + std::system_error se(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class system_error + +// system_error(int ev, const error_category& ecat, const char* what_arg); + +// Test is slightly non-portable + +#include +#include +#include + +int main() +{ + std::string what_arg("test message"); + std::system_error se(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class system_error + +// system_error(int ev, const error_category& ecat, const string& what_arg); + +// Test is slightly non-portable + +#include +#include +#include + +int main() +{ + std::string what_arg("test message"); + std::system_error se(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// SampleIterator sample(PopulationIterator first, PopulationIterator last, +// SampleIterator out, Distance n, +// UniformRandomNumberGenerator &&g); + +#include +#include +#include + +#include "test_iterators.h" + +template 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, output_iterator >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// SampleIterator sample(PopulationIterator first, PopulationIterator last, +// SampleIterator out, Distance n, +// UniformRandomNumberGenerator &&g); + +#include +#include +#include + +#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 struct TestExpectations + : public SelectionSampleExpectations {}; + +template <> +struct TestExpectations + : public ReservoirSampleExpectations {}; + +template class PopulationIteratorType, class PopulationItem, + template class SampleIteratorType, class SampleItem> +void test() { + typedef PopulationIteratorType PopulationIterator; + typedef SampleIteratorType SampleIterator; + PopulationItem ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const unsigned is = sizeof(ia) / sizeof(ia[0]); + typedef TestExpectations::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 class PopulationIteratorType, class PopulationItem, + template class SampleIteratorType, class SampleItem> +void test_empty_population() { + typedef PopulationIteratorType PopulationIterator; + typedef SampleIteratorType 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 class PopulationIteratorType, class PopulationItem, + template class SampleIteratorType, class SampleItem> +void test_empty_sample() { + typedef PopulationIteratorType PopulationIterator; + typedef SampleIteratorType 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 class PopulationIteratorType, class PopulationItem, + template class SampleIteratorType, class SampleItem> +void test_small_population() { + // The population size is less than the sample size. + typedef PopulationIteratorType PopulationIterator; + typedef SampleIteratorType 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(); + test(); + test(); + + test(); + test(); + test(); + + test_empty_population(); + test_empty_population(); + test_empty_population(); + + test_empty_sample(); + test_empty_sample(); + test_empty_sample(); + + test_small_population(); + test_small_population(); + test_small_population(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// SampleIterator sample(PopulationIterator first, PopulationIterator last, +// SampleIterator out, Distance n, +// UniformRandomNumberGenerator &&g); + +#include +#include +#include + +#include "test_iterators.h" + +// Stable if and only if PopulationIterator meets the requirements of a +// ForwardIterator type. +template +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, output_iterator >(true); + test_stability, random_access_iterator >(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 + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bad_optional_access is default constructible + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bad_optional_access : public logic_error + +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::bad_optional_access; + + static_assert(std::is_base_of::value, ""); + static_assert(std::is_convertible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator==(const optional& x, const T& v); +// template constexpr bool operator==(const T& v, const optional& x); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator>(const optional& x, const T& v); +// template constexpr bool operator>(const T& v, const optional& x); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator>=(const optional& x, const T& v); +// template constexpr bool operator>=(const T& v, const optional& x); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator<=(const optional& x, const T& v); +// template constexpr bool operator<=(const T& v, const optional& x); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator<(const optional& x, const T& v); +// template constexpr bool operator<(const T& v, const optional& x); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator!=(const optional& x, const T& v); +// template constexpr bool operator!=(const T& v, const optional& x); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct hash>; + +#include +#include +#include +#include + + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + { + typedef int T; + optional opt; + assert(std::hash>{}(opt) == 0); + opt = 2; + assert(std::hash>{}(opt) == std::hash{}(*opt)); + } + { + typedef std::string T; + optional opt; + assert(std::hash>{}(opt) == 0); + opt = std::string("123"); + assert(std::hash>{}(opt) == std::hash{}(*opt)); + } + { + typedef std::unique_ptr T; + optional opt; + assert(std::hash>{}(opt) == 0); + opt = std::unique_ptr(new int(3)); + assert(std::hash>{}(opt) == std::hash{}(*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. +// +//===----------------------------------------------------------------------===// + +// + +// struct in_place_t{}; +// constexpr in_place_t in_place{}; + +#include +#include + +#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::value), ""); + static_assert((std::is_empty::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. +// +//===----------------------------------------------------------------------===// + + +// + +// template constexpr bool operator==(const optional& x, nullopt_t) noexcept; +// template constexpr bool operator==(nullopt_t, const optional& x) noexcept; + +#include + +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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template constexpr bool operator>(const optional& x, nullopt_t) noexcept; +// template constexpr bool operator>(nullopt_t, const optional& x) noexcept; + +#include + +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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template constexpr bool operator>=(const optional& x, nullopt_t) noexcept; +// template constexpr bool operator>=(nullopt_t, const optional& x) noexcept; + +#include + +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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template constexpr bool operator<=(const optional& x, nullopt_t) noexcept; +// template constexpr bool operator<=(nullopt_t, const optional& x) noexcept; + +#include + +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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template constexpr bool operator<(const optional& x, nullopt_t) noexcept; +// template constexpr bool operator<(nullopt_t, const optional& x) noexcept; + +#include + +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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template constexpr bool operator!=(const optional& x, nullopt_t) noexcept; +// template constexpr bool operator!=(nullopt_t, const optional& x) noexcept; + +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// struct nullopt_t{see below}; +// constexpr nullopt_t nullopt(unspecified); + +#include +#include + +#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::value), ""); + static_assert((std::is_empty::value), ""); + static_assert((std::is_literal_type::value), ""); + static_assert((!std::is_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template optional& operator=(U&& v); + +#include +#include +#include +#include + +#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, int>::value, ""); + static_assert(std::is_assignable, int&>::value, ""); + static_assert(std::is_assignable&, int>::value, ""); + static_assert(std::is_assignable&, int&>::value, ""); + static_assert(std::is_assignable&, const int&>::value, ""); + static_assert(!std::is_assignable&, const int&>::value, ""); + static_assert(!std::is_assignable, X>::value, ""); + { + optional opt; + opt = 1; + assert(static_cast(opt) == true); + assert(*opt == 1); + } + { + optional opt; + const int i = 2; + opt = i; + assert(static_cast(opt) == true); + assert(*opt == i); + } + { + optional opt(3); + const int i = 2; + opt = i; + assert(static_cast(opt) == true); + assert(*opt == i); + } + { + optional> opt; + opt = std::unique_ptr(new int(3)); + assert(static_cast(opt) == true); + assert(**opt == 3); + } + { + optional> opt(std::unique_ptr(new int(2))); + opt = std::unique_ptr(new int(3)); + assert(static_cast(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& operator=(const optional& rhs); + +#include +#include +#include + +#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 opt; + constexpr optional opt2; + opt = opt2; + static_assert(static_cast(opt2) == false, ""); + assert(static_cast(opt) == static_cast(opt2)); + } + { + optional opt; + constexpr optional opt2(2); + opt = opt2; + static_assert(static_cast(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast(opt) == static_cast(opt2)); + assert(*opt == *opt2); + } + { + optional opt(3); + constexpr optional opt2; + opt = opt2; + static_assert(static_cast(opt2) == false, ""); + assert(static_cast(opt) == static_cast(opt2)); + } + { + optional opt(3); + constexpr optional opt2(2); + opt = opt2; + static_assert(static_cast(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast(opt) == static_cast(opt2)); + assert(*opt == *opt2); + } + { + optional opt; + optional opt2(X{}); + assert(static_cast(opt2) == true); + try + { + X::throw_now = true; + opt = opt2; + assert(false); + } + catch (int i) + { + assert(i == 6); + assert(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// template void optional::emplace(Args&&... args); + +#include +#include +#include +#include + +#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 opt; + opt.emplace(); + assert(static_cast(opt) == true); + assert(*opt == 0); + } + { + optional opt; + opt.emplace(1); + assert(static_cast(opt) == true); + assert(*opt == 1); + } + { + optional opt(2); + opt.emplace(); + assert(static_cast(opt) == true); + assert(*opt == 0); + } + { + optional opt(2); + opt.emplace(1); + assert(static_cast(opt) == true); + assert(*opt == 1); + } + { + optional opt; + opt.emplace(); + assert(static_cast(opt) == true); + assert(*opt == X()); + } + { + optional opt; + opt.emplace(1); + assert(static_cast(opt) == true); + assert(*opt == X(1)); + } + { + optional opt; + opt.emplace(1, 2); + assert(static_cast(opt) == true); + assert(*opt == X(1, 2)); + } + { + optional opt(X{3}); + opt.emplace(); + assert(static_cast(opt) == true); + assert(*opt == X()); + } + { + optional opt(X{3}); + opt.emplace(1); + assert(static_cast(opt) == true); + assert(*opt == X(1)); + } + { + optional opt(X{3}); + opt.emplace(1, 2); + assert(static_cast(opt) == true); + assert(*opt == X(1, 2)); + } + { + Y y; + { + optional opt(y); + assert(Y::dtor_called == false); + opt.emplace(); + assert(Y::dtor_called == true); + } + } + { + Z z; + optional opt(z); + try + { + assert(static_cast(opt) == true); + assert(Z::dtor_called == false); + opt.emplace(1); + } + catch (int i) + { + assert(i == 6); + assert(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void optional::emplace(initializer_list il, Args&&... args); + +#include +#include +#include +#include + +#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 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 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 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 opt(x); + assert(X::dtor_called == false); + opt.emplace({1, 2}); + assert(X::dtor_called == true); + assert(*opt == X({1, 2})); + } + } + { + optional> opt; + opt.emplace({1, 2, 3}, std::allocator()); + assert(static_cast(opt) == true); + assert(*opt == std::vector({1, 2, 3})); + } + { + optional opt; + opt.emplace({1, 2}); + assert(static_cast(opt) == true); + assert(*opt == Y({1, 2})); + } + { + Z z; + optional opt(z); + try + { + assert(static_cast(opt) == true); + assert(Z::dtor_called == false); + opt.emplace({1, 2}); + } + catch (int i) + { + assert(i == 6); + assert(static_cast(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& operator=(optional&& rhs) +// noexcept(is_nothrow_move_assignable::value && +// is_nothrow_move_constructible::value); + +#include +#include +#include + +#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>::value, ""); + optional opt; + constexpr optional opt2; + opt = std::move(opt2); + static_assert(static_cast(opt2) == false, ""); + assert(static_cast(opt) == static_cast(opt2)); + } + { + optional opt; + constexpr optional opt2(2); + opt = std::move(opt2); + static_assert(static_cast(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast(opt) == static_cast(opt2)); + assert(*opt == *opt2); + } + { + optional opt(3); + constexpr optional opt2; + opt = std::move(opt2); + static_assert(static_cast(opt2) == false, ""); + assert(static_cast(opt) == static_cast(opt2)); + } + { + optional opt(3); + constexpr optional opt2(2); + opt = std::move(opt2); + static_assert(static_cast(opt2) == true, ""); + static_assert(*opt2 == 2, ""); + assert(static_cast(opt) == static_cast(opt2)); + assert(*opt == *opt2); + } + { + static_assert(!std::is_nothrow_move_assignable>::value, ""); + optional opt; + optional opt2(X{}); + assert(static_cast(opt2) == true); + try + { + X::throw_now = true; + opt = std::move(opt2); + assert(false); + } + catch (int i) + { + assert(i == 6); + assert(static_cast(opt) == false); + } + } + { + static_assert(std::is_nothrow_move_assignable>::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& operator=(nullopt_t) noexcept; + +#include +#include +#include + +#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 opt; + static_assert(noexcept(opt = nullopt) == true, ""); + opt = nullopt; + assert(static_cast(opt) == false); + } + { + optional opt(3); + opt = nullopt; + assert(static_cast(opt) == false); + } + { + optional opt; + static_assert(noexcept(opt = nullopt) == true, ""); + assert(X::dtor_called == false); + opt = nullopt; + assert(X::dtor_called == false); + assert(static_cast(opt) == false); + } + { + X x; + { + optional opt(x); + assert(X::dtor_called == false); + opt = nullopt; + assert(X::dtor_called == true); + assert(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr optional(const T& v); + +#include +#include +#include + +#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 opt(t); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == 5, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(const T&) {} + }; + + } + { + typedef double T; + constexpr T t(3); + constexpr optional opt(t); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(const T&) {} + }; + + } + { + typedef X T; + const T t(3); + optional opt(t); + assert(static_cast(opt) == true); + assert(*opt == 3); + } + { + typedef Y T; + constexpr T t(3); + constexpr optional opt(t); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(const T&) {} + }; + + } + { + typedef Z T; + try + { + const T t(3); + optional 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(const optional& rhs); + +#include +#include +#include + +#if _LIBCPP_STD_VER > 11 + +using std::experimental::optional; + +template +void +test(const optional& rhs, bool is_going_to_throw = false) +{ + bool rhs_engaged = static_cast(rhs); + try + { + optional lhs = rhs; + assert(is_going_to_throw == false); + assert(static_cast(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 rhs; + test(rhs); + } + { + typedef int T; + optional rhs(3); + test(rhs); + } + { + typedef X T; + optional rhs; + test(rhs); + } + { + typedef X T; + optional rhs(X(3)); + test(rhs); + } + { + typedef Y T; + optional rhs; + test(rhs); + } + { + typedef Y T; + optional rhs(Y(3)); + test(rhs); + } + { + typedef Z T; + optional rhs; + test(rhs); + } + { + typedef Z T; + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr optional() noexcept; + +#include +#include +#include + +#if _LIBCPP_STD_VER > 11 + +using std::experimental::optional; + +template +void +test_constexpr() +{ + static_assert(std::is_nothrow_default_constructible::value, ""); + constexpr Opt opt; + static_assert(static_cast(opt) == false, ""); + + struct test_constexpr_ctor + : public Opt + { + constexpr test_constexpr_ctor() {} + }; + +} + +template +void +test() +{ + static_assert(std::is_nothrow_default_constructible::value, ""); + Opt opt; + assert(static_cast(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>(); + test_constexpr>(); + test>(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr explicit optional(in_place_t, Args&&... args); + +#include +#include +#include + +#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 opt(in_place, 5); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == 5, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(in_place_t, int i) + : optional(in_place, i) {} + }; + + } + { + const optional opt(in_place); + assert(static_cast(opt) == true); + assert(*opt == X()); + } + { + const optional opt(in_place, 5); + assert(static_cast(opt) == true); + assert(*opt == X(5)); + } + { + const optional opt(in_place, 5, 4); + assert(static_cast(opt) == true); + assert(*opt == X(5, 4)); + } + { + constexpr optional opt(in_place); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == Y(), ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(in_place_t) + : optional(in_place) {} + }; + + } + { + constexpr optional opt(in_place, 5); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == Y(5), ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(in_place_t, int i) + : optional(in_place, i) {} + }; + + } + { + constexpr optional opt(in_place, 5, 4); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == Y(5, 4), ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(in_place_t, int i, int j) + : optional(in_place, i, j) {} + }; + + } + { + try + { + const optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr +// explicit optional(in_place_t, initializer_list il, Args&&... args); + +#include +#include +#include +#include + +#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 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 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&>::value, ""); + static_assert(!std::is_constructible, std::initializer_list&>::value, ""); + } + { + optional> opt(in_place, {3, 1}); + assert(static_cast(opt) == true); + assert((*opt == std::vector{3, 1})); + assert(opt->size() == 2); + } + { + optional> opt(in_place, {3, 1}, std::allocator()); + assert(static_cast(opt) == true); + assert((*opt == std::vector{3, 1})); + assert(opt->size() == 2); + } + { + static_assert(std::is_constructible, std::initializer_list&>::value, ""); + constexpr optional opt(in_place, {3, 1}); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == Y{3, 1}, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(in_place_t, std::initializer_list i) + : optional(in_place, i) {} + }; + + } + { + static_assert(std::is_constructible, std::initializer_list&>::value, ""); + try + { + optional opt(in_place, {3, 1}); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(in_place_t, std::initializer_list i) + : optional(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&& rhs) noexcept(is_nothrow_move_constructible::value); + +#include +#include +#include + +#if _LIBCPP_STD_VER > 11 + +using std::experimental::optional; + +template +void +test(optional& rhs, bool is_going_to_throw = false) +{ + static_assert(std::is_nothrow_move_constructible>::value == + std::is_nothrow_move_constructible::value, ""); + bool rhs_engaged = static_cast(rhs); + try + { + optional lhs = std::move(rhs); + assert(is_going_to_throw == false); + assert(static_cast(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 rhs; + test(rhs); + } + { + typedef int T; + optional rhs(3); + test(rhs); + } + { + typedef X T; + optional rhs; + test(rhs); + } + { + typedef X T; + optional rhs(X(3)); + test(rhs); + } + { + typedef Y T; + optional rhs; + test(rhs); + } + { + typedef Y T; + optional rhs(Y(3)); + test(rhs); + } + { + typedef Z T; + optional rhs; + test(rhs); + } + { + typedef Z T; + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr optional(nullopt_t) noexcept; + +#include +#include +#include + +#if _LIBCPP_STD_VER > 11 + +using std::experimental::optional; +using std::experimental::nullopt_t; +using std::experimental::nullopt; + +template +void +test_constexpr() +{ + static_assert(noexcept(Opt(nullopt)), ""); + constexpr Opt opt(nullopt); + static_assert(static_cast(opt) == false, ""); + + struct test_constexpr_ctor + : public Opt + { + constexpr test_constexpr_ctor() {} + }; +} + +template +void +test() +{ + static_assert(noexcept(Opt(nullopt)), ""); + Opt opt(nullopt); + assert(static_cast(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>(); + test_constexpr>(); + test>(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr optional(T&& v); + +#include +#include +#include + +#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 opt(T(5)); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == 5, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(T&&) {} + }; + } + { + typedef double T; + constexpr optional opt(T(3)); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(T&&) {} + }; + } + { + typedef X T; + optional opt(T(3)); + assert(static_cast(opt) == true); + assert(*opt == 3); + } + { + typedef Y T; + constexpr optional opt(T(3)); + static_assert(static_cast(opt) == true, ""); + static_assert(*opt == 3, ""); + + struct test_constexpr_ctor + : public optional + { + constexpr test_constexpr_ctor(T&&) {} + }; + } + { + typedef Z T; + try + { + optional 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(); + +#include +#include +#include + +#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::value, ""); + static_assert(std::is_trivially_destructible>::value, ""); + } + { + typedef double T; + static_assert(std::is_trivially_destructible::value, ""); + static_assert(std::is_trivially_destructible>::value, ""); + } + { + typedef X T; + static_assert(!std::is_trivially_destructible::value, ""); + static_assert(!std::is_trivially_destructible>::value, ""); + { + X x; + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr explicit optional::operator bool() const noexcept; + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + { + constexpr optional opt; + static_assert(!opt, ""); + } + { + constexpr optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// T& optional::operator*(); + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include +#include + +#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 opt(X{}); + assert((*opt).test() == 4); + } +#ifdef _LIBCPP_DEBUG + { + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr const T& optional::operator*() const; + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include +#include + +#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 opt(X{}); + static_assert((*opt).test() == 3, ""); + } + { + constexpr optional opt(Y{}); + assert((*opt).test() == 2); + } +#ifdef _LIBCPP_DEBUG + { + const optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr T* optional::operator->(); + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include +#include + +#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 opt(X{}); + static_assert(opt->test() == 3, ""); + } +#ifdef _LIBCPP_DEBUG + { + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr const T* optional::operator->() const; + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include +#include + +#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 opt(X{}); + static_assert(opt->test() == 3, ""); + } + { + constexpr optional opt(Y{}); + assert(opt->test() == 2); + } + { + constexpr optional opt(Z{}); + assert(opt->test() == 1); + } +#ifdef _LIBCPP_DEBUG + { + const optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// T& optional::value(); + +#include +#include +#include + +#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 opt; + opt.emplace(); + assert(opt.value().test() == 4); + } + { + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr const T& optional::value() const; + +#include +#include +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr const T& optional::value() const; + +#include +#include +#include + +#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 opt(in_place); + static_assert(opt.value().test() == 3, ""); + } + { + const optional opt(in_place); + assert(opt.value().test() == 3); + } + { + const optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T optional::value_or(U&& v) &&; + +#include +#include +#include + +#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 opt(in_place, 2); + Y y(3); + assert(std::move(opt).value_or(y) == 2); + assert(*opt == 0); + } + { + optional opt(in_place, 2); + assert(std::move(opt).value_or(Y(3)) == 2); + assert(*opt == 0); + } + { + optional opt; + Y y(3); + assert(std::move(opt).value_or(y) == 3); + assert(!opt); + } + { + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr T optional::value_or(U&& v) const&; + +#include +#include +#include + +#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 opt(2); + constexpr Y y(3); + static_assert(opt.value_or(y) == 2, ""); + } + { + constexpr optional opt(2); + static_assert(opt.value_or(Y(3)) == 2, ""); + } + { + constexpr optional opt; + constexpr Y y(3); + static_assert(opt.value_or(y) == 3, ""); + } + { + constexpr optional opt; + static_assert(opt.value_or(Y(3)) == 4, ""); + } + { + const optional opt(2); + const Y y(3); + assert(opt.value_or(y) == 2); + } + { + const optional opt(2); + assert(opt.value_or(Y(3)) == 2); + } + { + const optional opt; + const Y y(3); + assert(opt.value_or(y) == 3); + } + { + const optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(optional&) +// noexcept(is_nothrow_move_constructible::value && +// noexcept(swap(declval(), declval()))); + +#include +#include +#include + +#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 opt1; + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + opt1.swap(opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + opt1.swap(opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + opt1.swap(opt2); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + opt1.swap(opt2); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + opt1.swap(opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + assert(X::dtor_called == 0); + } + { + optional opt1(1); + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + X::dtor_called = 0; + opt1.swap(opt2); + assert(X::dtor_called == 1); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + opt1.swap(opt2); + assert(X::dtor_called == 1); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + opt1.swap(opt2); + assert(X::dtor_called == 1); // from inside std::swap + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + opt1.swap(opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + assert(Y::dtor_called == 0); + } + { + optional opt1(1); + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + Y::dtor_called = 0; + opt1.swap(opt2); + assert(Y::dtor_called == 1); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + opt1.swap(opt2); + assert(Y::dtor_called == 1); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + opt1.swap(opt2); + assert(Y::dtor_called == 0); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + opt1.swap(opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + } + { + optional opt1; + opt1.emplace(1); + optional opt2; + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + try + { + opt1.swap(opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + } + { + optional opt1; + optional opt2; + opt2.emplace(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + try + { + opt1.swap(opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + } + { + optional opt1; + opt1.emplace(1); + optional opt2; + opt2.emplace(2); + static_assert(noexcept(opt1.swap(opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + try + { + opt1.swap(opt2); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// T shall be an object type and shall satisfy the requirements of Destructible + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class optional +// { +// public: +// typedef T value_type; +// ... + +#include +#include + +#if _LIBCPP_STD_VER > 11 + +using std::experimental::optional; + +template +void +test() +{ + static_assert(std::is_same::value, ""); +} + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + test, int>(); + test, const int>(); + test, double>(); + test, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator==(const optional& x, const optional& y); + +#include +#include +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator>= (const optional& x, const optional& y); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator> (const optional& x, const optional& y); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator<= (const optional& x, const optional& y); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator< (const optional& x, const optional& y); + +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template constexpr bool operator!=(const optional& x, const optional& y); + +#include +#include +#include + +#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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr +// optional::type> +// make_optional(T&& v); + +#include +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + using std::experimental::make_optional; + + { + optional opt = make_optional(2); + assert(*opt == 2); + } + { + std::string s("123"); + optional opt = make_optional(s); + assert(*opt == s); + } + { + std::string s("123"); + optional opt = make_optional(std::move(s)); + assert(*opt == "123"); + assert(s.empty()); + } + { + std::unique_ptr s(new int(3)); + optional> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template void swap(optional& x, optional& y) +// noexcept(noexcept(x.swap(y))); + +#include +#include +#include + +#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 opt1; + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + swap(opt1, opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + swap(opt1, opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + swap(opt1, opt2); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + swap(opt1, opt2); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + swap(opt1, opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + assert(X::dtor_called == 0); + } + { + optional opt1(1); + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + X::dtor_called = 0; + swap(opt1, opt2); + assert(X::dtor_called == 1); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + swap(opt1, opt2); + assert(X::dtor_called == 1); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == true, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + X::dtor_called = 0; + swap(opt1, opt2); + assert(X::dtor_called == 1); // from inside std::swap + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + swap(opt1, opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + assert(Y::dtor_called == 0); + } + { + optional opt1(1); + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + Y::dtor_called = 0; + swap(opt1, opt2); + assert(Y::dtor_called == 1); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + swap(opt1, opt2); + assert(Y::dtor_called == 1); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == false); + } + { + optional opt1(1); + optional opt2(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + Y::dtor_called = 0; + swap(opt1, opt2); + assert(Y::dtor_called == 0); + assert(static_cast(opt1) == true); + assert(*opt1 == 2); + assert(static_cast(opt2) == true); + assert(*opt2 == 1); + } + { + optional opt1; + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + swap(opt1, opt2); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == false); + } + { + optional opt1; + opt1.emplace(1); + optional opt2; + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + try + { + swap(opt1, opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == false); + } + { + optional opt1; + optional opt2; + opt2.emplace(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + try + { + swap(opt1, opt2); + assert(false); + } + catch (int i) + { + assert(i == 7); + } + assert(static_cast(opt1) == false); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + } + { + optional opt1; + opt1.emplace(1); + optional opt2; + opt2.emplace(2); + static_assert(noexcept(swap(opt1, opt2)) == false, ""); + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(opt2) == true); + assert(*opt2 == 2); + try + { + swap(opt1, opt2); + assert(false); + } + catch (int i) + { + assert(i == 6); + } + assert(static_cast(opt1) == true); + assert(*opt1 == 1); + assert(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) in_place_t is ill-formed. + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + using std::experimental::in_place_t; + using std::experimental::in_place; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// A program that necessitates the instantiation of template optional for a +// reference type is ill-formed. + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) null_opt_t is ill-formed. + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + using std::experimental::nullopt_t; + using std::experimental::nullopt; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) in_place_t is ill-formed. + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + using std::experimental::in_place_t; + using std::experimental::in_place; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// #include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + std::initializer_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// A program that necessitates the instantiation of template optional for a +// reference type is ill-formed. + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// A program that necessitates the instantiation of template optional for +// (possibly cv-qualified) null_opt_t is ill-formed. + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + using std::experimental::nullopt_t; + using std::experimental::nullopt; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +// A program that necessitates the instantiation of template optional for a +// reference type is ill-formed. + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::experimental::optional; + + optional 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +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 + +// + +// constexpr const _CharT& at(size_type _pos) const; + +#include +#include + +template +void test ( const CharT *s, size_t len ) { + std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr const _CharT& front(); + +#include +#include + +template +bool test ( const CharT *s, size_t len ) { + std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr const _CharT* data() const noexcept; + +#include +#include + +template +void test ( const CharT *s, size_t len ) { + std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr const _CharT& back(); + +#include +#include + +template +bool test ( const CharT *s, size_t len ) { + std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr const _CharT& operator[](size_type _pos) const; + +#include +#include + +template +void test ( const CharT *s, size_t len ) { + std::experimental::basic_string_view 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 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.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 +#include + +template +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 +void test2 ( const CharT *s, size_t len ) { + { + std::experimental::basic_string_view 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 (); + test1 (); + test1 (); + test1 (); + + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator==(basic_string_view lhs, const charT* rhs); +// template +// constexpr bool operator==(const charT* lhs, basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator==(const charT* lhs, const basic_string rhs); +// template +// bool operator==(const basic_string_view lhs, const CharT* rhs); + +#include +#include + +#if _LIBCPP_STD_VER > 11 + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator==(const basic_string_view lhs, +// const basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator>=(const charT* lhs, basic_string_wiew rhs); +// template +// constexpr bool operator>=(basic_string_wiew lhs, const charT* rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>=(const basic_string& lhs, +// basic_string_view rhs); +// bool operator>=(basic_string_view lhs, +// const basic_string& rhs); + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator>=(basic_string_view lhs, +// basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr template +// bool operator>(const charT* lhs, basic_string_wiew rhs); +// constexpr template +// bool operator>(basic_string_wiew lhs, const charT* rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>(const basic_string& lhs, +// basic_string_view rhs); +// bool operator>(basic_string_view lhs, +// const basic_string& rhs); + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator>(basic_string_view lhs, +// basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator<=(const charT* lhs, basic_string_wiew rhs); +// template +// constexpr bool operator<=(basic_string_wiew lhs, const charT* rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<=(const basic_string& lhs, +// basic_string_view rhs); +// bool operator<=(basic_string_view lhs, +// const basic_string& rhs); + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator<=(basic_string_view lhs, +// basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator<(const charT* lhs, basic_string_wiew rhs); +// template +// constexpr bool operator<(basic_string_wiew lhs, const charT* rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<(const basic_string& lhs, +// basic_string_view rhs); +// bool operator<(basic_string_view lhs, +// const basic_string& rhs); + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator<(basic_string_view lhs, +// basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator!=(basic_string_view lhs, const charT* rhs); +// template +// constexpr bool operator!=(const charT* lhs, basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator!=(const basic_string &lhs, basic_string_view rhs); +// template +// bool operator!=(basic_string_view lhs, const basic_string &rhs); + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// constexpr bool operator!=(const basic_string_view lhs, +// const basic_string_view rhs); + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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> 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr basic_string_view () noexcept; + +#include +#include + +template +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 (); + test (); + test (); + test (); + +} 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr basic_string_view(const _CharT* _s) +// : __data (_s), __size(_Traits::length(_s)) {} + + +#include +#include +#include + +#include "constexpr_char_traits.hpp" + +template +size_t StrLen ( const CharT *s ) { + size_t retVal = 0; + while ( *s != 0 ) { ++retVal; ++s; } + return retVal; + } + +template +void test ( const CharT *s ) { + std::experimental::basic_string_view 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> 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr basic_string_view(const _CharT* _s, size_type _len) +// : __data (_s), __size(_len) {} + + +#include +#include +#include + +template +void test ( const CharT *s, size_t sz ) { + { + std::experimental::basic_string_view 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template +// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept + + +#include +#include +#include + +struct dummy_char_traits : public std::char_traits {}; + +template +void test ( const std::basic_string &str ) { + std::experimental::basic_string_view 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("QBCDE") ); + test ( std::basic_string("") ); + test ( std::basic_string() ); + +} 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template +// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept + +#include +#include +#include + +struct dummy_char_traits : public std::char_traits {}; + +int main () { + using string_view = std::experimental::basic_string_view; + using string = std:: basic_string ; + + { + 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template +// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept + +#include +#include +#include + +struct dummy_char_traits : public std::char_traits {}; + +int main () { + using string_view = std::experimental::basic_string_view; + using string = std:: basic_string ; + + { + 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find(charT c, size_type pos = 0) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_first_not_of(charT c, size_type pos = 0) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const; + +#include +#include + +template +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 +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 +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 +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(); + test1(); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_first_of(charT c, size_type pos = 0) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_first_of(const charT* s, size_type pos = 0) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_of(const basic_string_view& str, size_type pos = 0) const; + +#include +#include + +template +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 +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 +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 +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(); + test1(); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// const size_type find_last_not_of(charT c, size_type pos = npos) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const; + +#include +#include + +template +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 +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 +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 +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(); + test1(); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_last_of(charT c, size_type pos = npos) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_last_of(const charT* s, size_type pos = npos) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_of(const basic_string& str, size_type pos = npos) const; + +#include +#include + +template +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 +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 +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 +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(); + test1(); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find(const charT* s, size_type pos = 0) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type find(const basic_string_view& str, size_type pos = 0) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// +// constexpr size_type rfind(charT c, size_type pos = npos) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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> 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. +// +//===----------------------------------------------------------------------===// + +// +// constexpr size_type rfind(const charT* s, size_type pos = npos) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// +// constexpr size_type rfind(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr size_type rfind(const basic_string& str, size_type pos = npos) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +template +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 +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 +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 +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(); + test1(); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::experimental::basic_string_view> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include + +using std::experimental::string_view; + +template +void +test() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const basic_string_view str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr const_iterator begin() const; + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr const_iterator end() const; + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// const_iterator rbegin() const; + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr const_iterator rend() const; + +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + + +// + +// void clear() noexcept + +#include +#include + +template +void test ( const CharT *s, size_t len ) { + typedef std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// void remove_prefix(size_type _n) + +#include +#include +#include + +template +void test ( const CharT *s, size_t len ) { + typedef std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// void remove_suffix(size_type _n) + +#include +#include + +template +void test ( const CharT *s, size_t len ) { + typedef std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + + +// + +// void swap(basic_string_view& _other) noexcept + +#include +#include + +template +void test ( const CharT *s, size_t len ) { + typedef std::experimental::basic_string_view 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// quoted + +#include +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + + +// + +// template +// explicit operator basic_string<_CharT, _Traits, _Allocator>() const + +#include +#include + +template +void test ( const CharT *s ) { + typedef std::experimental::basic_string_view string_view_t; + typedef std::basic_string string_t; + + { + string_view_t sv1 ( s ); + string_t str = (string_t) sv1; + + assert ( sv1.size() == str.size ()); + assert ( std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr int compare(const charT* s) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); } + +template +void test1 ( std::experimental::basic_string_view sv1, const CharT *s, int expected ) { + assert ( sign( sv1.compare(s)) == sign(expected)); +} + +template +void +test( const CharT *s1, const CharT *s2, int expected) +{ + typedef std::experimental::basic_string_view 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> 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr int compare(size_type pos1, size_type n1, const charT* s) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); } + +template +void test1 ( std::experimental::basic_string_view 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 +void +test( const CharT *s1, size_t pos1, size_t n1, const CharT *s2, int expected) +{ + typedef std::experimental::basic_string_view 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> 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); } + +template +void test1 ( std::experimental::basic_string_view sv1, size_t pos1, size_t n1, + std::experimental::basic_string_view 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 +void test ( const CharT *s1, size_t pos1, size_t n1, const CharT *s2, int expected ) { + typedef std::experimental::basic_string_view 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> 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr int compare(size_type pos1, size_type n1, +// const charT* s, size_type n2) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); } + +template +void test1 ( std::experimental::basic_string_view 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 +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 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> 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. +// +//===----------------------------------------------------------------------===// + + +// + +// constexpr int compare(size_type pos1, size_type n1, basic_string_view str, +// size_type pos2, size_type n2) const; + +#include +#include + +#include "constexpr_char_traits.hpp" + +int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); } + +template +void test1 ( std::experimental::basic_string_view sv1, size_t pos1, size_t n1, + std::experimental::basic_string_view 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 +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 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> 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. +// +//===----------------------------------------------------------------------===// + + +// +// constexpr int compare(basic_string_view str) const noexcept; + +#include +#include + +#include "constexpr_char_traits.hpp" + +int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); } + +template +void test1 ( std::experimental::basic_string_view sv1, + std::experimental::basic_string_view sv2, int expected ) { + assert ( sign( sv1.compare(sv2)) == sign(expected)); +} + + +template +void test ( const CharT *s1, const CharT *s2, int expected ) { + typedef std::experimental::basic_string_view 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> 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. +// +//===----------------------------------------------------------------------===// + + +// + +// 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 +#include + +template +void test1 ( std::experimental::basic_string_view 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 +void test ( const CharT *s ) { + typedef std::experimental::basic_string_view 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. +// +//===----------------------------------------------------------------------===// + + +// + +// 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 +#include + +template +void test1 ( std::experimental::basic_string_view sv, size_t n, size_t pos ) { + try { + std::experimental::basic_string_view 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 +void test ( const CharT *s ) { + typedef std::experimental::basic_string_view 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. +// +//===----------------------------------------------------------------------===// + + +// + +// template +// explicit operator basic_string<_CharT, _Traits, Allocator> () const; +// template, class Allocator = allocator<_CharT> > +// basic_string<_CharT, _Traits, Allocator> to_string ( +// basic_string_view<_CharT, _Traits> _sv, const Allocator& _a = Allocator()) const; + +#include +#include +#include "min_allocator.h" + +template +void test ( const CharT *s ) { + typedef std::basic_string String ; + { + const std::experimental::basic_string_view sv1 ( s ); + String str1 = (String) sv1; + + assert ( sv1.size() == str1.size ()); + assert ( std::char_traits::compare ( sv1.data(), str1.data(), sv1.size()) == 0 ); + +#if __cplusplus >= 201103L + auto str2 = sv1.to_string(min_allocator()); + assert ( sv1.size() == str2.size ()); + assert ( std::char_traits::compare ( sv1.data(), str2.data(), sv1.size()) == 0 ); +#endif + } + + { + const std::experimental::basic_string_view sv1; + String str1 = (String) sv1; + + assert ( sv1.size() == 0); + assert ( sv1.size() == str1.size ()); + +#if __cplusplus >= 201103L + auto str2 = sv1.to_string(min_allocator()); + 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 + +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 + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_TYPE_TRAITS +# error " must include " +# 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_same_v == std::is_same::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(!ex::is_same_v, ""); + static_assert(ex::is_same_v == std::is_same::value, ""); + } + { + typedef base_type T; + typedef derived_type U; + static_assert(ex::is_base_of_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_base_of_v == std::is_base_of::value, ""); + } + { + typedef int T; + typedef int U; + static_assert(!ex::is_base_of_v, ""); + static_assert(ex::is_base_of_v == std::is_base_of::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(ex::is_convertible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_convertible_v == std::is_convertible::value, ""); + } + { + typedef void T; + typedef int U; + static_assert(!ex::is_convertible_v, ""); + static_assert(ex::is_convertible_v == std::is_convertible::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_void_v == std::is_void::value, ""); + } + { + typedef int T; + static_assert(!ex::is_void_v, ""); + static_assert(ex::is_void_v == std::is_void::value, ""); + } + { + typedef decltype(nullptr) T; + static_assert(ex::is_null_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_null_pointer_v == std::is_null_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_null_pointer_v, ""); + static_assert(ex::is_null_pointer_v == std::is_null_pointer::value, ""); + } + { + typedef int T; + static_assert(ex::is_integral_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_integral_v == std::is_integral::value, ""); + } + { + typedef void T; + static_assert(!ex::is_integral_v, ""); + static_assert(ex::is_integral_v == std::is_integral::value, ""); + } + { + typedef float T; + static_assert(ex::is_floating_point_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_floating_point_v == std::is_floating_point::value, ""); + } + { + typedef int T; + static_assert(!ex::is_floating_point_v, ""); + static_assert(ex::is_floating_point_v == std::is_floating_point::value, ""); + } + { + typedef int(T)[42]; + static_assert(ex::is_array_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_array_v == std::is_array::value, ""); + } + { + typedef int T; + static_assert(!ex::is_array_v, ""); + static_assert(ex::is_array_v == std::is_array::value, ""); + } + { + typedef void* T; + static_assert(ex::is_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_pointer_v == std::is_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_pointer_v, ""); + static_assert(ex::is_pointer_v == std::is_pointer::value, ""); + } + { + typedef int & T; + static_assert(ex::is_lvalue_reference_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_lvalue_reference_v == std::is_lvalue_reference::value, ""); + } + { + typedef int T; + static_assert(!ex::is_lvalue_reference_v, ""); + static_assert(ex::is_lvalue_reference_v == std::is_lvalue_reference::value, ""); + } + { + typedef int && T; + static_assert(ex::is_rvalue_reference_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_rvalue_reference_v == std::is_rvalue_reference::value, ""); + } + { + typedef int T; + static_assert(!ex::is_rvalue_reference_v, ""); + static_assert(ex::is_rvalue_reference_v == std::is_rvalue_reference::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_object_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_member_object_pointer_v == std::is_member_object_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_object_pointer_v, ""); + static_assert(ex::is_member_object_pointer_v == std::is_member_object_pointer::value, ""); + } + { + typedef void(class_type::*T)(); + static_assert(ex::is_member_function_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_member_function_pointer_v == std::is_member_function_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_function_pointer_v, ""); + static_assert(ex::is_member_function_pointer_v == std::is_member_function_pointer::value, ""); + } + { + typedef enum_type T; + static_assert(ex::is_enum_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_enum_v == std::is_enum::value, ""); + } + { + typedef int T; + static_assert(!ex::is_enum_v, ""); + static_assert(ex::is_enum_v == std::is_enum::value, ""); + } + { + typedef union_type T; + static_assert(ex::is_union_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_union_v == std::is_union::value, ""); + } + { + typedef int T; + static_assert(!ex::is_union_v, ""); + static_assert(ex::is_union_v == std::is_union::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_class_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_class_v == std::is_class::value, ""); + } + { + typedef int T; + static_assert(!ex::is_class_v, ""); + static_assert(ex::is_class_v == std::is_class::value, ""); + } + { + typedef void(T)(); + static_assert(ex::is_function_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_function_v == std::is_function::value, ""); + } + { + typedef int T; + static_assert(!ex::is_function_v, ""); + static_assert(ex::is_function_v == std::is_function::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct class_type {}; + +int main() +{ + { + typedef int & T; + static_assert(ex::is_reference_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_reference_v == std::is_reference::value, ""); + } + { + typedef int T; + static_assert(!ex::is_reference_v, ""); + static_assert(ex::is_reference_v == std::is_reference::value, ""); + } + { + typedef int T; + static_assert(ex::is_arithmetic_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_arithmetic_v == std::is_arithmetic::value, ""); + } + { + typedef void* T; + static_assert(!ex::is_arithmetic_v, ""); + static_assert(ex::is_arithmetic_v == std::is_arithmetic::value, ""); + } + { + typedef int T; + static_assert(ex::is_fundamental_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_fundamental_v == std::is_fundamental::value, ""); + } + { + typedef class_type T; + static_assert(!ex::is_fundamental_v, ""); + static_assert(ex::is_fundamental_v == std::is_fundamental::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_object_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_object_v == std::is_object::value, ""); + } + { + typedef void T; + static_assert(!ex::is_object_v, ""); + static_assert(ex::is_object_v == std::is_object::value, ""); + } + { + typedef int T; + static_assert(ex::is_scalar_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_scalar_v == std::is_scalar::value, ""); + } + { + typedef void T; + static_assert(!ex::is_scalar_v, ""); + static_assert(ex::is_scalar_v == std::is_scalar::value, ""); + } + { + typedef void* T; + static_assert(ex::is_compound_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_compound_v == std::is_compound::value, ""); + } + { + typedef void T; + static_assert(!ex::is_compound_v, ""); + static_assert(ex::is_compound_v == std::is_compound::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_member_pointer_v == std::is_member_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_pointer_v, ""); + static_assert(ex::is_member_pointer_v == std::is_member_pointer::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_const_v == std::is_const::value, ""); + } + { + typedef int T; + static_assert(!ex::is_const_v, ""); + static_assert(ex::is_const_v == std::is_const::value, ""); + } + { + typedef volatile int T; + static_assert(ex::is_volatile_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_volatile_v == std::is_volatile::value, ""); + } + { + typedef int T; + static_assert(!ex::is_volatile_v, ""); + static_assert(ex::is_volatile_v == std::is_volatile::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivial_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivial_v == std::is_trivial::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivial_v, ""); + static_assert(ex::is_trivial_v == std::is_trivial::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copyable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_copyable_v == std::is_trivially_copyable::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_copyable_v, ""); + static_assert(ex::is_trivially_copyable_v == std::is_trivially_copyable::value, ""); + } + { + typedef int T; + static_assert(ex::is_standard_layout_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_standard_layout_v == std::is_standard_layout::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_standard_layout_v, ""); + static_assert(ex::is_standard_layout_v == std::is_standard_layout::value, ""); + } + { + typedef int T; + static_assert(ex::is_pod_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_pod_v == std::is_pod::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_pod_v, ""); + static_assert(ex::is_pod_v == std::is_pod::value, ""); + } + { + typedef int T; + static_assert(ex::is_literal_type_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_literal_type_v == std::is_literal_type::value, ""); + } + { + typedef non_literal_type T; + static_assert(!ex::is_literal_type_v, ""); + static_assert(ex::is_literal_type_v == std::is_literal_type::value, ""); + } + { + typedef empty_type T; + static_assert(ex::is_empty_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_empty_v == std::is_empty::value, ""); + } + { + typedef int T; + static_assert(!ex::is_empty_v, ""); + static_assert(ex::is_empty_v == std::is_empty::value, ""); + } + { + typedef polymorphic_type T; + static_assert(ex::is_polymorphic_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_polymorphic_v == std::is_polymorphic::value, ""); + } + { + typedef int T; + static_assert(!ex::is_polymorphic_v, ""); + static_assert(ex::is_polymorphic_v == std::is_polymorphic::value, ""); + } + { + typedef abstract_type T; + static_assert(ex::is_abstract_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_abstract_v == std::is_abstract::value, ""); + } + { + typedef int T; + static_assert(!ex::is_abstract_v, ""); + static_assert(ex::is_abstract_v == std::is_abstract::value, ""); + } + { + typedef final_type T; + static_assert(ex::is_final_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_final_v == std::is_final::value, ""); + } + { + typedef int T; + static_assert(!ex::is_final_v, ""); + static_assert(ex::is_final_v == std::is_final::value, ""); + } + { + typedef int T; + static_assert(ex::is_signed_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_signed_v == std::is_signed::value, ""); + } + { + typedef unsigned T; + static_assert(!ex::is_signed_v, ""); + static_assert(ex::is_signed_v == std::is_signed::value, ""); + } + { + typedef unsigned T; + static_assert(ex::is_unsigned_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_unsigned_v == std::is_unsigned::value, ""); + } + { + typedef int T; + static_assert(!ex::is_unsigned_v, ""); + static_assert(ex::is_unsigned_v == std::is_unsigned::value, ""); + } +} + +void is_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_constructible_v == std::is_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_constructible_v, ""); + static_assert(ex::is_constructible_v == std::is_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_default_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_default_constructible_v, ""); + static_assert(ex::is_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_constructible_v, ""); + static_assert(ex::is_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_constructible_v, ""); + static_assert(ex::is_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_assignable_v == std::is_assignable::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_assignable_v, ""); + static_assert(ex::is_assignable_v == std::is_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_assignable_v, ""); + static_assert(ex::is_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_assignable_v, ""); + static_assert(ex::is_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_destructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_destructible_v == std::is_destructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_destructible_v, ""); + static_assert(ex::is_destructible_v == std::is_destructible::value, ""); + } +} + +void is_trivially_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_trivially_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_constructible_v == std::is_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_constructible_v, ""); + static_assert(ex::is_trivially_constructible_v == std::is_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_default_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_default_constructible_v, ""); + static_assert(ex::is_trivially_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_constructible_v, ""); + static_assert(ex::is_trivially_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_constructible_v, ""); + static_assert(ex::is_trivially_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_trivially_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_assignable_v == std::is_assignable::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_trivially_assignable_v, ""); + static_assert(ex::is_trivially_assignable_v == std::is_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_assignable_v, ""); + static_assert(ex::is_trivially_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_assignable_v, ""); + static_assert(ex::is_trivially_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_destructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_destructible_v == std::is_destructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_destructible_v, ""); + static_assert(ex::is_trivially_destructible_v == std::is_destructible::value, ""); + } +} + + + +void is_nothrow_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_nothrow_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_constructible_v == std::is_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_constructible_v, ""); + static_assert(ex::is_nothrow_constructible_v == std::is_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_default_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_nothrow_default_constructible_v, ""); + static_assert(ex::is_nothrow_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_constructible_v, ""); + static_assert(ex::is_nothrow_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_constructible_v, ""); + static_assert(ex::is_nothrow_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_nothrow_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_assignable_v == std::is_assignable::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_nothrow_assignable_v, ""); + static_assert(ex::is_nothrow_assignable_v == std::is_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_assignable_v, ""); + static_assert(ex::is_nothrow_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_assignable_v, ""); + static_assert(ex::is_nothrow_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_destructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_destructible_v == std::is_destructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_destructible_v, ""); + static_assert(ex::is_nothrow_destructible_v == std::is_destructible::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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::has_virtual_destructor_v == std::has_virtual_destructor::value, ""); + } + { + typedef int T; + static_assert(!ex::has_virtual_destructor_v, ""); + static_assert(ex::has_virtual_destructor_v == std::has_virtual_destructor::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +int main() +{ + { + typedef char T; + static_assert(ex::alignment_of_v == 1, ""); + static_assert(std::is_same), const std::size_t>::value, ""); + static_assert(ex::alignment_of_v == std::alignment_of::value, ""); + } + { + typedef char(T)[1][1][1]; + static_assert(ex::rank_v == 3, ""); + static_assert(std::is_same), const std::size_t>::value, ""); + static_assert(ex::rank_v == std::rank::value, ""); + } + { + typedef void T; + static_assert(ex::rank_v == 0, ""); + static_assert(ex::rank_v == std::rank::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 2, ""); + static_assert(std::is_same), const std::size_t>::value, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 2, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 3, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 0, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef void T; + static_assert(ex::extent_v == 0, ""); + static_assert(ex::extent_v == std::extent::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +// + +// Test that is included. + +#include + +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 + +// + +// template constexpr bool ratio_equal_v; + +#include +#include + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_equal_v, "" + ); + static_assert( + ex::ratio_equal_v == std::ratio_equal::value, "" + ); + static_assert( + std::is_same), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert( + !ex::ratio_equal_v, "" + ); + static_assert( + ex::ratio_equal_v == std::ratio_equal::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 + +// + +// template constexpr bool ratio_greater_equal_v; + +#include +#include + +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, "" + ); + static_assert( + ex::ratio_greater_equal_v + == std::ratio_greater_equal::value, "" + ); + static_assert( + std::is_same< + decltype(ex::ratio_greater_equal_v), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_greater_equal_v, "" + ); + static_assert( + ex::ratio_greater_equal_v + == std::ratio_greater_equal::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_greater_equal_v, "" + ); + static_assert( + ex::ratio_greater_equal_v + == std::ratio_greater_equal::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 + +// + +// template constexpr bool ratio_greater_v; + +#include +#include + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_greater_v, "" + ); + static_assert( + ex::ratio_greater_v == std::ratio_greater::value, "" + ); + static_assert( + std::is_same), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_greater_v, "" + ); + static_assert( + ex::ratio_greater_v == std::ratio_greater::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_greater_v, "" + ); + static_assert( + ex::ratio_greater_v == std::ratio_greater::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 + +// + +// template constexpr bool ratio_less_equal_v; + +#include +#include + +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, "" + ); + static_assert( + ex::ratio_less_equal_v == std::ratio_less_equal::value, "" + ); + static_assert( + std::is_same), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_less_equal_v, "" + ); + static_assert( + ex::ratio_less_equal_v == std::ratio_less_equal::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_less_equal_v, "" + ); + static_assert( + ex::ratio_less_equal_v == std::ratio_less_equal::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 + +// + +// template constexpr bool ratio_less_v; + +#include +#include + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_less_v, "" + ); + static_assert( + ex::ratio_less_v == std::ratio_less::value, "" + ); + static_assert( + std::is_same), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_less_v, "" + ); + static_assert( + ex::ratio_less_v == std::ratio_less::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_less_v, "" + ); + static_assert( + ex::ratio_less_v == std::ratio_less::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 + +// + +// template constexpr bool ratio_not_equal_v; + +#include +#include + +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, "" + ); + static_assert( + ex::ratio_not_equal_v == std::ratio_not_equal::value, "" + ); + static_assert( + std::is_same), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_not_equal_v, "" + ); + static_assert( + ex::ratio_not_equal_v == std::ratio_not_equal::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 + +// + +#include + +int main() +{ + // Check that 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 + +// + +// template constexpr bool is_error_code_enum_v; + +#include +#include /* for std::io_errc */ + +namespace ex = std::experimental; + +int main() { + { + static_assert(ex::is_error_code_enum_v, ""); + + static_assert(ex::is_error_code_enum_v == + std::is_error_code_enum ::value, ""); + + static_assert(std::is_same), + const bool>::value, ""); + } + { + static_assert(!ex::is_error_code_enum_v, ""); + + static_assert(ex::is_error_code_enum_v == + std::is_error_code_enum ::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 + +// + +// template constexpr bool is_error_condition_enum_v; + +#include +#include +namespace ex = std::experimental; + +int main() { + { + static_assert(ex::is_error_condition_enum_v, ""); + + static_assert(ex::is_error_condition_enum_v == + std::is_error_condition_enum ::value, ""); + + static_assert( + std::is_same), + const bool>::value, + ""); + } + { + static_assert(!ex::is_error_condition_enum_v, ""); + + static_assert(ex::is_error_condition_enum_v == + std::is_error_condition_enum ::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +int main() +{ + // Check that 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 + +// + +// template constexpr bool treat_as_floating_point_v; + +#include +#include + +namespace ex = std::chrono::experimental; +namespace cr = std::chrono; + +template +void test() +{ + static_assert( + ex::treat_as_floating_point_v == Expect, "" + ); + static_assert( + ex::treat_as_floating_point_v == cr::treat_as_floating_point::value, "" + ); +} + +int main() +{ + { + static_assert( + std::is_same< + decltype(ex::treat_as_floating_point_v), const bool + >::value, "" + ); + } + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} 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 + +// + +#include + +int main() +{ + std::tuple 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 + +// + +// template constexpr decltype(auto) apply(F &&, T &&) + +// Test with different ref/ptr/cv qualified argument types. + +#include +#include +#include +#include + +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 +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(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 +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 +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 +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 +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>(); + test_values>(); + test_values>(); + + test_refs>(); + test_refs>(); + + test_const_refs>(); + test_const_refs>(); + + test_pointer>(); + test_pointer>(); + test_pointer>(); + + test_const_pointer>(); + test_const_pointer>(); + test_const_pointer>(); +} 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: * + +// + +// template constexpr decltype(auto) apply(F &&, T &&) + +// Testing constexpr evaluation + +#include +#include +#include + +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 +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 +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 +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>(); + test_1>(); + test_2>(); + test_2>(); +} 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 + +// + +// template 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 +#include +#include +#include + +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 +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_wrap_0; +typedef A_wrap A_wrap_1; +typedef A_wrap A_wrap_2; + + +template +struct A_base : public A +{ + A_base() : A() {} + A_base(int x) : A(x) {} +}; + +typedef A_base A_base_0; +typedef A_base A_base_1; +typedef A_base 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, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + >(); + test_ext_int_0< + std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + >(); + test_ext_int_0< + std::array, std::array + , std::array, std::array + , std::array, std::array + , std::array, std::array + >(); + } + { + test_ext_int_1< + std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + >(); + test_ext_int_1< + std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + >(); + test_ext_int_1< + std::pair, std::pair + , std::pair, std::pair + , std::pair, std::pair + , std::pair, std::pair + >(); + test_ext_int_1< + std::pair, std::pair + , std::pair, std::pair + , std::pair, std::pair + , std::pair, std::pair + >(); + } + { + test_ext_int_2< + std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + >(); + test_ext_int_2< + std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + , std::tuple, std::tuple + >(); + } +} 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 + +// + +// template constexpr decltype(auto) apply(F &&, T &&) + +// Stress testing large arities with tuple and array. + +#include +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +template +struct always_imp +{ + typedef T type; +}; + +template +using always_t = typename always_imp::type; + +//////////////////////////////////////////////////////////////////////////////// +template +struct make_function; + +template +struct make_function> +{ + using type = bool (*)(always_t...); +}; + +template +using make_function_t = typename make_function>::type; + +//////////////////////////////////////////////////////////////////////////////// +template +struct make_tuple_imp; + +//////////////////////////////////////////////////////////////////////////////// +template +struct make_tuple_imp> +{ + using type = std::tuple...>; +}; + +template +using make_tuple_t = typename make_tuple_imp>::type; + +template +bool test_apply_fn(Types...) { return true; } + +namespace ex = std::experimental; + +template +void test_all() +{ + + using A = std::array; + using ConstA = std::array; + + using Tuple = make_tuple_t; + using CTuple = make_tuple_t; + + using ValFn = make_function_t; + ValFn val_fn = &test_apply_fn; + + using RefFn = make_function_t; + RefFn ref_fn = &test_apply_fn; + + using CRefFn = make_function_t; + CRefFn cref_fn = &test_apply_fn; + + using RRefFn = make_function_t; + 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 +void test_one() +{ + using A = std::array; + using Tuple = make_tuple_t; + + using ValFn = make_function_t; + 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 + +// + +// template constexpr decltype(auto) apply(F &&, T &&) + +// Testing ref qualified functions + +#include +#include + +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(f), tp), ""); + static_assert(2 == ex::apply(static_cast(f), tp), ""); + } +*/ + { + func_obj f; + std::tuple<> tp; + assert(1 == ex::apply(static_cast(f), tp)); + assert(2 == ex::apply(static_cast(f), tp)); + assert(3 == ex::apply(static_cast(f), tp)); + assert(4 == ex::apply(static_cast(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 + +// + +// template constexpr decltype(auto) apply(F &&, T &&) + +// Test the return type deduction. + +#include +#include + +static int my_int = 42; + +template 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(my_int); } +int const & f(index<6>) { return static_cast(my_int); } +int volatile & f(index<7>) { return static_cast(my_int); } +int const volatile & f(index<8>) { return static_cast(my_int); } + +int && f(index<9>) { return static_cast(my_int); } +int const && f(index<10>) { return static_cast(my_int); } +int volatile && f(index<11>) { return static_cast(my_int); } +int const volatile && f(index<12>) { return static_cast(my_int); } + +int * f(index<13>) { return static_cast(&my_int); } +int const * f(index<14>) { return static_cast(&my_int); } +int volatile * f(index<15>) { return static_cast(&my_int); } +int const volatile * f(index<16>) { return static_cast(&my_int); } + + +template +void test() +{ + using F = decltype((f(index{}))); + static_assert(std::is_same::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 + +// + +// template constexpr decltype(auto) apply(F &&, T &&) + +// Test function types. + +#include +#include +#include +#include + +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 +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 +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 +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 +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 +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 +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 +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 +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 +void test_0() +{ + test_void_0(); + test_int_0(); +} + +template +void test_1() +{ + test_void_1(); + test_int_1(); +} + +template +void test_2() +{ + test_void_2(); + test_int_2(); +} + +template +void test_3() +{ + test_void_3(); + test_int_3(); +} + +int main() +{ + test_0>(); + + test_1>(); + test_1>(); + + test_2>(); + test_2>(); + test_2>(); + + test_3>(); + test_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 + +// + +// template constexpr size_t tuple_size_v = tuple_size::value; + +// Test with reference + +#include + +namespace ex = std::experimental; + +int main() +{ + auto x = ex::tuple_size_v &>; +} 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 + +// + +// template constexpr size_t tuple_size_v = tuple_size::value; + +#include +#include +#include + +namespace ex = std::experimental; + +template +void test() +{ + static_assert(ex::tuple_size_v == Expect, ""); + static_assert(ex::tuple_size_v == std::tuple_size::value, ""); + static_assert(ex::tuple_size_v == std::tuple_size::value, ""); + static_assert(ex::tuple_size_v == std::tuple_size::value, ""); + static_assert(ex::tuple_size_v == std::tuple_size::value, ""); +} + +int main() +{ + test, 0>(); + + test, 1>(); + test, 1>(); + + test, 2>(); + test, 2>(); + test, 2>(); + + test, 3>(); + test, 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 + +// + +// template constexpr size_t tuple_size_v = tuple_size::value; + +// Test with non tuple type + +#include + +namespace ex = std::experimental; + +int main() +{ + auto x = ex::tuple_size_v; +} 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 + +// + +// template constexpr size_t tuple_size_v = tuple_size::value; + +// Test with pointer + +#include + +namespace ex = std::experimental; + +int main() +{ + auto x = ex::tuple_size_v*>; +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_UTILITY +# error " must include " +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include +#include + +int main() +{ + assert(__gnu_cxx::hash()(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 +#include +#include + +int main() +{ + char str[] = "test"; + assert(__gnu_cxx::hash()("test") == + std::hash()("test")); + assert(__gnu_cxx::hash()(str) == std::hash()("test")); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(42) == 42); + assert(__gnu_cxx::hash()(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 + +int main() +{ + __gnu_cxx::hash_map m; + m[1] = 1; + const __gnu_cxx::hash_map &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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +#include +#include + +#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 + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + +#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + +#ifndef _LIBCPP_HAS_NO_STDIN + static_assert((std::is_same::value), ""); +#if _LIBCPP_STD_VER <= 11 + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +// gets + +#include + +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 + +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 + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_filebuf + +// void swap(basic_filebuf& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_filebuf + +// basic_filebuf& operator=(basic_filebuf&& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_filebuf + +// template +// void +// swap(basic_filebuf& x, basic_filebuf& y); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_filebuf + +// basic_filebuf(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_filebuf + +// basic_filebuf(basic_filebuf&& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_filebuf* open(const char* s, ios_base::openmode mode); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// int_type overflow(int_type c = traits::eof()); + +// This test is not entirely portable + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct test_buf + : public std::basic_filebuf +{ + typedef std::basic_filebuf 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 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 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// int_type pbackfail(int_type c = traits::eof()); + +// This test is not entirely portable + +#include +#include + +template +struct test_buf + : public std::basic_filebuf +{ + typedef std::basic_filebuf 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// int_type underflow(); + +// This test is not entirely portable + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct test_buf + : public std::basic_filebuf +{ + typedef std::basic_filebuf 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_filebuf +// : public basic_streambuf +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_filebuf >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// void swap(basic_fstream& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// basic_fstream& operator=(basic_fstream&& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// template +// void swap(basic_fstream& x, basic_fstream& y); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// basic_fstream(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// basic_fstream(basic_fstream&& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in | ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// void close(); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream + +// basic_filebuf* rdbuf() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_fstream +// : public basic_iostream +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_fstream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// void swap(basic_ifstream& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// basic_ifstream& operator=(basic_ifstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// template +// void swap(basic_ifstream& x, basic_ifstream& y); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// basic_ifstream(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// basic_ifstream(basic_ifstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// void close(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// void open(const char* s, ios_base::openmode mode = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// void open(const string& s, ios_base::openmode mode = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream + +// basic_filebuf* rdbuf() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ifstream +// : public basic_istream +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_ifstream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// void swap(basic_ofstream& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// basic_ofstream& operator=(basic_ofstream&& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// template +// void swap(basic_ofstream& x, basic_ofstream& y); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// basic_ofstream(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// basic_ofstream(basic_ofstream&& rhs); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// void close(); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// void open(const char* s, ios_base::openmode mode = ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// void open(const string& s, ios_base::openmode mode = ios_base::out); + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// basic_filebuf* rdbuf() const; + +#include +#include +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream +// : public basic_ostream +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_ofstream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template T7 get_money(moneyT& mon, bool intl = false); + +// REQUIRES: locale.en_US.UTF-8 + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(str_.data()) + str_.size()); + } +}; + +int main() +{ + { + testbuf 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T9 get_time(struct tm* tmb, const charT* fmt); + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(str_.data()) + str_.size()); + } +}; + +int main() +{ + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T8 put_money(const moneyT& mon, bool intl = false); + +// REQUIRES: locale.en_US.UTF-8 + +#include +#include + +#include "platform_support.h" // locale name macros + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T10 put_time(const struct tm* tmb, const charT* fmt); + +#include +#include + +#include "platform_support.h" // locale name macros + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_iostream; + +// void swap(basic_iostream& rhs); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_iostream + : public std::basic_iostream +{ + typedef std::basic_iostream base; + test_iostream(testbuf* sb) : base(sb) {} + + void swap(test_iostream& s) {base::swap(s);} +}; + +int main() +{ + { + testbuf sb1; + testbuf sb2; + test_iostream is1(&sb1); + test_iostream 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 sb1; + testbuf sb2; + test_iostream is1(&sb1); + test_iostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_iostream; + +// basic_iostream& operator=(basic_iostream&& rhs); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_iostream + : public std::basic_iostream +{ + typedef std::basic_iostream base; + test_iostream(testbuf* 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 sb1; + testbuf sb2; + test_iostream is1(&sb1); + test_iostream 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 sb1; + testbuf sb2; + test_iostream is1(&sb1); + test_iostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_iostream; + +// basic_iostream(basic_iostream&& rhs); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_iostream + : public std::basic_iostream +{ + typedef std::basic_iostream base; + test_iostream(testbuf* 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 sb; + test_iostream is1(&sb); + test_iostream 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 sb; + test_iostream is1(&sb); + test_iostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_iostream; + +// explicit basic_iostream(basic_streambuf* sb); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf sb; + std::basic_iostream 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 sb; + std::basic_iostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_iostream : +// public basic_istream, +// public basic_ostream +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_iostream >::value), ""); + static_assert((std::is_base_of, std::basic_iostream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(bool& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + bool n = true; + is >> n; + assert(n == false); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 1 "); + std::istream is(&sb); + bool n = 0; + is >> n; + assert(n == true); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(double& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + double n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + double n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(float& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + float n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + float n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(int& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + int n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + int n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf sb(L" -1234567890123456 "); + std::wistream is(&sb); + int n = 10; + is >> n; + assert(n == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(long& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(long double& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + long double n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + long double n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(long long& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + long long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + long long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(void*& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + void* n = (void*)1; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 1 "); + std::istream is(&sb); + void* n = 0; + is >> n; + assert(n == (void*)1); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf sb(L" 1 "); + std::wistream is(&sb); + void* n = 0; + is >> n; + assert(n == (void*)1); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf sb("12345678"); + std::istream is(&sb); + void* n = 0; + is >> n; + assert(n == (void*)0x12345678); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(short& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + short n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + short n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf sb(L" -1234567890 "); + std::wistream is(&sb); + short n = 10; + is >> n; + assert(n == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(unsigned int& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + unsigned int n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + unsigned int n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(unsigned long& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + unsigned long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + unsigned long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(unsigned long long& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + unsigned long long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + unsigned long long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// operator>>(unsigned short& val); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb("0"); + std::istream is(&sb); + unsigned short n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf sb(" 123 "); + std::istream is(&sb); + unsigned short n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// basic_istream& operator>>(basic_ios& +// (*pf)(basic_ios&)); + +#include +#include + +int f_called = 0; + +template +std::basic_ios& +f(std::basic_ios& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& operator>>(basic_istream&& in, charT& c); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" "); + std::istream is(&sb); + char c = 'z'; + is >> c; + assert( is.eof()); + assert( is.fail()); + assert(c == 'z'); + } + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// basic_istream& operator>>(ios_base& (*pf)(ios_base&)); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// basic_istream& operator>>(basic_istream& +// (*pf)(basic_istream&)); + +#include +#include + +int f_called = 0; + +template +std::basic_istream& +f(std::basic_istream& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& operator>>(basic_istream&& in, signed char& c); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" "); + std::istream is(&sb); + signed char c = 'z'; + is >> c; + assert( is.eof()); + assert( is.fail()); + assert(c == 'z'); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& operator>>(basic_istream&& in, signed char* s); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// basic_istream& operator<<(basic_streambuf* sb); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + testbuf(const std::basic_string& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(str_.data() + str_.size())); + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf sb("testing..."); + std::istream is(&sb); + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& operator>>(basic_istream&& in, unsigned char& c); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" "); + std::istream is(&sb); + unsigned char c = 'z'; + is >> c; + assert( is.eof()); + assert( is.fail()); + assert(c == 'z'); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& operator>>(basic_istream&& in, unsigned char* s); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& operator>>(basic_istream&& in, charT* s); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" abcdefghijk "); + std::istream is(&sb); + char s[20]; + is >> s; + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == "abcdefghijk"); + } + { + testbuf 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// ws(basic_istream& is); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" 123"); + std::istream is(&sb); + ws(is); + assert(is.good()); + assert(is.peek() == '1'); + } + { + testbuf sb(L" 123"); + std::wistream is(&sb); + ws(is); + assert(is.good()); + assert(is.peek() == L'1'); + } + { + testbuf sb(" "); + std::istream is(&sb); + ws(is); + assert(!is.fail()); + assert(is.eof()); + ws(is); + assert(is.eof()); + assert(is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// operator>>(basic_istream&& is, T& x); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" 123"); + int i = 0; + std::istream(&sb) >> i; + assert(i == 123); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// int_type get(); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" "); + std::istream is(&sb); + char c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == ' '); + assert(is.gcount() == 1); + } + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& get(char_type& c); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" "); + std::istream is(&sb); + char c; + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == ' '); + assert(is.gcount() == 1); + } + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& get(char_type* s, streamsize n); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& get(char_type* s, streamsize n, char_type delim); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& get(basic_streambuf& sb); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + testbuf(const std::basic_string& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(str_.data() + str_.size())); + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf sb("testing\n..."); + std::istream is(&sb); + testbuf 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 sb(L"testing\n..."); + std::wistream is(&sb); + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& get(basic_streambuf& sb, +// char_type delim); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + testbuf(const std::basic_string& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(str_.data() + str_.size())); + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf sb("testing*..."); + std::istream is(&sb); + testbuf 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 sb(L"testing*..."); + std::wistream is(&sb); + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& getline(char_type* s, streamsize n); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& getline(char_type* s, streamsize n, char_type delim); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& +// ignore(streamsize n = 1, int_type delim = traits::eof()); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& +// ignore(streamsize n = 1, int_type delim = traits::eof()); + +// http://llvm.org/bugs/show_bug.cgi?id=16427 + +#include +#include + +int main() +{ + int bad=-1; + std::ostringstream os; + os << "aaaabbbb" << static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// int_type peek(); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& putback(char_type c); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& read(char_type* s, streamsize n); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// streamsize readsome(char_type* s, streamsize n); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& seekg(pos_type pos); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" 123456789"); + std::istream is(&sb); + is.seekg(5); + assert(is.good()); + is.seekg(-1); + assert(is.fail()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& seekg(off_type off, ios_base::seekdir dir); + +#include +#include + +int seekoff_called = 0; + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// int sync(); + +#include +#include + +int sync_called = 0; + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" 123456789"); + std::istream is(&sb); + assert(is.sync() == 0); + assert(sync_called == 1); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// pos_type tellg(); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 sb(" 123456789"); + std::istream is(&sb); + assert(is.tellg() == 5); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_istream& unget(); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// void swap(basic_istream& rhs); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_istream + : public std::basic_istream +{ + typedef std::basic_istream base; + test_istream(testbuf* sb) : base(sb) {} + + void swap(test_istream& s) {base::swap(s);} +}; + +int main() +{ + { + testbuf sb1; + testbuf sb2; + test_istream is1(&sb1); + test_istream 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 sb1; + testbuf sb2; + test_istream is1(&sb1); + test_istream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// basic_istream& operator=(basic_istream&& rhs); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_istream + : public std::basic_istream +{ + typedef std::basic_istream base; + test_istream(testbuf* 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 sb1; + testbuf sb2; + test_istream is1(&sb1); + test_istream 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 sb1; + testbuf sb2; + test_istream is1(&sb1); + test_istream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// basic_istream(basic_istream&& rhs); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_istream + : public std::basic_istream +{ + typedef std::basic_istream base; + test_istream(testbuf* 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 sb; + test_istream is1(&sb); + test_istream 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 sb; + test_istream is1(&sb); + test_istream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream; + +// explicit basic_istream(basic_streambuf* sb); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf sb; + std::basic_istream 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 sb; + std::basic_istream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream::sentry; + +// explicit sentry(basic_istream& is, bool noskipws = false); + +#include +#include + +int sync_called = 0; + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_string string_type; + typedef std::basic_streambuf base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(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*)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*)0); + std::wistream::sentry sen(is, true); + assert(!(bool)sen); + assert(!is.good()); + assert(is.gcount() == 0); + assert(sync_called == 0); + } + { + testbuf 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_istream +// : virtual public basic_ios +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_istream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// void swap(basic_ostream& rhs); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_ostream + : public std::basic_ostream +{ + typedef std::basic_ostream base; + test_ostream(testbuf* sb) : base(sb) {} + + void swap(test_ostream& s) {base::swap(s);} +}; + +int main() +{ + { + testbuf sb1; + testbuf sb2; + test_ostream os1(&sb1); + test_ostream 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 sb1; + testbuf sb2; + test_ostream os1(&sb1); + test_ostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& operator=(basic_ostream&& rhs); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_ostream + : public std::basic_ostream +{ + typedef std::basic_ostream base; + test_ostream(testbuf* 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 sb1; + testbuf sb2; + test_ostream os1(&sb1); + test_ostream 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 sb1; + testbuf sb2; + test_ostream os1(&sb1); + test_ostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream(basic_ostream&& rhs); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +template +struct test_ostream + : public std::basic_ostream +{ + typedef std::basic_ostream base; + test_ostream(testbuf* 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 sb; + test_ostream os1(&sb); + test_ostream 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 sb; + test_ostream os1(&sb); + test_ostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// explicit basic_ostream(basic_streambuf* sb); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf sb; + std::basic_ostream 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 sb; + std::basic_ostream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(bool val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + bool b = false; + os << b; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + bool b = true; + os << b; + assert(sb.str() == "1"); + } + { + testbuf sb; + std::ostream os(&sb); + boolalpha(os); + bool b = true; + os << b; + assert(sb.str() == "true"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(double val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + double n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + double n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(float val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + float n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + float n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(int val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + int n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + int n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(long val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + long n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(long double val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + long double n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + long double n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(long long val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + long long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + long long n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include +#include + +template +void test_octal(const char *expected) +{ + std::stringstream ss; + ss << std::oct << static_cast(-1); + + assert(ss.str() == expected); +} + +template +void test_dec(const char *expected) +{ + std::stringstream ss; + ss << std::dec << static_cast(-1); + +// std::cout << ss.str() << " " << expected << std::endl; + assert(ss.str() == expected); +} + +template +void test_hex(const char *expected) +{ + std::stringstream ss; + ss << std::hex << static_cast(-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( "177777"); + test_octal< int16_t>( "177777"); + test_octal( "37777777777"); + test_octal< int32_t>( "37777777777"); + test_octal("1777777777777777777777"); + test_octal< int64_t>("1777777777777777777777"); + + test_dec( "65535"); + test_dec< int16_t>( "-1"); + test_dec( "4294967295"); + test_dec< int32_t>( "-1"); + test_dec("18446744073709551615"); + test_dec< int64_t>( "-1"); + + test_hex( "FFFF"); + test_hex< int16_t>( "FFFF"); + test_hex( "FFFFFFFF"); + test_hex< int32_t>( "FFFFFFFF"); + test_hex("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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(const void* val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb1; + std::ostream os1(&sb1); + int n1; + os1 << &n1; + assert(os1.good()); + std::string s1(sb1.str()); + + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(short val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + short n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + short n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(unsigned int val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + unsigned int n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + unsigned int n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(unsigned long val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + unsigned long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + unsigned long n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(unsigned long long val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + unsigned long long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + unsigned long long n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// operator<<(unsigned short val); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + unsigned short n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf sb; + std::ostream os(&sb); + unsigned short n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, charT c); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::wostream os(&sb); + wchar_t c = L'a'; + os << c; + assert(sb.str() == L"a"); + } + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, const charT* s); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::wostream os(&sb); + const wchar_t* c = L"123"; + os << c; + assert(sb.str() == L"123"); + } + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, char c); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + char c = 'a'; + os << c; + assert(sb.str() == "a"); + } + { + testbuf sb; + std::ostream os(&sb); + os.width(5); + char c = 'a'; + os << c; + assert(sb.str() == " a"); + assert(os.width() == 0); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, const char* s); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + const char* c = "123"; + os << c; + assert(sb.str() == "123"); + } + { + testbuf sb; + std::ostream os(&sb); + os.width(5); + const char* c = "123"; + os << c; + assert(sb.str() == " 123"); + assert(os.width() == 0); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, char c); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::wostream os(&sb); + char c = 'a'; + os << c; + assert(sb.str() == L"a"); + } + { + testbuf sb; + std::wostream os(&sb); + os.width(5); + char c = 'a'; + os << c; + assert(sb.str() == L" a"); + assert(os.width() == 0); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, const char* s); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::wostream os(&sb); + const char* c = "123"; + os << c; + assert(sb.str() == L"123"); + } + { + testbuf sb; + std::wostream os(&sb); + os.width(5); + const char* c = "123"; + os << c; + assert(sb.str() == L" 123"); + assert(os.width() == 0); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, signed char c); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + signed char c = 'a'; + os << c; + assert(sb.str() == "a"); + } + { + testbuf sb; + std::ostream os(&sb); + os.width(5); + signed char c = 'a'; + os << c; + assert(sb.str() == " a"); + assert(os.width() == 0); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, const signed char* s); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + const signed char* c = (const signed char*)"123"; + os << c; + assert(sb.str() == "123"); + } + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, unsigned char c); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + unsigned char c = 'a'; + os << c; + assert(sb.str() == "a"); + } + { + testbuf sb; + std::ostream os(&sb); + os.width(5); + unsigned char c = 'a'; + os << c; + assert(sb.str() == " a"); + assert(os.width() == 0); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& operator<<(basic_ostream& out, const unsigned char* s); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream os(&sb); + const unsigned char* c = (const unsigned char*)"123"; + os << c; + assert(sb.str() == "123"); + } + { + testbuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& operator<<(basic_ios& +// (*pf)(basic_ios&)); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +template +std::basic_ios& +f(std::basic_ios& os) +{ + std::uppercase(os); + return os; +} + +int main() +{ + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& operator<<(ios_base& (*pf)(ios_base&)); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& operator<< +// (basic_ostream& (*pf)(basic_ostream&)) + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +template +std::basic_ostream& +f(std::basic_ostream& os) +{ + os << "testing..."; + return os; +} + +int main() +{ + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& operator<<(basic_streambuf* sb); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + testbuf(const std::basic_string& str) + : str_(str) + { + base::setg(const_cast(str_.data()), + const_cast(str_.data()), + const_cast(str_.data() + str_.size())); + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf sb; + std::ostream os(&sb); + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& endl(basic_ostream& os); + +#include +#include + +int sync_called = 0; + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } + + virtual int + sync() + { + ++sync_called; + return 0; + } +}; + +int main() +{ + { + testbuf sb; + std::ostream os(&sb); + endl(os); + assert(sb.str() == "\n"); + assert(sync_called == 1); + assert(os.good()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& ends(basic_ostream& os); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf sb; + std::ostream os(&sb); + ends(os); + assert(sb.str().size() == 1); + assert(sb.str().back() == 0); + assert(os.good()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& flush(basic_ostream& os); + +#include +#include + +int sync_called = 0; + +template +class testbuf + : public std::basic_streambuf +{ +public: + testbuf() + { + } + +protected: + + virtual int + sync() + { + ++sync_called; + return 0; + } +}; + +int main() +{ + { + testbuf sb; + std::ostream os(&sb); + flush(os); + assert(sync_called == 1); + assert(os.good()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// template +// basic_ostream& +// operator<<(basic_ostream&& os, const T& x); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::ostream(&sb) << "testing..."; + assert(sb.str() == "testing..."); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& seekp(pos_type pos); + +#include +#include + +int seekpos_called = 0; + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& seekp(off_type off, ios_base::seekdir dir); + +#include +#include + +int seekoff_called = 0; + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// pos_type tellp(); + +#include +#include + +int seekoff_called = 0; + +template +struct testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& flush(); + +#include +#include + +int sync_called = 0; + +template +class testbuf + : public std::basic_streambuf +{ +public: + testbuf() + { + } + +protected: + + virtual int + sync() + { + if (sync_called++ == 1) + return -1; + return 0; + } +}; + +int main() +{ + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& put(char_type c); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 sb; + std::wostream os(&sb); + wchar_t c = L'a'; + os.put(c); + assert(sb.str() == L"a"); + assert(os.good()); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream; + +// basic_ostream& write(const char_type* s, streamsize n); + +#include +#include + +template +class testbuf + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + std::basic_string str_; +public: + testbuf() + { + } + + std::basic_string str() const + {return std::basic_string(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(str_.data()), + const_cast(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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream +// : virtual public basic_ios +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_ostream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream::sentry; + +// explicit sentry(basic_ostream& os); + +#include +#include + +int sync_called = 0; + +template +struct testbuf1 + : public std::basic_streambuf +{ + 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 sb; + std::ostream os(&sb); + std::ostream::sentry s(os); + assert(bool(s)); + } + { + testbuf1 sb; + std::ostream os(&sb); + testbuf1 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ostream::sentry; + +// ~sentry(); + +#include +#include + +int sync_called = 0; + +template +struct testbuf1 + : public std::basic_streambuf +{ + 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 sb; + std::ostream os(&sb); + std::ostream::sentry s(os); + assert(bool(s)); + } + assert(sync_called == 0); + { + testbuf1 sb; + std::ostream os(&sb); + std::ostream::sentry s(os); + assert(bool(s)); + unitbuf(os); + } + assert(sync_called == 1); + { + testbuf1 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// quoted + +#include +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// quoted + +#include +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// quoted + +#include +#include +#include +#include + +#if _LIBCPP_STD_VER > 11 + +template +struct test_traits +{ + typedef charT char_type; +}; + +void round_trip ( const char *p ) { + std::stringstream ss; + ss << std::quoted(p); + std::basic_string> 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. +// +//===----------------------------------------------------------------------===// + +// + +// T1 resetiosflags(ios_base::fmtflags mask); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// T3 setbase(int base); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template T4 setfill(charT c); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf sb; + std::ostream os(&sb); + os << std::setfill('*'); + assert(os.fill() == '*'); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// T2 setiosflags (ios_base::fmtflags mask); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// T5 setprecision(int n); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf sb; + std::istream is(&sb); + is >> std::setprecision(10); + assert(is.precision() == 10); + } + { + testbuf sb; + std::ostream os(&sb); + os << std::setprecision(10); + assert(os.precision() == 10); + } + { + testbuf sb; + std::wistream is(&sb); + is >> std::setprecision(10); + assert(is.precision() == 10); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// T6 setw(int n); + +#include +#include + +template +struct testbuf + : public std::basic_streambuf +{ + testbuf() {} +}; + +int main() +{ + { + testbuf sb; + std::istream is(&sb); + is >> std::setw(10); + assert(is.width() == 10); + } + { + testbuf sb; + std::ostream os(&sb); + os << std::setw(10); + assert(os.width() == 10); + } + { + testbuf sb; + std::wistream is(&sb); + is >> std::setw(10); + assert(is.width() == 10); + } + { + testbuf 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include // for mbstate_t + +int main() +{ + { + std::char_traits* t1 = 0; + std::char_traits* t2 = 0; + std::char_traits* t3 = 0; + } + { + std::basic_ios* t1 = 0; + std::basic_ios* t2 = 0; + std::basic_ios* t3 = 0; + } + { + std::basic_streambuf* t1 = 0; + std::basic_streambuf* t2 = 0; + std::basic_streambuf* t3 = 0; + } + { + std::basic_istream* t1 = 0; + std::basic_istream* t2 = 0; + std::basic_istream* t3 = 0; + } + { + std::basic_ostream* t1 = 0; + std::basic_ostream* t2 = 0; + std::basic_ostream* t3 = 0; + } + { + std::basic_iostream* t1 = 0; + std::basic_iostream* t2 = 0; + std::basic_iostream* t3 = 0; + } + { + std::basic_stringbuf* t1 = 0; + std::basic_stringbuf* t2 = 0; + std::basic_stringbuf* t3 = 0; + } + { + std::basic_istringstream* t1 = 0; + std::basic_istringstream* t2 = 0; + std::basic_istringstream* t3 = 0; + } + { + std::basic_ostringstream* t1 = 0; + std::basic_ostringstream* t2 = 0; + std::basic_ostringstream* t3 = 0; + } + { + std::basic_stringstream* t1 = 0; + std::basic_stringstream* t2 = 0; + std::basic_stringstream* t3 = 0; + } + { + std::basic_filebuf* t1 = 0; + std::basic_filebuf* t2 = 0; + std::basic_filebuf* t3 = 0; + } + { + std::basic_ifstream* t1 = 0; + std::basic_ifstream* t2 = 0; + std::basic_ifstream* t3 = 0; + } + { + std::basic_ofstream* t1 = 0; + std::basic_ofstream* t2 = 0; + std::basic_ofstream* t3 = 0; + } + { + std::basic_fstream* t1 = 0; + std::basic_fstream* t2 = 0; + std::basic_fstream* t3 = 0; + } + { + std::istreambuf_iterator* t1 = 0; + std::istreambuf_iterator* t2 = 0; + std::istreambuf_iterator* t3 = 0; + } + { + std::ostreambuf_iterator* t1 = 0; + std::ostreambuf_iterator* t2 = 0; + std::ostreambuf_iterator* 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* 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// istream cerr; + +#include +#include + +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 + +// + +// istream cin; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// istream clog; + +#include + +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 + +// + +// istream cout; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// istream wcerr; + +#include +#include + +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 + +// + +// istream wcin; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// istream wclog; + +#include + +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 + +// + +// istream wcout; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class fpos + +// void state(stateT s); + +#include +#include + +int main() +{ + std::fpos 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class fpos + +// Addition + +#include +#include + +int main() +{ + typedef std::fpos 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class fpos + +// fpos(int) + +#include +#include + +int main() +{ + typedef std::fpos 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class fpos + +// Subraction with fpos + +#include +#include + +int main() +{ + typedef std::fpos 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class fpos + +// == and != + +#include +#include + +int main() +{ + typedef std::fpos 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class fpos + +// converts to and from streamoff + +#include +#include + +int main() +{ + typedef std::fpos 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. +// +//===----------------------------------------------------------------------===// + +// + +// streamsize and streamoff interconvert + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class fpos + +// Subraction with offset + +#include +#include + +int main() +{ + typedef std::fpos 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// fmtflags flags() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// fmtflags flags(fmtflags fmtfl); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// streamsize precision() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// streamsize precision(streamsize prec); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// fmtflags setf(fmtflags fmtfl) + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// fmtflags setf(fmtflags fmtfl, fmtflags mask); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// void unsetf(fmtflags mask); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// streamsize width() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// streamsize width(streamsize wide); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// void register_callback(event_callback fn, int index); + +#include +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ~ios_base() + +#include +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// locale getloc() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// locale imbue(const locale& loc); + +#include +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// long& iword(int idx); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// void*& pword(int idx); + +#include +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// static int xalloc(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// bool sync_with_stdio(bool sync = true); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base::failure + +// explicit failure(const char* msg, const error_code& ec = io_errc::stream); + +#include +#include +#include + +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 + (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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base::failure + +// explicit failure(const string& msg, const error_code& ec = io_errc::stream); + +#include +#include +#include + +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 + (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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// static const iostate badbit; +// static const iostate eofbit; +// static const iostate failbit; +// static const iostate goodbit = 0; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// static const seekdir beg; +// static const seekdir cur; +// static const seekdir end; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// explicit basic_ios(basic_streambuf* sb); + +#include +#include +#include + +int main() +{ + { + std::streambuf* sb = 0; + std::basic_ios 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 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 + +// + +// template class basic_ios + +// basic_ios& copyfmt(const basic_ios& rhs); + +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// char_type fill() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// char_type fill(char_type fillch); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// locale imbue(const locale& loc); + +#include +#include +#include + +#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 + +// + +// template class basic_ios + +// void move(basic_ios&& rhs); + +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// char narrow(char_type c, char dfault) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// basic_streambuf* rdbuf() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// basic_streambuf* rdbuf(basic_streambuf* sb); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// void set_rdbuf(basic_streambuf* sb); + +#include +#include +#include + +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 + +// + +// template class basic_ios + +// void move(basic_ios&& rhs); + +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// basic_ostream* tie() const; + +#include +#include + +int main() +{ + const std::basic_ios 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// basic_ostream* tie(basic_ostream* tiestr); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// char_type widen(char c) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// bool bad() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// operator unspecified-bool-type() const; + +#include +#include + +int main() +{ + std::ios ios(0); + assert(static_cast(ios) == !ios.fail()); + ios.setstate(std::ios::failbit); + assert(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// void clear(iostate state = goodbit); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// bool eof() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// iostate exceptions() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// iostate exceptions() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// bool fail() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// bool good() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// bool operator!() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// iostate rdstate() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class basic_ios + +// void setstate(iostate state); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& internal(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& left(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& right(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& dec(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& hex(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& oct(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// const error_category& iostream_category(); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// error_code make_error_code(io_errc e); + +#include +#include + +int main() +{ + { + std::error_code ec = make_error_code(std::io_errc::stream); + assert(ec.value() == static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// error_condition make_error_condition(io_errc e); + +#include +#include + +int main() +{ + { + const std::error_condition ec1 = std::make_error_condition(std::io_errc::stream); + assert(ec1.value() == static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& defaultfloat(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& fixed(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& hexfloat(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& scientific(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& boolalpha(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& noboolalpha(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& noshowbase(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& noshowpoint(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& noshowpos(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& noskipws(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& nounitbuf(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& nouppercase(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& showbase(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& showpoint(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& showpos(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& skipws(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& unitbuf(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class ios_base + +// ios_base& uppercase(ios_base& str); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef OFF_T streamoff; + +#include +#include + +int main() +{ + static_assert(std::is_integral::value, ""); + static_assert(std::is_signed::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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef SZ_T streamsize; + +#include +#include + +int main() +{ + static_assert(std::is_integral::value, ""); + static_assert(std::is_signed::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// basic_streambuf(const basic_streambuf& rhs); // protected + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// basic_streambuf(const basic_streambuf& rhs); + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf base; + test() {} + + test(const test& t) + : std::basic_streambuf(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 t; + test t2 = t; + } + { + test t; + test t2 = t; + } + { + char g1, g2, g3, p1, p3; + test t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test t2 = t; + } + { + wchar_t g1, g2, g3, p1, p3; + test t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test t2 = t; + } + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + { + test t; + test t2 = t; + } + { + test t; + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// basic_streambuf(); // is protected + +#include + +int main() +{ + std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// basic_streambuf(); + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct test + : public std::basic_streambuf +{ + 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 t; + assert(t.getloc().name() == "C"); + } + { + test t; + assert(t.getloc().name() == "C"); + } + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + { + test t; + assert(t.getloc().name() == LOCALE_en_US_UTF_8); + } + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// pos_type pubseekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + test() {} +}; + +int main() +{ + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// pos_type pubseekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out; + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + test() {} +}; + +int main() +{ + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// basic_streambuf* pubsetbuf(char_type* s, streamsize n); + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + test() {} +}; + +int main() +{ + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int pubsync(); + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + test() {} +}; + +int main() +{ + { + test 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 + +// + +// template > +// class basic_streambuf; + +// locale pubimbue(const locale& loc); +// locale getloc() const; + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct test + : public std::basic_streambuf +{ + test() {} + + void imbue(const std::locale&) + { + assert(this->getloc().name() == LOCALE_en_US_UTF_8); + } +}; + +int main() +{ + { + test t; + assert(t.getloc().name() == "C"); + } + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// streamsize in_avail(); + +#include +#include + +int showmanyc_called = 0; + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type sbumpc(); + +#include +#include + +int uflow_called = 0; + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type sgetc(); + +#include +#include + +int underflow_called = 0; + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// streamsize sgetn(char_type* s, streamsize n); + +#include +#include + +int xsgetn_called = 0; + +struct test + : public std::basic_streambuf +{ + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type snextc(); + +#include +#include + +int uflow_called = 0; + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type sputbackc(char_type c); + +#include +#include + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type sungetc(); + +#include +#include + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type sputc(char_type c); + +#include +#include + +int overflow_called = 0; + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// streamsize sputn(const char_type* s, streamsize n); + +#include +#include + +int xsputn_called = 0; + +struct test + : public std::basic_streambuf +{ + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// basic_streambuf& operator=(const basic_streambuf& rhs); + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 t; + test t2; + t2 = t; + } + { + test t; + test t2; + t2 = t; + } + { + char g1, g2, g3, p1, p3; + test t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test t2; + t2 = t; + } + { + wchar_t g1, g2, g3, p1, p3; + test t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test t2; + t2 = t; + } + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + { + test t; + test t2; + t2 = t; + } + { + test t; + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// void swap(basic_streambuf& rhs); + +#include +#include + +#include "platform_support.h" // locale name macros + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 t; + test t2; + swap(t2, t); + } + { + test t; + test t2; + swap(t2, t); + } + { + char g1, g2, g3, p1, p3; + test t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test t2; + swap(t2, t); + } + { + wchar_t g1, g2, g3, p1, p3; + test t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test t2; + swap(t2, t); + } + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + { + test t; + test t2; + swap(t2, t); + } + { + test t; + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// void gbump(int n); + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 t; + char in[] = "ABCDE"; + t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); + t.gbump(2); + } + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// void setg(char_type* gbeg, char_type* gnext, char_type* gend); + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 t; + char in[] = "ABC"; + t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); + } + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// void pbump(int n); + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 t; + char in[] = "ABCDE"; + t.setp(in, in+sizeof(in)/sizeof(in[0])); + t.pbump(2); + t.pbump(1); + } + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// void setp(char_type* pbeg, char_type* pend); + +#include +#include + +template +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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 t; + char in[] = "ABC"; + t.setp(in, in+sizeof(in)/sizeof(in[0])); + } + { + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// streamsize showmanyc(); + +#include +#include + +int showmanyc_called = 0; + +template +struct test + : public std::basic_streambuf +{ + test() {} +}; + +int main() +{ + test 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type uflow(); + +#include +#include + +int underflow_called = 0; + +struct test + : public std::basic_streambuf +{ + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type underflow(); + +#include +#include + +struct test + : public std::basic_streambuf +{ + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// streamsize xsgetn(char_type* s, streamsize n); + +#include +#include + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type pbackfail(int_type c = traits::eof()); + +#include +#include + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf +{ + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// int_type overflow(int_type c = traits::eof()); + +#include +#include + +struct test + : public std::basic_streambuf +{ + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_streambuf; + +// streamsize xsputn(const char_type* s, streamsize n); + +#include +#include + +struct test + : public std::basic_streambuf +{ + typedef std::basic_streambuf 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include + +int main() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::int_type>::value), ""); + static_assert((std::is_same::pos_type>::value), ""); + static_assert((std::is_same::off_type>::value), ""); + + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::int_type>::value), ""); + static_assert((std::is_same::pos_type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream + +// void swap(basic_istringstream& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream + +// basic_istringstream& operator=(basic_istringstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream + +// template +// void +// swap(basic_istringstream& x, +// basic_istringstream& y); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream + +// explicit basic_istringstream(ios_base::openmode which = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream + +// basic_istringstream(basic_istringstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream + +// explicit basic_istringstream(const basic_string& str, +// ios_base::openmode which = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream + +// void str(const basic_string& s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_istringstream +// : public basic_istream +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_istringstream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::off_type>::value), ""); + static_assert((std::is_same::allocator_type, std::allocator >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream + +// void swap(basic_ostringstream& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream + +// basic_ostringstream& operator=(basic_ostringstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream + +// void swap(basic_ostringstream& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream + +// explicit basic_ostringstream(ios_base::openmode which = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream + +// basic_ostringstream(basic_ostringstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream + +// explicit basic_ostringstream(const basic_string& str, +// ios_base::openmode which = ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream + +// void str(const basic_string& s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_ostringstream +// : public basic_ostream +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_ostringstream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::off_type>::value), ""); + static_assert((std::is_same::allocator_type, std::allocator >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// void swap(basic_stringbuf& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// basic_stringbuf& operator=(basic_stringbuf&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// template +// void swap(basic_stringbuf& x, +// basic_stringbuf& y); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// basic_stringbuf(basic_stringbuf&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// explicit basic_stringbuf(const basic_string& s, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// void str(const basic_string& s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// int_type overflow(int_type c = traits::eof()); + +#include +#include + +int overflow_called = 0; + +template +struct testbuf + : public std::basic_stringbuf +{ + typedef std::basic_stringbuf base; + explicit testbuf(const std::basic_string& 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// int_type pbackfail(int_type c = traits::eof()); + +#include +#include + +template +struct testbuf + : public std::basic_stringbuf +{ + typedef std::basic_stringbuf base; + explicit testbuf(const std::basic_string& 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 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::eof()); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail('3') == std::char_traits::eof()); + assert(sb.pbackfail('2') == '2'); + assert(sb.pbackfail(std::char_traits::eof()) != std::char_traits::eof()); + assert(sb.pbackfail(std::char_traits::eof()) == std::char_traits::eof()); + assert(sb.str() == "123"); + } + { + testbuf sb("123"); + assert(sb.sgetc() == '1'); + assert(sb.snextc() == '2'); + assert(sb.snextc() == '3'); + assert(sb.sgetc() == '3'); + assert(sb.snextc() == std::char_traits::eof()); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail(std::char_traits::eof()) != std::char_traits::eof()); + assert(sb.pbackfail(std::char_traits::eof()) == std::char_traits::eof()); + assert(sb.str() == "133"); + } + { + testbuf 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::eof()); + assert(sb.pbackfail(L'3') == L'3'); + assert(sb.pbackfail(L'3') == std::char_traits::eof()); + assert(sb.pbackfail(L'2') == L'2'); + assert(sb.pbackfail(std::char_traits::eof()) != std::char_traits::eof()); + assert(sb.pbackfail(std::char_traits::eof()) == std::char_traits::eof()); + assert(sb.str() == L"123"); + } + { + testbuf 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::eof()); + assert(sb.pbackfail(L'3') == L'3'); + assert(sb.pbackfail(L'3') == L'3'); + assert(sb.pbackfail(std::char_traits::eof()) != std::char_traits::eof()); + assert(sb.pbackfail(std::char_traits::eof()) == std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// pos_type seekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// basic_streambuf* setbuf(charT* s, streamsize n); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf + +// int_type underflow(); + +#include +#include + +template +struct testbuf + : public std::basic_stringbuf +{ + typedef std::basic_stringbuf base; + explicit testbuf(const std::basic_string& str) + : base(str) {} + + typename base::int_type underflow() {return base::underflow();} + void pbump(int n) {base::pbump(n);} +}; + +int main() +{ + { + testbuf 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::eof()); + assert(sb.underflow() == std::char_traits::eof()); + assert(sb.underflow() == std::char_traits::eof()); + sb.sputc('4'); + assert(sb.underflow() == '4'); + assert(sb.underflow() == '4'); + } + { + testbuf 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::eof()); + assert(sb.underflow() == std::char_traits::eof()); + assert(sb.underflow() == std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringbuf +// : public basic_streambuf +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_stringbuf >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::off_type>::value), ""); + static_assert((std::is_same::allocator_type, std::allocator >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// basic_stringstream(basic_stringstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// basic_stringstream(basic_stringstream&& rhs); + +#include +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// explicit basic_stringstream(const basic_string& str, +// ios_base::openmode which = ios_base::out|ios_base::in); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// void swap(basic_stringstream& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// basic_stringstream& operator=(basic_stringstream&& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// template +// void +// swap(basic_stringstream& x, +// basic_stringstream& y); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream + +// void str(const basic_string& str); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Allocator = allocator > +// class basic_stringstream +// : public basic_iostream +// { +// 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 +#include + +int main() +{ + static_assert((std::is_base_of, std::basic_stringstream >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::traits_type, std::char_traits >::value), ""); + static_assert((std::is_same::int_type, std::char_traits::int_type>::value), ""); + static_assert((std::is_same::pos_type, std::char_traits::pos_type>::value), ""); + static_assert((std::is_same::off_type, std::char_traits::off_type>::value), ""); + static_assert((std::is_same::allocator_type, std::allocator >::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// +// template constexpr auto data(C& c) -> decltype(c.data()); // C++17 +// template constexpr auto data(const C& c) -> decltype(c.data()); // C++17 +// template constexpr T* data(T (&array)[N]) noexcept; // C++17 +// template constexpr const E* data(initializer_list il) noexcept; // C++17 + +#if __cplusplus <= 201402L +int main () {} +#else + +#include +#include +#include +#include +#include + +template +void test_const_container( const C& c ) +{ + assert ( std::data(c) == c.data()); +} + +template +void test_const_container( const std::initializer_list& c ) +{ + assert ( std::data(c) == c.begin()); +} + +template +void test_container( C& c ) +{ + assert ( std::data(c) == c.data()); +} + +template +void test_container( std::initializer_list& c) +{ + assert ( std::data(c) == c.begin()); +} + +template +void test_const_array( const T (&array)[Sz] ) +{ + assert ( std::data(array) == &array[0]); +} + +int main() +{ + std::vector v; v.push_back(1); + std::array a; a[0] = 3; + std::initializer_list 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. +// +//===----------------------------------------------------------------------===// + +// +// template constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17 +// template constexpr bool empty(const T (&array)[N]) noexcept; // C++17 +// template constexpr bool empty(initializer_list il) noexcept; // C++17 + +#if __cplusplus <= 201402L +int main () {} +#else + +#include +#include +#include +#include +#include +#include + +template +void test_const_container( const C& c ) +{ + assert ( std::empty(c) == c.empty()); +} + +template +void test_const_container( const std::initializer_list& c ) +{ + assert ( std::empty(c) == (c.size() == 0)); +} + +template +void test_container( C& c ) +{ + assert ( std::empty(c) == c.empty()); +} + +template +void test_container( std::initializer_list& c ) +{ + assert ( std::empty(c) == (c.size() == 0)); +} + +template +void test_const_array( const T (&array)[Sz] ) +{ + assert (!std::empty(array)); +} + +int main() +{ + std::vector v; v.push_back(1); + std::list l; l.push_back(2); + std::array a; a[0] = 3; + std::initializer_list 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. +// +//===----------------------------------------------------------------------===// + +// +// template constexpr auto size(const C& c) -> decltype(c.size()); // C++17 +// template constexpr size_t size(const T (&array)[N]) noexcept; // C++17 + +#if __cplusplus <= 201402L +int main () {} +#else + +#include +#include +#include +#include +#include +#include + +template +void test_const_container( const C& c ) +{ + assert ( std::size(c) == c.size()); +} + +template +void test_const_container( const std::initializer_list& c) +{ + assert ( std::size(c) == c.size()); +} + +template +void test_container( C& c) +{ + assert ( std::size(c) == c.size()); +} + +template +void test_container( std::initializer_list& c ) +{ + assert ( std::size(c) == c.size()); +} + +template +void test_const_array( const T (&array)[Sz] ) +{ + assert ( std::size(array) == Sz ); +} + +int main() +{ + std::vector v; v.push_back(1); + std::list l; l.push_back(2); + std::array a; a[0] = 3; + std::initializer_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct iterator +// { +// typedef T value_type; +// typedef Distance difference_type; +// typedef Pointer pointer; +// typedef Reference reference; +// typedef Category iterator_category; +// }; + +#include +#include + +struct A {}; + +template +void +test2() +{ + typedef std::iterator It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +template +void +test3() +{ + typedef std::iterator It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +template +void +test4() +{ + typedef std::iterator It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +template +void +test5() +{ + typedef std::iterator It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test2(); + test3(); + test4(); + test5(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void advance(Iter& i, Iter::difference_type n); +// +// template +// void advance(Iter& i, Iter::difference_type n); +// +// template +// void advance(Iter& i, Iter::difference_type n); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + std::advance(i, n); + assert(i == x); +} + +int main() +{ + const char* s = "1234567890"; + test(input_iterator(s), 10, input_iterator(s+10)); + test(forward_iterator(s), 10, forward_iterator(s+10)); + test(bidirectional_iterator(s+5), 5, bidirectional_iterator(s+10)); + test(bidirectional_iterator(s+5), -5, bidirectional_iterator(s)); + test(random_access_iterator(s+5), 5, random_access_iterator(s+10)); + test(random_access_iterator(s+5), -5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// Iter::difference_type +// distance(Iter first, Iter last); +// +// template +// Iter::difference_type +// distance(Iter first, Iter last); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It first, It last, typename std::iterator_traits::difference_type x) +{ + assert(std::distance(first, last) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(input_iterator(s), input_iterator(s+10), 10); + test(forward_iterator(s), forward_iterator(s+10), 10); + test(bidirectional_iterator(s), bidirectional_iterator(s+10), 10); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// Iter next(Iter x, Iter::difference_type n = 1); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + assert(std::next(i, n) == x); +} + +template +void +test(It i, It x) +{ + assert(std::next(i) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(forward_iterator(s), 10, forward_iterator(s+10)); + test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10)); + test(random_access_iterator(s), 10, random_access_iterator(s+10)); + test(s, 10, s+10); + + test(forward_iterator(s), forward_iterator(s+1)); + test(bidirectional_iterator(s), bidirectional_iterator(s+1)); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// Iter prev(Iter x, Iter::difference_type n = 1); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + assert(std::prev(i, n) == x); +} + +template +void +test(It i, It x) +{ + assert(std::prev(i) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s)); + test(random_access_iterator(s+10), 10, random_access_iterator(s)); + test(s+10, 10, s); + + test(bidirectional_iterator(s+1), bidirectional_iterator(s)); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct iterator_traits +// { +// 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 +#include + +struct A {}; + +int main() +{ + typedef std::iterator_traits It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct iterator_traits +// { +// }; + +#include + +struct not_an_iterator +{ +}; + +template +struct has_value_type +{ +private: + struct two {char lx; char lxx;}; + template static two test(...); + template static char test(typename _Up::value_type* = 0); +public: + static const bool value = sizeof(test<_Tp>(0)) == 1; +}; + +int main() +{ + typedef std::iterator_traits It; + static_assert(!(has_value_type::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct iterator_traits +// { +// typedef ptrdiff_t difference_type; +// typedef T value_type; +// typedef T* pointer; +// typedef T& reference; +// typedef random_access_iterator_tag iterator_category; +// }; + +#include +#include + +struct A {}; + +int main() +{ + typedef std::iterator_traits It; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// struct bidirectional_iterator_tag : public forward_iterator_tag {}; + +#include +#include + +int main() +{ + std::bidirectional_iterator_tag tag; + static_assert((std::is_base_of::value), ""); + static_assert((!std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +// struct forward_iterator_tag: public input_iterator_tag {}; + +#include +#include + +int main() +{ + std::forward_iterator_tag tag; + static_assert((std::is_base_of::value), ""); + static_assert((!std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +// struct input_iterator_tag {}; + +#include +#include + +int main() +{ + std::input_iterator_tag tag; + static_assert((!std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +// struct output_iterator_tag {}; + +#include +#include + +int main() +{ + std::output_iterator_tag tag; + static_assert((!std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +// struct random_access_iterator_tag : public bidirectional_iterator_tag {}; + +#include +#include + +int main() +{ + std::random_access_iterator_tag tag; + static_assert((std::is_base_of::value), ""); + static_assert((!std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// +// template auto begin(C& c) -> decltype(c.begin()); +// template auto begin(const C& c) -> decltype(c.begin()); +// template auto end(C& c) -> decltype(c.end()); +// template auto end(const C& c) -> decltype(c.end()); +// template reverse_iterator rbegin(initializer_list il); +// template reverse_iterator rend(initializer_list il); + +#if __cplusplus >= 201103L +#include +#include +#include +#include +#include +#include + +template +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 +void test_const_container( const std::initializer_list & 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 +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 +void test_container( std::initializer_list & 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 +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 v; v.push_back(1); + std::list l; l.push_back(2); + std::array a; a[0] = 3; + std::initializer_list 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 + +void f(const std::string &s) { s.begin(); } + +#include + +void AppendTo(const std::vector &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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// explicit back_insert_iterator(Cont& x); + +// test for explicit + +#include +#include + +int main() +{ + std::back_insert_iterator > i = std::vector(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// explicit back_insert_iterator(Cont& x); + +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::back_insert_iterator i(c); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// back_insert_iterator operator++(int); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::back_insert_iterator i(c); + std::back_insert_iterator r = i++; + r = 0; + assert(c.size() == 1); + assert(c.back() == 0); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// back_insert_iterator& operator++(); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::back_insert_iterator i(c); + std::back_insert_iterator& r = ++i; + assert(&r == &i); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// requires CopyConstructible +// back_insert_iterator& +// operator=(const Cont::value_type& value); + +#include +#include +#include + +template +void +test(C c) +{ + const typename C::value_type v = typename C::value_type(); + std::back_insert_iterator 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()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// requires CopyConstructible +// back_insert_iterator& +// operator=(Cont::value_type&& value); + +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +#include +#include +#include + +template +void +test(C c) +{ + std::back_insert_iterator 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 >()); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// back_insert_iterator& operator*(); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::back_insert_iterator i(c); + std::back_insert_iterator& r = *i; + assert(&r == &i); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// back_insert_iterator +// back_inserter(Cont& x); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::back_insert_iterator i = std::back_inserter(c); + i = 0; + assert(c.size() == 1); + assert(c.back() == 0); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// back_insert_iterator + +// Test nested types and data member: + +// template +// class back_insert_iterator { +// protected: +// Cont* container; +// public: +// typedef Cont container_type; +// typedef void value_type; +// typedef void difference_type; +// typedef back_insert_iterator& reference; +// typedef void pointer; +// }; + +#include +#include +#include + +template +struct find_container + : private std::back_insert_iterator +{ + explicit find_container(C& c) : std::back_insert_iterator(c) {} + void test() {this->container = 0;} +}; + +template +void +test() +{ + typedef std::back_insert_iterator R; + C c; + find_container q(c); + q.test(); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// explicit front_insert_iterator(Cont& x); + +// test for explicit + +#include +#include + +int main() +{ + std::front_insert_iterator > i = std::list(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// explicit front_insert_iterator(Cont& x); + +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::front_insert_iterator i(c); +} + +int main() +{ + test(std::list()); + test(nasty_list()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// front_insert_iterator operator++(int); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::front_insert_iterator i(c); + std::front_insert_iterator r = i++; + r = 0; + assert(c.size() == 1); + assert(c.back() == 0); +} + +int main() +{ + test(std::list()); + test(nasty_list()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// front_insert_iterator& operator++(); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::front_insert_iterator i(c); + std::front_insert_iterator& r = ++i; + assert(&r == &i); +} + +int main() +{ + test(std::list()); + test(nasty_list()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// front_insert_iterator& +// operator=(const Cont::value_type& value); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + const typename C::value_type v = typename C::value_type(); + std::front_insert_iterator 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()); + test(nasty_list()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// front_insert_iterator& +// operator=(Cont::value_type&& value); + +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +#include +#include +#include + +template +void +test(C c) +{ + std::front_insert_iterator 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 >()); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// front_insert_iterator& operator*(); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::front_insert_iterator i(c); + std::front_insert_iterator& r = *i; + assert(&r == &i); +} + +int main() +{ + test(std::list()); + test(nasty_list()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// front_insert_iterator +// front_inserter(Cont& x); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::front_insert_iterator i = std::front_inserter(c); + i = 0; + assert(c.size() == 1); + assert(c.front() == 0); +} + +int main() +{ + test(std::list()); + test(nasty_list()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// front_insert_iterator + +// Test nested types and data member: + +// template +// class front_insert_iterator { +// protected: +// Container* container; +// public: +// typedef Container container_type; +// typedef void value_type; +// typedef void difference_type; +// typedef front_insert_iterator& reference; +// typedef void pointer; +// typedef output_iterator_tag iterator_category; +// }; + +#include +#include +#include + +template +struct find_container + : private std::front_insert_iterator +{ + explicit find_container(C& c) : std::front_insert_iterator(c) {} + void test() {this->container = 0;} +}; + +template +void +test() +{ + typedef std::front_insert_iterator R; + C c; + find_container q(c); + q.test(); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// insert_iterator + +// insert_iterator(Cont& x, Cont::iterator i); + +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::insert_iterator i(c, c.begin()); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// insert_iterator + +// insert_iterator operator++(int); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::insert_iterator i(c, c.end()); + std::insert_iterator r = i++; + r = 0; + assert(c.size() == 1); + assert(c.back() == 0); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// insert_iterator + +// insert_iterator& operator++(); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::insert_iterator i(c, c.end()); + std::insert_iterator& r = ++i; + assert(&r == &i); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// insert_iterator + +// requires CopyConstructible +// insert_iterator& +// operator=(const Cont::value_type& value); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +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 q(c1, c1.begin() + j); + q = x1; + q = x2; + q = x3; + assert(c1 == c2); +} + +template +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// insert_iterator + +// requires CopyConstructible +// insert_iterator& +// operator=(const Cont::value_type& value); + +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#include +#include +#include + +template +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 q(c1, c1.begin() + j); + q = std::move(x1); + q = std::move(x2); + q = std::move(x3); + assert(c1 == c2); +} + +template +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 Ptr; + typedef std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// insert_iterator + +// insert_iterator& operator*(); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::insert_iterator i(c, c.end()); + std::insert_iterator& r = *i; + assert(&r == &i); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// insert_iterator +// inserter(Cont& x, Cont::iterator i); + +#include +#include +#include +#include "nasty_containers.hpp" + +template +void +test(C c) +{ + std::insert_iterator i = std::inserter(c, c.end()); + i = 0; + assert(c.size() == 1); + assert(c.back() == 0); +} + +int main() +{ + test(std::vector()); + test(nasty_vector()); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// insert_iterator + +// Test nested types and data members: + +// template +// 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& reference; +// typedef void pointer; +// }; + +#include +#include +#include + +template +struct find_members + : private std::insert_iterator +{ + explicit find_members(C& c) : std::insert_iterator(c, c.begin()) {} + void test() + { + this->container = 0; + (void)(this->iter == this->iter); + } +}; + +template +void +test() +{ + typedef std::insert_iterator R; + C c; + find_members q(c); + q.test(); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// move_iterator +// make_move_iterator(const Iter& i); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i) +{ + const std::move_iterator r(i); + assert(std::make_move_iterator(i) == r); +} + +int main() +{ + { + char s[] = "1234567890"; + test(input_iterator(s+5)); + test(forward_iterator(s+5)); + test(bidirectional_iterator(s+5)); + test(random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasMinus +// auto +// operator-(const move_iterator& x, const move_iterator& y) +// -> decltype(x.base() - y.base()); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, typename std::iterator_traits::difference_type x) +{ + const std::move_iterator r1(l); + const std::move_iterator r2(r); + assert(r1 - r2 == x); +} + +int main() +{ + char s[] = "1234567890"; + test(random_access_iterator(s+5), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// move_iterator +// operator+(Iter::difference_type n, const move_iterator& x); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + const std::move_iterator r(i); + std::move_iterator rr = n + r; + assert(rr.base() == x); +} + +int main() +{ + char s[] = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// requires RandomAccessIterator +// move_iterator operator+(difference_type n) const; + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + const std::move_iterator r(i); + std::move_iterator rr = r + n; + assert(rr.base() == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// requires RandomAccessIterator +// move_iterator& operator+=(difference_type n); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + std::move_iterator r(i); + std::move_iterator& rr = r += n; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// requires RandomAccessIterator +// move_iterator operator-(difference_type n) const; + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + const std::move_iterator r(i); + std::move_iterator rr = r - n; + assert(rr.base() == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// requires RandomAccessIterator +// move_iterator& operator-=(difference_type n); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + std::move_iterator r(i); + std::move_iterator& rr = r -= n; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasEqualTo +// bool +// operator==(const move_iterator& x, const move_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::move_iterator r1(l); + const std::move_iterator r2(r); + assert((r1 == r2) == x); +} + +int main() +{ + char s[] = "1234567890"; + test(input_iterator(s), input_iterator(s), true); + test(input_iterator(s), input_iterator(s+1), false); + test(forward_iterator(s), forward_iterator(s), true); + test(forward_iterator(s), forward_iterator(s+1), false); + test(bidirectional_iterator(s), bidirectional_iterator(s), true); + test(bidirectional_iterator(s), bidirectional_iterator(s+1), false); + test(random_access_iterator(s), random_access_iterator(s), true); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasLess +// bool +// operator>(const move_iterator& x, const move_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::move_iterator r1(l); + const std::move_iterator r2(r); + assert((r1 > r2) == x); +} + +int main() +{ + char s[] = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), false); + test(random_access_iterator(s), random_access_iterator(s+1), false); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasLess +// bool +// operator>=(const move_iterator& x, const move_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::move_iterator r1(l); + const std::move_iterator r2(r); + assert((r1 >= r2) == x); +} + +int main() +{ + char s[] = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), true); + test(random_access_iterator(s), random_access_iterator(s+1), false); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasLess +// bool +// operator<(const move_iterator& x, const move_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::move_iterator r1(l); + const std::move_iterator r2(r); + assert((r1 < r2) == x); +} + +int main() +{ + char s[] = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), false); + test(random_access_iterator(s), random_access_iterator(s+1), true); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasLess +// bool +// operator<=(const move_iterator& x, const move_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::move_iterator r1(l); + const std::move_iterator r2(r); + assert((r1 <= r2) == x); +} + +int main() +{ + char s[] = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), true); + test(random_access_iterator(s), random_access_iterator(s+1), true); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasEqualTo +// bool +// operator!=(const move_iterator& x, const move_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::move_iterator r1(l); + const std::move_iterator r2(r); + assert((r1 != r2) == x); +} + +int main() +{ + char s[] = "1234567890"; + test(input_iterator(s), input_iterator(s), false); + test(input_iterator(s), input_iterator(s+1), true); + test(forward_iterator(s), forward_iterator(s), false); + test(forward_iterator(s), forward_iterator(s+1), true); + test(bidirectional_iterator(s), bidirectional_iterator(s), false); + test(bidirectional_iterator(s), bidirectional_iterator(s+1), true); + test(random_access_iterator(s), random_access_iterator(s), false); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasConstructor +// move_iterator(const move_iterator &u); + +// test requires + +#include + +template +void +test(U u) +{ + std::move_iterator r2(u); + std::move_iterator r1 = r2; +} + +struct base {}; +struct derived {}; + +int main() +{ + derived d; + + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasConstructor +// move_iterator(const move_iterator &u); + +#include +#include + +#include "test_iterators.h" + +template +void +test(U u) +{ + const std::move_iterator r2(u); + std::move_iterator r1 = r2; + assert(r1.base() == u); +} + +struct Base {}; +struct Derived : Base {}; + +int main() +{ + Derived d; + + test >(input_iterator(&d)); + test >(forward_iterator(&d)); + test >(bidirectional_iterator(&d)); + test >(random_access_iterator(&d)); + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// move_iterator(); + +#include + +#include "test_iterators.h" + +template +void +test() +{ + std::move_iterator r; +} + +int main() +{ + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// explicit move_iterator(Iter ); + +// test explicit + +#include + +template +void +test(It i) +{ + std::move_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// explicit move_iterator(Iter i); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i) +{ + std::move_iterator r(i); + assert(r.base() == i); +} + +int main() +{ + char s[] = "123"; + test(input_iterator(s)); + test(forward_iterator(s)); + test(bidirectional_iterator(s)); + test(random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// move_iterator operator--(int); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::move_iterator r(i); + std::move_iterator rr = r--; + assert(r.base() == x); + assert(rr.base() == i); +} + +int main() +{ + char s[] = "123"; + test(bidirectional_iterator(s+1), bidirectional_iterator(s)); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// move_iterator& operator--(); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::move_iterator r(i); + std::move_iterator& rr = --r; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + char s[] = "123"; + test(bidirectional_iterator(s+1), bidirectional_iterator(s)); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// move_iterator operator++(int); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::move_iterator r(i); + std::move_iterator rr = r++; + assert(r.base() == x); + assert(rr.base() == i); +} + +int main() +{ + char s[] = "123"; + test(input_iterator(s), input_iterator(s+1)); + test(forward_iterator(s), forward_iterator(s+1)); + test(bidirectional_iterator(s), bidirectional_iterator(s+1)); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// move_iterator& operator++(); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::move_iterator r(i); + std::move_iterator& rr = ++r; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + char s[] = "123"; + test(input_iterator(s), input_iterator(s+1)); + test(forward_iterator(s), forward_iterator(s+1)); + test(bidirectional_iterator(s), bidirectional_iterator(s+1)); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// requires RandomAccessIterator +// unspecified operator[](difference_type n) const; + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#endif + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, + typename std::iterator_traits::value_type x) +{ + typedef typename std::iterator_traits::value_type value_type; + const std::move_iterator 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(s+5), 4, '0'); + test(s+5, 4, '0'); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + int i[5]; + typedef std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// pointer operator->() const; + +#include +#include + +template +void +test(It i) +{ + std::move_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// reference operator*() const; + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#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 +void +test(It i, typename std::iterator_traits::value_type x) +{ + std::move_iterator r(i); + assert(*r == x); + typename std::iterator_traits::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 p(&i); + test(&p, std::unique_ptr(&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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasAssign +// move_iterator& +// operator=(const move_iterator& u); + +// test requires + +#include + +template +void +test(U u) +{ + const std::move_iterator r2(u); + std::move_iterator r1; + r1 = r2; +} + +struct base {}; +struct derived {}; + +int main() +{ + derived d; + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// template +// requires HasAssign +// move_iterator& +// operator=(const move_iterator& u); + +#include +#include + +#include "test_iterators.h" + +template +void +test(U u) +{ + const std::move_iterator r2(u); + std::move_iterator r1; + std::move_iterator& rr = r1 = r2; + assert(r1.base() == u); + assert(&rr == &r1); +} + +struct Base {}; +struct Derived : Base {}; + +int main() +{ + Derived d; + + test >(input_iterator(&d)); + test >(forward_iterator(&d)); + test >(bidirectional_iterator(&d)); + test >(random_access_iterator(&d)); + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// move_iterator + +// Test nested types: + +// template +// 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 +#include + +#include "test_iterators.h" + +template +void +test() +{ + typedef std::move_iterator R; + typedef std::iterator_traits T; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + static_assert((std::is_same::value), ""); +#else + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// reverse_iterator(); + +#include + +#include "test_iterators.h" + +template +void +test() +{ + std::reverse_iterator r; +} + +int main() +{ + test >(); + test >(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// explicit reverse_iterator(Iter x); + +// test explicit + +#include + +template +void +test(It i) +{ + std::reverse_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// explicit reverse_iterator(Iter x); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i) +{ + std::reverse_iterator r(i); + assert(r.base() == i); +} + +int main() +{ + const char s[] = "123"; + test(bidirectional_iterator(s)); + test(random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasConstructor +// reverse_iterator(const reverse_iterator &u); + +// test requires + +#include + +template +void +test(U u) +{ + std::reverse_iterator r2(u); + std::reverse_iterator r1 = r2; +} + +struct base {}; +struct derived {}; + +int main() +{ + derived d; + + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasConstructor +// reverse_iterator(const reverse_iterator &u); + +#include +#include + +#include "test_iterators.h" + +template +void +test(U u) +{ + const std::reverse_iterator r2(u); + std::reverse_iterator r1 = r2; + assert(r1.base() == u); +} + +struct Base {}; +struct Derived : Base {}; + +int main() +{ + Derived d; + + test >(bidirectional_iterator(&d)); + test >(random_access_iterator(&d)); + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template reverse_iterator +// make_reverse_iterator(Iterator i); + +#include +#include + +#include "test_iterators.h" + +#if _LIBCPP_STD_VER > 11 + +template +void +test(It i) +{ + const std::reverse_iterator r = std::make_reverse_iterator(i); + assert(r.base() == i); +} + +int main() +{ + const char* s = "1234567890"; + random_access_iteratorb(s); + random_access_iteratore(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasEqualTo +// bool +// operator!=(const reverse_iterator& x, const reverse_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::reverse_iterator r1(l); + const std::reverse_iterator r2(r); + assert((r1 != r2) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(bidirectional_iterator(s), bidirectional_iterator(s), false); + test(bidirectional_iterator(s), bidirectional_iterator(s+1), true); + test(random_access_iterator(s), random_access_iterator(s), false); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// reverse_iterator operator++(int); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::reverse_iterator r(i); + std::reverse_iterator rr = r++; + assert(r.base() == x); + assert(rr.base() == i); +} + +int main() +{ + const char* s = "123"; + test(bidirectional_iterator(s+1), bidirectional_iterator(s)); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// reverse_iterator& operator++(); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::reverse_iterator r(i); + std::reverse_iterator& rr = ++r; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + const char* s = "123"; + test(bidirectional_iterator(s+1), bidirectional_iterator(s)); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// requires RandomAccessIterator +// reverse_iterator operator+(difference_type n) const; + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + const std::reverse_iterator r(i); + std::reverse_iterator rr = r + n; + assert(rr.base() == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// requires RandomAccessIterator +// reverse_iterator& operator+=(difference_type n); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + std::reverse_iterator r(i); + std::reverse_iterator& rr = r += n; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// reverse_iterator operator--(int); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::reverse_iterator r(i); + std::reverse_iterator rr = r--; + assert(r.base() == x); + assert(rr.base() == i); +} + +int main() +{ + const char* s = "123"; + test(bidirectional_iterator(s+1), bidirectional_iterator(s+2)); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// reverse_iterator& operator--(); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, It x) +{ + std::reverse_iterator r(i); + std::reverse_iterator& rr = --r; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + const char* s = "123"; + test(bidirectional_iterator(s+1), bidirectional_iterator(s+2)); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// requires RandomAccessIterator +// reverse_iterator operator-(difference_type n) const; + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + const std::reverse_iterator r(i); + std::reverse_iterator rr = r - n; + assert(rr.base() == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// requires RandomAccessIterator +// reverse_iterator& operator-=(difference_type n); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + std::reverse_iterator r(i); + std::reverse_iterator& rr = r -= n; + assert(r.base() == x); + assert(&rr == &r); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 +void +test(It i, typename std::iterator_traits::value_type x) +{ + std::reverse_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasAssign +// reverse_iterator& +// operator=(const reverse_iterator& u); + +// test requires + +#include + +template +void +test(U u) +{ + const std::reverse_iterator r2(u); + std::reverse_iterator r1; + r1 = r2; +} + +struct base {}; +struct derived {}; + +int main() +{ + derived d; + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasAssign +// reverse_iterator& +// operator=(const reverse_iterator& u); + +#include +#include + +#include "test_iterators.h" + +template +void +test(U u) +{ + const std::reverse_iterator r2(u); + std::reverse_iterator r1; + std::reverse_iterator& rr = r1 = r2; + assert(r1.base() == u); + assert(&rr == &r1); +} + +struct Base {}; +struct Derived : Base {}; + +int main() +{ + Derived d; + + test >(bidirectional_iterator(&d)); + test >(random_access_iterator(&d)); + test(&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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasEqualTo +// bool +// operator==(const reverse_iterator& x, const reverse_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::reverse_iterator r1(l); + const std::reverse_iterator r2(r); + assert((r1 == r2) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(bidirectional_iterator(s), bidirectional_iterator(s), true); + test(bidirectional_iterator(s), bidirectional_iterator(s+1), false); + test(random_access_iterator(s), random_access_iterator(s), true); + test(random_access_iterator(s), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasMinus +// auto operator-(const reverse_iterator& x, const reverse_iterator& y) +// -> decltype(y.base() - x.base()); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(It1 l, It2 r, std::ptrdiff_t x) +{ + const std::reverse_iterator r1(l); + const std::reverse_iterator r2(r); + assert((r1 - r2) == x); +} + +int main() +{ + char s[3] = {0}; + test(random_access_iterator(s), random_access_iterator(s), 0); + test(random_access_iterator(s), random_access_iterator(s+1), 1); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasGreater +// bool +// operator>(const reverse_iterator& x, const reverse_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::reverse_iterator r1(l); + const std::reverse_iterator r2(r); + assert((r1 > r2) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), false); + test(random_access_iterator(s), random_access_iterator(s+1), true); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasGreater +// bool +// operator>=(const reverse_iterator& x, const reverse_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::reverse_iterator r1(l); + const std::reverse_iterator r2(r); + assert((r1 >= r2) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), true); + test(random_access_iterator(s), random_access_iterator(s+1), true); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// requires RandomAccessIterator +// unspecified operator[](difference_type n) const; + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, + typename std::iterator_traits::value_type x) +{ + typedef typename std::iterator_traits::value_type value_type; + const std::reverse_iterator r(i); + value_type rr = r[n]; + assert(rr == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasGreater +// bool +// operator<(const reverse_iterator& x, const reverse_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::reverse_iterator r1(l); + const std::reverse_iterator r2(r); + assert((r1 < r2) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), false); + test(random_access_iterator(s), random_access_iterator(s+1), false); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// requires HasGreater +// bool +// operator<=(const reverse_iterator& x, const reverse_iterator& y); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It l, It r, bool x) +{ + const std::reverse_iterator r1(l); + const std::reverse_iterator r2(r); + assert((r1 <= r2) == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s), random_access_iterator(s), true); + test(random_access_iterator(s), random_access_iterator(s+1), false); + test(random_access_iterator(s+1), random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +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 +void +test(It i, typename std::iterator_traits::value_type x) +{ + std::reverse_iterator 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 l; + l.push_back(B(0)); + l.push_back(B(1)); + l.push_back(B(2)); + + { + std::list::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// template +// reverse_iterator +// operator+(Iter::difference_type n, const reverse_iterator& x); + +#include +#include + +#include "test_iterators.h" + +template +void +test(It i, typename std::iterator_traits::difference_type n, It x) +{ + const std::reverse_iterator r(i); + std::reverse_iterator rr = n + r; + assert(rr.base() == x); +} + +int main() +{ + const char* s = "1234567890"; + test(random_access_iterator(s+5), 5, random_access_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator + +// Test nested types and data member: + +// template +// class reverse_iterator { +// protected: +// Iter current; +// public: +// iterator::iterator_category, +// typename iterator_traits::value_type, +// typename iterator_traits::difference_type, +// typename iterator_traits::pointer, +// typename iterator_traits::reference> { +// }; + +#include +#include + +#include "test_iterators.h" + +template +struct find_current + : private std::reverse_iterator +{ + void test() {++(this->current);} +}; + +template +void +test() +{ + typedef std::reverse_iterator R; + typedef std::iterator_traits T; + find_current q; + q.test(); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::pointer>::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// istream_iterator(const istream_iterator& x); + +#include +#include +#include + +int main() +{ + { + std::istream_iterator io; + std::istream_iterator i = io; + assert(i == std::istream_iterator()); + } + { + std::istringstream inf(" 1 23"); + std::istream_iterator io(inf); + std::istream_iterator i = io; + assert(i != std::istream_iterator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// constexpr istream_iterator(); + +#include +#include + +struct S { S(); }; // not constexpr + +int main() +{ +#if __cplusplus >= 201103L + { + constexpr std::istream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// constexpr istream_iterator(); + +#include +#include + +int main() +{ + { + typedef std::istream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// istream_iterator(istream_type& s); + +#include +#include +#include + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator i(inf); + assert(i != std::istream_iterator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// const T* operator->() const; + +#include +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// const T& operator*() const; + +#include +#include +#include + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// template +// bool operator==(const istream_iterator &x, +// const istream_iterator &y); +// +// template +// bool operator!=(const istream_iterator &x, +// const istream_iterator &y); + +#include +#include +#include + +int main() +{ + std::istringstream inf1(" 1 23"); + std::istringstream inf2(" 1 23"); + std::istream_iterator i1(inf1); + std::istream_iterator i2(inf1); + std::istream_iterator i3(inf2); + std::istream_iterator i4; + std::istream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// istream_iterator operator++(int); + +#include +#include +#include + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator i(inf); + std::istream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class istream_iterator + +// istream_iterator& operator++(); + +#include +#include +#include + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator i(inf); + std::istream_iterator& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Distance = ptrdiff_t> +// class istream_iterator +// : public iterator +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef basic_istream 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 +#include +#include + +int main() +{ + typedef std::istream_iterator I1; + static_assert((std::is_convertible >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert( std::is_trivially_copy_constructible::value, ""); + static_assert( std::is_trivially_destructible::value, ""); + + typedef std::istream_iterator I2; + static_assert((std::is_convertible >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert( std::is_trivially_copy_constructible::value, ""); + static_assert( std::is_trivially_destructible::value, ""); + + typedef std::istream_iterator I3; + static_assert(!std::is_trivially_copy_constructible::value, ""); + static_assert(!std::is_trivially_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +int main() +{ + { + typedef std::istreambuf_iterator T; + T it; + assert(it == T()); +#if __cplusplus >= 201103L + constexpr T it2; +#endif + } + { + typedef std::istreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// istreambuf_iterator(basic_istream& s) throw(); + +#include +#include +#include + +int main() +{ + { + std::istringstream inf; + std::istreambuf_iterator i(inf); + assert(i == std::istreambuf_iterator()); + } + { + std::istringstream inf("a"); + std::istreambuf_iterator i(inf); + assert(i != std::istreambuf_iterator()); + } + { + std::wistringstream inf; + std::istreambuf_iterator i(inf); + assert(i == std::istreambuf_iterator()); + } + { + std::wistringstream inf(L"a"); + std::istreambuf_iterator i(inf); + assert(i != std::istreambuf_iterator()); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// istreambuf_iterator(const proxy& p) throw(); + +#include +#include +#include + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator j(inf); + std::istreambuf_iterator i = j++; + assert(i != std::istreambuf_iterator()); + assert(*i == 'b'); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator j(inf); + std::istreambuf_iterator i = j++; + assert(i != std::istreambuf_iterator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// istreambuf_iterator(basic_streambuf* s) throw(); + +#include +#include +#include + +int main() +{ + { + std::istreambuf_iterator i(nullptr); + assert(i == std::istreambuf_iterator()); + } + { + std::istringstream inf; + std::istreambuf_iterator i(inf.rdbuf()); + assert(i == std::istreambuf_iterator()); + } + { + std::istringstream inf("a"); + std::istreambuf_iterator i(inf.rdbuf()); + assert(i != std::istreambuf_iterator()); + } + { + std::istreambuf_iterator i(nullptr); + assert(i == std::istreambuf_iterator()); + } + { + std::wistringstream inf; + std::istreambuf_iterator i(inf.rdbuf()); + assert(i == std::istreambuf_iterator()); + } + { + std::wistringstream inf(L"a"); + std::istreambuf_iterator i(inf.rdbuf()); + assert(i != std::istreambuf_iterator()); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// bool equal(istreambuf_iterator& b) const; + +#include +#include +#include + +int main() +{ + { + std::istringstream inf1("abc"); + std::istringstream inf2("def"); + std::istreambuf_iterator i1(inf1); + std::istreambuf_iterator i2(inf2); + std::istreambuf_iterator i3; + std::istreambuf_iterator 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 i1(inf1); + std::istreambuf_iterator i2(inf2); + std::istreambuf_iterator i3; + std::istreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// template +// bool operator!=(const istreambuf_iterator& a, +// const istreambuf_iterator& b); + +#include +#include +#include + +int main() +{ + { + std::istringstream inf1("abc"); + std::istringstream inf2("def"); + std::istreambuf_iterator i1(inf1); + std::istreambuf_iterator i2(inf2); + std::istreambuf_iterator i3; + std::istreambuf_iterator 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 i1(inf1); + std::istreambuf_iterator i2(inf2); + std::istreambuf_iterator i3; + std::istreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// charT operator*() const + +#include +#include +#include + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator i(inf); + assert(*i == 'a'); + ++i; + assert(*i == 'b'); + ++i; + assert(*i == 'c'); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// template +// bool operator==(const istreambuf_iterator& a, +// const istreambuf_iterator& b); + +#include +#include +#include + +int main() +{ + { + std::istringstream inf1("abc"); + std::istringstream inf2("def"); + std::istreambuf_iterator i1(inf1); + std::istreambuf_iterator i2(inf2); + std::istreambuf_iterator i3; + std::istreambuf_iterator 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 i1(inf1); + std::istreambuf_iterator i2(inf2); + std::istreambuf_iterator i3; + std::istreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// pointer operator->() const; + +#include +#include +#include + +typedef char C; +int main () +{ + std::istringstream s("filename"); + std::istreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// proxy istreambuf_iterator::operator++(int); + +#include +#include +#include + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator i(inf); + assert(*i++ == 'a'); + assert(*i++ == 'b'); + assert(*i++ == 'c'); + assert(i == std::istreambuf_iterator()); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator i(inf); + assert(*i++ == L'a'); + assert(*i++ == L'b'); + assert(*i++ == L'c'); + assert(i == std::istreambuf_iterator()); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// istreambuf_iterator + +// istreambuf_iterator& +// istreambuf_iterator::operator++(); + +#include +#include +#include + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator i(inf); + assert(*i == 'a'); + assert(*++i == 'b'); + assert(*++i == 'c'); + assert(++i == std::istreambuf_iterator()); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator i(inf); + assert(*i == L'a'); + assert(*++i == L'b'); + assert(*++i == L'c'); + assert(++i == std::istreambuf_iterator()); + } +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class istreambuf_iterator +// : public iterator +// { +// public: +// ... +// proxy operator++(int); + +// class proxy +// { +// public: +// charT operator*(); +// }; + +#include +#include +#include + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator i(inf); + assert(*i++ == 'a'); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class istreambuf_iterator +// : public iterator +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits::int_type int_type; +// typedef basic_streambuf streambuf_type; +// typedef basic_istream istream_type; +// ... +// +// All specializations of istreambuf_iterator shall have a trivial copy constructor, +// a constexpr default constructor and a trivial destructor. + +#include +#include +#include + +int main() +{ + typedef std::istreambuf_iterator I1; + static_assert((std::is_convertible::off_type, + char*, char> >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_nothrow_default_constructible::value), "" ); + static_assert((std::is_trivially_copy_constructible::value), "" ); + static_assert((std::is_trivially_destructible::value), "" ); + + typedef std::istreambuf_iterator I2; + static_assert((std::is_convertible::off_type, + wchar_t*, wchar_t> >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_nothrow_default_constructible::value), "" ); + static_assert((std::is_trivially_copy_constructible::value), "" ); + static_assert((std::is_trivially_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// template T* begin(T (&array)[N]); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template auto begin(const C& c) -> decltype(c.begin()); + +#include +#include + +int main() +{ + int ia[] = {1, 2, 3}; + const std::vector v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector::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. +// +//===----------------------------------------------------------------------===// + +// + +// template auto begin(C& c) -> decltype(c.begin()); + +#include +#include + +int main() +{ + int ia[] = {1, 2, 3}; + std::vector v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector::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. +// +//===----------------------------------------------------------------------===// + +// + +// template T* end(T (&array)[N]); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template auto end(const C& c) -> decltype(c.end()); + +#include +#include + +int main() +{ + int ia[] = {1, 2, 3}; + const std::vector v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector::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. +// +//===----------------------------------------------------------------------===// + +// + +// template auto end(C& c) -> decltype(c.end()); + +#include +#include + +int main() +{ + int ia[] = {1, 2, 3}; + std::vector v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector::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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostream_iterator + +// ostream_iterator(const ostream_iterator& x); + +#include +#include +#include + +int main() +{ + std::ostringstream outf; + std::ostream_iterator i(outf); + std::ostream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostream_iterator + +// ostream_iterator(ostream_type& s); + +#include +#include +#include + +int main() +{ + std::ostringstream outf; + std::ostream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostream_iterator + +// ostream_iterator(ostream_type& s, const charT* delimiter); + +#include +#include +#include + +int main() +{ + { + std::ostringstream outf; + std::ostream_iterator i(outf, ", "); + assert(outf.good()); + } + { + std::wostringstream outf; + std::ostream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostream_iterator + +// ostream_iterator& operator=(const T& value); + +#include +#include +#include + +int main() +{ + { + std::ostringstream outf; + std::ostream_iterator i(outf); + i = 2.4; + assert(outf.str() == "2"); + } + { + std::ostringstream outf; + std::ostream_iterator i(outf, ", "); + i = 2.4; + assert(outf.str() == "2, "); + } + { + std::wostringstream outf; + std::ostream_iterator i(outf); + i = 2.4; + assert(outf.str() == L"2"); + } + { + std::wostringstream outf; + std::ostream_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostream_iterator + +// ostream_iterator& operator*() const; + +#include +#include +#include + +int main() +{ + std::ostringstream os; + std::ostream_iterator i(os); + std::ostream_iterator& 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostream_iterator + +// ostream_iterator& operator++(); +// ostream_iterator& operator++(int); + +#include +#include +#include + +int main() +{ + std::ostringstream os; + std::ostream_iterator i(os); + std::ostream_iterator& iref1 = ++i; + assert(&iref1 == &i); + std::ostream_iterator& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template , +// class Distance = ptrdiff_t> +// class ostream_iterator +// : public iterator +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef basic_istream istream_type; +// ... + +#include +#include + +int main() +{ + typedef std::ostream_iterator I1; + static_assert((std::is_convertible >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + typedef std::ostream_iterator I2; + static_assert((std::is_convertible >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostreambuf_iterator + +// ostreambuf_iterator(ostream_type& s) throw(); + +#include +#include +#include + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator i(outf); + assert(!i.failed()); + } + { + std::wostringstream outf; + std::ostreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostreambuf_iterator + +// ostreambuf_iterator(streambuf_type* s) throw(); + +#include +#include +#include + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator i(outf.rdbuf()); + assert(!i.failed()); + } + { + std::wostringstream outf; + std::ostreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostreambuf_iterator + +// ostreambuf_iterator& +// operator=(charT c); + +#include +#include +#include + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator i(outf); + i = 'a'; + assert(outf.str() == "a"); + i = 'b'; + assert(outf.str() == "ab"); + } + { + std::wostringstream outf; + std::ostreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostreambuf_iterator + +// ostreambuf_iterator& operator*(); + +#include +#include +#include + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator i(outf); + std::ostreambuf_iterator& iref = *i; + assert(&iref == &i); + } + { + std::wostringstream outf; + std::ostreambuf_iterator i(outf); + std::ostreambuf_iterator& 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostreambuf_iterator + +// bool failed() const throw(); + +#include +#include +#include + +int main() +{ + { + std::ostreambuf_iterator i(nullptr); + assert(i.failed()); + } + { + std::ostreambuf_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class ostreambuf_iterator + +// ostreambuf_iterator& operator++(); +// ostreambuf_iterator& operator++(int); + +#include +#include +#include + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator i(outf); + std::ostreambuf_iterator& iref = ++i; + assert(&iref == &i); + std::ostreambuf_iterator& iref2 = i++; + assert(&iref2 == &i); + } + { + std::wostringstream outf; + std::ostreambuf_iterator i(outf); + std::ostreambuf_iterator& iref = ++i; + assert(&iref == &i); + std::ostreambuf_iterator& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class ostreambuf_iterator +// : public iterator +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef basic_streambuf streambuf_type; +// typedef basic_ostream ostream_type; +// ... + +#include +#include +#include + +int main() +{ + typedef std::ostreambuf_iterator I1; + static_assert((std::is_convertible >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + + typedef std::ostreambuf_iterator I2; + static_assert((std::is_convertible >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_signed::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::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::value, + "std::is_unsigned::value"); + + // typedef std::intptr_t + static_assert(sizeof(std::intptr_t) >= sizeof(void*), + "sizeof(std::intptr_t) >= sizeof(void*)"); + static_assert(std::is_signed::value, + "std::is_signed::value"); + // typedef std::uintptr_t + static_assert(sizeof(std::uintptr_t) >= sizeof(void*), + "sizeof(std::uintptr_t) >= sizeof(void*)"); + static_assert(std::is_unsigned::value, + "std::is_unsigned::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::value, + "std::is_signed::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::value, + "std::is_unsigned::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::min()); + + // INTPTR_MAX + assert(INTPTR_MAX == std::numeric_limits::max()); + + // UINTPTR_MAX + assert(UINTPTR_MAX == std::numeric_limits::max()); + + // INTMAX_MIN + assert(INTMAX_MIN == std::numeric_limits::min()); + + // INTMAX_MAX + assert(INTMAX_MAX == std::numeric_limits::max()); + + // UINTMAX_MAX + assert(UINTMAX_MAX == std::numeric_limits::max()); + + // PTRDIFF_MIN + assert(PTRDIFF_MIN == std::numeric_limits::min()); + + // PTRDIFF_MAX + assert(PTRDIFF_MAX == std::numeric_limits::max()); + + // SIG_ATOMIC_MIN + assert(SIG_ATOMIC_MIN == std::numeric_limits::min()); + + // SIG_ATOMIC_MAX + assert(SIG_ATOMIC_MAX == std::numeric_limits::max()); + + // SIZE_MAX + assert(SIZE_MAX == std::numeric_limits::max()); + + // WCHAR_MIN + assert(WCHAR_MIN == std::numeric_limits::min()); + + // WCHAR_MAX + assert(WCHAR_MAX == std::numeric_limits::max()); + + // WINT_MIN + assert(WINT_MIN == std::numeric_limits::min()); + + // WINT_MAX + assert(WINT_MAX == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include + +int main() +{ +#if __LIBCPP_STD_VER > 11 + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 + +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 +#include + +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 +#include + +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 +#include +#include +#include + +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::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 +#include +#include +#include + +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::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 +#include +#include +#include +#include + +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 +#include +#include +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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 +#include + +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 +#include + +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 +#include +#include +#include + +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::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 +#include +#include +#include + +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::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 +#include +#include +#include +#include + +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 +#include +#include +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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 +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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. +// +//===----------------------------------------------------------------------===// + +// + +// class nested_exception; + +// nested_exception& operator=(const nested_exception&) throw() = default; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class nested_exception; + +// nested_exception(const nested_exception&) throw() = default; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class nested_exception; + +// nested_exception() throw(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class nested_exception; + +// template void rethrow_if_nested(const E& e); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class nested_exception; + +// void rethrow_nested [[noreturn]] () const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class nested_exception; + +// template void throw_with_nested [[noreturn]] (T&& t); + +#include +#include +#include + +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(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 +#include +#include + +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 +#include +#include + +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 + +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 +#include +#include + +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 +#include +#include + +int main() +{ + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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_ptr current_exception(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef unspecified exception_ptr; + +// exception_ptr shall satisfy the requirements of NullablePointer. + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template exception_ptr make_exception_ptr(E e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// void rethrow_exception [[noreturn]] (exception_ptr p); + +#include +#include + +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 +#include + +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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 initializer_list; + +// const E* begin() const; +// const E* end() const; +// size_t size() const; + +#include +#include + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +struct A +{ + A(std::initializer_list 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 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 initializer_list; + +// initializer_list(); + +#include +#include + +struct A {}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + std::initializer_list il; + assert(il.size() == 0); +#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + constexpr std::initializer_list 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. +// +//===----------------------------------------------------------------------===// + +// + +// template const E* begin(initializer_list il); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +struct A +{ + A(std::initializer_list 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 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 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 +#include + +struct A {}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + static_assert((std::is_same::value_type, A>::value), ""); + static_assert((std::is_same::reference, const A&>::value), ""); + static_assert((std::is_same::const_reference, const A&>::value), ""); + static_assert((std::is_same::size_type, std::size_t>::value), ""); + static_assert((std::is_same::iterator, const A*>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +#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 + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +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 (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 +#include + +template +void test() +{ + static_assert(std::numeric_limits::is_specialized, + "std::numeric_limits::is_specialized"); + static_assert(std::numeric_limits::is_specialized, + "std::numeric_limits::is_specialized"); + static_assert(std::numeric_limits::is_specialized, + "std::numeric_limits::is_specialized"); + static_assert(std::numeric_limits::is_specialized, + "std::numeric_limits::is_specialized"); +} + +int main() +{ + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(); + test<__uint128_t>(); +#endif + test(); + test(); + test(); + static_assert(!std::numeric_limits >::is_specialized, + "!std::numeric_limits >::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 + +/* +: + 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 +void test(const _Tp &) {} + +#define TEST_NUMERIC_LIMITS(type) \ + test(std::numeric_limits::is_specialized); \ + test(std::numeric_limits::digits); \ + test(std::numeric_limits::digits10); \ + test(std::numeric_limits::max_digits10); \ + test(std::numeric_limits::is_signed); \ + test(std::numeric_limits::is_integer); \ + test(std::numeric_limits::is_exact); \ + test(std::numeric_limits::radix); \ + test(std::numeric_limits::min_exponent); \ + test(std::numeric_limits::min_exponent10); \ + test(std::numeric_limits::max_exponent); \ + test(std::numeric_limits::max_exponent10); \ + test(std::numeric_limits::has_infinity); \ + test(std::numeric_limits::has_quiet_NaN); \ + test(std::numeric_limits::has_signaling_NaN); \ + test(std::numeric_limits::has_denorm); \ + test(std::numeric_limits::has_denorm_loss); \ + test(std::numeric_limits::is_iec559); \ + test(std::numeric_limits::is_bounded); \ + test(std::numeric_limits::is_modulo); \ + test(std::numeric_limits::traps); \ + test(std::numeric_limits::tinyness_before); \ + test(std::numeric_limits::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 +#include + +template +void +test(T expected) +{ + assert(std::numeric_limits::denorm_min() == expected); + assert(std::numeric_limits::denorm_min() == expected); + assert(std::numeric_limits::denorm_min() == expected); + assert(std::numeric_limits::denorm_min() == expected); +} + +int main() +{ + test(false); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(0); + test<__uint128_t>(0); +#endif + test(__FLT_DENORM_MIN__); + test(__DBL_DENORM_MIN__); + test(__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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::digits == expected, "digits test 1"); + static_assert(std::numeric_limits::digits == expected, "digits test 2"); + static_assert(std::numeric_limits::digits == expected, "digits test 3"); + static_assert(std::numeric_limits::digits == expected, "digits test 4"); +} + +int main() +{ + test(); + test::is_signed ? 7 : 8>(); + test(); + test(); + test::is_signed ? sizeof(wchar_t)*8-1 : sizeof(wchar_t)*8>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 127>(); + test<__uint128_t, 128>(); +#endif + test(); + test(); + test(); +} 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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::digits10 == expected, "digits10 test 1"); + static_assert(std::numeric_limits::is_bounded, "digits10 test 5"); + static_assert(std::numeric_limits::digits10 == expected, "digits10 test 2"); + static_assert(std::numeric_limits::is_bounded, "digits10 test 6"); + static_assert(std::numeric_limits::digits10 == expected, "digits10 test 3"); + static_assert(std::numeric_limits::is_bounded, "digits10 test 7"); + static_assert(std::numeric_limits::digits10 == expected, "digits10 test 4"); + static_assert(std::numeric_limits::is_bounded, "digits10 test 8"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); // 4 -> 9 and 2 -> 4 +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 38>(); + test<__uint128_t, 38>(); +#endif + test(); + test(); + test(); +} 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 +#include +#include + +template +void +test(T expected) +{ + assert(std::numeric_limits::epsilon() == expected); + assert(std::numeric_limits::epsilon() == expected); + assert(std::numeric_limits::epsilon() == expected); + assert(std::numeric_limits::epsilon() == expected); +} + +int main() +{ + test(false); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(0); + test<__uint128_t>(0); +#endif + test(FLT_EPSILON); + test(DBL_EPSILON); + test(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 + +template +void +test() +{ + static_assert(std::numeric_limits::has_denorm == expected, "has_denorm test 1"); + static_assert(std::numeric_limits::has_denorm == expected, "has_denorm test 2"); + static_assert(std::numeric_limits::has_denorm == expected, "has_denorm test 3"); + static_assert(std::numeric_limits::has_denorm == expected, "has_denorm test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, std::denorm_absent>(); + test<__uint128_t, std::denorm_absent>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::has_denorm_loss == expected, "has_denorm_loss test 1"); + static_assert(std::numeric_limits::has_denorm_loss == expected, "has_denorm_loss test 2"); + static_assert(std::numeric_limits::has_denorm_loss == expected, "has_denorm_loss test 3"); + static_assert(std::numeric_limits::has_denorm_loss == expected, "has_denorm_loss test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, false>(); + test<__uint128_t, false>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::has_infinity == expected, "has_infinity test 1"); + static_assert(std::numeric_limits::has_infinity == expected, "has_infinity test 2"); + static_assert(std::numeric_limits::has_infinity == expected, "has_infinity test 3"); + static_assert(std::numeric_limits::has_infinity == expected, "has_infinity test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, false>(); + test<__uint128_t, false>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::has_quiet_NaN == expected, "has_quiet_NaN test 1"); + static_assert(std::numeric_limits::has_quiet_NaN == expected, "has_quiet_NaN test 2"); + static_assert(std::numeric_limits::has_quiet_NaN == expected, "has_quiet_NaN test 3"); + static_assert(std::numeric_limits::has_quiet_NaN == expected, "has_quiet_NaN test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, false>(); + test<__uint128_t, false>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::has_signaling_NaN == expected, "has_signaling_NaN test 1"); + static_assert(std::numeric_limits::has_signaling_NaN == expected, "has_signaling_NaN test 2"); + static_assert(std::numeric_limits::has_signaling_NaN == expected, "has_signaling_NaN test 3"); + static_assert(std::numeric_limits::has_signaling_NaN == expected, "has_signaling_NaN test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, false>(); + test<__uint128_t, false>(); +#endif + test(); + test(); + test(); +} 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 +#include +#include + +template +void +test(T expected) +{ + assert(std::numeric_limits::infinity() == expected); + assert(std::numeric_limits::infinity() == expected); + assert(std::numeric_limits::infinity() == expected); + assert(std::numeric_limits::infinity() == expected); +} + +extern float zero; + +int main() +{ + test(false); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(0); + test<__uint128_t>(0); +#endif + test(1./zero); + test(1./zero); + test(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 + +template +void +test() +{ + static_assert(std::numeric_limits::is_bounded == expected, "is_bounded test 1"); + static_assert(std::numeric_limits::is_bounded == expected, "is_bounded test 2"); + static_assert(std::numeric_limits::is_bounded == expected, "is_bounded test 3"); + static_assert(std::numeric_limits::is_bounded == expected, "is_bounded test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, true>(); + test<__uint128_t, true>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::is_exact == expected, "is_exact test 1"); + static_assert(std::numeric_limits::is_exact == expected, "is_exact test 2"); + static_assert(std::numeric_limits::is_exact == expected, "is_exact test 3"); + static_assert(std::numeric_limits::is_exact == expected, "is_exact test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, true>(); + test<__uint128_t, true>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::is_iec559 == expected, "is_iec559 test 1"); + static_assert(std::numeric_limits::is_iec559 == expected, "is_iec559 test 2"); + static_assert(std::numeric_limits::is_iec559 == expected, "is_iec559 test 3"); + static_assert(std::numeric_limits::is_iec559 == expected, "is_iec559 test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, false>(); + test<__uint128_t, false>(); +#endif + test(); + test(); +#if (defined(__ppc__) || defined(__ppc64__)) + test(); +#else + test(); +#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 + +template +void +test() +{ + static_assert(std::numeric_limits::is_integer == expected, "is_integer test 1"); + static_assert(std::numeric_limits::is_integer == expected, "is_integer test 2"); + static_assert(std::numeric_limits::is_integer == expected, "is_integer test 3"); + static_assert(std::numeric_limits::is_integer == expected, "is_integer test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, true>(); + test<__uint128_t, true>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::is_modulo == expected, "is_modulo test 1"); + static_assert(std::numeric_limits::is_modulo == expected, "is_modulo test 2"); + static_assert(std::numeric_limits::is_modulo == expected, "is_modulo test 3"); + static_assert(std::numeric_limits::is_modulo == expected, "is_modulo test 4"); +} + +int main() +{ + test(); +// test(); // don't know + test(); + test(); +// test(); // don't know +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, false>(); + test<__uint128_t, true>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::is_signed == expected, "is_signed test 1"); + static_assert(std::numeric_limits::is_signed == expected, "is_signed test 2"); + static_assert(std::numeric_limits::is_signed == expected, "is_signed test 3"); + static_assert(std::numeric_limits::is_signed == expected, "is_signed test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, true>(); + test<__uint128_t, false>(); +#endif + test(); + test(); + test(); +} 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 +#include +#include +#include +#include + +template +void +test(T expected) +{ + assert(std::numeric_limits::lowest() == expected); + assert(std::numeric_limits::is_bounded); + assert(std::numeric_limits::lowest() == expected); + assert(std::numeric_limits::is_bounded); + assert(std::numeric_limits::lowest() == expected); + assert(std::numeric_limits::is_bounded); + assert(std::numeric_limits::lowest() == expected); + assert(std::numeric_limits::is_bounded); +} + +int main() +{ + test(false); + test(CHAR_MIN); + test(SCHAR_MIN); + test(0); + test(WCHAR_MIN); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(SHRT_MIN); + test(0); + test(INT_MIN); + test(0); + test(LONG_MIN); + test(0); + test(LLONG_MIN); + test(0); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1); + test<__uint128_t>(0); +#endif + test(-FLT_MAX); + test(-DBL_MAX); + test(-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 +#include +#include +#include +#include + +template +void +test(T expected) +{ + assert(std::numeric_limits::max() == expected); + assert(std::numeric_limits::is_bounded); + assert(std::numeric_limits::max() == expected); + assert(std::numeric_limits::is_bounded); + assert(std::numeric_limits::max() == expected); + assert(std::numeric_limits::is_bounded); + assert(std::numeric_limits::max() == expected); + assert(std::numeric_limits::is_bounded); +} + +int main() +{ + test(true); + test(CHAR_MAX); + test(SCHAR_MAX); + test(UCHAR_MAX); + test(WCHAR_MAX); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(USHRT_MAX); + test(UINT_MAX); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(SHRT_MAX); + test(USHRT_MAX); + test(INT_MAX); + test(UINT_MAX); + test(LONG_MAX); + test(ULONG_MAX); + test(LLONG_MAX); + test(ULLONG_MAX); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(__int128_t(__uint128_t(-1)/2)); + test<__uint128_t>(__uint128_t(-1)); +#endif + test(FLT_MAX); + test(DBL_MAX); + test(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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::max_digits10 == expected, "max_digits10 test 1"); + static_assert(std::numeric_limits::max_digits10 == expected, "max_digits10 test 2"); + static_assert(std::numeric_limits::max_digits10 == expected, "max_digits10 test 3"); + static_assert(std::numeric_limits::max_digits10 == expected, "max_digits10 test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 0>(); + test<__uint128_t, 0>(); +#endif + test(); + test(); + test(); +} 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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::max_exponent == expected, "max_exponent test 1"); + static_assert(std::numeric_limits::max_exponent == expected, "max_exponent test 2"); + static_assert(std::numeric_limits::max_exponent == expected, "max_exponent test 3"); + static_assert(std::numeric_limits::max_exponent == expected, "max_exponent test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 0>(); + test<__uint128_t, 0>(); +#endif + test(); + test(); + test(); +} 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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::max_exponent10 == expected, "max_exponent10 test 1"); + static_assert(std::numeric_limits::max_exponent10 == expected, "max_exponent10 test 2"); + static_assert(std::numeric_limits::max_exponent10 == expected, "max_exponent10 test 3"); + static_assert(std::numeric_limits::max_exponent10 == expected, "max_exponent10 test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 0>(); + test<__uint128_t, 0>(); +#endif + test(); + test(); + test(); +} 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 +#include +#include +#include +#include + +template +void +test(T expected) +{ + assert(std::numeric_limits::min() == expected); + assert(std::numeric_limits::is_bounded || !std::numeric_limits::is_signed); + assert(std::numeric_limits::min() == expected); + assert(std::numeric_limits::is_bounded || !std::numeric_limits::is_signed); + assert(std::numeric_limits::min() == expected); + assert(std::numeric_limits::is_bounded || !std::numeric_limits::is_signed); + assert(std::numeric_limits::min() == expected); + assert(std::numeric_limits::is_bounded || !std::numeric_limits::is_signed); +} + +int main() +{ + test(false); + test(CHAR_MIN); + test(SCHAR_MIN); + test(0); + test(WCHAR_MIN); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(SHRT_MIN); + test(0); + test(INT_MIN); + test(0); + test(LONG_MIN); + test(0); + test(LLONG_MIN); + test(0); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1); + test<__uint128_t>(0); +#endif + test(FLT_MIN); + test(DBL_MIN); + test(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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::min_exponent == expected, "min_exponent test 1"); + static_assert(std::numeric_limits::min_exponent == expected, "min_exponent test 2"); + static_assert(std::numeric_limits::min_exponent == expected, "min_exponent test 3"); + static_assert(std::numeric_limits::min_exponent == expected, "min_exponent test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 0>(); + test<__uint128_t, 0>(); +#endif + test(); + test(); + test(); +} 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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::min_exponent10 == expected, "min_exponent10 test 1"); + static_assert(std::numeric_limits::min_exponent10 == expected, "min_exponent10 test 2"); + static_assert(std::numeric_limits::min_exponent10 == expected, "min_exponent10 test 3"); + static_assert(std::numeric_limits::min_exponent10 == expected, "min_exponent10 test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 0>(); + test<__uint128_t, 0>(); +#endif + test(); + test(); + test(); +} 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 +#include +#include +#include + +template +void +test_imp(std::true_type) +{ + assert(std::isnan(std::numeric_limits::quiet_NaN())); + assert(std::isnan(std::numeric_limits::quiet_NaN())); + assert(std::isnan(std::numeric_limits::quiet_NaN())); + assert(std::isnan(std::numeric_limits::quiet_NaN())); +} + +template +void +test_imp(std::false_type) +{ + assert(std::numeric_limits::quiet_NaN() == T()); + assert(std::numeric_limits::quiet_NaN() == T()); + assert(std::numeric_limits::quiet_NaN() == T()); + assert(std::numeric_limits::quiet_NaN() == T()); +} + +template +inline +void +test() +{ + test_imp(std::is_floating_point()); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(); + test<__uint128_t>(); +#endif + test(); + test(); + test(); +} 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 +#include + +template +void +test() +{ + static_assert(std::numeric_limits::radix == expected, "radix test 1"); + static_assert(std::numeric_limits::radix == expected, "radix test 2"); + static_assert(std::numeric_limits::radix == expected, "radix test 3"); + static_assert(std::numeric_limits::radix == expected, "radix test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, 2>(); + test<__uint128_t, 2>(); +#endif + test(); + test(); + test(); +} 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 +#include +#include + +template +void +test(T expected) +{ + assert(std::numeric_limits::round_error() == expected); + assert(std::numeric_limits::round_error() == expected); + assert(std::numeric_limits::round_error() == expected); + assert(std::numeric_limits::round_error() == expected); +} + +int main() +{ + test(false); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); + test(0); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(0); + test<__uint128_t>(0); +#endif + test(0.5); + test(0.5); + test(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 + +template +void +test() +{ + static_assert(std::numeric_limits::round_style == expected, "round_style test 1"); + static_assert(std::numeric_limits::round_style == expected, "round_style test 2"); + static_assert(std::numeric_limits::round_style == expected, "round_style test 3"); + static_assert(std::numeric_limits::round_style == expected, "round_style test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, std::round_toward_zero>(); + test<__uint128_t, std::round_toward_zero>(); +#endif + test(); + test(); + test(); +} 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 +#include +#include +#include + +template +void +test_imp(std::true_type) +{ + assert(std::isnan(std::numeric_limits::signaling_NaN())); + assert(std::isnan(std::numeric_limits::signaling_NaN())); + assert(std::isnan(std::numeric_limits::signaling_NaN())); + assert(std::isnan(std::numeric_limits::signaling_NaN())); +} + +template +void +test_imp(std::false_type) +{ + assert(std::numeric_limits::signaling_NaN() == T()); + assert(std::numeric_limits::signaling_NaN() == T()); + assert(std::numeric_limits::signaling_NaN() == T()); + assert(std::numeric_limits::signaling_NaN() == T()); +} + +template +inline +void +test() +{ + test_imp(std::is_floating_point()); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t>(); + test<__uint128_t>(); +#endif + test(); + test(); + test(); +} 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 + +template +void +test() +{ + static_assert(std::numeric_limits::tinyness_before == expected, "tinyness_before test 1"); + static_assert(std::numeric_limits::tinyness_before == expected, "tinyness_before test 2"); + static_assert(std::numeric_limits::tinyness_before == expected, "tinyness_before test 3"); + static_assert(std::numeric_limits::tinyness_before == expected, "tinyness_before test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, false>(); + test<__uint128_t, false>(); +#endif + test(); + test(); + test(); +} 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 + +#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 +void +test() +{ + static_assert(std::numeric_limits::traps == expected, "traps test 1"); + static_assert(std::numeric_limits::traps == expected, "traps test 2"); + static_assert(std::numeric_limits::traps == expected, "traps test 3"); + static_assert(std::numeric_limits::traps == expected, "traps test 4"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_INT128 + test<__int128_t, integral_types_trap>(); + test<__uint128_t, integral_types_trap>(); +#endif + test(); + test(); + test(); +} 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 template shall have all members, but with +// 0 or false values. + +#include +#include + +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::is_specialized == false, + "std::numeric_limits::is_specialized == false"); + assert(std::numeric_limits::min() == A()); + assert(std::numeric_limits::max() == A()); + assert(std::numeric_limits::lowest() == A()); + static_assert(std::numeric_limits::digits == 0, + "std::numeric_limits::digits == 0"); + static_assert(std::numeric_limits::digits10 == 0, + "std::numeric_limits::digits10 == 0"); + static_assert(std::numeric_limits::max_digits10 == 0, + "std::numeric_limits::max_digits10 == 0"); + static_assert(std::numeric_limits::is_signed == false, + "std::numeric_limits::is_signed == false"); + static_assert(std::numeric_limits::is_integer == false, + "std::numeric_limits::is_integer == false"); + static_assert(std::numeric_limits::is_exact == false, + "std::numeric_limits::is_exact == false"); + static_assert(std::numeric_limits::radix == 0, + "std::numeric_limits::radix == 0"); + assert(std::numeric_limits::epsilon() == A()); + assert(std::numeric_limits::round_error() == A()); + static_assert(std::numeric_limits::min_exponent == 0, + "std::numeric_limits::min_exponent == 0"); + static_assert(std::numeric_limits::min_exponent10 == 0, + "std::numeric_limits::min_exponent10 == 0"); + static_assert(std::numeric_limits::max_exponent == 0, + "std::numeric_limits::max_exponent == 0"); + static_assert(std::numeric_limits::max_exponent10 == 0, + "std::numeric_limits::max_exponent10 == 0"); + static_assert(std::numeric_limits::has_infinity == false, + "std::numeric_limits::has_infinity == false"); + static_assert(std::numeric_limits::has_quiet_NaN == false, + "std::numeric_limits::has_quiet_NaN == false"); + static_assert(std::numeric_limits::has_signaling_NaN == false, + "std::numeric_limits::has_signaling_NaN == false"); + static_assert(std::numeric_limits::has_denorm == std::denorm_absent, + "std::numeric_limits::has_denorm == std::denorm_absent"); + static_assert(std::numeric_limits::has_denorm_loss == false, + "std::numeric_limits::has_denorm_loss == false"); + assert(std::numeric_limits::infinity() == A()); + assert(std::numeric_limits::quiet_NaN() == A()); + assert(std::numeric_limits::signaling_NaN() == A()); + assert(std::numeric_limits::denorm_min() == A()); + static_assert(std::numeric_limits::is_iec559 == false, + "std::numeric_limits::is_iec559 == false"); + static_assert(std::numeric_limits::is_bounded == false, + "std::numeric_limits::is_bounded == false"); + static_assert(std::numeric_limits::is_modulo == false, + "std::numeric_limits::is_modulo == false"); + static_assert(std::numeric_limits::traps == false, + "std::numeric_limits::traps == false"); + static_assert(std::numeric_limits::tinyness_before == false, + "std::numeric_limits::tinyness_before == false"); + static_assert(std::numeric_limits::round_style == std::round_toward_zero, + "std::numeric_limits::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 + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include + +int main() +{ + static_assert((std::is_base_of::value), + "std::is_base_of::value"); + static_assert(std::is_polymorphic::value, + "std::is_polymorphic::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 +#include +#include + +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 +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +#include +#include + +#ifndef setjmp +#error setjmp not defined +#endif + +int main() +{ + std::jmp_buf jb; + static_assert((std::is_same::value), + "std::is_same::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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::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 + +#include + +#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 + +#include + +#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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + char* c1 = 0; + const char* c2 = 0; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +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 + +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 + +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 +#include + +// max_align_t is a POD type whose alignment requirement is at least as +// great as that of every scalar type + +#include + +int main() +{ + static_assert(std::is_pod::value, + "std::is_pod::value"); + static_assert((std::alignment_of::value >= + std::alignment_of::value), + "std::alignment_of::value >= " + "std::alignment_of::value"); + static_assert(std::alignment_of::value >= + std::alignment_of::value, + "std::alignment_of::value >= " + "std::alignment_of::value"); + static_assert(std::alignment_of::value >= + std::alignment_of::value, + "std::alignment_of::value >= " + "std::alignment_of::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 + +#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 +#include +#include + +// typedef decltype(nullptr) nullptr_t; + +struct A +{ + A(std::nullptr_t) {} +}; + +template +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 +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(); + test_conversions(); + test_conversions(); + test_conversions(); + test_conversions(); + test_conversions(); + } + { + test_comparisons(); + test_comparisons(); + test_comparisons(); + test_comparisons(); + } + { + 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 + +int main() +{ + std::ptrdiff_t i = static_cast(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 +#include + +int main() +{ + std::ptrdiff_t i = reinterpret_cast(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 + +#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 +#include + +// 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::value, + "std::is_signed::value"); + static_assert(std::is_integral::value, + "std::is_integral::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 +#include + +// 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::value, + "std::is_unsigned::value"); + static_assert(std::is_integral::value, + "std::is_integral::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); +#endif + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +// _ForwardIterator +// __scan_keyword(_InputIterator& __b, _InputIterator __e, +// _ForwardIterator __kb, _ForwardIterator __ke, +// const _Ctype& __ct, ios_base::iostate& __err, +// bool __case_sensitive = true); + +#include +#include + +int main() +{ + const std::ctype& ct = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template 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 +#include +#include + +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + const std::collate& f = std::use_facet >(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& f = std::use_facet >(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& f = std::use_facet >(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& f = std::use_facet >(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& f = std::use_facet >(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& f = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class collate_byname + +// long hash(const charT* low, const charT* high) const; + +// This test is not portable + +#include +#include +#include + +#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& f = std::use_facet >(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& f = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class collate_byname + +// string_type transform(const charT* low, const charT* high) const; + +// REQUIRES: locale.en_US.UTF-8 + +#include +#include +#include + +#include + +#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("LANG=" LOCALE_en_US_UTF_8)); + { + std::locale l(LOCALE_en_US_UTF_8); + { + std::string x("1234"); + const std::collate& f = std::use_facet >(l); + assert(f.transform(x.data(), x.data() + x.size()) != x); + } + { + std::wstring x(L"1234"); + const std::collate& f = std::use_facet >(l); + assert(f.transform(x.data(), x.data() + x.size()) != x); + } + } + { + std::locale l(""); + { + std::string x("1234"); + const std::collate& f = std::use_facet >(l); + assert(f.transform(x.data(), x.data() + x.size()) != x); + } + { + std::wstring x(L"1234"); + const std::collate& f = std::use_facet >(l); + assert(f.transform(x.data(), x.data() + x.size()) != x); + } + } + { + std::locale l("C"); + { + std::string x("1234"); + const std::collate& f = std::use_facet >(l); + assert(f.transform(x.data(), x.data() + x.size()) == x); + } + { + std::wstring x(L"1234"); + const std::collate& f = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class collate_byname +// : public collate +// { +// public: +// typedef basic_string string_type; +// explicit collate_byname(const char*, size_t refs = 0); +// explicit collate_byname(const string&, size_t refs = 0); +// protected: +// ~collate_byname(); +// }; + +#include +#include +#include + +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + std::locale l(LOCALE_en_US_UTF_8); + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(l)); + } + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class collate; + +// explicit collate(size_t refs = 0); + +#include +#include +#include + +template +class my_facet + : public std::collate +{ +public: + static int count; + + explicit my_facet(std::size_t refs = 0) + : std::collate(refs) {++count;} + + ~my_facet() {--count;} +}; + +template 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); + { + 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.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. +// +//===----------------------------------------------------------------------===// + +// + +// template class collate; + +// int compare(const charT* low1, const charT* high1, +// const charT* low2, const charT* high2) const; + +#include +#include + +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& f = std::use_facet >(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& f = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class collate; + +// long hash(const charT* low, const charT* high) const; + +// This test is not portable + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + std::string x1("1234"); + std::string x2("12345"); + const std::collate& f = std::use_facet >(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& f = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class collate; + +// string_type transform(const charT* low, const charT* high) const; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + std::string x("1234"); + const std::collate& f = std::use_facet >(l); + assert(f.transform(x.data(), x.data() + x.size()) == x); + } + { + std::wstring x(L"1234"); + const std::collate& f = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class collate +// : public locale::facet { +// public: +// typedef charT char_type; +// typedef basic_stringstring_type; +// +// static locale::id id; +// }; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + assert(std::has_facet >(l)); + const std::collate& f = std::use_facet >(l); + { + (void)std::collate::id; + } + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::string_type, std::string>::value), ""); + static_assert((std::is_base_of >::value), ""); + } + { + assert(std::has_facet >(l)); + const std::collate& f = std::use_facet >(l); + { + (void)std::collate::id; + } + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::string_type, std::wstring>::value), ""); + static_assert((std::is_base_of >::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 + +// + +// 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 +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype + +// ~ctype(); + +#include +#include + +#include "count_new.hpp" + +int main() +{ + { + std::locale l(std::locale::classic(), new std::ctype); + assert(globalMemCounter.checkDeleteArrayCalledEq(0)); + } + assert(globalMemCounter.checkDeleteArrayCalledEq(0)); + { + std::ctype::mask table[256]; + std::locale l(std::locale::classic(), new std::ctype(table)); + assert(globalMemCounter.checkDeleteArrayCalledEq(0)); + } + assert(globalMemCounter.checkDeleteArrayCalledEq(0)); + { + std::locale l(std::locale::classic(), + new std::ctype(new std::ctype::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// explicit ctype(const mask* tbl = 0, bool del = false, size_t refs = 0); + +#include +#include + +class my_facet + : public std::ctype +{ +public: + static int count; + + explicit my_facet(const mask* tbl = 0, bool del = false, std::size_t refs = 0) + : std::ctype(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// bool is(mask m, char c) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// const char* is(const char* low, const char* high, mask* vec) const; + +#include +#include +#include +#include + +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::string in(" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// char narrow(char c, char dfault) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// const char* narrow(const char* low, const char*, char dfault, char* to) const; + +#include +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + std::string in(" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// const char* scan_is(mask m, const char* low, const char* high) const; + +#include +#include +#include +#include + +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::string in(" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// const char* scan_not(mask m, const char* low, const char* high) const; + +#include +#include +#include +#include + +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::string in(" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype + +// const mask* table() const throw(); + +#include +#include + +int main() +{ + typedef std::ctype F; + { + std::locale l(std::locale::classic(), new std::ctype); + const F& f = std::use_facet(l); + assert(f.table() == f.classic_table()); + } + { + std::ctype::mask table[256]; + std::locale l(std::locale::classic(), new std::ctype(table)); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// char tolower(char) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// const char* tolower(char* low, const char* high) const; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// char toupper(char) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// const char* toupper(char* low, const char* high) const; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// char widen(char c) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype; + +// const char* widen(const char* low, const char* high, char* to) const; + +#include +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + std::string in(" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class ctype + +// static const mask* classic_table() throw(); + +#include +#include + +int main() +{ + typedef std::ctype 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> +// class ctype +// : public locale::facet, +// public ctype_base +// { +// public: +// typedef char char_type; +// }; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + assert(std::has_facet >(l)); + const std::ctype& f = std::use_facet >(l); + { + (void)std::ctype::id; + } + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt_byname + +// explicit codecvt_byname(const char* nm, size_t refs = 0); +// explicit codecvt_byname(const string& nm, size_t refs = 0); + +#include +#include + +typedef std::codecvt_byname 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt_byname + +// explicit codecvt_byname(const char* nm, size_t refs = 0); +// explicit codecvt_byname(const string& nm, size_t refs = 0); + +#include +#include + +typedef std::codecvt_byname 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt_byname + +// explicit codecvt_byname(const char* nm, size_t refs = 0); +// explicit codecvt_byname(const string& nm, size_t refs = 0); + +#include +#include + +typedef std::codecvt_byname 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt_byname + +// explicit codecvt_byname(const char* nm, size_t refs = 0); +// explicit codecvt_byname(const string& nm, size_t refs = 0); + +#include +#include + +#include "platform_support.h" // locale name macros + +typedef std::codecvt_byname 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. +// +//===----------------------------------------------------------------------===// + +// + +// class codecvt_base +// { +// public: +// enum result {ok, partial, error, noconv}; +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// explicit codecvt(size_t refs = 0); + +#include +#include + +typedef std::codecvt 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// explicit codecvt(size_t refs = 0); + +#include +#include + +//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + +typedef std::codecvt 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// explicit codecvt(size_t refs = 0); + +#include +#include + +//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + +typedef std::codecvt 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// explicit codecvt(size_t refs = 0); + +#include +#include + +typedef std::codecvt 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// bool always_noconv() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int encoding() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +typedef std::codecvt 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(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const; + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int max_length() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// result unshift(stateT& state, +// externT* to, externT* to_end, externT*& to_next) const; + +#include +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + std::vector to(3); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// bool always_noconv() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int encoding() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +typedef std::codecvt 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(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const; + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int max_length() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// result unshift(stateT& state, +// externT* to, externT* to_end, externT*& to_next) const; + +#include +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + std::vector to(3); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// bool always_noconv() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int encoding() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const std::basic_string from("some text"); + std::vector to(from.size()); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const; + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int max_length() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const std::basic_string from("some text"); + std::vector to(from.size()); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// result unshift(stateT& state, +// externT* to, externT* to_end, externT*& to_next) const; + +#include +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + std::vector to(3); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt +// template <> class codecvt +// template <> class codecvt // extension + +// sanity check + +#include +#include +#include + +#include + +int main() +{ + typedef std::codecvt F32_8; + typedef std::codecvt F16_8; + typedef std::codecvt_utf16 F32_16; + std::locale l = std::locale(std::locale::classic(), new F32_16); + const F32_8& f32_8 = std::use_facet(std::locale::classic()); + const F32_16& f32_16 = std::use_facet(l); + const F16_8& f16_8 = std::use_facet(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(c16[i] >> 8); + c16c[2*i+1] = static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// bool always_noconv() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int encoding() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const std::basic_string from("some text"); + const std::basic_string expected(from.begin(), from.end()); + std::basic_string to(from.size(), F::intern_type()); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const; + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// int max_length() const throw(); + +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// 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 +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + const F& f = std::use_facet(l); + { + const std::basic_string from(L"some text"); + std::vector 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 from(L"some text"); + from[4] = '\0'; + std::vector 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 from(L"some text"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> class codecvt + +// result unshift(stateT& state, +// externT* to, externT* to_end, externT*& to_next) const; + +// This is pretty much just an "are you breathing" test + +#include +#include +#include +#include + +typedef std::codecvt F; + +int main() +{ + std::locale l = std::locale::classic(); + std::vector to(3); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> +// class codecvt +// : public locale::facet, +// public codecvt_base +// { +// public: +// typedef char intern_type; +// typedef char extern_type; +// typedef mbstate_t state_type; +// ... +// }; + +#include +#include +#include + +int main() +{ + typedef std::codecvt F; + static_assert((std::is_base_of::value), ""); + static_assert((std::is_base_of::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + std::locale l = std::locale::classic(); + assert(std::has_facet(l)); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> +// class codecvt +// : public locale::facet, +// public codecvt_base +// { +// public: +// typedef char16_t intern_type; +// typedef char extern_type; +// typedef mbstate_t state_type; +// ... +// }; + +#include +#include +#include + +int main() +{ +//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + typedef std::codecvt F; + static_assert((std::is_base_of::value), ""); + static_assert((std::is_base_of::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + std::locale l = std::locale::classic(); + assert(std::has_facet(l)); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> +// class codecvt +// : public locale::facet, +// public codecvt_base +// { +// public: +// typedef char32_t intern_type; +// typedef char extern_type; +// typedef mbstate_t state_type; +// ... +// }; + +#include +#include +#include + +int main() +{ +//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + typedef std::codecvt F; + static_assert((std::is_base_of::value), ""); + static_assert((std::is_base_of::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + std::locale l = std::locale::classic(); + assert(std::has_facet(l)); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> +// class codecvt +// : public locale::facet, +// public codecvt_base +// { +// public: +// typedef wchar_t intern_type; +// typedef char extern_type; +// typedef mbstate_t state_type; +// ... +// }; + +#include +#include +#include + +int main() +{ + typedef std::codecvt F; + static_assert((std::is_base_of::value), ""); + static_assert((std::is_base_of::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + std::locale l = std::locale::classic(); + assert(std::has_facet(l)); + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype_byname; + +// bool is(mask m, charT c) const; + +// REQUIRES: locale.en_US.UTF-8 + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype_byname; + +// const charT* do_is(const charT* low, const charT* high, mask* vec) const; + +// REQUIRES: locale.en_US.UTF-8 + +#include +#include +#include +#include + +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::wstring in(L"\x00DA A\x07.a1"); + std::vector 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 F; + const F& f = std::use_facet(l); + const std::wstring in(L"\x00DA A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype_byname; + +// bool is(mask m, charT c) const; + +#include +#include +#include + +int main() +{ + { + std::locale l("C"); + { + typedef std::ctype WF; + const WF& wf = std::use_facet(l); + typedef std::ctype CF; + const CF& cf = std::use_facet(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 + +// + +// template class ctype_byname; + +// char narrow(charT c, char dfault) const; + +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(std::string(LOCALE_fr_CA_ISO8859_1)); + { + typedef std::ctype F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 + +// + +// template class ctype_byname; + +// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const; + +#include +#include +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_fr_CA_ISO8859_1); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + std::wstring in(L" A\x07.a1\xDA"); + std::vector 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 F; + const F& f = std::use_facet(l); + std::wstring in(L" A\x07.a1\xDA"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype_byname; + +// const charT* scan_is(mask m, const charT* low, const charT* high) const; + +// REQUIRES: locale.en_US.UTF-8 + +#include +#include +#include +#include + +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::wstring in(L"\x00DA A\x07.a1"); + std::vector 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 F; + const F& f = std::use_facet(l); + const std::wstring in(L"\x00DA A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype_byname; + +// const charT* scan_not(mask m, const charT* low, const charT* high) const; + +// REQUIRES: locale.en_US.UTF-8 + +#include +#include +#include +#include + +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::wstring in(L"\x00DA A\x07.a1"); + std::vector 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 F; + const F& f = std::use_facet(l); + const std::wstring in(L"\x00DA A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template 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 +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template 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 +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template 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 +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template 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 +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class ctype_byname +// : public ctype +// { +// public: +// explicit ctype_byname(const char*, size_t = 0); +// explicit ctype_byname(const string&, size_t = 0); +// +// protected: +// ~ctype_byname(); +// }; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(l)); + } + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(l)); + } + } + { + std::locale l(""); + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(l)); + } + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(l)); + } + } + { + std::locale l("C"); + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(l)); + } + { + assert(std::has_facet >(l)); + assert(&std::use_facet >(l) + == &std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype_byname; + +// charT widen(char c) const; + +// I doubt this test is portable + +// XFAIL: linux + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(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 F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype_byname; + +// const char* widen(const char* low, const char* high, charT* to) const; + +// I doubt this test is portable + +// XFAIL: linux + +#include +#include +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + std::string in(" A\x07.a1\x85"); + std::vector 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 F; + const F& f = std::use_facet(l); + std::string in(" A\x07.a1\x85"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// explicit ctype(size_t refs = 0); + +#include +#include + +template +class my_facet + : public std::ctype +{ +public: + static int count; + + explicit my_facet(std::size_t refs = 0) + : std::ctype(refs) {++count;} + + ~my_facet() {--count;} +}; + +template 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.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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// bool is(mask m, charT c) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// const charT* do_is(const charT* low, const charT* high, mask* vec) const; + +#include +#include +#include +#include + +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::wstring in(L" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// char narrow(charT c, char dfault) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const; + +#include +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + std::wstring in(L" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// const charT* scan_is(mask m, const charT* low, const charT* high) const; + +#include +#include +#include +#include + +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::wstring in(L" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// const charT* scan_not(mask m, const charT* low, const charT* high) const; + +#include +#include +#include +#include + +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + const std::wstring in(L" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// charT tolower(charT) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// const charT* tolower(charT* low, const charT* high) const; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// charT toupper(charT) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// const charT* toupper(charT* low, const charT* high) const; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// charT widen(char c) const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class ctype; + +// const char* widen(const char* low, const char* high, charT* to) const; + +#include +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef std::ctype F; + const F& f = std::use_facet(l); + std::string in(" A\x07.a1"); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class ctype +// : public locale::facet, +// public ctype_base +// { +// public: +// typedef CharT char_type; +// }; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + assert(std::has_facet >(l)); + const std::ctype& f = std::use_facet >(l); + { + (void)std::ctype::id; + } + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::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. +// +//===----------------------------------------------------------------------===// + +// + +// class messages + +// explicit messages(size_t refs = 0); + +#include +#include + +typedef std::messages 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. +// +//===----------------------------------------------------------------------===// + +// + +// class messages + +// catalog open(const basic_string& name, const locale&) const; + +#include +#include + +// 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 F + : public std::messages +{ +public: + explicit F(std::size_t refs = 0) + : std::messages(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. +// +//===----------------------------------------------------------------------===// + +// + +// class messages_base +// { +// public: +// typedef unspecified catalog; +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class messages +// : public locale::facet, +// public messages_base +// { +// public: +// typedef _CharT char_type; +// typedef basic_string<_CharT> string_type; + +#include +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::string_type, std::string>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class money_get + +// explicit money_get(size_t refs = 0); + +#include +#include + +typedef std::money_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class money_get + +// 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 +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_get > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_get > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + { + const my_facet f(1); + // char, national + { // zero + std::string v = "0.00"; + typedef input_iterator 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 + +// + +// class money_get + +// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob, +// ios_base::iostate& err, long double& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_get > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_get > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + { + const my_facet f(1); + // char, national + { // zero + std::string v = "0,00"; + typedef input_iterator 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 + +// + +// class money_get + +// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob, +// ios_base::iostate& err, long double& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_get > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_get > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + { + const my_facet f(1); + // char, national + { // zero + std::string v = "0,00 "; + typedef input_iterator 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 + +// + +// class money_get + +// 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 +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_get > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_get > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + { + const my_facet f(1); + // char, national + { // zero + std::string v = "0.00"; + typedef input_iterator 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class money_get + +// 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 +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_get > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_get > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + { + const my_facet f(1); + // char, national + { // zero + std::string v = "0.00"; + typedef input_iterator 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class money_get +// : public locale::facet +// { +// public: +// typedef CharT char_type; +// typedef InputIterator iter_type; +// typedef basic_string string_type; + +#include +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::iter_type, std::istreambuf_iterator >::value), ""); + static_assert((std::is_same::iter_type, std::istreambuf_iterator >::value), ""); + static_assert((std::is_same::string_type, std::string>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class money_put + +// explicit money_put(size_t refs = 0); + +#include +#include + +typedef std::money_put 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. +// +//===----------------------------------------------------------------------===// + +// + +// class money_put + +// 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 +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_put > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_put > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); +{ + const my_facet f(1); + // char, national + { // zero + long double v = 0; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + false, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0.01"); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + true, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0.01"); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 + +// + +// class money_put + +// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, +// long double units) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_put > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_put > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); +{ + const my_facet f(1); + // char, national + { // zero + long double v = 0; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + false, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0,01"); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + true, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0,01"); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 + +// + +// class money_put + +// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, +// long double units) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_put > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_put > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); +{ + const my_facet f(1); + // char, national + { // zero + long double v = 0; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + false, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0,01 "); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + true, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0,01 "); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 + +// + +// class money_put + +// 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 +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_put > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_put > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); +{ + const my_facet f(1); + // char, national + { // zero + long double v = 0; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + false, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0.01"); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + true, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0.01"); + } + { // positive + long double v = 123456789; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class money_put + +// 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 +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::money_put > Fn; + +class my_facet + : public Fn +{ +public: + explicit my_facet(std::size_t refs = 0) + : Fn(refs) {} +}; + +typedef std::money_put > 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(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); + ios.imbue(std::locale(ios.getloc(), + new std::moneypunct_byname(loc_name))); +{ + const my_facet f(1); + // char, national + { // zero + std::string v = "0"; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + false, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0.01"); + } + { // positive + std::string v = "123456789"; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), + true, ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0.01"); + } + { // positive + std::string v = "123456789"; + char str[100]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class money_put +// : public locale::facet +// { +// public: +// typedef CharT char_type; +// typedef OutputIterator iter_type; +// typedef basic_string string_type; + +#include +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::iter_type, std::ostreambuf_iterator >::value), ""); + static_assert((std::is_same::iter_type, std::ostreambuf_iterator >::value), ""); + static_assert((std::is_same::string_type, std::string>::value), ""); + static_assert((std::is_same::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 + +// + +// class moneypunct_byname + +// string_type curr_symbol() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(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 + +// + +// class moneypunct_byname + +// charT decimal_point() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +int main() +{ + { + Fnf f("C", 1); + assert(f.decimal_point() == std::numeric_limits::max()); + } + { + Fnt f("C", 1); + assert(f.decimal_point() == std::numeric_limits::max()); + } + { + Fwf f("C", 1); + assert(f.decimal_point() == std::numeric_limits::max()); + } + { + Fwt f("C", 1); + assert(f.decimal_point() == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +// int frac_digits() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(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 + +// + +// class moneypunct_byname + +// string grouping() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(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 + +// + +// class moneypunct_byname + +// pattern neg_format() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(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 + +// + +// class moneypunct_byname + +// string_type negative_sign() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(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 + +// + +// class moneypunct_byname + +// pattern pos_format() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(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 + +// + +// class moneypunct_byname + +// string_type positive_sign() const; + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(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 + +// + +// class moneypunct_byname + +// 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 +#include +#include + +#include "platform_support.h" // locale name macros + +class Fnf + : public std::moneypunct_byname +{ +public: + explicit Fnf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fnt + : public std::moneypunct_byname +{ +public: + explicit Fnt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwf + : public std::moneypunct_byname +{ +public: + explicit Fwf(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +class Fwt + : public std::moneypunct_byname +{ +public: + explicit Fwt(const std::string& nm, std::size_t refs = 0) + : std::moneypunct_byname(nm, refs) {} +}; + +int main() +{ + { + Fnf f("C", 1); + assert(f.thousands_sep() == std::numeric_limits::max()); + } + { + Fnt f("C", 1); + assert(f.thousands_sep() == std::numeric_limits::max()); + } + { + Fwf f("C", 1); + assert(f.thousands_sep() == std::numeric_limits::max()); + } + { + Fwt f("C", 1); + assert(f.thousands_sep() == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// explicit moneypunct(size_t refs = 0); + +#include +#include + +typedef std::moneypunct 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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// string_type curr_symbol() const; + +// The C++ and C standards are silent. +// POSIX standard is being followed (as a guideline). + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// charT decimal_point() const; + +// The C++ and C standards are silent. +// POSIX standard is being followed (as a guideline). + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +int main() +{ + { + Fnf f(1); + assert(f.decimal_point() == std::numeric_limits::max()); + } + { + Fnt f(1); + assert(f.decimal_point() == std::numeric_limits::max()); + } + { + Fwf f(1); + assert(f.decimal_point() == std::numeric_limits::max()); + } + { + Fwt f(1); + assert(f.decimal_point() == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// int frac_digits() const; + +// The C++ and C standards are silent. +// POSIX standard is being followed (as a guideline). + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// string grouping() const; + +// The C++ and C standards are silent. +// POSIX standard is being followed (as a guideline). + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// pattern neg_format() const; + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// 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 +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// pattern pos_format() const; + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// string_type positive_sign() const; + +// The C++ and C standards are silent. +// POSIX standard is being followed (as a guideline). + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(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. +// +//===----------------------------------------------------------------------===// + +// + +// class moneypunct + +// charT thousands_sep() const; + +// The C++ and C standards are silent. +// POSIX standard is being followed (as a guideline). + +#include +#include +#include + +typedef std::moneypunct F; + +class Fnf + : public std::moneypunct +{ +public: + explicit Fnf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fnt + : public std::moneypunct +{ +public: + explicit Fnt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwf + : public std::moneypunct +{ +public: + explicit Fwf(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +class Fwt + : public std::moneypunct +{ +public: + explicit Fwt(std::size_t refs = 0) + : std::moneypunct(refs) {} +}; + +int main() +{ + { + Fnf f(1); + assert(f.thousands_sep() == std::numeric_limits::max()); + } + { + Fnt f(1); + assert(f.thousands_sep() == std::numeric_limits::max()); + } + { + Fwf f(1); + assert(f.thousands_sep() == std::numeric_limits::max()); + } + { + Fwt f(1); + assert(f.thousands_sep() == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// class money_base +// { +// public: +// enum part {none, space, symbol, sign, value}; +// struct pattern {char field[4];}; +// }; + +#include +#include + +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 + +// + +// template +// class moneypunct +// : public locale::facet, +// public money_base +// { +// public: +// typedef _CharT char_type; +// typedef basic_string string_type; +// static const bool intl = International; + +#include +#include + +template +void test(const _Tp &) {} + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::string_type, std::string>::value), ""); + static_assert((std::is_same::string_type, std::wstring>::value), ""); + + test(std::moneypunct::intl); + test(std::moneypunct::intl); + test(std::moneypunct::intl); + test(std::moneypunct::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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// explicit num_put(size_t refs = 0); + +#include +#include + +typedef std::num_put 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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// iter_type put(iter_type s, ios_base& iob, char_type fill, bool v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = f.put(output_iterator(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "0"); + } + { + bool v = true; + char str[50]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "false"); + } + { + bool v = true; + char str[50]; + output_iterator iter = f.put(output_iterator(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 iter = f.put(output_iterator(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "no"); + } + { + bool v = true; + char str[50]; + output_iterator iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const; + +#include +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000"); + assert(ios.width() == 0); + } + } + } + } + } + } + } + } +} + +void test2() +{ + char str[200]; + output_iterator 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000"); + assert(ios.width() == 0); + } + } + } + } + } + } + } + } +} + +void test4() +{ + char str[200]; + output_iterator 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// iter_type put(iter_type s, ios_base& iob, char_type fill, long v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// 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 +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000"); + assert(ios.width() == 0); + } + } + } + } + } + } + } + } +} + +void test2() +{ + char str[200]; + output_iterator 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000"); + assert(ios.width() == 0); + } + } + } + } + } + } + } + } +} + +void test3() +{ + char str[200]; + output_iterator 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000"); + assert(ios.width() == 0); + } + } + } + } + } + } + } + } +} + +void test7() +{ + char str[200]; + output_iterator 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(str), ios, '*', v); + std::string ex(str, iter.base()); + assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000"); + assert(ios.width() == 0); + } + } + } + } + } + } + } + } +} + +void test8() +{ + char str[200]; + output_iterator 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// iter_type put(iter_type s, ios_base& iob, char_type fill, long long v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// iter_type put(iter_type s, ios_base& iob, char_type fill, void* v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > 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 iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_put + +// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long long v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_put > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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 iter = f.put(output_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class num_put +// : public locale::facet +// { +// public: +// typedef charT char_type; +// typedef OutputIterator iter_type; + +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::iter_type, std::ostreambuf_iterator >::value), ""); + static_assert((std::is_same::iter_type, std::ostreambuf_iterator >::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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// explicit num_get(size_t refs = 0); + +#include +#include + +typedef std::num_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, bool& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class p1 + : public std::numpunct +{ +public: + p1() : std::numpunct() {} + +protected: + virtual string_type do_truename() const {return "a";} + virtual string_type do_falsename() const {return "abb";} +}; + +class p2 + : public std::numpunct +{ +public: + p2() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, double& v) const; + +#include +#include +#include +#include +#include +#include "test_iterators.h" +#include "hexfloat.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.goodbit); + assert(v == hexfloat(0x125, 0, -1)); + } + { + const char str[] = "inf"; + hex(ios); + std::ios_base::iostate err = ios.goodbit; + input_iterator iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, float& v) const; + +#include +#include +#include +#include +#include +#include "test_iterators.h" +#include "hexfloat.h" + +typedef std::num_get > 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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.goodbit); + assert(v == hexfloat(0x125, 0, -1)); + } + { + const char str[] = "inf"; + hex(ios); + std::ios_base::iostate err = ios.goodbit; + input_iterator iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, long& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.failbit); + assert(v == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, long double& v) const; + +#include +#include +#include +#include +#include +#include "test_iterators.h" +#include "hexfloat.h" + +typedef std::num_get > 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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.goodbit); + assert(v == hexfloat(0x125, 0, -1)); + } + { + const char str[] = "inf"; + hex(ios); + std::ios_base::iostate err = ios.goodbit; + input_iterator iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, long long& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, void*& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > 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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, unsigned int& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, unsigned long& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, unsigned long long& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// class num_get + +// iter_type get(iter_type in, iter_type end, ios_base&, +// ios_base::iostate& err, unsigned short& v) const; + +#include +#include +#include +#include +#include "test_iterators.h" + +typedef std::num_get > F; + +class my_facet + : public F +{ +public: + explicit my_facet(std::size_t refs = 0) + : F(refs) {} +}; + +class my_numpunct + : public std::numpunct +{ +public: + my_numpunct() : std::numpunct() {} + +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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 iter = + f.get(input_iterator(str), + input_iterator(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 +#include +#include +#include +#include + +using namespace std; + +template +void check_limits() +{ + T minv = numeric_limits::min(); + T maxv = numeric_limits::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(); + check_limits(); + check_limits(); + check_limits(); + check_limits(); + check_limits(); + check_limits(); + check_limits(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class num_get +// : public locale::facet +// { +// public: +// typedef charT char_type; +// typedef InputIterator iter_type; + +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::iter_type, std::istreambuf_iterator >::value), ""); + static_assert((std::is_same::iter_type, std::istreambuf_iterator >::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 + +// + +// class time_get_byname + +// dateorder date_order() const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::time_get_byname > 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 + +// + +// class time_get_byname + +// dateorder date_order() const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::time_get_byname > 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 + +// + +// class time_get_byname + +// iter_type +// get_date(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// iter_type +// get_date(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// iter_type +// get_monthname(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// iter_type +// get_monthname(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 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 + +// + +// class time_get_byname + +// 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 +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// 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 +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// iter_type +// get_time(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// iter_type +// get_time(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// 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 +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// 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 +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// iter_type get_year(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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 + +// + +// class time_get_byname + +// iter_type get_year(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef input_iterator I; + +typedef std::time_get_byname 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// explicit time_get(size_t refs = 0); + +#include +#include + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// dateorder date_order() const; + +#include +#include +#include "test_iterators.h" + +typedef std::time_get > 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_date(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_date(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// 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 +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_monthname(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_monthname(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// 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 +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_time(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_time(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_weekday(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type +// get_weekday(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_get + +// iter_type get_year(iter_type s, iter_type end, ios_base& str, +// ios_base::iostate& err, tm* t) const; + +#include +#include +#include "test_iterators.h" + +typedef input_iterator I; + +typedef std::time_get 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_base +// { +// public: +// enum dateorder {no_order, dmy, mdy, ymd, ydm}; +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_base +// { +// public: +// enum dateorder {no_order, dmy, mdy, ymd, ydm}; +// }; +// +// template > +// class time_get +// : public locale::facet, +// public time_base +// { +// public: +// typedef charT char_type; +// typedef InputIterator iter_type; + +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::iter_type, std::istreambuf_iterator >::value), ""); + static_assert((std::is_same::iter_type, std::istreambuf_iterator >::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 + +// + +// template > +// class time_put_byname +// : public time_put +// { +// 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 +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +typedef std::time_put_byname > 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 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(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(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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_put + +// explicit time_put(size_t refs = 0); + +#include +#include + +typedef std::time_put 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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_put + +// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t, +// const charT* pattern, const charT* pat_end) const; + +#include +#include +#include "test_iterators.h" + +typedef std::time_put > 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 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(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(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. +// +//===----------------------------------------------------------------------===// + +// + +// class time_put + +// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t, +// char format, char modifier = 0) const; + +#include +#include +#include "test_iterators.h" + +typedef std::time_put > 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 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(str), ios, '*', &t, 'A'); + std::string ex(str, iter.base()); + assert(ex == "Saturday"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'a'); + std::string ex(str, iter.base()); + assert(ex == "Sat"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'B'); + std::string ex(str, iter.base()); + assert(ex == "May"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'b'); + std::string ex(str, iter.base()); + assert(ex == "May"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'C'); + std::string ex(str, iter.base()); + assert(ex == "20"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'c'); + std::string ex(str, iter.base()); + assert(ex == "Sat May 2 13:03:06 2009"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'D'); + std::string ex(str, iter.base()); + assert(ex == "05/02/09"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'd'); + std::string ex(str, iter.base()); + assert(ex == "02"); + } + { + iter = f.put(output_iterator(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(str), ios, '*', &t, 'C', 'E'); + std::string ex(str, iter.base()); + assert(ex == "20"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'x', 'E'); + std::string ex(str, iter.base()); + assert(ex == "05/02/09"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'X', 'E'); + std::string ex(str, iter.base()); + assert(ex == "13:03:06"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'y', 'E'); + std::string ex(str, iter.base()); + assert(ex == "09"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'Y', 'E'); + std::string ex(str, iter.base()); + assert(ex == "2009"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'd', 'O'); + std::string ex(str, iter.base()); + assert(ex == "02"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'e', 'O'); + std::string ex(str, iter.base()); + assert(ex == " 2"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'H', 'O'); + std::string ex(str, iter.base()); + assert(ex == "13"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'I', 'O'); + std::string ex(str, iter.base()); + assert(ex == "01"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'm', 'O'); + std::string ex(str, iter.base()); + assert(ex == "05"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'M', 'O'); + std::string ex(str, iter.base()); + assert(ex == "03"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'S', 'O'); + std::string ex(str, iter.base()); + assert(ex == "06"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'u', 'O'); + std::string ex(str, iter.base()); + assert(ex == "6"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'U', 'O'); + std::string ex(str, iter.base()); + assert(ex == "17"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'V', 'O'); + std::string ex(str, iter.base()); + assert(ex == "18"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'w', 'O'); + std::string ex(str, iter.base()); + assert(ex == "6"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'W', 'O'); + std::string ex(str, iter.base()); + assert(ex == "17"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'y', 'O'); + std::string ex(str, iter.base()); + assert(ex == "09"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'e'); + std::string ex(str, iter.base()); + assert(ex == " 2"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'F'); + std::string ex(str, iter.base()); + assert(ex == "2009-05-02"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'G'); + std::string ex(str, iter.base()); + assert(ex == "2009"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'g'); + std::string ex(str, iter.base()); + assert(ex == "09"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'H'); + std::string ex(str, iter.base()); + assert(ex == "13"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'h'); + std::string ex(str, iter.base()); + assert(ex == "May"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'I'); + std::string ex(str, iter.base()); + assert(ex == "01"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'j'); + std::string ex(str, iter.base()); + assert(ex == "122"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'M'); + std::string ex(str, iter.base()); + assert(ex == "03"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'm'); + std::string ex(str, iter.base()); + assert(ex == "05"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'n'); + std::string ex(str, iter.base()); + assert(ex == "\n"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'p'); + std::string ex(str, iter.base()); + assert(ex == "PM"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'R'); + std::string ex(str, iter.base()); + assert(ex == "13:03"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'r'); + std::string ex(str, iter.base()); + assert(ex == "01:03:06 PM"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'S'); + std::string ex(str, iter.base()); + assert(ex == "06"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'T'); + std::string ex(str, iter.base()); + assert(ex == "13:03:06"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 't'); + std::string ex(str, iter.base()); + assert(ex == "\t"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'U'); + std::string ex(str, iter.base()); + assert(ex == "17"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'u'); + std::string ex(str, iter.base()); + assert(ex == "6"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'V'); + std::string ex(str, iter.base()); + assert(ex == "18"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'W'); + std::string ex(str, iter.base()); + assert(ex == "17"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'w'); + std::string ex(str, iter.base()); + assert(ex == "6"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'X'); + std::string ex(str, iter.base()); + assert(ex == "13:03:06"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'x'); + std::string ex(str, iter.base()); + assert(ex == "05/02/09"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'Y'); + std::string ex(str, iter.base()); + assert(ex == "2009"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'y'); + std::string ex(str, iter.base()); + assert(ex == "09"); + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'Z'); + std::string ex(str, iter.base()); +// assert(ex == "EDT"); depends on time zone + } + { + iter = f.put(output_iterator(str), ios, '*', &t, 'z'); + std::string ex(str, iter.base()); +// assert(ex == "-0400"); depends on time zone + } + { + iter = f.put(output_iterator(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(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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class time_put +// : public locale::facet +// { +// public: +// typedef charT char_type; +// typedef OutputIterator iter_type; + +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_base_of >::value), ""); + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::iter_type, std::ostreambuf_iterator >::value), ""); + static_assert((std::is_same::iter_type, std::ostreambuf_iterator >::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 + +// + +// template class numpunct_byname; + +// char_type decimal_point() const; + +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l("C"); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.decimal_point() == '.'); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(l); + assert(np.decimal_point() == L'.'); + } + } + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.decimal_point() == '.'); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(l); + assert(np.decimal_point() == L'.'); + } + } + { + std::locale l(LOCALE_fr_FR_UTF_8); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.decimal_point() == ','); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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 + +// + +// template class numpunct_byname; + +// string grouping() const; + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l("C"); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.grouping() == ""); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(l); + assert(np.grouping() == ""); + } + } + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.grouping() == "\3\3"); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(l); + assert(np.grouping() == "\3\3"); + } + } + { + std::locale l(LOCALE_fr_FR_UTF_8); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.grouping() == "\x7F"); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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 + +// + +// template class numpunct_byname; + +// char_type thousands_sep() const; + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::locale l("C"); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.thousands_sep() == ','); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(l); + assert(np.thousands_sep() == L','); + } + } + { + std::locale l(LOCALE_en_US_UTF_8); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.thousands_sep() == ','); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(l); + assert(np.thousands_sep() == L','); + } + } + { + std::locale l(LOCALE_fr_FR_UTF_8); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.thousands_sep() == ','); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class numpunct; + +// explicit numpunct(size_t refs = 0); + +#include +#include + +template +class my_facet + : public std::numpunct +{ +public: + static int count; + + explicit my_facet(std::size_t refs = 0) + : std::numpunct(refs) {++count;} + + ~my_facet() {--count;} +}; + +template 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); + { + 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/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. +// +//===----------------------------------------------------------------------===// + +// + +// template class numpunct; + +// char_type decimal_point() const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.decimal_point() == '.'); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class numpunct; + +// string_type falsename() const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.falsename() == std::string("false")); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class numpunct; + +// string grouping() const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.grouping() == std::string()); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class numpunct; + +// char_type thousands_sep() const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.thousands_sep() == ','); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class numpunct; + +// string_type truename() const; + +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + typedef char C; + const std::numpunct& np = std::use_facet >(l); + assert(np.truename() == std::string("true")); + } + { + typedef wchar_t C; + const std::numpunct& np = std::use_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class numpunct +// : public locale::facet +// { +// public: +// typedef charT char_type; +// typedef basic_string string_type; +// static locale::id id; + +#include +#include +#include + +int main() +{ + std::locale l = std::locale::classic(); + { + assert(std::has_facet >(l)); + const std::numpunct& f = std::use_facet >(l); + { + (void)std::numpunct::id; + } + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::string_type, std::string>::value), ""); + static_assert((std::is_base_of >::value), ""); + } + { + assert(std::has_facet >(l)); + const std::numpunct& f = std::use_facet >(l); + { + (void)std::numpunct::id; + } + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::string_type, std::wstring>::value), ""); + static_assert((std::is_base_of >::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. +// +//===----------------------------------------------------------------------===// + +// + +// enum codecvt_mode +// { +// consume_header = 4, +// generate_header = 2, +// little_endian = 1 +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// Not a portable test + +#include +#include +#include + +#include "count_new.hpp" + +int main() +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + typedef std::codecvt_utf16 C; + C c; + assert(globalMemCounter.checkOutstandingNewEq(0)); + } + { + typedef std::codecvt_utf16 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// bool always_noconv() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf16 C; + C c; + bool r = c.always_noconv(); + assert(r == false); + } + { + typedef std::codecvt_utf16 C; + C c; + bool r = c.always_noconv(); + assert(r == false); + } + { + typedef std::codecvt_utf16 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// int encoding() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf16 C; + C c; + int r = c.encoding(); + assert(r == 0); + } + { + typedef std::codecvt_utf16 C; + C c; + int r = c.encoding(); + assert(r == 0); + } + { + typedef std::codecvt_utf16 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // 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 +#include + +int main() +{ + { + typedef std::codecvt_utf16 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// int length(stateT& state, const externT* from, const externT* from_end, +// size_t max) const; + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf16 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// int max_length() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf16 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf16 C; + C c; + int r = c.max_length(); + assert(r == 6); + } + { + typedef std::codecvt_utf16 C; + C c; + int r = c.max_length(); + assert(r == 2); + } + { + typedef std::codecvt_utf16 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf16 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf16 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // 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 +#include + +int main() +{ + { + typedef std::codecvt_utf16 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// result +// unshift(stateT& state, +// externT* to, externT* to_end, externT*& to_next) const; + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf16 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // unspecified +// }; + +// Not a portable test + +#include +#include +#include + +#include "count_new.hpp" + +int main() +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + typedef std::codecvt_utf8 C; + C c; + assert(globalMemCounter.checkOutstandingNewEq(0)); + } + { + typedef std::codecvt_utf8 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // unspecified +// }; + +// bool always_noconv() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8 C; + C c; + bool r = c.always_noconv(); + assert(r == false); + } + { + typedef std::codecvt_utf8 C; + C c; + bool r = c.always_noconv(); + assert(r == false); + } + { + typedef std::codecvt_utf8 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // unspecified +// }; + +// int encoding() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8 C; + C c; + int r = c.encoding(); + assert(r == 0); + } + { + typedef std::codecvt_utf8 C; + C c; + int r = c.encoding(); + assert(r == 0); + } + { + typedef std::codecvt_utf8 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // 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 +#include + +int main() +{ + { + typedef std::codecvt_utf8 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // unspecified +// }; + +// int length(stateT& state, const externT* from, const externT* from_end, +// size_t max) const; + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // unspecified +// }; + +// int max_length() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf8 C; + C c; + int r = c.max_length(); + assert(r == 7); + } + { + typedef std::codecvt_utf8 C; + C c; + int r = c.max_length(); + assert(r == 3); + } + { + typedef std::codecvt_utf8 C; + C c; + int r = c.max_length(); + assert(r == 6); + } + { + typedef std::codecvt_utf8 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf8 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // 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 +#include + +int main() +{ + { + typedef std::codecvt_utf8 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8 +// : public codecvt +// { +// // unspecified +// }; + +// result +// unshift(stateT& state, +// externT* to, externT* to_end, externT*& to_next) const; + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// bool always_noconv() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8_utf16 C; + C c; + bool r = c.always_noconv(); + assert(r == false); + } + { + typedef std::codecvt_utf8_utf16 C; + C c; + bool r = c.always_noconv(); + assert(r == false); + } + { + typedef std::codecvt_utf8_utf16 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// int encoding() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8_utf16 C; + C c; + int r = c.encoding(); + assert(r == 0); + } + { + typedef std::codecvt_utf8_utf16 C; + C c; + int r = c.encoding(); + assert(r == 0); + } + { + typedef std::codecvt_utf8_utf16 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8_utf16 +// : public codecvt +// { +// // 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 +#include + +int main() +{ + { + typedef std::codecvt_utf8_utf16 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// int length(stateT& state, const externT* from, const externT* from_end, +// size_t max) const; + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8_utf16 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// int max_length() const throw(); + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8_utf16 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf8_utf16 C; + C c; + int r = c.max_length(); + assert(r == 7); + } + { + typedef std::codecvt_utf8_utf16 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf8_utf16 C; + C c; + int r = c.max_length(); + assert(r == 7); + } + { + typedef std::codecvt_utf8_utf16 C; + C c; + int r = c.max_length(); + assert(r == 4); + } + { + typedef std::codecvt_utf8_utf16 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8_utf16 +// : public codecvt +// { +// // 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 +#include + +int main() +{ + { + typedef std::codecvt_utf8_utf16 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class codecvt_utf8_utf16 +// : public codecvt +// { +// // unspecified +// }; + +// result +// unshift(stateT& state, +// externT* to, externT* to_end, externT*& to_next) const; + +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8_utf16 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isalnum (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isalpha (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool iscntrl (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isdigit (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isgraph (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool islower (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isprint (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool ispunct (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isspace (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isupper (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool isxdigit (charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +// wbuffer_convert(streambuf *bytebuf = 0, Codecvt *pcvt = new Codecvt, +// state_type state = state_type()); + +#include +#include +#include +#include + +#include "count_new.hpp" + +int main() +{ + typedef std::wbuffer_convert > B; +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible::value, ""); + static_assert( std::is_constructible::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); + assert(b.rdbuf() == s.rdbuf()); + assert(globalMemCounter.checkOutstandingNewNotEq(0)); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::stringstream s; + B b(s.rdbuf(), new std::codecvt_utf8, 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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +// int_type overflow(int_type c = traits::eof()); + +// This test is not entirely portable + +#include +#include +#include +#include + +struct test_buf + : public std::wbuffer_convert > +{ + typedef std::wbuffer_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +// int_type pbackfail(int_type c = traits::eof()); + +// This test is not entirely portable + +#include +#include +#include +#include + +struct test_buf + : public std::wbuffer_convert > +{ + typedef std::wbuffer_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +// streambuf *rdbuf(streambuf *bytebuf); + +#include +#include +#include +#include + +int main() +{ + typedef std::wbuffer_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +// 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 +#include +#include +#include + +class test_codecvt + : public std::codecvt +{ + typedef std::codecvt 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_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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +// state_type state() const; + +#include +#include +#include +#include + +int main() +{ + typedef std::wbuffer_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +#include +#include +#include +#include + +int main() +{ + { + std::ofstream bytestream("myfile.txt"); + std::wbuffer_convert > mybuf(bytestream.rdbuf()); + std::wostream mystr(&mybuf); + mystr << L"Hello" << std::endl; + } + { + std::ifstream bytestream("myfile.txt"); + std::wbuffer_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// wbuffer_convert + +// int_type underflow(); + +// This test is not entirely portable + +#include +#include +#include +#include + +struct test_buf + : public std::wbuffer_convert > +{ + typedef std::wbuffer_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template charT tolower(charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template charT toupper(charT c, const locale& loc); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// wstring_convert + +// size_t converted() const; + +#include +#include +#include + +int main() +{ + typedef std::codecvt_utf8 Codecvt; + typedef std::wstring_convert 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. +// +//===----------------------------------------------------------------------===// + +// + +// wstring_convert + +// wstring_convert(Codecvt* pcvt = new Codecvt); + +#include +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8 Codecvt; + typedef std::wstring_convert Myconv; + Myconv myconv; + assert(myconv.converted() == 0); + } + { + typedef std::codecvt_utf8 Codecvt; + typedef std::wstring_convert Myconv; + Myconv myconv(new Codecvt); + assert(myconv.converted() == 0); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible::value, ""); + static_assert( std::is_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// wstring_convert + +// wstring_convert(Codecvt* pcvt, state_type state); + +#include +#include +#include + +int main() +{ + { + typedef std::codecvt_utf8 Codecvt; + typedef std::wstring_convert 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. +// +//===----------------------------------------------------------------------===// + +// + +// wstring_convert + +// wstring_convert(const byte_string& byte_err, +// const wide_string& wide_err = wide_string()); + +#include +#include +#include + +int main() +{ + typedef std::codecvt_utf8 Codecvt; + typedef std::wstring_convert Myconv; +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible::value, ""); + static_assert( std::is_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// wstring_convert + +// 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 +#include +#include + +int main() +{ + { + std::wstring_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// wstring_convert + +// state_type state() const; + +#include +#include + +int main() +{ + typedef std::codecvt_utf8 Codecvt; + typedef std::wstring_convert 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. +// +//===----------------------------------------------------------------------===// + +// + +// wstring_convert + +// 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 +#include +#include + +int main() +{ + { + std::wstring_convert > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template, +// class Byte_alloc = allocator> +// class wstring_convert +// { +// public: +// typedef basic_string, Byte_alloc> byte_string; +// typedef basic_string, Wide_alloc> wide_string; +// typedef typename Codecvt::state_type state_type; +// typedef typename wide_string::traits_type::int_type int_type; + +#include +#include + +int main() +{ + { + typedef std::wstring_convert > myconv; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template bool has_facet(const locale& loc) throw(); + +#include +#include + +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 >(loc)); + assert(!std::has_facet(loc)); + std::locale loc2(loc, new my_facet); + assert(std::has_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. +// +//===----------------------------------------------------------------------===// + +// + +// template const Facet& use_facet(const locale& loc); + +#include +#include + +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(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(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 + +// + +// const locale& operator=(const locale& other) throw(); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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 + +// + +// explicit locale(const char* std_name); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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(const locale& other) throw(); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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() throw(); + +#include +#include + +#include "platform_support.h" // locale name macros +#include "count_new.hpp" + +void check(const std::locale& loc) +{ + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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(const locale& other, const char* std_name, category); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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 + +// + +// template locale(const locale& other, Facet* f); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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(loc2))); + const my_facet& f = std::use_facet(loc2); + assert(f.test() == 5); + } + assert(new_called == 0); +} +{ + { + std::locale loc; + check(loc); + std::locale loc2(loc, (std::ctype*)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(const locale& other, const locale& one, category cats); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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(const locale& other, const string& std_name, category cat); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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 + +// + +// explicit locale(const string& std_name); + +#include +#include +#include + +#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 >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// template locale combine(const locale& other) const; + +#include +#include + +#include "count_new.hpp" + +void check(const std::locale& loc) +{ + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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(loc2); + check(loc3); + assert(loc3.name() == "*"); + assert((std::has_facet(loc3))); + const my_facet& f = std::use_facet(loc3); + assert(f.test() == 5); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); +} +{ + { + std::locale loc; + std::locale loc2; + try + { + std::locale loc3 = loc.combine(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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string name() const; + +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator()(const basic_string& s1, +// const basic_string& s2) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string name() const; + +#include +#include + +#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 >(cloc); + std::locale nonamec = noname1; + std::locale noname2 = n1.combine >(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. +// +//===----------------------------------------------------------------------===// + +// + +// static const locale& classic(); + +#include +#include + +void check(const std::locale& loc) +{ + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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. +// +//===----------------------------------------------------------------------===// + +// + +// static const locale& classic(); + +#include +#include + +#include "platform_support.h" // locale name macros + +void check(const std::locale& loc) +{ + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + + assert(std::has_facet >(loc)); + assert(std::has_facet >(loc)); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + assert((std::has_facet >(loc))); + + assert((std::has_facet >(loc))); + assert((std::has_facet >(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 + +// + +// typedef int category; + +#include +#include +#include + +template +void test(const _Tp &) {} + + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class locale::id +// { +// public: +// id(); +// void operator=(const id&) = delete; +// id(const id&) = delete; +// }; + +// This test isn't portable + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#include "hexfloat.h" + +// convertible to int/float/double/etc +template +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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::abs(-1.) == 1); +} + +void test_acos() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::acos(1) == 0); +} + +void test_asin() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::asin(0) == 0); +} + +void test_atan() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::atan(0) == 0); +} + +void test_atan2() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::atan2(0,1) == 0); +} + +void test_ceil() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::ceil(0) == 0); +} + +void test_cos() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::cos(0) == 1); +} + +void test_cosh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::cosh(0) == 1); +} + +void test_exp() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::exp(0) == 1); +} + +void test_fabs() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::fabs(-1) == 1); +} + +void test_floor() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::floor(1) == 1); +} + +void test_fmod() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::fmod(1.5,1) == .5); +} + +void test_frexp() +{ + int ip; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::frexp(0, &ip) == 0); +} + +void test_ldexp() +{ + int ip = 1; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::ldexp(1, ip) == 2); +} + +void test_log() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::log(1) == 0); +} + +void test_log10() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::log10(1) == 0); +} + +void test_modf() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + double i; + assert(std::modf(1., &i) == 0); +} + +void test_pow() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +// static_assert((std::is_same(), (int)0)), double>::value), ""); +// static_assert((std::is_same(), (float)0)), long double>::value), ""); +// static_assert((std::is_same())), float>::value), ""); + static_assert((std::is_same::value), ""); + assert(std::pow(1,1) == 1); +// assert(std::pow(Value(), Value()) == 1); +// assert(std::pow(1.0f, Value()) == 1); +// assert(std::pow(1.0, Value()) == 1); +// assert(std::pow(Value(), 1LL) == 1); +} + +void test_sin() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::sin(0) == 0); +} + +void test_sinh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::sinh(0) == 0); +} + +void test_sqrt() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::sqrt(4) == 2); +} + +void test_tan() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::tan(0) == 0); +} + +void test_tanh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::tanh(0) == 0); +} + +void test_signbit() +{ +#ifdef signbit +#error signbit defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::signbit(-1.0) == true); +} + +void test_fpclassify() +{ +#ifdef fpclassify +#error fpclassify defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::fpclassify(-1.0) == FP_NORMAL); +} + +void test_isfinite() +{ +#ifdef isfinite +#error isfinite defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::isfinite(-1.0) == true); +} + +void test_isnormal() +{ +#ifdef isnormal +#error isnormal defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::isnormal(-1.0) == true); +} + +void test_isgreater() +{ +#ifdef isgreater +#error isgreater defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::isgreater(-1.0, 0.F) == false); +} + +void test_isgreaterequal() +{ +#ifdef isgreaterequal +#error isgreaterequal defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::isgreaterequal(-1.0, 0.F) == false); +} + +void test_isless() +{ +#ifdef isless +#error isless defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::isless(-1.0, 0.F) == true); +} + +void test_islessequal() +{ +#ifdef islessequal +#error islessequal defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::islessequal(-1.0, 0.F) == true); +} + +void test_islessgreater() +{ +#ifdef islessgreater +#error islessgreater defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::islessgreater(-1.0, 0.F) == true); +} + +void test_isunordered() +{ +#ifdef isunordered +#error isunordered defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::isunordered(-1.0, 0.F) == false); +} + +void test_acosh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::acosh(1) == 0); +} + +void test_asinh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::asinh(0) == 0); +} + +void test_atanh() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::atanh(0) == 0); +} + +void test_cbrt() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::cbrt(1) == 1); +} + +void test_copysign() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::copysign(1,1) == 1); +} + +void test_erf() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::erf(0) == 0); +} + +void test_erfc() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::erfc(0) == 1); +} + +void test_exp2() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::exp2(1) == 2); +} + +void test_expm1() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::expm1(0) == 0); +} + +void test_fdim() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::fdim(1,0) == 1); +} + +void test_fma() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::fma(1,1,1) == 2); +} + +void test_fmax() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::fmax(1,0) == 1); +} + +void test_fmin() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::fmin(1,0) == 0); +} + +void test_hypot() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::hypot(3,4) == 5); +} + +void test_ilogb() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::ilogb(1) == 0); +} + +void test_lgamma() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::lgamma(1) == 0); +} + +void test_llrint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::llrint(1) == 1LL); +} + +void test_llround() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::llround(1) == 1LL); +} + +void test_log1p() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::log1p(0) == 0); +} + +void test_log2() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::log2(1) == 0); +} + +void test_logb() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::logb(1) == 0); +} + +void test_lrint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::lrint(1) == 1L); +} + +void test_lround() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::lround(1) == 1L); +} + +void test_nan() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +void test_nearbyint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::nearbyint(1) == 1); +} + +void test_nextafter() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::nextafter(0,1) == hexfloat(0x1, 0, -1074)); +} + +void test_nexttoward() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::nexttoward(0, 1) == hexfloat(0x1, 0, -1074)); +} + +void test_remainder() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::remainder(0.5,1) == 0.5); +} + +void test_remquo() +{ + int ip; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::remquo(0.5,1, &ip) == 0.5); +} + +void test_rint() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::rint(1) == 1); +} + +void test_round() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::round(1) == 1); +} + +void test_scalbln() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::scalbln(1, 1) == 2); +} + +void test_scalbn() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::scalbn(1, 1) == 2); +} + +void test_tgamma() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(std::tgamma(1) == 1); +} + +void test_trunc() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// isinf + +// XFAIL: linux + +#include +#include +#include + +int main() +{ +#ifdef isinf +#error isinf defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// isnan + +// XFAIL: linux + +#include +#include +#include + +int main() +{ +#ifdef isnan +#error isnan defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// test cases + +#ifndef CASES_H +#define CASES_H + +#include +#include + +std::complex x[] = +{ + std::complex( 1.e-6, 1.e-6), + std::complex(-1.e-6, 1.e-6), + std::complex(-1.e-6, -1.e-6), + std::complex( 1.e-6, -1.e-6), + + std::complex( 1.e+6, 1.e-6), + std::complex(-1.e+6, 1.e-6), + std::complex(-1.e+6, -1.e-6), + std::complex( 1.e+6, -1.e-6), + + std::complex( 1.e-6, 1.e+6), + std::complex(-1.e-6, 1.e+6), + std::complex(-1.e-6, -1.e+6), + std::complex( 1.e-6, -1.e+6), + + std::complex( 1.e+6, 1.e+6), + std::complex(-1.e+6, 1.e+6), + std::complex(-1.e+6, -1.e+6), + std::complex( 1.e+6, -1.e+6), + + std::complex(NAN, NAN), + std::complex(-INFINITY, NAN), + std::complex(-2, NAN), + std::complex(-1, NAN), + std::complex(-0.5, NAN), + std::complex(-0., NAN), + std::complex(+0., NAN), + std::complex(0.5, NAN), + std::complex(1, NAN), + std::complex(2, NAN), + std::complex(INFINITY, NAN), + + std::complex(NAN, -INFINITY), + std::complex(-INFINITY, -INFINITY), + std::complex(-2, -INFINITY), + std::complex(-1, -INFINITY), + std::complex(-0.5, -INFINITY), + std::complex(-0., -INFINITY), + std::complex(+0., -INFINITY), + std::complex(0.5, -INFINITY), + std::complex(1, -INFINITY), + std::complex(2, -INFINITY), + std::complex(INFINITY, -INFINITY), + + std::complex(NAN, -2), + std::complex(-INFINITY, -2), + std::complex(-2, -2), + std::complex(-1, -2), + std::complex(-0.5, -2), + std::complex(-0., -2), + std::complex(+0., -2), + std::complex(0.5, -2), + std::complex(1, -2), + std::complex(2, -2), + std::complex(INFINITY, -2), + + std::complex(NAN, -1), + std::complex(-INFINITY, -1), + std::complex(-2, -1), + std::complex(-1, -1), + std::complex(-0.5, -1), + std::complex(-0., -1), + std::complex(+0., -1), + std::complex(0.5, -1), + std::complex(1, -1), + std::complex(2, -1), + std::complex(INFINITY, -1), + + std::complex(NAN, -0.5), + std::complex(-INFINITY, -0.5), + std::complex(-2, -0.5), + std::complex(-1, -0.5), + std::complex(-0.5, -0.5), + std::complex(-0., -0.5), + std::complex(+0., -0.5), + std::complex(0.5, -0.5), + std::complex(1, -0.5), + std::complex(2, -0.5), + std::complex(INFINITY, -0.5), + + std::complex(NAN, -0.), + std::complex(-INFINITY, -0.), + std::complex(-2, -0.), + std::complex(-1, -0.), + std::complex(-0.5, -0.), + std::complex(-0., -0.), + std::complex(+0., -0.), + std::complex(0.5, -0.), + std::complex(1, -0.), + std::complex(2, -0.), + std::complex(INFINITY, -0.), + + std::complex(NAN, +0.), + std::complex(-INFINITY, +0.), + std::complex(-2, +0.), + std::complex(-1, +0.), + std::complex(-0.5, +0.), + std::complex(-0., +0.), + std::complex(+0., +0.), + std::complex(0.5, +0.), + std::complex(1, +0.), + std::complex(2, +0.), + std::complex(INFINITY, +0.), + + std::complex(NAN, 0.5), + std::complex(-INFINITY, 0.5), + std::complex(-2, 0.5), + std::complex(-1, 0.5), + std::complex(-0.5, 0.5), + std::complex(-0., 0.5), + std::complex(+0., 0.5), + std::complex(0.5, 0.5), + std::complex(1, 0.5), + std::complex(2, 0.5), + std::complex(INFINITY, 0.5), + + std::complex(NAN, 1), + std::complex(-INFINITY, 1), + std::complex(-2, 1), + std::complex(-1, 1), + std::complex(-0.5, 1), + std::complex(-0., 1), + std::complex(+0., 1), + std::complex(0.5, 1), + std::complex(1, 1), + std::complex(2, 1), + std::complex(INFINITY, 1), + + std::complex(NAN, 2), + std::complex(-INFINITY, 2), + std::complex(-2, 2), + std::complex(-1, 2), + std::complex(-0.5, 2), + std::complex(-0., 2), + std::complex(+0., 2), + std::complex(0.5, 2), + std::complex(1, 2), + std::complex(2, 2), + std::complex(INFINITY, 2), + + std::complex(NAN, INFINITY), + std::complex(-INFINITY, INFINITY), + std::complex(-2, INFINITY), + std::complex(-1, INFINITY), + std::complex(-0.5, INFINITY), + std::complex(-0., INFINITY), + std::complex(+0., INFINITY), + std::complex(0.5, INFINITY), + std::complex(1, INFINITY), + std::complex(2, INFINITY), + std::complex(INFINITY, INFINITY) +}; + +enum {zero, non_zero, inf, NaN, non_zero_nan}; + +template +int +classify(const std::complex& x) +{ + if (x == std::complex()) + 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// arg(T x); + +#include +#include +#include + +#include "../cases.h" + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::value), ""); + assert(std::arg(x) == arg(std::complex(x, 0))); +} + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::value), ""); + assert(std::arg(x) == arg(std::complex(x, 0))); +} + +template +void +test() +{ + test(0); + test(1); + test(10); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template complex conj(const complex&); +// complex conj(long double); +// complex conj(double); +// template complex conj(T); +// complex conj(float); + +#include +#include +#include + +#include "../cases.h" + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same >::value), ""); + assert(std::conj(x) == conj(std::complex(x, 0))); +} + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same >::value), ""); + assert(std::conj(x) == conj(std::complex(x, 0))); +} + +template +void +test(T x, typename std::enable_if::value && + !std::is_floating_point::value>::type* = 0) +{ + static_assert((std::is_same >::value), ""); + assert(std::conj(x) == conj(std::complex(x, 0))); +} + +template +void +test() +{ + test(0); + test(1); + test(10); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// imag(const T& x); + +#include +#include +#include + +#include "../cases.h" + +template +void +test(typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::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{val, val}; + static_assert(t.imag() == x, "" ); +#endif +} + +template +void +test(typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::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{val, val}; + static_assert(t.imag() == x, "" ); +#endif +} + +template +void +test() +{ + test(); + test(); + test(); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// norm(T x); + +#include +#include +#include + +#include "../cases.h" + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::value), ""); + assert(std::norm(x) == norm(std::complex(x, 0))); +} + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::value), ""); + assert(std::norm(x) == norm(std::complex(x, 0))); +} + +template +void +test() +{ + test(0); + test(1); + test(10); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex::type> +// pow(const T& x, const complex& y); + +// template +// complex::type> +// pow(const complex& x, const U& y); + +// template +// complex::type> +// pow(const complex& x, const complex& y); + +#include +#include +#include + +#include "../cases.h" + +template +double +promote(T, typename std::enable_if::value>::type* = 0); + +float promote(float); +double promote(double); +long double promote(long double); + +template +void +test(T x, const std::complex& y) +{ + typedef decltype(promote(x)+promote(real(y))) V; + static_assert((std::is_same >::value), ""); + assert(std::pow(x, y) == pow(std::complex(x, 0), std::complex(y))); +} + +template +void +test(const std::complex& x, U y) +{ + typedef decltype(promote(real(x))+promote(y)) V; + static_assert((std::is_same >::value), ""); + assert(std::pow(x, y) == pow(std::complex(x), std::complex(y, 0))); +} + +template +void +test(const std::complex& x, const std::complex& y) +{ + typedef decltype(promote(real(x))+promote(real(y))) V; + static_assert((std::is_same >::value), ""); + assert(std::pow(x, y) == pow(std::complex(x), std::complex(y))); +} + +template +void +test(typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0) +{ + test(T(3), std::complex(4, 5)); + test(std::complex(3, 4), T(5)); +} + +template +void +test(typename std::enable_if::value>::type* = 0, typename std::enable_if::value>::type* = 0) +{ + test(T(3), std::complex(4, 5)); + test(std::complex(3, 4), U(5)); + test(std::complex(3, 4), std::complex(5, 6)); +} + +int main() +{ + test(); + test(); + test(); + + test(); + test(); + test(); + + test(); + test(); + test(); + + test(); + test(); + + test(); + test(); + + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template complex proj(const complex&); +// complex proj(long double); +// complex proj(double); +// template complex proj(T); +// complex proj(float); + +#include +#include +#include + +#include "../cases.h" + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same >::value), ""); + assert(std::proj(x) == proj(std::complex(x, 0))); +} + +template +void +test(T x, typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same >::value), ""); + assert(std::proj(x) == proj(std::complex(x, 0))); +} + +template +void +test(T x, typename std::enable_if::value && + !std::is_floating_point::value>::type* = 0) +{ + static_assert((std::is_same >::value), ""); + assert(std::proj(x) == proj(std::complex(x, 0))); +} + +template +void +test() +{ + test(0); + test(1); + test(10); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// real(const T& x); + +#include +#include +#include + +#include "../cases.h" + +template +void +test(typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::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{val, val}; + static_assert(t.real() == x, "" ); +#endif +} + +template +void +test(typename std::enable_if::value>::type* = 0) +{ + static_assert((std::is_same::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{val, val}; + static_assert(t.real() == x, "" ); +#endif +} + +template +void +test() +{ + test(); + test(); + test(); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals::complex_literals; + +// Make sure the types are right + static_assert ( std::is_same>::value, "" ); + static_assert ( std::is_same>::value, "" ); + static_assert ( std::is_same>::value, "" ); + static_assert ( std::is_same>::value, "" ); + static_assert ( std::is_same>::value, "" ); + static_assert ( std::is_same>::value, "" ); + + { + std::complex c1 = 3.0il; + assert ( c1 == std::complex(0, 3.0)); + auto c2 = 3il; + assert ( c1 == c2 ); + } + + { + std::complex c1 = 3.0i; + assert ( c1 == std::complex(0, 3.0)); + auto c2 = 3i; + assert ( c1 == c2 ); + } + + { + std::complex c1 = 3.0if; + assert ( c1 == std::complex(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 +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals; + + { + std::complex c1 = 3.0il; + assert ( c1 == std::complex(0, 3.0)); + auto c2 = 3il; + assert ( c1 == c2 ); + } + + { + std::complex c1 = 3.0i; + assert ( c1 == std::complex(0, 3.0)); + auto c2 = 3i; + assert ( c1 == c2 ); + } + + { + std::complex c1 = 3.0if; + assert ( c1 == std::complex(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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std; + + { + std::complex c1 = 3.0il; + assert ( c1 == std::complex(0, 3.0)); + auto c2 = 3il; + assert ( c1 == c2 ); + } + + { + std::complex c1 = 3.0i; + assert ( c1 == std::complex(0, 3.0)); + auto c2 = 3i; + assert ( c1 == c2 ); + } + + { + std::complex c1 = 3.0if; + assert ( c1 == std::complex(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& operator=(const complex&); +// template complex& operator= (const complex&); + +#include +#include + +template +void +test() +{ + std::complex c; + assert(c.real() == 0); + assert(c.imag() == 0); + std::complex c2(1.5, 2.5); + c = c2; + assert(c.real() == 1.5); + assert(c.imag() == 2.5); + std::complex c3(3.5, -4.5); + c = c3; + assert(c.real() == 3.5); + assert(c.imag() == -4.5); +} + +int main() +{ + test(); + test(); + test(); + + test(); + test(); + test(); + + test(); + test(); + test(); +} 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& operator= (const T&); + +#include +#include + +template +void +test() +{ + std::complex 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(); + test(); + test(); +} 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& operator/=(const complex& rhs); + +#include +#include + +template +void +test() +{ + std::complex c(-4, 7.5); + const std::complex 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 c3; + + c3 = c; + std::complex ic (1,1); + c3 /= ic; + assert(c3.real() == 0.5); + assert(c3.imag() == -0.5); + + c3 = c; + std::complex fc (1,1); + c3 /= fc; + assert(c3.real() == 0.5); + assert(c3.imag() == -0.5); + +} + +int main() +{ + test(); + test(); + test(); +} 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& operator/=(const T& rhs); + +#include +#include + +template +void +test() +{ + std::complex 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(); + test(); + test(); +} 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& operator-=(const complex& rhs); + +#include +#include + +template +void +test() +{ + std::complex c; + const std::complex 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 c3; + + c3 = c; + std::complex ic (1,1); + c3 -= ic; + assert(c3.real() == -4); + assert(c3.imag() == -6); + + c3 = c; + std::complex fc (1,1); + c3 -= fc; + assert(c3.real() == -4); + assert(c3.imag() == -6); +} + +int main() +{ + test(); + test(); + test(); +} 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& operator-=(const T& rhs); + +#include +#include + +template +void +test() +{ + std::complex 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(); + test(); + test(); +} 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& operator+=(const complex& rhs); + +#include +#include + +template +void +test() +{ + std::complex c; + const std::complex 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 c3; + + c3 = c; + std::complex ic (1,1); + c3 += ic; + assert(c3.real() == 4); + assert(c3.imag() == 6); + + c3 = c; + std::complex fc (1,1); + c3 += fc; + assert(c3.real() == 4); + assert(c3.imag() == 6); +} + +int main() +{ + test(); + test(); + test(); +} 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& operator+=(const T& rhs); + +#include +#include + +template +void +test() +{ + std::complex 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(); + test(); + test(); +} 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& operator*=(const complex& rhs); + +#include +#include + +template +void +test() +{ + std::complex c(1); + const std::complex 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 c3; + + c3 = c; + std::complex ic (1,1); + c3 *= ic; + assert(c3.real() == -11.5); + assert(c3.imag() == 3.5); + + c3 = c; + std::complex fc (1,1); + c3 *= fc; + assert(c3.real() == -11.5); + assert(c3.imag() == 3.5); +} + +int main() +{ + test(); + test(); + test(); +} 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& operator*=(const T& rhs); + +#include +#include + +template +void +test() +{ + std::complex 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(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr complex(const T& re = T(), const T& im = T()); + +#include +#include + +template +void +test() +{ + { + const std::complex c; + assert(c.real() == 0); + assert(c.imag() == 0); + } + { + const std::complex c = 7.5; + assert(c.real() == 7.5); + assert(c.imag() == 0); + } + { + const std::complex c(8.5); + assert(c.real() == 8.5); + assert(c.imag() == 0); + } + { + const std::complex c(10.5, -9.5); + assert(c.real() == 10.5); + assert(c.imag() == -9.5); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex c; + static_assert(c.real() == 0, ""); + static_assert(c.imag() == 0, ""); + } + { + constexpr std::complex c = 7.5; + static_assert(c.real() == 7.5, ""); + static_assert(c.imag() == 0, ""); + } + { + constexpr std::complex c(8.5); + static_assert(c.real() == 8.5, ""); + static_assert(c.imag() == 0, ""); + } + { + constexpr std::complex c(10.5, -9.5); + static_assert(c.real() == 10.5, ""); + static_assert(c.imag() == -9.5, ""); + } +#endif +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// void real(T val); +// void imag(T val); + +#include +#include + +template +void +test_constexpr() +{ +#if _LIBCPP_STD_VER > 11 + constexpr std::complex c1; + static_assert(c1.real() == 0, ""); + static_assert(c1.imag() == 0, ""); + constexpr std::complex c2(3); + static_assert(c2.real() == 3, ""); + static_assert(c2.imag() == 0, ""); + constexpr std::complex c3(3, 4); + static_assert(c3.real() == 3, ""); + static_assert(c3.imag() == 4, ""); +#endif +} + +template +void +test() +{ + std::complex 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 (); +} + +int main() +{ + test(); + test(); + test(); + test_constexpr (); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator/(const complex& lhs, const complex& rhs); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs / rhs == x); +} + +template +void +test() +{ + std::complex lhs(-4.0, 7.5); + std::complex rhs(1.5, 2.5); + std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator/(const complex& lhs, const T& rhs); + +#include +#include + +template +void +test(const std::complex& lhs, const T& rhs, std::complex x) +{ + assert(lhs / rhs == x); +} + +template +void +test() +{ + std::complex lhs(-4.0, 7.5); + T rhs(2); + std::complex x(-2, 3.75); + test(lhs, rhs, x); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator==(const complex& lhs, const complex& rhs); + +#include +#include + +template +void +test_constexpr() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::complex lhs(1.5, 2.5); + constexpr std::complex rhs(1.5, -2.5); + static_assert( !(lhs == rhs), ""); + } + { + constexpr std::complex lhs(1.5, 2.5); + constexpr std::complex rhs(1.5, 2.5); + static_assert(lhs == rhs, ""); + } +#endif +} + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + std::complex rhs(1.5, -2.5); + assert( !(lhs == rhs)); + } + { + std::complex lhs(1.5, 2.5); + std::complex rhs(1.5, 2.5); + assert(lhs == rhs); + } + test_constexpr (); +} + +int main() +{ + test(); + test(); + test(); +// test_constexpr (); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator==(const complex& lhs, const T& rhs); + +#include +#include + +template +void +test_constexpr() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::complex lhs(1.5, 2.5); + constexpr T rhs(-2.5); + static_assert(!(lhs == rhs), ""); + } + { + constexpr std::complex lhs(1.5, 0); + constexpr T rhs(-2.5); + static_assert(!(lhs == rhs), ""); + } + { + constexpr std::complex lhs(1.5, 2.5); + constexpr T rhs(1.5); + static_assert(!(lhs == rhs), ""); + } + { + constexpr std::complex lhs(1.5, 0); + constexpr T rhs(1.5); + static_assert( (lhs == rhs), ""); + } +#endif +} + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + T rhs(-2.5); + assert(!(lhs == rhs)); + } + { + std::complex lhs(1.5, 0); + T rhs(-2.5); + assert(!(lhs == rhs)); + } + { + std::complex lhs(1.5, 2.5); + T rhs(1.5); + assert(!(lhs == rhs)); + } + { + std::complex lhs(1.5, 0); + T rhs(1.5); + assert( (lhs == rhs)); + } + + test_constexpr (); + } + +int main() +{ + test(); + test(); + test(); +// test_constexpr (); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator-(const complex& lhs, const complex& rhs); + +#include +#include + +template +void +test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs - rhs == x); +} + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + std::complex rhs(3.5, 4.5); + std::complex x(-2.0, -2.0); + test(lhs, rhs, x); + } + { + std::complex lhs(1.5, -2.5); + std::complex rhs(-3.5, 4.5); + std::complex x(5.0, -7.0); + test(lhs, rhs, x); + } +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator-(const complex& lhs, const T& rhs); + +#include +#include + +template +void +test(const std::complex& lhs, const T& rhs, std::complex x) +{ + assert(lhs - rhs == x); +} + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + T rhs(3.5); + std::complex x(-2.0, 2.5); + test(lhs, rhs, x); + } + { + std::complex lhs(1.5, -2.5); + T rhs(-3.5); + std::complex x(5.0, -2.5); + test(lhs, rhs, x); + } +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator!=(const complex& lhs, const complex& rhs); + +#include +#include + +template +void +test_constexpr() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::complex lhs(1.5, 2.5); + constexpr std::complex rhs(1.5, -2.5); + static_assert(lhs != rhs, ""); + } + { + constexpr std::complex lhs(1.5, 2.5); + constexpr std::complex rhs(1.5, 2.5); + static_assert(!(lhs != rhs), "" ); + } +#endif +} + + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + std::complex rhs(1.5, -2.5); + assert(lhs != rhs); + } + { + std::complex lhs(1.5, 2.5); + std::complex rhs(1.5, 2.5); + assert(!(lhs != rhs)); + } + + test_constexpr (); + } + +int main() +{ + test(); + test(); + test(); +// test_constexpr (); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator!=(const complex& lhs, const T& rhs); + +#include +#include + +template +void +test_constexpr() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr std::complex lhs(1.5, 2.5); + constexpr T rhs(-2.5); + static_assert(lhs != rhs, ""); + } + { + constexpr std::complex lhs(1.5, 0); + constexpr T rhs(-2.5); + static_assert(lhs != rhs, ""); + } + { + constexpr std::complex lhs(1.5, 2.5); + constexpr T rhs(1.5); + static_assert(lhs != rhs, ""); + } + { + constexpr std::complex lhs(1.5, 0); + constexpr T rhs(1.5); + static_assert( !(lhs != rhs), ""); + } +#endif +} + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + T rhs(-2.5); + assert(lhs != rhs); + } + { + std::complex lhs(1.5, 0); + T rhs(-2.5); + assert(lhs != rhs); + } + { + std::complex lhs(1.5, 2.5); + T rhs(1.5); + assert(lhs != rhs); + } + { + std::complex lhs(1.5, 0); + T rhs(1.5); + assert( !(lhs != rhs)); + } + + test_constexpr (); +} + +int main() +{ + test(); + test(); + test(); +// test_constexpr (); + } 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator+(const complex& lhs, const complex& rhs); + +#include +#include + +template +void +test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs + rhs == x); +} + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + std::complex rhs(3.5, 4.5); + std::complex x(5.0, 7.0); + test(lhs, rhs, x); + } + { + std::complex lhs(1.5, -2.5); + std::complex rhs(-3.5, 4.5); + std::complex x(-2.0, 2.0); + test(lhs, rhs, x); + } +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator+(const complex& lhs, const T& rhs); + +#include +#include + +template +void +test(const std::complex& lhs, const T& rhs, std::complex x) +{ + assert(lhs + rhs == x); +} + +template +void +test() +{ + { + std::complex lhs(1.5, 2.5); + T rhs(3.5); + std::complex x(5.0, 2.5); + test(lhs, rhs, x); + } + { + std::complex lhs(1.5, -2.5); + T rhs(-3.5); + std::complex x(-2.0, -2.5); + test(lhs, rhs, x); + } +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator*(const complex& lhs, const complex& rhs); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs * rhs == x); +} + +template +void +test() +{ + std::complex lhs(1.5, 2.5); + std::complex rhs(1.5, 2.5); + std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator*(const complex& lhs, const T& rhs); + +#include +#include + +template +void +test(const std::complex& lhs, const T& rhs, std::complex x) +{ + assert(lhs * rhs == x); +} + +template +void +test() +{ + std::complex lhs(1.5, 2.5); + T rhs(1.5); + std::complex x(2.25, 3.75); + test(lhs, rhs, x); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator/(const T& lhs, const complex& rhs); + +#include +#include + +template +void +test(const T& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs / rhs == x); +} + +template +void +test() +{ + T lhs(-8.5); + std::complex rhs(1.5, 2.5); + std::complex x(-1.5, 2.5); + test(lhs, rhs, x); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator==(const T& lhs, const complex& rhs); + +#include +#include + +template +void +test_constexpr() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr T lhs(-2.5); + constexpr std::complex rhs(1.5, 2.5); + static_assert(!(lhs == rhs), ""); + } + { + constexpr T lhs(-2.5); + constexpr std::complex rhs(1.5, 0); + static_assert(!(lhs == rhs), ""); + } + { + constexpr T lhs(1.5); + constexpr std::complex rhs(1.5, 2.5); + static_assert(!(lhs == rhs), ""); + } + { + constexpr T lhs(1.5); + constexpr std::complex rhs(1.5, 0); + static_assert(lhs == rhs, ""); + } +#endif +} + +template +void +test() +{ + { + T lhs(-2.5); + std::complex rhs(1.5, 2.5); + assert(!(lhs == rhs)); + } + { + T lhs(-2.5); + std::complex rhs(1.5, 0); + assert(!(lhs == rhs)); + } + { + T lhs(1.5); + std::complex rhs(1.5, 2.5); + assert(!(lhs == rhs)); + } + { + T lhs(1.5); + std::complex rhs(1.5, 0); + assert(lhs == rhs); + } + + test_constexpr (); +} + +int main() +{ + test(); + test(); + test(); +// test_constexpr(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator-(const T& lhs, const complex& rhs); + +#include +#include + +template +void +test(const T& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs - rhs == x); +} + +template +void +test() +{ + { + T lhs(1.5); + std::complex rhs(3.5, 4.5); + std::complex x(-2.0, -4.5); + test(lhs, rhs, x); + } + { + T lhs(1.5); + std::complex rhs(-3.5, 4.5); + std::complex x(5.0, -4.5); + test(lhs, rhs, x); + } +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// operator!=(const T& lhs, const complex& rhs); + +#include +#include + +template +void +test_constexpr() +{ +#if _LIBCPP_STD_VER > 11 + { + constexpr T lhs(-2.5); + constexpr std::complex rhs(1.5, 2.5); + static_assert (lhs != rhs, ""); + } + { + constexpr T lhs(-2.5); + constexpr std::complex rhs(1.5, 0); + static_assert (lhs != rhs, ""); + } + { + constexpr T lhs(1.5); + constexpr std::complex rhs(1.5, 2.5); + static_assert (lhs != rhs, ""); + } + { + constexpr T lhs(1.5); + constexpr std::complex rhs(1.5, 0); + static_assert (!(lhs != rhs), ""); + } +#endif +} + +template +void +test() +{ + { + T lhs(-2.5); + std::complex rhs(1.5, 2.5); + assert (lhs != rhs); + } + { + T lhs(-2.5); + std::complex rhs(1.5, 0); + assert (lhs != rhs); + } + { + T lhs(1.5); + std::complex rhs(1.5, 2.5); + assert (lhs != rhs); + } + { + T lhs(1.5); + std::complex rhs(1.5, 0); + assert (!(lhs != rhs)); + } + + test_constexpr (); + } + +int main() +{ + test(); + test(); + test(); +// test_constexpr(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator+(const T& lhs, const complex& rhs); + +#include +#include + +template +void +test(const T& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs + rhs == x); +} + +template +void +test() +{ + { + T lhs(1.5); + std::complex rhs(3.5, 4.5); + std::complex x(5.0, 4.5); + test(lhs, rhs, x); + } + { + T lhs(1.5); + std::complex rhs(-3.5, 4.5); + std::complex x(-2.0, 4.5); + test(lhs, rhs, x); + } +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator*(const T& lhs, const complex& rhs); + +#include +#include + +template +void +test(const T& lhs, const std::complex& rhs, std::complex x) +{ + assert(lhs * rhs == x); +} + +template +void +test() +{ + T lhs(1.5); + std::complex rhs(1.5, 2.5); + std::complex x(2.25, 3.75); + test(lhs, rhs, x); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// operator>>(basic_istream& is, complex& x); + +#include +#include +#include + +int main() +{ + { + std::istringstream is("5"); + std::complex c; + is >> c; + assert(c == std::complex(5, 0)); + assert(is.eof()); + } + { + std::istringstream is(" 5 "); + std::complex c; + is >> c; + assert(c == std::complex(5, 0)); + assert(is.good()); + } + { + std::istringstream is(" 5, "); + std::complex c; + is >> c; + assert(c == std::complex(5, 0)); + assert(is.good()); + } + { + std::istringstream is(" , 5, "); + std::complex c; + is >> c; + assert(c == std::complex(0, 0)); + assert(is.fail()); + } + { + std::istringstream is("5.5 "); + std::complex c; + is >> c; + assert(c == std::complex(5.5, 0)); + assert(is.good()); + } + { + std::istringstream is(" ( 5.5 ) "); + std::complex c; + is >> c; + assert(c == std::complex(5.5, 0)); + assert(is.good()); + } + { + std::istringstream is(" 5.5)"); + std::complex c; + is >> c; + assert(c == std::complex(5.5, 0)); + assert(is.good()); + } + { + std::istringstream is("(5.5 "); + std::complex c; + is >> c; + assert(c == std::complex(0, 0)); + assert(is.fail()); + } + { + std::istringstream is("(5.5,"); + std::complex c; + is >> c; + assert(c == std::complex(0, 0)); + assert(is.fail()); + } + { + std::istringstream is("( -5.5 , -6.5 )"); + std::complex c; + is >> c; + assert(c == std::complex(-5.5, -6.5)); + assert(!is.eof()); + } + { + std::istringstream is("(-5.5,-6.5)"); + std::complex c; + is >> c; + assert(c == std::complex(-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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_ostream& +// operator<<(basic_ostream& o, const complex& x); + +#include +#include +#include + +int main() +{ + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator-(const complex& lhs); + +#include +#include + +template +void +test() +{ + std::complex z(1.5, 2.5); + assert(z.real() == 1.5); + assert(z.imag() == 2.5); + std::complex c = -z; + assert(c.real() == -1.5); + assert(c.imag() == -2.5); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// operator+(const complex&); + +#include +#include + +template +void +test() +{ + std::complex z(1.5, 2.5); + assert(z.real() == 1.5); + assert(z.imag() == 2.5); + std::complex c = +z; + assert(c.real() == 1.5); + assert(c.imag() == 2.5); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf(cd); + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf = cd; + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// explicit constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf(cd); + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// explicit constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + const std::complex cd(2.5, 3.5); + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// explicit constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf(cd); + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// explicit constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + const std::complex cd(2.5, 3.5); + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// explicit constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf(cd); + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// explicit constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + const std::complex cd(2.5, 3.5); + std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf(cd); + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf = cd; + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf(cd); + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> class complex +// { +// public: +// constexpr complex(const complex&); +// }; + +#include +#include + +int main() +{ + { + const std::complex cd(2.5, 3.5); + std::complex cf = cd; + assert(cf.real() == cd.real()); + assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex cd(2.5, 3.5); + constexpr std::complex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// acos(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(acos(c) == x); +} + +template +void +test() +{ + test(std::complex(INFINITY, 1), std::complex(0, -INFINITY)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// acosh(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(acosh(c) == x); +} + +template +void +test() +{ + test(std::complex(INFINITY, 1), std::complex(INFINITY, 0)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// asin(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(asin(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// asinh(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(asinh(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// atan(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(atan(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); +} + +void test_edges() +{ + typedef std::complex C; + const unsigned N = sizeof(x) / sizeof(x[0]); + for (unsigned i = 0; i < N; ++i) + { + std::complex r = atan(x[i]); + std::complex t1(-imag(x[i]), real(x[i])); + std::complex t2 = atanh(t1); + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// atanh(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(atanh(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// cos(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(cos(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(1, 0)); +} + +void test_edges() +{ + typedef std::complex 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 r = cos(x[i]); + std::complex t1(-imag(x[i]), real(x[i])); + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// cosh(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(cosh(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(1, 0)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// exp(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(exp(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(1, 0)); +} + +void test_edges() +{ + const unsigned N = sizeof(x) / sizeof(x[0]); + for (unsigned i = 0; i < N; ++i) + { + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// log(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(log(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(-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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// log10(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(log10(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(-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 r = log10(x[i]); + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// pow(const complex& x, const complex& y); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& a, const std::complex& b, std::complex x) +{ + std::complex c = pow(a, b); + is_about(real(c), real(x)); + is_about(imag(c), imag(x)); +} + +template +void +test() +{ + test(std::complex(2, 3), std::complex(2, 0), std::complex(-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 r = pow(x[i], x[j]); + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// pow(const complex& x, const T& y); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& a, const T& b, std::complex x) +{ + std::complex c = pow(a, b); + is_about(real(c), real(x)); + is_about(imag(c), imag(x)); +} + +template +void +test() +{ + test(std::complex(2, 3), T(2), std::complex(-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 r = pow(x[i], real(x[j])); + std::complex z = exp(std::complex(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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// pow(const T& x, const complex& y); + +#include +#include + +#include "../cases.h" + +template +void +test(const T& a, const std::complex& b, std::complex x) +{ + std::complex c = pow(a, b); + is_about(real(c), real(x)); + assert(std::abs(imag(c)) < 1.e-6); +} + +template +void +test() +{ + test(T(2), std::complex(2), std::complex(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 r = pow(real(x[i]), x[j]); + std::complex z = exp(x[j] * log(std::complex(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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// sin(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(sin(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); +} + +void test_edges() +{ + typedef std::complex 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 r = sin(x[i]); + std::complex t1(-imag(x[i]), real(x[i])); + std::complex t2 = sinh(t1); + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// sinh(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(sinh(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// sqrt(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + std::complex a = sqrt(c); + is_about(real(a), real(x)); + assert(std::abs(imag(c)) < 1.e-6); +} + +template +void +test() +{ + test(std::complex(64, 0), std::complex(8, 0)); +} + +void test_edges() +{ + const unsigned N = sizeof(x) / sizeof(x[0]); + for (unsigned i = 0; i < N; ++i) + { + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// tan(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(tan(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); + test(std::complex(10000, -10000), std::complex(0, -1)); +} + +void test_edges() +{ + typedef std::complex 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 r = tan(x[i]); + std::complex t1(-imag(x[i]), real(x[i])); + std::complex t2 = tanh(t1); + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// tanh(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& c, std::complex x) +{ + assert(tanh(c) == x); +} + +template +void +test() +{ + test(std::complex(0, 0), std::complex(0, 0)); +} + +void test_edges() +{ + typedef std::complex 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 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// abs(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test() +{ + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// arg(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test() +{ + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// conj(const complex& x); + +#include +#include + +template +void +test(const std::complex& z, std::complex x) +{ + assert(conj(z) == x); +} + +template +void +test() +{ + test(std::complex(1, 2), std::complex(1, -2)); + test(std::complex(-1, 2), std::complex(-1, -2)); + test(std::complex(1, -2), std::complex(1, 2)); + test(std::complex(-1, -2), std::complex(-1, 2)); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// imag(const complex& x); + +#include +#include + +template +void +test() +{ + std::complex z(1.5, 2.5); + assert(imag(z) == 2.5); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// norm(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test() +{ + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// polar(const T& rho, const T& theta = 0); + +#include +#include + +#include "../cases.h" + +template +void +test(const T& rho, std::complex x) +{ + assert(std::polar(rho) == x); +} + +template +void +test(const T& rho, const T& theta, std::complex x) +{ + assert(std::polar(rho, theta) == x); +} + +template +void +test() +{ + test(T(0), std::complex(0, 0)); + test(T(1), std::complex(1, 0)); + test(T(100), std::complex(100, 0)); + test(T(0), T(0), std::complex(0, 0)); + test(T(1), T(0), std::complex(1, 0)); + test(T(100), T(0), std::complex(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 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()); + } + 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// complex +// proj(const complex& x); + +#include +#include + +#include "../cases.h" + +template +void +test(const std::complex& z, std::complex x) +{ + assert(proj(z) == x); +} + +template +void +test() +{ + test(std::complex(1, 2), std::complex(1, 2)); + test(std::complex(-1, 2), std::complex(-1, 2)); + test(std::complex(1, -2), std::complex(1, -2)); + test(std::complex(-1, -2), std::complex(-1, -2)); +} + +void test_edges() +{ + const unsigned N = sizeof(x) / sizeof(x[0]); + for (unsigned i = 0; i < N; ++i) + { + std::complex 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(); + test(); + test(); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// T +// real(const complex& x); + +#include +#include + +template +void +test() +{ + std::complex z(1.5, 2.5); + assert(real(z) == 1.5); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class complex +// { +// public: +// typedef T value_type; +// ... +// }; + +#include +#include + +template +void +test() +{ + typedef std::complex C; + static_assert((std::is_same::value), ""); +} + +int main() +{ + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +template +void +test() +{ + std::complex 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(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// class glice; + +// gslice(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class glice; + +// gslice(size_t start, const valarray& size, +// const valarray& stride); + +#include +#include + +int main() +{ + std::size_t a1[] = {1, 2, 3}; + std::size_t a2[] = {4, 5, 6}; + std::valarray size(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray stride(a2, sizeof(a2)/sizeof(a2[0])); + std::gslice gs(7, size, stride); + assert(gs.start() == 7); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// class slice; + +// slice(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class slice; + +// slice(size_t start, size_t size, size_t stride); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// gslice_array() = delete; + +#include +#include + +int main() +{ + std::gslice_array 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// const gslice_array& operator=(const gslice_array& ga) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + const std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator=(const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator+= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator&= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator/= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator%= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator*= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator|= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator<<= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator>>= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator-= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator^= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class gslice_array + +// void operator=(const value_type& x) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gslice_array +// { +// public: +// typedef T value_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// indirect_array() = delete; + +#include +#include + +int main() +{ + std::indirect_array 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// const indirect_array& operator=(const indirect_array& ia) const; + +#include +#include + +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 v1(a1, N1); + const std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator+=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator&=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator/=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator%=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator*=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator|=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator<<=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator>>=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator-=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator^=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class indirect_array + +// void operator=(const value_type& x) const; + +#include +#include + +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 v1(a1, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class indirect_array +// { +// public: +// typedef T value_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// mask_array() = delete; + +#include +#include + +int main() +{ + std::mask_array 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void mask_array& operator=(const mask_array& ma) const; + +#include +#include + +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 v1(a1, N1); + const std::valarray v2(a2, N2); + std::valarray vb1(b1, N1); + std::valarray 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 v1(a1, 3); + std::valarray v2(a2, 3); + std::valarray const vb1(b1, 3); + std::mask_array m1 = v1[vb1]; + std::mask_array const m2 = v2[vb1]; + std::mask_array 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator+=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator&=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator/=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator%=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator*=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator|=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator<<=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator>>=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator-=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator^=(const valarray& v) const; + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + assert(N2 == std::count(b, b+N1, true)); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class mask_array + +// void operator=(const value_type& x) const; + +#include +#include + +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 v1(a1, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mask_array +// { +// public: +// typedef T value_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// slice_array() = delete; + +#include +#include + +int main() +{ + std::slice_array 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// const slice_array& operator=(const slice_array& sa) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + const std::valarray 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 v1(a1, 3); + std::slice_array s1 = v1[std::slice(1, 1, 1)]; + std::slice_array s2 = v1[std::slice(0, 1, 1)]; + std::slice_array 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator=(const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator+= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator&= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator/= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator%= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator*= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator|= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator<<=(const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator>>=(const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator-= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator^= (const valarray& v) const; + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class slice_array + +// void operator=(const value_type& x) const; + +#include +#include + +int main() +{ + int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class slice_array +// { +// public: +// typedef T value_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class valarray +// { +// public: +// typedef T value_type; +// ... + +#include +#include + +int main() +{ + static_assert((std::is_same::value_type, int>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// value_type& operator[](size_t i); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {5, 4, 3, 2, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// const value_type& operator[](size_t i) const; + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {5, 4, 3, 2, 1}; + const unsigned N = sizeof(a)/sizeof(a[0]); + const std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(const valarray& v); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray v2; + v2 = v; + assert(v2.size() == v.size()); + for (int i = 0; i < v2.size(); ++i) + assert(v2[i] == v[i]); + } + { + typedef std::valarray T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(const gslice_array& ga); + +#include +#include + +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 v1(a, sizeof(a)/sizeof(a[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray strides; + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(const indirect_array& ia); + +#include +#include + +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 v1(a, N1); + std::valarray ia(s, S); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(initializer_list il); + +#include +#include + +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 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 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 T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(const mask_array& ma); + +#include +#include + +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 v1(a1, N1); + std::valarray vb(b, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(valarray&& v); + +#include +#include + +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 v(a, N); + std::valarray 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 v(a, N); + std::valarray 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 T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(const slice_array& sa); + +#include +#include + +int main() +{ + int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + std::valarray v1(a, sizeof(a)/sizeof(a[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator=(const value_type& x); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator&=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator&=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator/=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator/=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator-=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator-=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator%=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator%=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator|=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator|=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator+=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator+=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator<<=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator<<=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator>>=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator>>=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator*=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator*=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator^=(const valarray& v); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray& operator^=(const value_type& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const valarray& v); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray v2 = v; + assert(v2.size() == v.size()); + for (int i = 0; i < v2.size(); ++i) + assert(v2[i] == v[i]); + } + { + typedef std::valarray T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(); + +#include +#include + +int main() +{ + { + std::valarray v; + assert(v.size() == 0); + } + { + std::valarray v; + assert(v.size() == 0); + } + { + std::valarray v; + assert(v.size() == 0); + } + { + std::valarray > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const gslice_array& sa); + +#include +#include + +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 v1(a, sizeof(a)/sizeof(a[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray strides; + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const indirect_array& ia); + +#include +#include + +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 v1(a, N1); + std::valarray ia(s, S); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(initializer_list); + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const mask_array& ma); + +#include +#include + +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 v1(a1, N1); + std::valarray vb(b, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const valarray& v); + +#include +#include +#include + +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 v(a, N); + std::valarray 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 v(a, N); + std::valarray 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 T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const value_type* p, size_t n); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray 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 v(a, N); + assert(v.size() == N); + for (int i = 0; i < N; ++i) + assert(v[i] == a[i]); + } + { + typedef std::valarray T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// explicit valarray(size_t); + +#include +#include + +int main() +{ + { + std::valarray v(100); + assert(v.size() == 100); + for (int i = 0; i < 100; ++i) + assert(v[i] == 0); + } + { + std::valarray v(100); + assert(v.size() == 100); + for (int i = 0; i < 100; ++i) + assert(v[i] == 0); + } + { + std::valarray > 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const slice_array& sa); + +#include +#include + +int main() +{ + int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + std::valarray v1(a, sizeof(a)/sizeof(a[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray(const value_type& x, size_t n); + +#include +#include + +int main() +{ + { + std::valarray v(5, 100); + assert(v.size() == 100); + for (int i = 0; i < 100; ++i) + assert(v[i] == 5); + } + { + std::valarray v(2.5, 100); + assert(v.size() == 100); + for (int i = 0; i < 100; ++i) + assert(v[i] == 2.5); + } + { + std::valarray > v(std::valarray(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray apply(value_type f(const value_type&)) const; + +#include +#include + +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 v1(a1, N1); + std::valarray 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 v1; + std::valarray 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 v1(a1, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray apply(value_type f(value_type)) const; + +#include +#include + +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 v1(a1, N1); + std::valarray 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 v1; + std::valarray 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 v1(a1, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray cshift(int i) const; + +#include +#include + +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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1; + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// value_type max() const; + +#include +#include + +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 v1(a1, N1); + assert(v1.max() == 4.0); + } + { + typedef double T; + std::valarray 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// value_type min() const; + +#include +#include + +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 v1(a1, N1); + assert(v1.min() == -3.0); + } + { + typedef double T; + std::valarray 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// void resize(size_t n, value_type x = value_type()); + +#include +#include + +int main() +{ + { + typedef int T; + T a1[] = {1, 2, 3, 4, 5}; + const unsigned N1 = sizeof(a1)/sizeof(a1[0]); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray shift(int i) const; + +#include +#include + +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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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 v1; + std::valarray 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 v1(a1, N1); + std::valarray 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 v1(a1, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// size_t size() const; + +#include +#include + +int main() +{ + { + typedef int T; + T a1[] = {1, 2, 3, 4, 5}; + const unsigned N1 = sizeof(a1)/sizeof(a1[0]); + std::valarray v1(a1, N1); + assert(v1.size() == N1); + } + { + typedef int T; + T a1[] = {1, 2, 3, 4, 5}; + const unsigned N1 = 0; + std::valarray v1(a1, N1); + assert(v1.size() == N1); + } + { + typedef int T; + const unsigned N1 = 0; + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// value_type sum() const; + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// void swap(valarray& v); + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray v1_save = v1; + std::valarray 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 v1(a1, N1); + std::valarray v2; + std::valarray v1_save = v1; + std::valarray 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 v1; + std::valarray v2(a2, N2); + std::valarray v1_save = v1; + std::valarray 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 v1; + std::valarray v2; + std::valarray v1_save = v1; + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// gslice_array operator[](const gslice& gs); + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray v2(a2, sizeof(a2)/sizeof(a2[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator[](const gslice& gs) const; + +#include +#include + +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 v1(a, sizeof(a)/sizeof(a[0])); + std::size_t sz[] = {2, 4, 3}; + std::size_t st[] = {19, 4, 1}; + typedef std::valarray sizes; + typedef std::valarray strides; + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator[](const valarray& vs) const; + +#include +#include + +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 v1(a, N1); + std::valarray ia(s, S); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// indirect_array operator[](const valarray& vs); + +#include +#include + +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 v1(a, N1); + std::valarray ia(s, S); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator[](slice s) const; + +#include +#include + +int main() +{ + int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + std::valarray v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// slice_array operator[](slice s); + +#include +#include + +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 v1(a1, sizeof(a1)/sizeof(a1[0])); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator[](const valarray& vb) const; + +#include +#include + +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 v1(a1, N1); + std::valarray vb(b, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// mask_array operator[](const valarray& vb); + +#include +#include + +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 v1(a1, N1); + std::valarray vb(b, N1); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator~() const; + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray v2 = ~v; + assert(v2.size() == v.size()); + for (int i = 0; i < v2.size(); ++i) + assert(v2[i] == ~v[i]); + } + { + typedef std::valarray T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator-() const; + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray v2 = -v; + assert(v2.size() == v.size()); + for (int i = 0; i < v2.size(); ++i) + assert(v2[i] == -v[i]); + } + { + typedef std::valarray T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator!() const; + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// valarray operator+() const; + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray v2 = +v; + assert(v2.size() == v.size()); + for (int i = 0; i < v2.size(); ++i) + assert(v2[i] == +v[i]); + } + { + typedef std::valarray T; + T a[] = {T(1), T(2), T(3), T(4), T(5)}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray v(a, N); + std::valarray 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 v(a, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator&(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator&(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator&(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator/(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator/(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator/(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator-(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator-(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator-(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator%(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator%(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator%(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator|(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator|(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator|(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator+(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator+(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator+(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator<<(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator<<(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator<<(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator>>(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator>>(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator>>(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator*(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator+(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator*(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator^(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator^(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template valarray operator^(const T& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator&&(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator&&(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator&&(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator==(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator==(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator==(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator>=(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator>=(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator>=(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator>(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator>(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator>(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator<=(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator<=(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator<=(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator<(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator<(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator<(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator!=(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator!=(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator!=(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator||(const valarray& x, const valarray& y); + +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator||(const valarray& x, const T& y); + +#include +#include + +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 v1(a1, N); + std::valarray 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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// operator||(const T& x, const valarray& y); + +#include +#include + +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 v2(a2, N); + std::valarray 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 v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// void +// swap(valarray& x, valarray& y); + +#include +#include + +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 v1(a1, N1); + std::valarray v2(a2, N2); + std::valarray v1_save = v1; + std::valarray 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 v1(a1, N1); + std::valarray v2; + std::valarray v1_save = v1; + std::valarray 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 v1; + std::valarray v2(a2, N2); + std::valarray v1_save = v1; + std::valarray 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 v1; + std::valarray v2; + std::valarray v1_save = v1; + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// abs(const valarray& x); + +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// acos(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// asin(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// atan2(const valarray& x, const valarray& y); + +#include +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// atan2(const valarray& x, const T& y); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// atan2(const T& x, const valarray& y); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// atan(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// cos(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// cosh(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// exp(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// log10(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// log(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// pow(const valarray& x, const valarray& y); + +#include +#include +#include + +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 v1(a1, N); + std::valarray v2(a2, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// pow(const valarray& x, const T& y); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// pow(const T& x, const valarray& y); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// sin(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// sinh(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// sqrt(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// tan(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// valarray +// tanh(const valarray& x); + +#include +#include +#include + +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 v1(a1, N); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// unspecified1 +// begin(const valarray& v); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + const std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// unspecified1 +// begin(valarray& v); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// unspecified1 +// end(const valarray& v); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + const std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class valarray; + +// template +// unspecified1 +// end(valarray& v); + +#include +#include + +int main() +{ + { + typedef int T; + T a[] = {1, 2, 3, 4, 5}; + const unsigned N = sizeof(a)/sizeof(a[0]); + std::valarray 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasPlus +// && HasAssign::result_type> +// T +// accumulate(Iter first, Iter last, T init); + +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, T init, T x) +{ + assert(std::accumulate(first, last, init) == x); +} + +template +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 >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template BinaryOperation> +// requires HasAssign +// && CopyConstructible +// T +// accumulate(Iter first, Iter last, T init, BinaryOperation binary_op); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, T init, T x) +{ + assert(std::accumulate(first, last, init, std::multiplies()) == x); +} + +template +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 >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter> +// requires HasMinus +// && Constructible +// && OutputIterator::result_type> +// && MoveAssignable +// OutIter +// adjacent_difference(InIter first, InIter last, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter, +// Callable BinaryOperation> +// requires Constructible +// && OutputIterator +// && MoveAssignable +// && CopyConstructible +// OutIter +// adjacent_difference(InIter first, InIter last, OutIter result, BinaryOperation binary_op); + +#include +#include +#include + +#include "test_iterators.h" + +template +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()); + 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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); + +#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()); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires HasMultiply +// && HasPlus::result_type> +// && HasAssign::result_type>::result_type> +// T +// inner_product(Iter1 first1, Iter1 last1, Iter2 first2, T init); + +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x) +{ + assert(std::inner_product(first1, last1, first2, init) == x); +} + +template +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 >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template BinaryOperation2> +// requires Callable +// && HasAssign +// && CopyConstructible +// && CopyConstructible +// T +// inner_product(Iter1 first1, Iter1 last1, Iter2 first2, +// T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x) +{ + assert(std::inner_product(first1, last1, first2, init, + std::multiplies(), std::plus()) == x); +} + +template +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 >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test, input_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, const int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void iota(ForwardIterator first, ForwardIterator last, T value); + +#include +#include + +#include "test_iterators.h" + +template +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 >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter> +// requires HasPlus +// && HasAssign::result_type> +// && Constructible +// OutIter +// partial_sum(InIter first, InIter last, OutIter result); + +#include +#include + +#include "test_iterators.h" + +template +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, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template OutIter, +// Callable BinaryOperation> +// requires HasAssign +// && Constructible +// && CopyConstructible +// OutIter +// partial_sum(InIter first, InIter last, OutIter result, BinaryOperation binary_op); + +#include +#include +#include + +#include "test_iterators.h" + +template +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()); + assert(base(r) == ib + s); + for (unsigned i = 0; i < s; ++i) + assert(ib[i] == ir[i]); +} + +int main() +{ + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test, output_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, int*>(); + + test >(); + test >(); + test >(); + test >(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// discard_block_engine& operator=(const discard_block_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// discard_block_engine(const discard_block_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// explicit discard_block_engine(const Engine& e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// explicit discard_block_engine(const Engine& e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// explicit discard_block_engine(result_type s = default_seed); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// template explicit discard_block_engine(Sseq& q); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// explicit discard_block_engine(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// void discard(unsigned long long z); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// result_type operator()(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const discard_block_engine& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// discard_block_engine& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine +// { +// public: +// // types +// typedef typename Engine::result_type result_type; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// void seed(result_type s = default_seed); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discard_block_engine + +// template void seed(Sseq& q); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// independent_bits_engine& operator=(const independent_bits_engine&); + +#include +#include + +void +test1() +{ + typedef std::independent_bits_engine 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// independent_bits_engine(const independent_bits_engine&); + +#include +#include + +void +test1() +{ + typedef std::independent_bits_engine 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// explicit independent_bits_engine(const Engine& e); + +#include +#include + +int main() +{ + { + typedef std::mt19937 Engine; + typedef std::independent_bits_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// explicit independent_bits_engine(const Engine& e); + +#include +#include + +int main() +{ + { + typedef std::mt19937 Engine; + typedef std::independent_bits_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// explicit independent_bits_engine(result_type s = default_seed); + +#include +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// template explicit independent_bits_engine(Sseq& q); + +#include +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// explicit independent_bits_engine(); + +#include +#include + +void +test1() +{ + std::independent_bits_engine e1; + std::independent_bits_engine e2(std::ranlux24_base::default_seed); + assert(e1 == e2); + assert(e1() == 2066486613); +} + +void +test2() +{ + std::independent_bits_engine e1; + std::independent_bits_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// void discard(unsigned long long z); + +#include +#include + +void +test1() +{ + std::independent_bits_engine e1; + std::independent_bits_engine e2 = e1; + assert(e1 == e2); + e1.discard(3); + assert(e1 != e2); + e2(); + e2(); + e2(); + assert(e1 == e2); +} + +void +test2() +{ + std::independent_bits_engine e1; + std::independent_bits_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// result_type operator()(); + +#include +#include + +template +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, 16, unsigned> E; + + E e; + assert(e() == 6958); +} + +void +test2() +{ + typedef std::independent_bits_engine, 16, unsigned> E; + + E e; + assert(e() == 66); +} + +void +test3() +{ + typedef std::independent_bits_engine, 32, unsigned> E; + + E e(5); + assert(e() == 5); +} + +void +test4() +{ + typedef std::independent_bits_engine, 7, unsigned> E; + + E e(129); + assert(e() == 1); +} + +void +test5() +{ + typedef std::independent_bits_engine, 1, unsigned> E; + + E e(6); + assert(e() == 1); +} + +void +test6() +{ + typedef std::independent_bits_engine, 11, unsigned> E; + + E e(6); + assert(e() == 1365); +} + +void +test7() +{ + typedef std::independent_bits_engine, 32, unsigned> E; + + E e(6); + assert(e() == 2863311530u); +} + +void +test8() +{ + typedef std::independent_bits_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const independent_bits_engine& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// independent_bits_engine& x); + +#include +#include +#include + +void +test1() +{ + typedef std::independent_bits_engine 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine +// { +// public: +// // types +// typedef UIntType result_type; + +#include +#include + +template +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, 16, unsigned>::result_type, + unsigned>::value), ""); +} + +void +test2() +{ + static_assert((std::is_same< + std::independent_bits_engine, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// void seed(result_type s = default_seed); + +#include +#include + +void +test1() +{ + for (int s = 0; s < 20; ++s) + { + typedef std::independent_bits_engine 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class independent_bits_engine + +// template void seed(Sseq& q); + +#include +#include + +void +test1() +{ + unsigned a[] = {3, 5, 7}; + std::seed_seq sseq(a, a+3); + std::independent_bits_engine e1; + std::independent_bits_engine 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 e1; + std::independent_bits_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include + +void +test1() +{ + typedef std::independent_bits_engine E; + /*static_*/assert((E::min() == 0)/*, ""*/); + /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/); +} + +void +test2() +{ + typedef std::independent_bits_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// shuffle_order_engine& operator=(const shuffle_order_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// shuffle_order_engine(const shuffle_order_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// explicit shuffle_order_engine(const Engine& e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// explicit shuffle_order_engine(const Engine& e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// explicit shuffle_order_engine(result_type s = default_seed); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// template explicit shuffle_order_engine(Sseq& q); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// explicit shuffle_order_engine(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// void discard(unsigned long long z); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// result_type operator()(); + +#include +#include + +template +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 E0; + typedef std::shuffle_order_engine E; + E e; + e.discard(400); + assert(e() == 501); +} + +void +test3() +{ + typedef rand1 E0; + typedef std::shuffle_order_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const shuffle_order_engine& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// shuffle_order_engine& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine +// { +// public: +// // types +// typedef typename Engine::result_type result_type; + +#include +#include + +template +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, 16>::result_type, + unsigned long>::value), ""); +} + +void +test2() +{ + static_assert((std::is_same< + std::shuffle_order_engine, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// void seed(result_type s = default_seed); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class shuffle_order_engine + +// template void seed(Sseq& q); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class random_device; + +// double entropy() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class random_device; + +// result_type operator()(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// bernoulli_distribution& operator=(const bernoulli_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// bernoulli_distribution(const bernoulli_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// explicit bernoulli_distribution(double p = 0.5); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// explicit bernoulli_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// bool operator=(const bernoulli_distribution& x, +// const bernoulli_distribution& y); +// bool operator!(const bernoulli_distribution& x, +// const bernoulli_distribution& y); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const bernoulli_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// bernoulli_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class bernoulli_distribution +// { +// typedef bool result_type; + +#include +#include + +int main() +{ + { + typedef std::bernoulli_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// binomial_distribution& operator=(const binomial_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// binomial_distribution(const binomial_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// explicit binomial_distribution(IntType t = 1, double p = 0.5); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// explicit binomial_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// bool operator=(const binomial_distribution& x, +// const binomial_distribution& y); +// bool operator!(const binomial_distribution& x, +// const binomial_distribution& y); + +#include +#include + +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 + +// + +// template +// class binomial_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 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 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 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 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 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 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 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 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 + +// + +// template +// class binomial_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const binomial_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// binomial_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class binomial_distribution +// { +// typedef bool result_type; + +#include +#include + +int main() +{ + { + typedef std::binomial_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::binomial_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// geometric_distribution& operator=(const geometric_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// geometric_distribution(const geometric_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// explicit geometric_distribution(double p = 0.5); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// explicit geometric_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// bool operator=(const geometric_distribution& x, +// const geometric_distribution& y); +// bool operator!(const geometric_distribution& x, +// const geometric_distribution& y); + +#include +#include + +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 + +// + +// template +// class geometric_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 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 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 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 + +// + +// template +// class geometric_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const geometric_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// geometric_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// result_type max() const; + +#include +#include + +int main() +{ + { + typedef std::geometric_distribution<> D; + D d(.25); + assert(d.max() == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class geometric_distribution +// { +// typedef bool result_type; + +#include +#include + +int main() +{ + { + typedef std::geometric_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::geometric_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// negative_binomial_distribution& operator=(const negative_binomial_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// negative_binomial_distribution(const negative_binomial_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// explicit negative_binomial_distribution(IntType t = 1, double p = 0.5); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// explicit negative_binomial_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class negative_binomial_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 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 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 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 + +// + +// template +// class negative_binomial_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const negative_binomial_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// negative_binomial_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// result_type max() const; + +#include +#include + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + D d(4, .25); + assert(d.max() == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class negative_binomial_distribution +// { +// typedef bool result_type; + +#include +#include + +int main() +{ + { + typedef std::negative_binomial_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::negative_binomial_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// cauchy_distribution& operator=(const cauchy_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// cauchy_distribution(const cauchy_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// explicit cauchy_distribution(result_type a = 0, result_type b = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// explicit cauchy_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// bool operator=(const cauchy_distribution& x, +// const cauchy_distribution& y); +// bool operator!(const cauchy_distribution& x, +// const cauchy_distribution& y); + +#include +#include + +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 + +// + +// template +// class cauchy_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +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 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 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 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 + +// + +// template +// class cauchy_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const cauchy_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// cauchy_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::cauchy_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// chi_squared_distribution& operator=(const chi_squared_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// chi_squared_distribution(const chi_squared_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// explicit chi_squared_distribution(result_type alpha = 0, result_type beta = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// explicit chi_squared_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class chi_squared_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 + +// + +// template +// class chi_squared_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const chi_squared_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// chi_squared_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class chi_squared_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::chi_squared_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::chi_squared_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// fisher_f_distribution& operator=(const fisher_f_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// fisher_f_distribution(const fisher_f_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// explicit fisher_f_distribution(result_type alpha = 0, result_type beta = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// explicit fisher_f_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class fisher_f_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include +#include + +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(m/2), static_cast(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 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 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 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 + +// + +// template +// class fisher_f_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include +#include + +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(m/2), static_cast(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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const fisher_f_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// fisher_f_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class fisher_f_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::fisher_f_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::fisher_f_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// lognormal_distribution& operator=(const lognormal_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// lognormal_distribution(const lognormal_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// explicit lognormal_distribution(result_type mean = 0, result_type stddev = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// explicit lognormal_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// bool operator=(const lognormal_distribution& x, +// const lognormal_distribution& y); +// bool operator!(const lognormal_distribution& x, +// const lognormal_distribution& y); + +#include +#include + +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 + +// + +// template +// class lognormal_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 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 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 + +// + +// template +// class lognormal_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const lognormal_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// lognormal_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class lognormal_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::lognormal_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::lognormal_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// normal_distribution& operator=(const normal_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// normal_distribution(const normal_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// explicit normal_distribution(result_type mean = 0, result_type stddev = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// explicit normal_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// bool operator=(const normal_distribution& x, +// const normal_distribution& y); +// bool operator!(const normal_distribution& x, +// const normal_distribution& y); + +#include +#include + +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 + +// + +// template +// class normal_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 + +// + +// template +// class normal_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const normal_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// normal_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class normal_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::normal_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::normal_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// student_t_distribution& operator=(const student_t_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// student_t_distribution(const student_t_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// explicit student_t_distribution(result_type alpha = 0, result_type beta = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// explicit student_t_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class student_t_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 + +// + +// template +// class student_t_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const student_t_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// student_t_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::student_t_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// exponential_distribution& operator=(const exponential_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// exponential_distribution(const exponential_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// explicit exponential_distribution(RealType lambda = 1.0); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// explicit exponential_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// bool operator=(const exponential_distribution& x, +// const exponential_distribution& y); +// bool operator!(const exponential_distribution& x, +// const exponential_distribution& y); + +#include +#include + +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 + +// + +// template +// class exponential_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 + +// + +// template +// class exponential_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const exponential_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// exponential_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// result_type max() const; + +#include +#include + +int main() +{ + { + typedef std::exponential_distribution<> D; + D d(.25); + D::result_type m = d.max(); + assert(m == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class exponential_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::exponential_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::exponential_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// extreme_value_distribution& operator=(const extreme_value_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// extreme_value_distribution(const extreme_value_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// explicit extreme_value_distribution(result_type a = 0, result_type b = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// explicit extreme_value_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class extreme_value_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 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 + +// + +// template +// class extreme_value_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const extreme_value_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// extreme_value_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class extreme_value_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::extreme_value_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::extreme_value_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// gamma_distribution& operator=(const gamma_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// gamma_distribution(const gamma_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// explicit gamma_distribution(result_type alpha = 0, result_type beta = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// explicit gamma_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// bool operator=(const gamma_distribution& x, +// const gamma_distribution& y); +// bool operator!(const gamma_distribution& x, +// const gamma_distribution& y); + +#include +#include + +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 + +// + +// template +// class gamma_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 + +// + +// template +// class gamma_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const gamma_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// gamma_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class gamma_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::gamma_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::gamma_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// poisson_distribution& operator=(const poisson_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// poisson_distribution(const poisson_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// explicit poisson_distribution(RealType lambda = 1.0); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// explicit poisson_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// bool operator=(const poisson_distribution& x, +// const poisson_distribution& y); +// bool operator!(const poisson_distribution& x, +// const poisson_distribution& y); + +#include +#include + +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 + +// + +// template +// class poisson_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 + +// + +// template +// class poisson_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const poisson_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// poisson_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// result_type max() const; + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + D d(.25); + D::result_type m = d.max(); + assert(m == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::poisson_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// weibull_distribution& operator=(const weibull_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// weibull_distribution(const weibull_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// explicit weibull_distribution(result_type a = 0, result_type b = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// explicit weibull_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// bool operator=(const weibull_distribution& x, +// const weibull_distribution& y); +// bool operator!(const weibull_distribution& x, +// const weibull_distribution& y); + +#include +#include + +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 + +// + +// template +// class weibull_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 + +// + +// template +// class weibull_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const weibull_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// weibull_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution; + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class weibull_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::weibull_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::weibull_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// discrete_distribution& operator=(const discrete_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// discrete_distribution(const discrete_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// discrete_distribution(); + +#include +#include + +int main() +{ + { + typedef std::discrete_distribution<> D; + D d; + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// template +// discrete_distribution(size_t nw, double xmin, double xmax, +// UnaryOperation fw); + +#include +#include + +double fw(double x) +{ + return x+1; +} + +int main() +{ + { + typedef std::discrete_distribution<> D; + D d(0, 0, 1, fw); + std::vector p = d.probabilities(); + assert(p.size() == 1); + assert(p[0] == 1); + } + { + typedef std::discrete_distribution<> D; + D d(1, 0, 1, fw); + std::vector 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// discrete_distribution(initializer_list wl); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::discrete_distribution<> D; + D d = {}; + std::vector p = d.probabilities(); + assert(p.size() == 1); + assert(p[0] == 1); + } + { + typedef std::discrete_distribution<> D; + D d = {10}; + std::vector p = d.probabilities(); + assert(p.size() == 1); + assert(p[0] == 1); + } + { + typedef std::discrete_distribution<> D; + D d = {10, 30}; + std::vector 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// template +// discrete_distribution(InputIterator firstW, InputIterator lastW); + +#include +#include + +int main() +{ + { + typedef std::discrete_distribution<> D; + double p0[] = {1}; + D d(p0, p0); + std::vector 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// explicit discrete_distribution(const param_type& parm); + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// bool operator=(const discrete_distribution& x, +// const discrete_distribution& y); +// bool operator!(const discrete_distribution& x, +// const discrete_distribution& y); + +#include +#include + +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 + +// + +// template +// class discrete_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include + +int main() +{ + { + typedef std::discrete_distribution<> D; + typedef std::minstd_rand G; + G g; + D d; + const int N = 100; + std::vector 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 + +// + +// template +// class discrete_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const discrete_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// discrete_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// param_type(initializer_list wl); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::discrete_distribution<> D; + typedef D::param_type P; + P pa = {1}; + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// template +// param_type(size_t nw, double xmin, double xmax, +// UnaryOperation fw); + +#include +#include + +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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// param_type(initializer_list wl); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::discrete_distribution<> D; + typedef D::param_type P; + P pa = {}; + std::vector 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// template +// param_type(InputIterator firstW, InputIterator lastW); + +#include +#include + +int main() +{ + { + typedef std::discrete_distribution<> D; + typedef D::param_type P; + double p0[] = {1}; + P pa(p0, p0); + std::vector 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class discrete_distribution +// { +// typedef bool result_type; + +#include +#include + +int main() +{ + { + typedef std::discrete_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::discrete_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// piecewise_constant_distribution& operator=(const piecewise_constant_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// piecewise_constant_distribution(const piecewise_constant_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// piecewise_constant_distribution(initializer_list wl); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::piecewise_constant_distribution<> D; + D d; + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// template +// piecewise_constant_distribution(size_t nw, result_type xmin, +// result_type xmax, UnaryOperation fw); + +#include +#include + +double fw(double x) +{ + return 2*x; +} + +int main() +{ + { + typedef std::piecewise_constant_distribution<> D; + D d(0, 0, 1, fw); + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 12); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 6); + assert(iv[1] == 10); + assert(iv[2] == 14); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// piecewise_constant_distribution(initializer_list bl, +// UnaryOperation fw); + +#include + +#include +#include + +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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector dn = d.densities(); + assert(dn.size() == 1); + assert(dn[0] == 1); + } + { + typedef std::piecewise_constant_distribution<> D; + D d({12}, f); + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector dn = d.densities(); + assert(dn.size() == 1); + assert(dn[0] == 1); + } + { + typedef std::piecewise_constant_distribution<> D; + D d({12, 14}, f); + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 12); + assert(iv[1] == 14); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 5.5); + assert(iv[1] == 7.5); + assert(iv[2] == 11.5); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// template +// piecewise_constant_distribution(InputIteratorB firstB, +// InputIteratorB lastB, +// InputIteratorW firstW); + +#include +#include + +int main() +{ + { + typedef std::piecewise_constant_distribution<> D; + double b[] = {10}; + double p[] = {12}; + D d(b, b, p); + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 15); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 10); + assert(iv[1] == 15); + assert(iv[2] == 16); + std::vector 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// explicit piecewise_constant_distribution(const param_type& parm); + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class piecewise_constant_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include +#include + +template +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 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 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::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 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 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::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 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 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::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 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 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::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 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 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::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 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 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::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 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 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::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 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 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::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 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 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::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 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 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::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 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 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::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 + +// + +// template +// class piecewise_constant_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include +#include + +template +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 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 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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const piecewise_constant_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// piecewise_constant_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// param_type(); + +#include +#include + +int main() +{ + { + typedef std::piecewise_constant_distribution<> D; + typedef D::param_type P; + P pa; + std::vector iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// template +// param_type(size_t nw, double xmin, double xmax, +// UnaryOperation fw); + +#include +#include + +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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 12); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 6); + assert(iv[1] == 10); + assert(iv[2] == 14); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// param_type(initializer_list bl, UnaryOperation fw); + +#include +#include + +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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 12); + assert(iv[1] == 14); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 5.5); + assert(iv[1] == 7.5); + assert(iv[2] == 11.5); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// template +// param_type(InputIteratorB firstB, InputIteratorB lastB, +// InputIteratorW firstW); + +#include +#include + +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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 15); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 10); + assert(iv[1] == 15); + assert(iv[2] == 16); + std::vector 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_constant_distribution +// { +// typedef bool result_type; + +#include +#include + +int main() +{ + { + typedef std::piecewise_constant_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::piecewise_constant_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// piecewise_linear_distribution& operator=(const piecewise_linear_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// piecewise_linear_distribution(const piecewise_linear_distribution&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// piecewise_linear_distribution(initializer_list wl); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::piecewise_linear_distribution<> D; + D d; + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// template +// piecewise_linear_distribution(size_t nw, result_type xmin, +// result_type xmax, UnaryOperation fw); + +#include + +#include +#include + +double fw(double x) +{ + return 2*x; +} + +int main() +{ + { + typedef std::piecewise_linear_distribution<> D; + D d(0, 0, 1, fw); + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 12); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 6); + assert(iv[1] == 10); + assert(iv[2] == 14); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// piecewise_linear_distribution(initializer_list bl, +// UnaryOperation fw); + +#include + +#include +#include + +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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 12); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 6); + assert(iv[1] == 10); + assert(iv[2] == 14); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// template +// piecewise_linear_distribution(InputIteratorB firstB, +// InputIteratorB lastB, +// InputIteratorW firstW); + +#include +#include + +int main() +{ + { + typedef std::piecewise_linear_distribution<> D; + double b[] = {10}; + double p[] = {12}; + D d(b, b, p); + std::vector iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 15); + std::vector 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 iv = d.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 10); + assert(iv[1] == 15); + assert(iv[2] == 16); + std::vector 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// explicit piecewise_linear_distribution(const param_type& parm); + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class piecewise_linear_distribution + +// template result_type operator()(_URNG& g); + +#include + +#include +#include +#include +#include +#include + +template +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 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 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 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 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 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 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 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 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 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 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 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 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 + +// + +// template +// class piecewise_linear_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include +#include + +template +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const piecewise_linear_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// piecewise_linear_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// param_type(); + +#include +#include + +int main() +{ + { + typedef std::piecewise_linear_distribution<> D; + typedef D::param_type P; + P pa; + std::vector iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// template +// param_type(size_t nw, double xmin, double xmax, +// UnaryOperation fw); + +#include +#include + +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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 12); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 6); + assert(iv[1] == 10); + assert(iv[2] == 14); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// param_type(initializer_list bl, UnaryOperation fw); + +#include +#include + +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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 12); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 6); + assert(iv[1] == 10); + assert(iv[2] == 14); + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// template +// param_type(InputIteratorB firstB, InputIteratorB lastB, +// InputIteratorW firstW); + +#include +#include + +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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 0); + assert(iv[1] == 1); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 2); + assert(iv[0] == 10); + assert(iv[1] == 15); + std::vector 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 iv = pa.intervals(); + assert(iv.size() == 3); + assert(iv[0] == 10); + assert(iv[1] == 15); + assert(iv[2] == 16); + std::vector 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution +// { +// class param_type; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution +// { +// class param_type; + +#include +#include + +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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class piecewise_linear_distribution +// { +// typedef bool result_type; + +#include +#include + +int main() +{ + { + typedef std::piecewise_linear_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::piecewise_linear_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// uniform_int_distribution& operator=(const uniform_int_distribution&); + +#include +#include + +void +test1() +{ + typedef std::uniform_int_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// uniform_int_distribution(const uniform_int_distribution&); + +#include +#include + +void +test1() +{ + typedef std::uniform_int_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// explicit uniform_int_distribution(IntType a = 0, +// IntType b = numeric_limits::max()); + +#include +#include + +int main() +{ + { + typedef std::uniform_int_distribution<> D; + D d; + assert(d.a() == 0); + assert(d.b() == std::numeric_limits::max()); + } + { + typedef std::uniform_int_distribution<> D; + D d(-6); + assert(d.a() == -6); + assert(d.b() == std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// explicit uniform_int_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class uniform_int_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const uniform_int_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// uniform_int_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_int_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_int_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_int_distribution D; + typedef D::param_type param_type; + param_type p; + assert(p.a() == 0); + assert(p.b() == std::numeric_limits::max()); + } + { + typedef std::uniform_int_distribution D; + typedef D::param_type param_type; + param_type p(5); + assert(p.a() == 5); + assert(p.b() == std::numeric_limits::max()); + } + { + typedef std::uniform_int_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_int_distribution 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution +// { +// class param_type; + +#include +#include + +int main() +{ + { + typedef std::uniform_int_distribution D; + typedef D::param_type param_type; + typedef param_type::distribution_type distribution_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_int_distribution +// { +// typedef IntType result_type; + +#include +#include + +int main() +{ + { + typedef std::uniform_int_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// uniform_real_distribution& operator=(const uniform_real_distribution&); + +#include +#include + +void +test1() +{ + typedef std::uniform_real_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// uniform_real_distribution(const uniform_real_distribution&); + +#include +#include + +void +test1() +{ + typedef std::uniform_real_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// explicit uniform_real_distribution(RealType a = 0, +// RealType b = 1); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// explicit uniform_real_distribution(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +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 + +// + +// template +// class uniform_real_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +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 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 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 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 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 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 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// param_type param() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const uniform_real_distribution& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// uniform_real_distribution& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// result_type max() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// result_type min() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_real_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_real_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_real_distribution D; + typedef D::param_type param_type; + param_type p; + assert(p.a() == 0); + assert(p.b() == 1); + } + { + typedef std::uniform_real_distribution D; + typedef D::param_type param_type; + param_type p(5); + assert(p.a() == 5); + assert(p.b() == 1); + } + { + typedef std::uniform_real_distribution 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::uniform_real_distribution 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution +// { +// class param_type; + +#include +#include + +int main() +{ + { + typedef std::uniform_real_distribution D; + typedef D::param_type param_type; + typedef param_type::distribution_type distribution_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// void param(const param_type& parm); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution +// { +// typedef IntType result_type; + +#include +#include + +int main() +{ + { + typedef std::uniform_real_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// linear_congruential_engine& operator=(const linear_congruential_engine&); + +#include +#include + +template +void +test1() +{ + typedef std::linear_congruential_engine E; + E e1; + E e2; + assert(e1 == e2); + e1(); + e2 = e1; + assert(e1 == e2); +} + +template +void +test() +{ + test1(); + test1(); + test1(); + const T M(~0); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); +} + +int main() +{ + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// linear_congruential_engine(const linear_congruential_engine&); + +#include +#include + +template +void +test1() +{ + typedef std::linear_congruential_engine E; + E e1; + E e2 = e1; + assert(e1 == e2); + e1(); + e2(); + assert(e1 == e2); +} + +template +void +test() +{ + test1(); + test1(); + test1(); + const T M(~0); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); +} + +int main() +{ + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// explicit linear_congruential_engine(result_type s = default_seed); + +#include +#include +#include + +template +void +test1() +{ + // c % m != 0 && s % m != 0 + { + typedef std::linear_congruential_engine E; + E e(5); + std::ostringstream os; + os << e; + assert(os.str() == "5"); + } + { + typedef std::linear_congruential_engine E; + E e(5); + std::ostringstream os; + os << e; + assert(os.str() == "5"); + } + { + typedef std::linear_congruential_engine E; + E e(5); + std::ostringstream os; + os << e; + assert(os.str() == "1"); + } +} + +template +void +test2() +{ + // c % m != 0 && s % m == 0 + { + typedef std::linear_congruential_engine E; + E e(7); + std::ostringstream os; + os << e; + assert(os.str() == "0"); + } + { + typedef std::linear_congruential_engine E; + E e(0); + std::ostringstream os; + os << e; + assert(os.str() == "0"); + } + { + typedef std::linear_congruential_engine E; + E e(4); + std::ostringstream os; + os << e; + assert(os.str() == "0"); + } +} + +template +void +test3() +{ + // c % m == 0 && s % m != 0 + { + typedef std::linear_congruential_engine E; + E e(3); + std::ostringstream os; + os << e; + assert(os.str() == "3"); + } + { + typedef std::linear_congruential_engine E; + E e(5); + std::ostringstream os; + os << e; + assert(os.str() == "5"); + } + { + typedef std::linear_congruential_engine E; + E e(7); + std::ostringstream os; + os << e; + assert(os.str() == "3"); + } +} + +template +void +test4() +{ + // c % m == 0 && s % m == 0 + { + typedef std::linear_congruential_engine E; + E e(7); + std::ostringstream os; + os << e; + assert(os.str() == "1"); + } + { + typedef std::linear_congruential_engine E; + E e(0); + std::ostringstream os; + os << e; + assert(os.str() == "1"); + } + { + typedef std::linear_congruential_engine E; + E e(8); + std::ostringstream os; + os << e; + assert(os.str() == "1"); + } +} + +int main() +{ + test1(); + test1(); + test1(); + test1(); + + test2(); + test2(); + test2(); + test2(); + + test3(); + test3(); + test3(); + test3(); + + test4(); + test4(); + test4(); + test4(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// template explicit linear_congruential_engine(Sseq& q); + +#include +#include + +int main() +{ + { + unsigned a[] = {3, 5, 7}; + std::seed_seq sseq(a, a+3); + std::linear_congruential_engine e1(sseq); + std::linear_congruential_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// linear_congruential_engine(); + +#include +#include + +template +void +test1() +{ + typedef std::linear_congruential_engine LCE; + typedef typename LCE::result_type result_type; + LCE e1; + LCE e2; + e2.seed(); + assert(e1 == e2); +} + +template +void +test() +{ + test1(); + test1(); + test1(); + const T M(~0); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); +} + +int main() +{ + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// void discard(unsigned long long z); + +#include +#include + +template +void +rand0() +{ + typedef std::linear_congruential_engine E; + E e; + e.discard(9999); + assert(e() == 1043618065); +} + +template +void +rand() +{ + typedef std::linear_congruential_engine E; + E e; + e.discard(9999); + assert(e() == 399268537); +} + +template +void +other() +{ + typedef std::linear_congruential_engine 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(); + rand0(); + rand0(); + + rand(); + rand(); + rand(); + + other(); + other(); + other(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// result_type operator()(); + +#include +#include + +template +void +randu() +{ + typedef std::linear_congruential_engine 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 +void +minstd() +{ + typedef std::linear_congruential_engine 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 +void +Haldir() +{ + typedef std::linear_congruential_engine 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(); + randu(); + randu(); + + minstd(); + minstd(); + minstd(); + + Haldir(); + Haldir(); + Haldir(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const linear_congruential_engine& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// linear_congruential_engine& x); + +#include +#include +#include + +int main() +{ + { + typedef std::linear_congruential_engine 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine +// { +// public: +// // types +// typedef UIntType result_type; + +#include +#include + +template +void +test() +{ + static_assert((std::is_same< + typename std::linear_congruential_engine::result_type, + T>::value), ""); +} + +int main() +{ + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// void seed(result_type s = default_seed); + +#include +#include + +template +void +test1() +{ + for (int s = 0; s < 20; ++s) + { + typedef std::linear_congruential_engine E; + E e1(s); + E e2; + e2.seed(s); + assert(e1 == e2); + } +} + +int main() +{ + test1(); + test1(); + test1(); + test1(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class linear_congruential_engine; + +// template void seed(Sseq& q); + +#include +#include + +int main() +{ + { + unsigned a[] = {3, 5, 7}; + std::seed_seq sseq(a, a+3); + std::linear_congruential_engine e1; + std::linear_congruential_engine 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include + +template +void where(const _Tp &) {} + +template +void +test1() +{ + typedef std::linear_congruential_engine 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 +void +test() +{ + test1(); + test1(); + test1(); + const T M(~0); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); +} + +int main() +{ + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// mersenne_twister_engine& operator=(const mersenne_twister_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// mersenne_twister_engine(const mersenne_twister_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// explicit mersenne_twister_engine(result_type s = default_seed); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// template explicit mersenne_twister_engine(Sseq& q); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// explicit mersenne_twister_engine(); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// void discard(unsigned long long z); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// result_type operator()(); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const mersenne_twister_engine& x); +// +// template +// basic_ostream& +// operator>>(basic_istream& is, +// mersenne_twister_engine& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine +// { +// public: +// // types +// typedef UIntType result_type; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// void seed(result_type s = default_seed); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class mersenne_twister_engine; + +// template void seed(Sseq& q); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// subtract_with_carry_engine& operator=(const subtract_with_carry_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// subtract_with_carry_engine(const subtract_with_carry_engine&); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// explicit subtract_with_carry_engine(result_type s = default_seed); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// template explicit subtract_with_carry_engine(Sseq& q); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// explicit subtract_with_carry_engine(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// void discard(unsigned long long z); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// result_type operator()(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const subtract_with_carry_engine& x); +// +// template +// basic_istream& +// operator>>(basic_istream& is, +// subtract_with_carry_engine& x); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine +// { +// public: +// // types +// typedef UIntType result_type; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// void seed(result_type s = default_seed); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class subtract_with_carry_engine; + +// template void seed(Sseq& q); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include +#include + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef minstd_rand0 default_random_engine; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef shuffle_order_engine knuth_b; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef linear_congruential_engine +// minstd_rand; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef linear_congruential_engine +// minstd_rand0; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef mersenne_twister_engine mt19937; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef mersenne_twister_engine mt19937_64; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef discard_block_engine ranlux24; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef subtract_with_carry_engine ranlux24_base; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef discard_block_engine ranlux48; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef subtract_with_carry_engine ranlux48_base; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// RealType generate_canonical(URNG& g); + +#include +#include + +int main() +{ + { + typedef std::minstd_rand0 E; + typedef float F; + E r; + F f = std::generate_canonical(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(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::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::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::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(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(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::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::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// class seed_seq; + +// seed_seq(); + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class seed_seq; + +// seed_seq(); + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class seed_seq; + +// seed_seq(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class seed_seq; + +// template +// void generate(RandomAccessIterator begin, RandomAccessIterator end); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class seed_seq; + +// template +// seed_seq(initializer_list il); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class seed_seq; + +// template +// seed_seq(InputIterator begin, InputIterator end); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class seed_seq +// { +// public: +// // types +// typedef uint_least32_t result_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags +// = regex_constants::match_default); + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::length(s)); + assert(m.length(0) == std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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::length(s)); + assert(m.length(0) == std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool regex_match(const basic_string&&, +// match_results< +// typename basic_string::const_iterator, +// Allocator>&, +// const basic_regex&, +// regex_constants::match_flag_type = +// regex_constants::match_default) = delete; + +#if __cplusplus <= 201402L +#error +#else + +#include +#include + +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 + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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 + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr)); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::length(s)); + assert(m.length(0) == std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr)); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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::length(s)); + assert(m.length(0) == std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +#include +#include + +#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::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::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::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 + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +#include +#include + +#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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& 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 +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// http://llvm.org/bugs/show_bug.cgi?id=16135 + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// OutputIterator +// regex_replace(OutputIterator out, +// BidirectionalIterator first, BidirectionalIterator last, +// const basic_regex& e, +// const basic_string& fmt, +// regex_constants::match_flag_type flags = +// regex_constants::match_default); + +#include +#include + +#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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// OutputIterator +// regex_replace(OutputIterator out, +// BidirectionalIterator first, BidirectionalIterator last, +// const basic_regex& e, +// const charT* fmt, +// regex_constants::match_flag_type flags = +// regex_constants::match_default); + +#include +#include + +#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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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 Out; + typedef bidirectional_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// basic_string +// regex_replace(const basic_string& s, +// const basic_regex& e, +// const basic_string& fmt, +// regex_constants::match_flag_type flags = +// regex_constants::match_default); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// regex_replace(const basic_string& s, +// const basic_regex& e, const charT* fmt, +// regex_constants::match_flag_type flags = +// regex_constants::match_default); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// regex_replace(const charT* s, +// const basic_regex& e, +// const basic_string& fmt, +// regex_constants::match_flag_type flags = +// regex_constants::match_default); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// regex_replace(const charT* s, +// const basic_regex& e, +// const charT* fmt, +// regex_constants::match_flag_type flags = +// regex_constants::match_default); + +#include +#include + +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 + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::length(s)); + assert(m.length(0) == std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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::length(s)); + assert(m.length(0) == std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +#include +#include +#include +#include + +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 l(s.begin(), s.end()); + std::regex re("\\ba"); + std::regex_iterator::iterator> it(l.begin(), l.end(), re); + std::regex_iterator::iterator> end = std::regex_iterator::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool regex_search(const basic_string&&, +// match_results< +// typename basic_string::const_iterator, +// Allocator>&, +// const basic_regex&, +// regex_constants::match_flag_type = +// regex_constants::match_default) = delete; + +#if __cplusplus <= 201402L +#error +#else + +#include +#include + +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 + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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 + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr)); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::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::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::length(s)); + assert(m.length(0) == std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr)); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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::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::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::length(s)); + assert(m.length(0) == std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +#include +#include + +#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::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::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::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::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 + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended); + std::match_results m; + const char s[] = "-40C"; + std::ptrdiff_t ss = std::char_traits::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::length(r); + typedef forward_iterator FI; + typedef bidirectional_iterator BI; + std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended); + std::match_results m; + const wchar_t s[] = L"-40C"; + std::ptrdiff_t ss = std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +#include +#include + +#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::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// http://llvm.org/bugs/show_bug.cgi?id=11118 + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool +// regex_search(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_error +// : public runtime_error +// { +// public: +// explicit regex_error(regex_constants::error_type ecode); +// regex_constants::error_type code() const; +// }; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// regex_iterator(BidirectionalIterator a, BidirectionalIterator b, +// const regex_type& re, +// regex_constants::match_flag_type m = regex_constants::match_default); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// regex_iterator(); + +#include +#include + +template +void +test() +{ + typedef std::regex_iterator I; + I i1; + assert(i1 == I()); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// const value_type& operator*() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// regex_iterator operator++(int); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template ::value_type, +// class traits = regex_traits> +// class regex_iterator +// { +// public: +// typedef basic_regex regex_type; +// typedef match_results value_type; +// typedef ptrdiff_t difference_type; +// typedef const value_type* pointer; +// typedef const value_type& reference; +// typedef forward_iterator_tag iterator_category; + +#include +#include + +template +void +test() +{ + typedef std::regex_iterator I; + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same*>::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// template +// 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 +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// template +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// regex_token_iterator(); + +#include +#include + +template +void +test() +{ + typedef std::regex_token_iterator I; + I i1; + assert(i1 == I()); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, +// const regex_type&& re, +// initializer_list submatches, +// regex_constants::match_flag_type m = +// regex_constants::match_default); + +#if __cplusplus <= 201402L +#error +#else + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, +// const regex_type& re, +// initializer_list submatches, +// regex_constants::match_flag_type m = +// regex_constants::match_default); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_iterator + +// template +// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, +// const regex_type&& re, +// const std::vector& submatches, +// regex_constants::match_flag_type m = +// regex_constants::match_default); + +#if __cplusplus <= 201402L +#error +#else + +#include +#include + +int main() +{ + { + std::regex phone_numbers("\\d{3}-(\\d{4})"); + const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end"; + std::vector 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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, +// const regex_type& re, +// const std::vector& submatches, +// regex_constants::match_flag_type m = +// regex_constants::match_default); + +#include +#include + +int main() +{ + { + std::regex phone_numbers("\\d{3}-(\\d{4})"); + const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end"; + std::vector 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// bool operator==(const regex_token_iterator& right) const; +// bool operator!=(const regex_token_iterator& right) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// const value_type& operator*() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class regex_token_iterator + +// regex_token_iterator& operator++(int); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template ::value_type, +// class traits = regex_traits> +// class regex_token_iterator +// { +// public: +// typedef basic_regex regex_type; +// typedef sub_match value_type; +// typedef ptrdiff_t difference_type; +// typedef const value_type* pointer; +// typedef const value_type& reference; +// typedef forward_iterator_tag iterator_category; + +#include +#include + +template +void +test() +{ + typedef std::regex_token_iterator I; + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same*>::value), ""); + static_assert((std::is_same&>::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex& +// assign(initializer_list il, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex& assign(const basic_regex& that); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex& +// assign(InputIterator first, InputIterator last, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +#include "test_iterators.h" + +int main() +{ + typedef input_iterator I; + typedef forward_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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex& assign(const charT* ptr, size_t len, flag_type f); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex& assign(const basic_string& s, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex& operator=(const basic_regex& e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex& operator=(initializer_list il); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex& operator=(const charT* ptr); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex& operator=(const basic_string& p); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include + +template +void where(const _Tp &) {} + +template +void +test() +{ + typedef std::basic_regex 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(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const basic_regex& e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(); + +#include +#include + +template +void +test() +{ + std::basic_regex r; + assert(r.flags() == 0); + assert(r.mark_count() == 0); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(initializer_list il, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +void +test(std::initializer_list il, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(ForwardIterator first, ForwardIterator last); + +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, unsigned mc) +{ + std::basic_regex::value_type> r(first, last); + assert(r.flags() == std::regex_constants::ECMAScript); + assert(r.mark_count() == mc); +} + +int main() +{ + typedef forward_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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(ForwardIterator first, ForwardIterator last, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex::value_type> r(first, last, f); + assert(r.flags() == f); + assert(r.mark_count() == mc); +} + +int main() +{ + typedef forward_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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const charT* p); + +#include +#include + +template +void +test(const CharT* p, unsigned mc) +{ + std::basic_regex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); + +#include +#include + +template +void +test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const charT* p, size_t len, flag_type f); + +#include +#include + +template +void +test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f, + unsigned mc) +{ + std::basic_regex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s); + +#include +#include + +template +void +test(const String& p, unsigned mc) +{ + std::basic_regex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +template +void +test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex 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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// locale_type imbue(locale_type loc); + +#include +#include +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// void swap(basic_regex& lhs, basic_regex& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// void swap(basic_regex& e); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// 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 +#include + +int main() +{ + static_assert((std::is_same::value_type, char>::value), ""); + static_assert((std::is_same::flag_type, + std::regex_constants::syntax_option_type>::value), ""); + static_assert((std::is_same::locale_type, std::locale>::value), ""); + + static_assert((std::is_same::value_type, wchar_t>::value), ""); + static_assert((std::is_same::flag_type, + std::regex_constants::syntax_option_type>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// const_iterator begin() const; +// const_iterator end() const; + +#include +#include + +void +test() +{ + std::match_results m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cd((e)fg)hi"))); + + std::match_results::const_iterator i = m.begin(); + std::match_results::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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include +#include + +void +test() +{ + std::match_results m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cd((e)fg)hi"))); + + std::match_results::const_iterator i = m.cbegin(); + std::match_results::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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// const_reference operator[](size_type n) const; + +#include +#include + +void +test(std::regex_constants::syntax_option_type syntax) +{ + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// difference_type length(size_type sub = 0) const; + +#include +#include + +void +test() +{ + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// difference_type position(size_type sub = 0) const; + +#include +#include + +void +test() +{ + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// const_reference prefix() const; + +#include +#include + +void +test() +{ + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// string_type str(size_type sub = 0) const; + +#include +#include + +void +test() +{ + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// const_reference suffix() const; + +#include +#include + +void +test() +{ + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// allocator_type get_allocator() const; + +#include +#include + +#include "test_allocator.h" + +template +void +test(const Allocator& a) +{ + std::match_results m(a); + assert(m.size() == 0); + assert(m.str() == std::basic_string()); + assert(m.get_allocator() == a); +} + +int main() +{ + test(test_allocator >(3)); + test(test_allocator >(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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// match_results(const Allocator& a = Allocator()); + +#include +#include + +#include "test_allocator.h" + +template +void +test(const Allocator& a) +{ + std::match_results m(a); + assert(m.size() == 0); + assert(m.str() == std::basic_string()); + assert(m.get_allocator() == a); +} + +int main() +{ + test(test_allocator >(3)); + test(test_allocator >(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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// match_results(const Allocator& a = Allocator()); + +#include +#include + +template +void +test() +{ + std::match_results m; + assert(m.size() == 0); + assert(m.str() == std::basic_string()); + assert(m.get_allocator() == std::allocator >()); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// template +// 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 +#include + +#include "test_iterators.h" + +int main() +{ + { + std::match_results 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(out), + fmt, fmt + std::char_traits::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 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(out), + fmt, fmt + std::char_traits::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 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(out), + fmt, fmt + std::char_traits::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 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(out), + fmt, fmt + std::char_traits::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 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(out), + fmt, fmt + std::char_traits::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 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(out), + fmt, fmt + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// template +// OutputIter +// format(OutputIter out, const basic_string& fmt, +// regex_constants::match_flag_type flags = regex_constants::format_default) const; + +#include + +#include +#include + +#include "test_iterators.h" +#include "test_allocator.h" + +int main() +{ + typedef std::basic_string, test_allocator > nstr; + typedef std::basic_string, test_allocator > wstr; + { + std::match_results 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(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 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(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 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(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 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(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 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(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 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(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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// template +// basic_string +// format(const basic_string& fmt, +// regex_constants::match_flag_type flags = regex_constants::format_default) const; + +#include + +#include +#include + +#include "test_allocator.h" + +int main() +{ + typedef std::basic_string, test_allocator > nstr; + typedef std::basic_string, test_allocator > wstr; + { + std::match_results 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// string_type +// format(const char_type* fmt, +// regex_constants::match_flag_type flags = regex_constants::format_default) const; + +#include + +#include +#include + +int main() +{ + { + std::match_results 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// template +// bool +// operator==(const match_results& m1, +// const match_results& m2); + +// template +// bool +// operator!=(const match_results& m1, +// const match_results& m2); + +#include +#include + +void +test() +{ + std::match_results m1; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi"))); + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// size_type size() const; +// bool empty() const; + +#include +#include + +template +void +test() +{ + std::match_results 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(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// size_type max_size() const; + +#include +#include + +template +void +test() +{ + std::match_results m; + assert(m.max_size() > 0); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// bool ready() const; + +#include +#include + +void +test1() +{ + std::match_results 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// void swap(match_results& that); + +#include +#include + +void +test() +{ + std::match_results m1; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi"))); + std::match_results m2; + + std::match_results m1_save = m1; + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// class match_results + +// template +// void swap(match_results& m1, +// match_results& m2); + +#include +#include + +void +test() +{ + std::match_results m1; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi"))); + std::match_results m2; + + std::match_results m1_save = m1; + std::match_results 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. +// +//===----------------------------------------------------------------------===// + +// + +// template >> +// class match_results +// { +// public: +// typedef sub_match 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::difference_type difference_type; +// typedef typename allocator_traits::size_type size_type; +// typedef Allocator allocator_type; +// typedef typename iterator_traits::value_type char_type; +// typedef basic_string string_type; + +#include +#include + +template +void +test() +{ + typedef std::match_results MR; + static_assert((std::is_same >::value), ""); + static_assert((std::is_same& >::value), ""); + static_assert((std::is_same& >::value), ""); + static_assert((!std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same > >::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// int compare(const string_type& s) const; + +#include +#include + +int main() +{ + { + typedef char CharT; + typedef std::sub_match 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// int compare(const sub_match& s) const; + +#include +#include + +int main() +{ + { + typedef char CharT; + typedef std::sub_match 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// int compare(const value_type* s) const; + +#include +#include + +int main() +{ + { + typedef char CharT; + typedef std::sub_match 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// constexpr sub_match(); + +#include +#include + +int main() +{ + { + typedef char CharT; + typedef std::sub_match SM; + SM sm; + assert(sm.matched == false); + } + { + typedef wchar_t CharT; + typedef std::sub_match 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// difference_type length() const; + +#include +#include + +int main() +{ + { + typedef char CharT; + typedef std::sub_match 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// operator string_type() const; + +#include +#include + +int main() +{ + { + typedef char CharT; + typedef std::sub_match 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// string_type str() const; + +#include +#include + +int main() +{ + { + typedef char CharT; + typedef std::sub_match 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// template +// bool +// operator==(const sub_match& lhs, const sub_match& rhs); +// +// template +// bool +// operator!=(const sub_match& lhs, const sub_match& rhs); +// +// template +// bool +// operator<(const sub_match& lhs, const sub_match& rhs); +// +// template +// bool +// operator<=(const sub_match& lhs, const sub_match& rhs); +// +// template +// bool +// operator>=(const sub_match& lhs, const sub_match& rhs); +// +// template +// bool +// operator>(const sub_match& lhs, const sub_match& rhs); +// +// template +// bool +// operator==(const basic_string::value_type, ST, SA>& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator!=(const basic_string::value_type, ST, SA>& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator<(const basic_string::value_type, ST, SA>& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator>(const basic_string::value_type, ST, SA>& lhs, +// const sub_match& rhs); +// +// template +// bool operator>=(const basic_string::value_type, ST, SA>& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator<=(const basic_string::value_type, ST, SA>& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator==(const sub_match& lhs, +// const basic_string::value_type, ST, SA>& rhs); +// +// template +// bool +// operator!=(const sub_match& lhs, +// const basic_string::value_type, ST, SA>& rhs); +// +// template +// bool +// operator<(const sub_match& lhs, +// const basic_string::value_type, ST, SA>& rhs); +// +// template +// bool operator>(const sub_match& lhs, +// const basic_string::value_type, ST, SA>& rhs); +// +// template +// bool +// operator>=(const sub_match& lhs, +// const basic_string::value_type, ST, SA>& rhs); +// +// template +// bool +// operator<=(const sub_match& lhs, +// const basic_string::value_type, ST, SA>& rhs); +// +// template +// bool +// operator==(typename iterator_traits::value_type const* lhs, +// const sub_match& rhs); +// +// template +// bool +// operator!=(typename iterator_traits::value_type const* lhs, +// const sub_match& rhs); +// +// template +// bool +// operator<(typename iterator_traits::value_type const* lhs, +// const sub_match& rhs); +// +// template +// bool +// operator>(typename iterator_traits::value_type const* lhs, +// const sub_match& rhs); +// +// template +// bool +// operator>=(typename iterator_traits::value_type const* lhs, +// const sub_match& rhs); +// +// template +// bool +// operator<=(typename iterator_traits::value_type const* lhs, +// const sub_match& rhs); +// +// template +// bool +// operator==(const sub_match& lhs, +// typename iterator_traits::value_type const* rhs); +// +// template +// bool +// operator!=(const sub_match& lhs, +// typename iterator_traits::value_type const* rhs); +// +// template +// bool +// operator<(const sub_match& lhs, +// typename iterator_traits::value_type const* rhs); +// +// template +// bool +// operator>(const sub_match& lhs, +// typename iterator_traits::value_type const* rhs); +// +// template +// bool +// operator>=(const sub_match& lhs, +// typename iterator_traits::value_type const* rhs); +// +// template +// bool +// operator<=(const sub_match& lhs, +// typename iterator_traits::value_type const* rhs); +// +// template +// bool +// operator==(typename iterator_traits::value_type const& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator!=(typename iterator_traits::value_type const& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator<(typename iterator_traits::value_type const& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator>(typename iterator_traits::value_type const& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator>=(typename iterator_traits::value_type const& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator<=(typename iterator_traits::value_type const& lhs, +// const sub_match& rhs); +// +// template +// bool +// operator==(const sub_match& lhs, +// typename iterator_traits::value_type const& rhs); +// +// template +// bool +// operator!=(const sub_match& lhs, +// typename iterator_traits::value_type const& rhs); +// +// template +// bool +// operator<(const sub_match& lhs, +// typename iterator_traits::value_type const& rhs); +// +// template +// bool +// operator>(const sub_match& lhs, +// typename iterator_traits::value_type const& rhs); +// +// template +// bool +// operator>=(const sub_match& lhs, +// typename iterator_traits::value_type const& rhs); +// +// template +// bool +// operator<=(const sub_match& lhs, +// typename iterator_traits::value_type const& rhs); + +#include +#include + +template +void +test(const std::basic_string& x, const std::basic_string& y, bool doCStrTests = true) +{ + typedef std::basic_string string; + typedef std::sub_match 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class sub_match; + +// template +// basic_ostream& +// operator<<(basic_ostream& os, const sub_match& m); + +#include +#include +#include + +template +void +test(const std::basic_string& s) +{ + typedef std::basic_string string; + typedef std::sub_match SM; + typedef std::basic_ostringstream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class sub_match +// : public pair +// { +// public: +// typedef BidirectionalIterator iterator; +// typedef typename iterator_traits::value_type value_type; +// typedef typename iterator_traits::difference_type difference_type; +// typedef basic_string string_type; +// +// bool matched; +// ... +// }; + +#include +#include +#include + +int main() +{ + { + typedef std::sub_match SM; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_convertible*>::value), ""); + + SM sm; + sm.first = nullptr; + sm.second = nullptr; + sm.matched = false; + } + { + typedef std::sub_match SM; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_convertible*>::value), ""); + + SM sm; + sm.first = nullptr; + sm.second = nullptr; + sm.matched = false; + } + { + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef match_results cmatch; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_iterator cregex_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_token_iterator cregex_token_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef sub_match csub_match; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef basic_regex regex; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef match_results smatch; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_iterator sregex_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_token_iterator sregex_token_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef sub_match ssub_match; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef match_results wcmatch; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_iterator wcregex_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_token_iterator wcregex_token_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef sub_match wcsub_match; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef basic_regex wregex; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef match_results wsmatch; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_iterator wsregex_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef regex_token_iterator wsregex_token_iterator; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef sub_match wssub_match; + +#include +#include + +int main() +{ + static_assert((std::is_same, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// regex_traits(); + +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::regex_traits t1; + assert(t1.getloc().name() == "C"); + std::regex_traits t2; + assert(t2.getloc().name() == "C"); + } + { + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + std::regex_traits t1; + assert(t1.getloc().name() == LOCALE_en_US_UTF_8); + std::regex_traits 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// locale_type getloc()const; + +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::regex_traits t1; + assert(t1.getloc().name() == "C"); + std::regex_traits t2; + assert(t2.getloc().name() == "C"); + } + { + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + std::regex_traits t1; + assert(t1.getloc().name() == LOCALE_en_US_UTF_8); + std::regex_traits 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// locale_type imbue(locale_type l); + +#include +#include +#include + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::regex_traits 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// bool isctype(charT c, char_class_type f) const; + +#include +#include + +int main() +{ + { + std::regex_traits 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// static std::size_t length(const char_type* p); + +#include +#include + +int main() +{ + assert(std::regex_traits::length("") == 0); + assert(std::regex_traits::length("1") == 1); + assert(std::regex_traits::length("12") == 2); + assert(std::regex_traits::length("123") == 3); + + assert(std::regex_traits::length(L"") == 0); + assert(std::regex_traits::length(L"1") == 1); + assert(std::regex_traits::length(L"12") == 2); + assert(std::regex_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// template +// char_class_type +// lookup_classname(ForwardIterator first, ForwardIterator last, +// bool icase = false) const; + +#include +#include +#include "test_iterators.h" + +template +void +test(const char_type* A, + typename std::regex_traits::char_class_type expected, + bool icase = false) +{ + std::regex_traits t; + typedef forward_iterator 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::__regex_word | std::ctype_base::alnum + | std::ctype_base::upper | std::ctype_base::lower); + test("W", std::regex_traits::__regex_word | std::ctype_base::alnum + | std::ctype_base::upper | std::ctype_base::lower); + test("w", std::regex_traits::__regex_word | std::ctype_base::alnum + | std::ctype_base::upper | std::ctype_base::lower, true); + test("W", std::regex_traits::__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::__regex_word | std::ctype_base::alnum + | std::ctype_base::upper | std::ctype_base::lower); + test(L"W", std::regex_traits::__regex_word | std::ctype_base::alnum + | std::ctype_base::upper | std::ctype_base::lower); + test(L"w", std::regex_traits::__regex_word | std::ctype_base::alnum + | std::ctype_base::upper | std::ctype_base::lower, true); + test(L"W", std::regex_traits::__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 + +// + +// template struct regex_traits; + +// template +// string_type +// lookup_collatename(ForwardIterator first, ForwardIterator last) const; + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +template +void +test(const char_type* A, const std::basic_string& expected) +{ + std::regex_traits t; + typedef forward_iterator 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 + +// + +// template struct regex_traits; + +// template +// string_type transform(ForwardIterator first, ForwardIterator last) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::regex_traits t; + const char a[] = "a"; + const char B[] = "B"; + typedef forward_iterator 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 t; + const wchar_t a[] = L"a"; + const wchar_t B[] = L"B"; + typedef forward_iterator 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 + +// + +// template struct regex_traits; + +// template +// string_type +// transform_primary(ForwardIterator first, ForwardIterator last) const; + +#include +#include +#include "test_iterators.h" + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::regex_traits t; + const char A[] = "A"; + const char Aacute[] = "\xC1"; + typedef forward_iterator 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 t; + const wchar_t A[] = L"A"; + const wchar_t Aacute[] = L"\xC1"; + typedef forward_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// charT translate(charT c) const; + +#include +#include + +int main() +{ + { + std::regex_traits t; + assert(t.translate('a') == 'a'); + assert(t.translate('B') == 'B'); + assert(t.translate('c') == 'c'); + } + { + std::regex_traits 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. +// +//===----------------------------------------------------------------------===// + +// + +// template 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 +#include + +#include "platform_support.h" + +int main() +{ + { + std::regex_traits 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct regex_traits +// { +// public: +// typedef charT char_type; +// typedef basic_string string_type; +// typedef locale locale_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::string_type, std::string>::value), ""); + static_assert((std::is_same::locale_type, std::locale>::value), ""); + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::string_type, std::wstring>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct regex_traits; + +// int value(charT ch, int radix) const; + +#include +#include + +int main() +{ + { + std::regex_traits 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include + +template +void +test() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test(); + test(); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + test(); +} 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 +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals::string_literals; + + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::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 +#include + +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 +#include + +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 +#include + +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 +#include + +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 +#include + +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 + +template +class input_iterator +{ + It it_; +public: + typedef typename std::input_iterator_tag iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef It pointer; + typedef typename std::iterator_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// const_reference at(size_type pos) const; +// reference at(size_type pos); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const charT& back() const; +// charT& back(); + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call back() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call back() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call front() on empty const container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Index const string out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call front() on empty container. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Index string out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const charT& front() const; +// charT& front(); + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type capacity() const; + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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, test_allocator > 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void clear(); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// bool empty() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type length() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "min_allocator.h" + +template +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 +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type max_size() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void reserve(size_type res_arg=0); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type n); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void resize(size_type n, charT c); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void shrink_to_fit(); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type size() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// explicit basic_string(const Allocator& a = Allocator()); + +#include +#include + +#include "test_macros.h" +#include "test_allocator.h" +#include "min_allocator.h" + +template +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::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 +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::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, test_allocator > >(); +#if TEST_STD_VER >= 11 + test2, min_allocator > >(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& operator=(charT c); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(const basic_string& str); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 A; + typedef std::basic_string, A> S; + test(S(A(3))); + test(S("1", A(5))); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7))); + } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(const basic_string& str, const Allocator& alloc); + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 A; + typedef std::basic_string, A> S; + test(S(), A(3)); + test(S("1"), A(5)); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7)); + } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// operator=(const basic_string& str); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string() +// noexcept(is_nothrow_default_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "test_macros.h" +#include "test_allocator.h" + +template +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::value, ""); + } + { + typedef std::basic_string, test_allocator> C; + static_assert(std::is_nothrow_default_constructible::value, ""); + } + { + typedef std::basic_string, some_alloc> C; + static_assert(!std::is_nothrow_default_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// ~basic_string() // implied noexcept; + +#include +#include + +#include "test_allocator.h" + +#if __has_feature(cxx_noexcept) + +template +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::value, ""); + } + { + typedef std::basic_string, test_allocator> C; + static_assert(std::is_nothrow_destructible::value, ""); + } + { + typedef std::basic_string, some_alloc> C; + static_assert(!std::is_nothrow_destructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(initializer_list il, const Allocator& a = Allocator()); + +#include +#include + +#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, min_allocator> S; + S s = {'a', 'b', 'c'}; + assert(s == "abc"); + } + { + typedef std::basic_string, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& operator=(initializer_list il); + +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string(InputIterator begin, InputIterator end, +// const Allocator& a = Allocator()); + +#include +#include +#include + +#include "test_allocator.h" +#include "../input_iterator.h" +#include "min_allocator.h" + +template +void +test(It first, It last) +{ + typedef typename std::iterator_traits::value_type charT; + typedef std::basic_string, test_allocator > 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 +void +test(It first, It last, const A& a) +{ + typedef typename std::iterator_traits::value_type charT; + typedef std::basic_string, 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 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(s), input_iterator(s)); + test(input_iterator(s), input_iterator(s), A(2)); + + test(input_iterator(s), input_iterator(s+1)); + test(input_iterator(s), input_iterator(s+1), A(2)); + + test(input_iterator(s), input_iterator(s+10)); + test(input_iterator(s), input_iterator(s+10), A(2)); + + test(input_iterator(s), input_iterator(s+50)); + test(input_iterator(s), input_iterator(s+50), A(2)); + } +#if __cplusplus >= 201103L + { + typedef min_allocator 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(s), input_iterator(s)); + test(input_iterator(s), input_iterator(s), A()); + + test(input_iterator(s), input_iterator(s+1)); + test(input_iterator(s), input_iterator(s+1), A()); + + test(input_iterator(s), input_iterator(s+10)); + test(input_iterator(s), input_iterator(s+10), A()); + + test(input_iterator(s), input_iterator(s+50)); + test(input_iterator(s), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(basic_string&& str); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 A; + typedef std::basic_string, A> S; + test(S(A(3))); + test(S("1", A(5))); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7))); + } +#if __cplusplus >= 201103L + { + typedef min_allocator A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(basic_string&& str, const Allocator& alloc); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +#include "test_macros.h" +#include "test_allocator.h" +#include "min_allocator.h" + + +template +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::value); +// #else +// _NOEXCEPT; +// #endif + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef test_allocator A; + typedef std::basic_string, 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::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 A; + typedef std::basic_string, 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::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 A; + typedef std::basic_string, 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::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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& operator=(basic_string&& c) +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value); + +// This tests a conforming extension + +#include +#include + +#include "test_allocator.h" + +template +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::value, ""); + } + { + typedef std::basic_string, test_allocator> C; + static_assert(!std::is_nothrow_move_assignable::value, ""); + } + { + typedef std::basic_string, some_alloc> C; + static_assert(!std::is_nothrow_move_assignable::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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// operator=(basic_string&& str); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(basic_string&&) +// noexcept(is_nothrow_move_constructible::value); + +// This tests a conforming extension + +#include +#include + +#include "test_macros.h" +#include "test_allocator.h" + +template +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::value, ""); + } + { + typedef std::basic_string, test_allocator> C; + static_assert(std::is_nothrow_move_constructible::value, ""); + } + { + typedef std::basic_string, some_alloc> C; +#if TEST_STD_VER <= 14 + static_assert(!std::is_nothrow_move_constructible::value, ""); +#else + static_assert( std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(const charT* s, const Allocator& a = Allocator()); + +#include +#include +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +void +test(const charT* s) +{ + typedef std::basic_string, test_allocator > 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 +void +test(const charT* s, const A& a) +{ + typedef std::basic_string, 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 A; + typedef std::basic_string, 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 A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// operator=(const charT* s); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(const charT* s, size_type n, const Allocator& a = Allocator()); + +#include +#include +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +void +test(const charT* s, unsigned n) +{ + typedef std::basic_string, test_allocator > 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 +void +test(const charT* s, unsigned n, const A& a) +{ + typedef std::basic_string, 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 A; + typedef std::basic_string, 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 A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(size_type n, charT c, const Allocator& a = Allocator()); + +#include +#include +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +void +test(unsigned n, charT c) +{ + typedef std::basic_string, test_allocator > 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 +void +test(unsigned n, charT c, const A& a) +{ + typedef std::basic_string, 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 +void +test(Tp n, Tp c) +{ + typedef char charT; + typedef std::basic_string, test_allocator > 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 +void +test(Tp n, Tp c, const A& a) +{ + typedef char charT; + typedef std::basic_string, 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 A; + typedef std::basic_string, 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 A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string(const basic_string& str, +// size_type pos, size_type n = npos, +// const Allocator& a = Allocator()); + +#include +#include +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +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 +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(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 +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(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 A; + typedef std::basic_string, 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 A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator begin(); +// const_iterator begin() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_iterator cbegin() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_iterator cend() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_reverse_iterator crbegin() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const_reverse_iterator crend() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Compare iterators from different containers with <. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Subtract iterators from different containers with <. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Index iterator out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Add to iterator out of bounds. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Decrement iterator prior to begin. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator end(); +// const_iterator end() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator rbegin(); +// const_reverse_iterator rbegin() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// reverse_iterator rend(); +// const_reverse_iterator rend() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& append(initializer_list il); + +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string& append(InputIterator first, InputIterator last); + +#include +#include + +#include "../../input_iterator.h" +#include "min_allocator.h" + +template +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(s), input_iterator(s), S()); + test(S(), input_iterator(s), input_iterator(s+1), S("A")); + test(S(), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S(), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), input_iterator(s), input_iterator(s), + S("12345")); + test(S("12345"), input_iterator(s), input_iterator(s+1), + S("12345A")); + test(S("12345"), input_iterator(s), input_iterator(s+10), + S("12345ABCDEFGHIJ")); + test(S("12345"), input_iterator(s), input_iterator(s+52), + S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), input_iterator(s), input_iterator(s), + S("1234567890")); + test(S("1234567890"), input_iterator(s), input_iterator(s+1), + S("1234567890A")); + test(S("1234567890"), input_iterator(s), input_iterator(s+10), + S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), input_iterator(s), input_iterator(s+52), + S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), input_iterator(s), input_iterator(s), + S("12345678901234567890")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+1), + S("12345678901234567890""A")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+10), + S("12345678901234567890""ABCDEFGHIJ")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+52), + S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> 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(s), input_iterator(s), S()); + test(S(), input_iterator(s), input_iterator(s+1), S("A")); + test(S(), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S(), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), input_iterator(s), input_iterator(s), + S("12345")); + test(S("12345"), input_iterator(s), input_iterator(s+1), + S("12345A")); + test(S("12345"), input_iterator(s), input_iterator(s+10), + S("12345ABCDEFGHIJ")); + test(S("12345"), input_iterator(s), input_iterator(s+52), + S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), input_iterator(s), input_iterator(s), + S("1234567890")); + test(S("1234567890"), input_iterator(s), input_iterator(s+1), + S("1234567890A")); + test(S("1234567890"), input_iterator(s), input_iterator(s+10), + S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), input_iterator(s), input_iterator(s+52), + S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), input_iterator(s), input_iterator(s), + S("12345678901234567890")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+1), + S("12345678901234567890""A")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+10), + S("12345678901234567890""ABCDEFGHIJ")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& append(const charT* s); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// append(const charT* s, size_type n); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void push_back(charT c) + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// append(size_type n, charT c); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// append(const basic_string& str); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// append(const basic_string& str, size_type pos, size_type n = npos); +// the "= npos" was added for C++14 + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& assign(initializer_list il); + +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string& assign(InputIterator first, InputIterator last); + +#include +#include + +#include "../../input_iterator.h" +#include "min_allocator.h" + +template +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(s), input_iterator(s), S()); + test(S(), input_iterator(s), input_iterator(s+1), S("A")); + test(S(), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S(), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), input_iterator(s), input_iterator(s), + S()); + test(S("12345"), input_iterator(s), input_iterator(s+1), + S("A")); + test(S("12345"), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("12345"), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), input_iterator(s), input_iterator(s), + S()); + test(S("1234567890"), input_iterator(s), input_iterator(s+1), + S("A")); + test(S("1234567890"), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("1234567890"), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), input_iterator(s), input_iterator(s), + S()); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+1), + S("A")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> 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(s), input_iterator(s), S()); + test(S(), input_iterator(s), input_iterator(s+1), S("A")); + test(S(), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S(), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), input_iterator(s), input_iterator(s), + S()); + test(S("12345"), input_iterator(s), input_iterator(s+1), + S("A")); + test(S("12345"), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("12345"), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), input_iterator(s), input_iterator(s), + S()); + test(S("1234567890"), input_iterator(s), input_iterator(s+1), + S("A")); + test(S("1234567890"), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("1234567890"), input_iterator(s), input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), input_iterator(s), input_iterator(s), + S()); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+1), + S("A")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("12345678901234567890"), input_iterator(s), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& assign(const charT* s); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// assign(const charT* s, size_type n); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// assign(basic_string&& str); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// assign(size_type n, charT c); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// assign(const basic_string& str); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// assign(const basic_string& str, size_type pos, size_type n=npos); +// the =npos was added for C++14 + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type copy(charT* s, size_type n, size_type pos = 0) const; + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with end() + +#if _LIBCPP_DEBUG >= 1 + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase(const_iterator p); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator erase(const_iterator first, const_iterator last); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void pop_back(); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// erase(size_type pos = 0, size_type n = npos); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert(const_iterator p, charT c); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// iterator insert(const_iterator p, initializer_list il); + +#if _LIBCPP_DEBUG >= 1 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +#include "../../input_iterator.h" +#include "min_allocator.h" + +template +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(s), input_iterator(s), S()); + test(S(), 0, input_iterator(s), input_iterator(s+1), S("A")); + test(S(), 0, input_iterator(s), input_iterator(s+10), S("ABCDEFGHIJ")); + test(S(), 0, input_iterator(s), input_iterator(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), 0, input_iterator(s), input_iterator(s), S("12345")); + test(S("12345"), 1, input_iterator(s), input_iterator(s+1), S("1A2345")); + test(S("12345"), 4, input_iterator(s), input_iterator(s+10), S("1234ABCDEFGHIJ5")); + test(S("12345"), 5, input_iterator(s), input_iterator(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), 0, input_iterator(s), input_iterator(s), S("1234567890")); + test(S("1234567890"), 1, input_iterator(s), input_iterator(s+1), S("1A234567890")); + test(S("1234567890"), 10, input_iterator(s), input_iterator(s+10), S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), 8, input_iterator(s), input_iterator(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); + + test(S("12345678901234567890"), 3, input_iterator(s), input_iterator(s), S("12345678901234567890")); + test(S("12345678901234567890"), 3, input_iterator(s), input_iterator(s+1), S("123A45678901234567890")); + test(S("12345678901234567890"), 15, input_iterator(s), input_iterator(s+10), S("123456789012345ABCDEFGHIJ67890")); + test(S("12345678901234567890"), 20, input_iterator(s), input_iterator(s+52), + S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> 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(s), input_iterator(s), S()); + test(S(), 0, input_iterator(s), input_iterator(s+1), S("A")); + test(S(), 0, input_iterator(s), input_iterator(s+10), S("ABCDEFGHIJ")); + test(S(), 0, input_iterator(s), input_iterator(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), 0, input_iterator(s), input_iterator(s), S("12345")); + test(S("12345"), 1, input_iterator(s), input_iterator(s+1), S("1A2345")); + test(S("12345"), 4, input_iterator(s), input_iterator(s+10), S("1234ABCDEFGHIJ5")); + test(S("12345"), 5, input_iterator(s), input_iterator(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), 0, input_iterator(s), input_iterator(s), S("1234567890")); + test(S("1234567890"), 1, input_iterator(s), input_iterator(s+1), S("1A234567890")); + test(S("1234567890"), 10, input_iterator(s), input_iterator(s+10), S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), 8, input_iterator(s), input_iterator(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); + + test(S("12345678901234567890"), 3, input_iterator(s), input_iterator(s), S("12345678901234567890")); + test(S("12345678901234567890"), 3, input_iterator(s), input_iterator(s+1), S("123A45678901234567890")); + test(S("12345678901234567890"), 15, input_iterator(s), input_iterator(s+10), S("123456789012345ABCDEFGHIJ67890")); + test(S("12345678901234567890"), 20, input_iterator(s), input_iterator(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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// insert(size_type pos, const charT* s); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// insert(size_type pos, const charT* s, size_type n); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// insert(size_type pos, size_type n, charT c); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// insert(size_type pos1, const basic_string& str); + +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// insert(size_type pos1, const basic_string& str, +// size_type pos2, size_type n=npos); +// the "=npos" was added in C++14 + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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(); + 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(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + 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(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& operator+=(charT c); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& operator+=(initializer_list il); + +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& operator+=(const charT* s); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// operator+=(const basic_string& str); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& replace(const_iterator i1, const_iterator i2, initializer_list il); + +#include +#include + +#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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string& +// replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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 +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(const_iterator i1, const_iterator i2, const charT* s); + +#include + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(const_iterator i1, const_iterator i2, const charT* s, size_type n); + +#include + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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 +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(const_iterator i1, const_iterator i2, size_type n, charT c); + +#include + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(const_iterator i1, const_iterator i2, const basic_string& str); + +#include + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(size_type pos, size_type n1, const charT* s); + +#include + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(size_type pos, size_type n1, const charT* s, size_type n2); + +#include + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(size_type pos, size_type n1, size_type n2, charT c); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(size_type pos1, size_type n1, const basic_string& str); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string& +// replace(size_type pos1, size_type n1, const basic_string& str, +// size_type pos2, size_type n2=npos); +// the "=npos" was added in C++14 + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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(); + 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(); + test55(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + 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(); + test55(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(basic_string& s); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// getline(basic_istream& is, +// basic_string& str); + +#include +#include +#include + +#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, min_allocator> 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// getline(basic_istream& is, +// basic_string& str, charT delim); + +#include +#include +#include + +#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, min_allocator> 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// getline(basic_istream&& is, +// basic_string& str, charT delim); + +#include +#include +#include + +#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, min_allocator> S; + S s("initial text"); + getline(std::istringstream(" abc* def* ghij"), s, '*'); + assert(s == " abc"); + } + { + typedef std::basic_string, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// getline(basic_istream&& is, +// basic_string& str); + +#include +#include +#include + +#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, min_allocator> S; + S s("initial text"); + getline(std::istringstream(" abc\n def\n ghij"), s); + assert(s == " abc"); + } + { + typedef std::basic_string, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_istream& +// operator>>(basic_istream& is, +// basic_string& str); + +#include +#include +#include + +#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, min_allocator> 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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const basic_string& str); + +#include +#include +#include + +#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, min_allocator> S; + std::basic_ostringstream out; + S s("some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + typedef std::basic_string, min_allocator> S; + std::basic_ostringstream out; + S s("some text"); + out.width(12); + out << s; + assert(out.good()); + assert(" " + s == out.str()); + } + { + typedef std::basic_string, min_allocator> S; + std::basic_ostringstream out; + S s(L"some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + typedef std::basic_string, min_allocator> S; + std::basic_ostringstream 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void swap(basic_string& lhs, +// basic_string& rhs); + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// void swap(basic_string& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable::value); +// +// In C++17, the standard says that swap shall have: +// noexcept(allocator_traits::propagate_on_container_swap::value || +// allocator_traits::is_always_equal::value); + +// This tests a conforming extension + +#include +#include + +#include "test_allocator.h" + +template +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 +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, test_allocator> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::basic_string, some_alloc> 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, some_alloc2> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator!=(const charT* lhs, const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator!=(const basic_string& lhs, const charT* rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator!=(const basic_string& lhs, +// const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// operator+(charT lhs, const basic_string& rhs); + +// template +// basic_string&& +// operator+(charT lhs, basic_string&& rhs); + +#include +#include +#include + +#include "min_allocator.h" + +template +void +test0(typename S::value_type lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// operator+(const charT* lhs, const basic_string& rhs); + +// template +// basic_string&& +// operator+(const charT* lhs, basic_string&& rhs); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// operator+(const basic_string& lhs, charT rhs); + +// template +// basic_string&& +// operator+(basic_string&& lhs, charT rhs); + +#include +#include +#include + +#include "min_allocator.h" + +template +void +test0(const S& lhs, typename S::value_type rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// operator+(const basic_string& lhs, const charT* rhs); + +// template +// basic_string&& +// operator+(basic_string&& lhs, const charT* rhs); + +#include +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// basic_string +// operator+(const basic_string& lhs, +// const basic_string& rhs); + +// template +// basic_string&& +// operator+(const basic_string&& lhs, +// const basic_string& rhs); + +// template +// basic_string&& +// operator+(const basic_string& lhs, +// const basic_string&& rhs); + +// template +// basic_string&& +// operator+(const basic_string&& lhs, +// const basic_string&& rhs); + +#include +#include +#include + +#include "min_allocator.h" + +template +void +test0(const S& lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +void +test1(S&& lhs, const S& rhs, const S& x) +{ + assert(move(lhs) + rhs == x); +} + +template +void +test2(const S& lhs, S&& rhs, const S& x) +{ + assert(lhs + move(rhs) == x); +} + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator==(const charT* lhs, const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator==(const basic_string& lhs, const charT* rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator==(const basic_string& lhs, +// const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>(const charT* lhs, const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>(const basic_string& lhs, const charT* rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>(const basic_string& lhs, +// const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>=(const charT* lhs, const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>=(const basic_string& lhs, const charT* rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator>=(const basic_string& lhs, +// const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<(const charT* lhs, const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<(const basic_string& lhs, const charT* rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<(const basic_string& lhs, +// const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<=(const charT* lhs, const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<=(const basic_string& lhs, const charT* rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// bool operator<=(const basic_string& lhs, +// const basic_string& rhs); + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const charT* c_str() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// const charT* data() const; + +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// allocator_type get_allocator() const; + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + +template +void +test(const S& s, const typename S::allocator_type& a) +{ + assert(s.get_allocator() == a); +} + +int main() +{ + { + typedef test_allocator A; + typedef std::basic_string, 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 A; + typedef std::basic_string, 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. +// +//===----------------------------------------------------------------------===// + +// + +// int compare(const charT *s) const; + +#include +#include + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// int compare(size_type pos, size_type n1, const charT *s) const; + +#include +#include +#include + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// int compare(size_type pos, size_type n1, const charT *s, size_type n2) const; + +#include +#include +#include + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// int compare(size_type pos1, size_type n1, const basic_string& str) const; + +#include +#include +#include + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +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 +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 +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 +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(); + test1(); + test2(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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(); + 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(); + test55(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + 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(); + test55(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// int compare(const basic_string& str) const + +#include +#include + +#include "min_allocator.h" + +int sign(int x) +{ + if (x == 0) + return 0; + if (x < 0) + return -1; + return 1; +} + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_not_of(charT c, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_not_of(const charT* s, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_of(charT c, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_of(const charT* s, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_first_of(const basic_string& str, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_not_of(charT c, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_not_of(const charT* s, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_of(charT c, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_of(const charT* s, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_of(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find_last_of(const basic_string& str, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find(charT c, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find(const charT* s, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type find(const basic_string& str, size_type pos = 0) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type rfind(charT c, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type rfind(const charT* s, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type rfind(const charT* s, size_type pos, size_type n) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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 +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(); + test1(); + test2(); + test3(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + test2(); + test3(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// size_type rfind(const basic_string& str, size_type pos = npos) const; + +#include +#include + +#include "min_allocator.h" + +template +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 +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 +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 +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(); + test1(); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string, min_allocator> S; + test0(); + test1(); + } +#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. +// +//===----------------------------------------------------------------------===// + +// + +// basic_string substr(size_type pos = 0, size_type n = npos) const; + +#include +#include +#include +#include + +#include "min_allocator.h" + +template +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, min_allocator> 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. +// +//===----------------------------------------------------------------------===// + +// + +// An string is a contiguous container + +#include +#include + +#include "test_allocator.h" +#include "min_allocator.h" + + +template +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 A; + typedef std::basic_string, 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 A; + typedef std::basic_string, 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 +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. +// +//===----------------------------------------------------------------------===// + +// + +// Test nested types and default template args: + +// template, +// class Allocator = allocator > +// { +// 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 reverse_iterator; +// typedef std::reverse_iterator const_reverse_iterator; +// static const size_type npos = -1; +// }; + +#include +#include +#include + +#include "test_traits.h" +#include "test_allocator.h" +#include "min_allocator.h" + +template +void +test() +{ + typedef std::basic_string S; + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::size_type>::value), ""); + static_assert((std::is_same::difference_type>::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::pointer>::value), ""); + static_assert((std::is_same::const_pointer>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename S::reverse_iterator, + std::reverse_iterator >::value), ""); + static_assert((std::is_same< + typename S::const_reverse_iterator, + std::reverse_iterator >::value), ""); + static_assert(S::npos == -1, ""); +} + +int main() +{ + test, test_allocator >(); + test, std::allocator >(); + static_assert((std::is_same::traits_type, + std::char_traits >::value), ""); + static_assert((std::is_same::allocator_type, + std::allocator >::value), ""); +#if __cplusplus >= 201103L + test, min_allocator >(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +// static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +// static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +// static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +// static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +// static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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: * + +// + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + +#ifndef _LIBCPP_HAS_NO_STDIN + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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: * + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static void assign(char_type& c1, const char_type& c2); + +#include +#include + +int main() +{ + char c = '\0'; + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include +#include + +int main() +{ + char s1[] = {1, 2, 3}; + char s2[3] = {0}; + assert(std::char_traits::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ + assert(std::char_traits::compare("", "", 0) == 0); + assert(std::char_traits::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits::compare("1", "1", 1) == 0); + assert(std::char_traits::compare("1", "2", 1) < 0); + assert(std::char_traits::compare("2", "1", 1) > 0); + + assert(std::char_traits::compare("12", "12", 2) == 0); + assert(std::char_traits::compare("12", "13", 2) < 0); + assert(std::char_traits::compare("12", "22", 2) < 0); + assert(std::char_traits::compare("13", "12", 2) > 0); + assert(std::char_traits::compare("22", "12", 2) > 0); + + assert(std::char_traits::compare("123", "123", 3) == 0); + assert(std::char_traits::compare("123", "223", 3) < 0); + assert(std::char_traits::compare("123", "133", 3) < 0); + assert(std::char_traits::compare("123", "124", 3) < 0); + assert(std::char_traits::compare("223", "123", 3) > 0); + assert(std::char_traits::compare("133", "123", 3) > 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ + char s1[] = {1, 2, 3}; + char s2[3] = {0}; + assert(std::char_traits::copy(s2, s1, 3) == s2); + assert(s2[0] == char(1)); + assert(s2[1] == char(2)); + assert(s2[2] == char(3)); + assert(std::char_traits::copy(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type eof(); + +#include +#include + +int main() +{ + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq(char_type c1, char_type c2); + +#include +#include + +int main() +{ + char c = '\0'; + assert(std::char_traits::eq('a', 'a')); + assert(!std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include +#include + +int main() +{ + assert( std::char_traits::eq_int_type('a', 'a')); + assert(!std::char_traits::eq_int_type('a', 'A')); + assert(!std::char_traits::eq_int_type(std::char_traits::eof(), 'A')); + assert( std::char_traits::eq_int_type(std::char_traits::eof(), + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include +#include + +int main() +{ + char s1[] = {1, 2, 3}; + assert(std::char_traits::find(s1, 3, char(1)) == s1); + assert(std::char_traits::find(s1, 3, char(2)) == s1+1); + assert(std::char_traits::find(s1, 3, char(3)) == s1+2); + assert(std::char_traits::find(s1, 3, char(4)) == 0); + assert(std::char_traits::find(s1, 3, char(0)) == 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static size_t length(const char_type* s); + +#include +#include + +int main() +{ + assert(std::char_traits::length("") == 0); + assert(std::char_traits::length("a") == 1); + assert(std::char_traits::length("aa") == 2); + assert(std::char_traits::length("aaa") == 3); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool lt(char_type c1, char_type c2); + +#include +#include + +int main() +{ + char c = '\0'; + assert(!std::char_traits::lt('a', 'a')); + assert( std::char_traits::lt('A', 'a')); + assert(!std::char_traits::lt('A' + 127, 'a')); + assert(!std::char_traits::lt('A' - 127, 'a')); + assert( std::char_traits::lt('A', 'a' + 127)); + assert( std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ + char s1[] = {1, 2, 3}; + assert(std::char_traits::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::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::move(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type not_eof(int_type c); + +#include +#include + +int main() +{ + assert(std::char_traits::not_eof('a') == 'a'); + assert(std::char_traits::not_eof('A') == 'A'); + assert(std::char_traits::not_eof(0) == 0); + assert(std::char_traits::not_eof(std::char_traits::eof()) != + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr char_type to_char_type(int_type c); + +#include +#include + +int main() +{ + assert(std::char_traits::to_char_type('a') == 'a'); + assert(std::char_traits::to_char_type('A') == 'A'); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type to_int_type(char_type c); + +#include +#include + +int main() +{ + assert(std::char_traits::to_int_type('a') == 'a'); + assert(std::char_traits::to_int_type('A') == 'A'); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// typedef char char_type; +// typedef int int_type; +// typedef streamoff off_type; +// typedef streampos pos_type; +// typedef mbstate_t state_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::char_type, char>::value), ""); + static_assert((std::is_same::int_type, int>::value), ""); + static_assert((std::is_same::off_type, std::streamoff>::value), ""); + static_assert((std::is_same::pos_type, std::streampos>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static void assign(char_type& c1, const char_type& c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + char16_t s2[3] = {0}; + assert(std::char_traits::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::compare(u"", u"", 0) == 0); + assert(std::char_traits::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits::compare(u"1", u"1", 1) == 0); + assert(std::char_traits::compare(u"1", u"2", 1) < 0); + assert(std::char_traits::compare(u"2", u"1", 1) > 0); + + assert(std::char_traits::compare(u"12", u"12", 2) == 0); + assert(std::char_traits::compare(u"12", u"13", 2) < 0); + assert(std::char_traits::compare(u"12", u"22", 2) < 0); + assert(std::char_traits::compare(u"13", u"12", 2) > 0); + assert(std::char_traits::compare(u"22", u"12", 2) > 0); + + assert(std::char_traits::compare(u"123", u"123", 3) == 0); + assert(std::char_traits::compare(u"123", u"223", 3) < 0); + assert(std::char_traits::compare(u"123", u"133", 3) < 0); + assert(std::char_traits::compare(u"123", u"124", 3) < 0); + assert(std::char_traits::compare(u"223", u"123", 3) > 0); + assert(std::char_traits::compare(u"133", u"123", 3) > 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + char16_t s2[3] = {0}; + assert(std::char_traits::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::copy(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type eof(); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + std::char_traits::int_type i = std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq(char_type c1, char_type c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + assert(std::char_traits::eq(u'a', u'a')); + assert(!std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert( std::char_traits::eq_int_type(u'a', u'a')); + assert(!std::char_traits::eq_int_type(u'a', u'A')); + assert(!std::char_traits::eq_int_type(std::char_traits::eof(), u'A')); +#endif + assert( std::char_traits::eq_int_type(std::char_traits::eof(), + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + assert(std::char_traits::find(s1, 3, char16_t(1)) == s1); + assert(std::char_traits::find(s1, 3, char16_t(2)) == s1+1); + assert(std::char_traits::find(s1, 3, char16_t(3)) == s1+2); + assert(std::char_traits::find(s1, 3, char16_t(4)) == 0); + assert(std::char_traits::find(s1, 3, char16_t(0)) == 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static size_t length(const char_type* s); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::length(u"") == 0); + assert(std::char_traits::length(u"a") == 1); + assert(std::char_traits::length(u"aa") == 2); + assert(std::char_traits::length(u"aaa") == 3); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool lt(char_type c1, char_type c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + assert(!std::char_traits::lt(u'a', u'a')); + assert( std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + assert(std::char_traits::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::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::move(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type not_eof(int_type c); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::not_eof(u'a') == u'a'); + assert(std::char_traits::not_eof(u'A') == u'A'); +#endif + assert(std::char_traits::not_eof(0) == 0); + assert(std::char_traits::not_eof(std::char_traits::eof()) != + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr char_type to_char_type(int_type c); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::to_char_type(u'a') == u'a'); + assert(std::char_traits::to_char_type(u'A') == u'A'); +#endif + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type to_int_type(char_type c); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::to_int_type(u'a') == u'a'); + assert(std::char_traits::to_int_type(u'A') == u'A'); +#endif + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// 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 +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert((std::is_same::char_type, char16_t>::value), ""); + static_assert((std::is_same::int_type, std::uint_least16_t>::value), ""); + static_assert((std::is_same::off_type, std::streamoff>::value), ""); + static_assert((std::is_same::pos_type, std::u16streampos>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static void assign(char_type& c1, const char_type& c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + char32_t s2[3] = {0}; + assert(std::char_traits::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::compare(U"", U"", 0) == 0); + assert(std::char_traits::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits::compare(U"1", U"1", 1) == 0); + assert(std::char_traits::compare(U"1", U"2", 1) < 0); + assert(std::char_traits::compare(U"2", U"1", 1) > 0); + + assert(std::char_traits::compare(U"12", U"12", 2) == 0); + assert(std::char_traits::compare(U"12", U"13", 2) < 0); + assert(std::char_traits::compare(U"12", U"22", 2) < 0); + assert(std::char_traits::compare(U"13", U"12", 2) > 0); + assert(std::char_traits::compare(U"22", U"12", 2) > 0); + + assert(std::char_traits::compare(U"123", U"123", 3) == 0); + assert(std::char_traits::compare(U"123", U"223", 3) < 0); + assert(std::char_traits::compare(U"123", U"133", 3) < 0); + assert(std::char_traits::compare(U"123", U"124", 3) < 0); + assert(std::char_traits::compare(U"223", U"123", 3) > 0); + assert(std::char_traits::compare(U"133", U"123", 3) > 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + char32_t s2[3] = {0}; + assert(std::char_traits::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::copy(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type eof(); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + std::char_traits::int_type i = std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq(char_type c1, char_type c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + assert(std::char_traits::eq(U'a', U'a')); + assert(!std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert( std::char_traits::eq_int_type(U'a', U'a')); + assert(!std::char_traits::eq_int_type(U'a', U'A')); + assert(!std::char_traits::eq_int_type(std::char_traits::eof(), U'A')); +#endif + assert( std::char_traits::eq_int_type(std::char_traits::eof(), + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + assert(std::char_traits::find(s1, 3, char32_t(1)) == s1); + assert(std::char_traits::find(s1, 3, char32_t(2)) == s1+1); + assert(std::char_traits::find(s1, 3, char32_t(3)) == s1+2); + assert(std::char_traits::find(s1, 3, char32_t(4)) == 0); + assert(std::char_traits::find(s1, 3, char32_t(0)) == 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static size_t length(const char_type* s); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::length(U"") == 0); + assert(std::char_traits::length(U"a") == 1); + assert(std::char_traits::length(U"aa") == 2); + assert(std::char_traits::length(U"aaa") == 3); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool lt(char_type c1, char_type c2); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + assert(!std::char_traits::lt(U'a', U'a')); + assert( std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + assert(std::char_traits::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::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::move(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type not_eof(int_type c); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::not_eof(U'a') == U'a'); + assert(std::char_traits::not_eof(U'A') == U'A'); +#endif + assert(std::char_traits::not_eof(0) == 0); + assert(std::char_traits::not_eof(std::char_traits::eof()) != + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr char_type to_char_type(int_type c); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::to_char_type(U'a') == U'a'); + assert(std::char_traits::to_char_type(U'A') == U'A'); +#endif + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type to_int_type(char_type c); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits::to_int_type(U'a') == U'a'); + assert(std::char_traits::to_int_type(U'A') == U'A'); +#endif + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// 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 +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert((std::is_same::char_type, char32_t>::value), ""); + static_assert((std::is_same::int_type, std::uint_least32_t>::value), ""); + static_assert((std::is_same::off_type, std::streamoff>::value), ""); + static_assert((std::is_same::pos_type, std::u32streampos>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static void assign(char_type& c1, const char_type& c2); + +#include +#include + +int main() +{ + wchar_t c = L'\0'; + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include +#include + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + wchar_t s2[3] = {0}; + assert(std::char_traits::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ + assert(std::char_traits::compare(L"", L"", 0) == 0); + assert(std::char_traits::compare(NULL, NULL, 0) == 0); + + assert(std::char_traits::compare(L"1", L"1", 1) == 0); + assert(std::char_traits::compare(L"1", L"2", 1) < 0); + assert(std::char_traits::compare(L"2", L"1", 1) > 0); + + assert(std::char_traits::compare(L"12", L"12", 2) == 0); + assert(std::char_traits::compare(L"12", L"13", 2) < 0); + assert(std::char_traits::compare(L"12", L"22", 2) < 0); + assert(std::char_traits::compare(L"13", L"12", 2) > 0); + assert(std::char_traits::compare(L"22", L"12", 2) > 0); + + assert(std::char_traits::compare(L"123", L"123", 3) == 0); + assert(std::char_traits::compare(L"123", L"223", 3) < 0); + assert(std::char_traits::compare(L"123", L"133", 3) < 0); + assert(std::char_traits::compare(L"123", L"124", 3) < 0); + assert(std::char_traits::compare(L"223", L"123", 3) > 0); + assert(std::char_traits::compare(L"133", L"123", 3) > 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + wchar_t s2[3] = {0}; + assert(std::char_traits::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::copy(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type eof(); + +#include +#include + +int main() +{ + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq(char_type c1, char_type c2); + +#include +#include + +int main() +{ + wchar_t c = L'\0'; + assert(std::char_traits::eq(L'a', L'a')); + assert(!std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include +#include + +int main() +{ + assert( std::char_traits::eq_int_type(L'a', L'a')); + assert(!std::char_traits::eq_int_type(L'a', L'A')); + assert(!std::char_traits::eq_int_type(std::char_traits::eof(), L'A')); + assert( std::char_traits::eq_int_type(std::char_traits::eof(), + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include +#include + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + assert(std::char_traits::find(s1, 3, wchar_t(1)) == s1); + assert(std::char_traits::find(s1, 3, wchar_t(2)) == s1+1); + assert(std::char_traits::find(s1, 3, wchar_t(3)) == s1+2); + assert(std::char_traits::find(s1, 3, wchar_t(4)) == 0); + assert(std::char_traits::find(s1, 3, wchar_t(0)) == 0); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static size_t length(const char_type* s); + +#include +#include + +int main() +{ + assert(std::char_traits::length(L"") == 0); + assert(std::char_traits::length(L"a") == 1); + assert(std::char_traits::length(L"aa") == 2); + assert(std::char_traits::length(L"aaa") == 3); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr bool lt(char_type c1, char_type c2); + +#include +#include + +int main() +{ + wchar_t c = L'\0'; + assert(!std::char_traits::lt(L'a', L'a')); + assert( std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include +#include + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + assert(std::char_traits::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::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::move(NULL, s1, 0) == NULL); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type not_eof(int_type c); + +#include +#include + +int main() +{ + assert(std::char_traits::not_eof(L'a') == L'a'); + assert(std::char_traits::not_eof(L'A') == L'A'); + assert(std::char_traits::not_eof(0) == 0); + assert(std::char_traits::not_eof(std::char_traits::eof()) != + std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr char_type to_char_type(int_type c); + +#include +#include + +int main() +{ + assert(std::char_traits::to_char_type(L'a') == L'a'); + assert(std::char_traits::to_char_type(L'A') == L'A'); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// static constexpr int_type to_int_type(char_type c); + +#include +#include + +int main() +{ + assert(std::char_traits::to_int_type(L'a') == L'a'); + assert(std::char_traits::to_int_type(L'A') == L'A'); + assert(std::char_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template<> struct char_traits + +// typedef wchar_t char_type; +// typedef int int_type; +// typedef streamoff off_type; +// typedef streampos pos_type; +// typedef mbstate_t state_type; + +#include +#include + +int main() +{ + static_assert((std::is_same::char_type, wchar_t>::value), ""); + static_assert((std::is_same::int_type, std::wint_t>::value), ""); + static_assert((std::is_same::off_type, std::streamoff>::value), ""); + static_assert((std::is_same::pos_type, std::wstreampos>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// Test for the existence of: + +// basic_string typedef names +// typedef basic_string string; +// typedef basic_string u16string; +// typedef basic_string u32string; +// typedef basic_string wstring; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// double stod(const string& str, size_t *idx = 0); +// double stod(const wstring& str, size_t *idx = 0); + +#include +#include +#include + +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 + +// + +// float stof(const string& str, size_t *idx = 0); +// float stof(const wstring& str, size_t *idx = 0); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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::max() > std::numeric_limits::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 + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// long double stold(const string& str, size_t *idx = 0); +// long double stold(const wstring& str, size_t *idx = 0); + +#include + +#include +#include +#include + +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 + +// + +// 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 +#include + +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 + +// + +// 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 +#include + +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 + +// + +// 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 +#include + +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 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 +#include +#include + +template +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::max()); + assert(s.size() == std::numeric_limits::digits10 + 1); + std::istringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits::max()); + } + { + std::string s = std::to_string(std::numeric_limits::min()); + std::istringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits::min()); + } +} + +template +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::max()); + assert(s.size() == std::numeric_limits::digits10 + 1); + std::istringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits::max()); + } +} + +template +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(); + test_signed(); + test_signed(); + test_unsigned(); + test_unsigned(); + test_unsigned(); + test_float(); + test_float(); + test_float(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +template +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::max()); + assert(s.size() == std::numeric_limits::digits10 + 1); + std::wistringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits::max()); + } + { + std::wstring s = std::to_wstring(std::numeric_limits::min()); + std::wistringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits::min()); + } +} + +template +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::max()); + assert(s.size() == std::numeric_limits::digits10 + 1); + std::wistringstream is(s); + T t(0); + is >> t; + assert(t == std::numeric_limits::max()); + } +} + +template +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(); + test_signed(); + test_signed(); + test_unsigned(); + test_unsigned(); + test_unsigned(); + test_float(); + test_float(); + test_float(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +// + +// template +// future::type> +// async(F&& f, Args&&... args); + +// template +// future::type> +// async(launch policy, F&& f, Args&&... args); + +#include +#include +#include + +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 f3(int i) +{ + std::this_thread::sleep_for(ms(200)); + return std::unique_ptr(new int(i)); +} + +std::unique_ptr f4(std::unique_ptr&& 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 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 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 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 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 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 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 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 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 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 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 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 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> 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> f = + std::async(f4, std::unique_ptr(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 f = std::async(f5, 3); + std::this_thread::sleep_for(ms(300)); + try { f.get(); assert (false); } catch ( int ex ) {} + } + + { + std::future 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 + +// + +// template +// future::type> +// async(F&& f, Args&&... args); + +// template +// future::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 +#include +#include +#include +#include + +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 f = std::async(f_async); + int const result = f.get(); + assert(result == 42); + } + { + std::future f = std::async(std::launch::async, f_async); + int const result = f.get(); + assert(result == 42); + } + { + ran = false; + std::future 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 + +// + +// const error_category& future_category(); + +// virtual error_condition default_error_condition(int ev) const; + +#include +#include + +int main() +{ + const std::error_category& e_cat = std::future_category(); + std::error_condition e_cond = e_cat.default_error_condition(static_cast(std::errc::not_a_directory)); + assert(e_cond.category() == e_cat); + assert(e_cond.value() == static_cast(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 + +// + +// const error_category& future_category(); + +// virtual bool equivalent(const error_code& code, int condition) const; + +#include +#include + +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 + +// + +// const error_category& future_category(); + +// virtual bool equivalent(int code, const error_condition& condition) const; + +#include +#include + +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 + +// + +// const error_category& future_category(); + +#include +#include +#include + +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 + +// + +// class error_code + +// error_code make_error_code(future_errc e); + +#include +#include + +int main() +{ + { + std::error_code ec = make_error_code(std::future_errc::broken_promise); + assert(ec.value() == static_cast(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 + +// + +// class error_condition + +// error_condition make_error_condition(future_errc e); + +#include +#include + +int main() +{ + { + const std::error_condition ec1 = + std::make_error_condition(std::future_errc::future_already_retrieved); + assert(ec1.value() == + static_cast(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 + +// + +// class future_error + +// const error_code& code() const throw(); + +#include +#include + +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 + +// + +// class future_error : public logic_error {...}; + +#include +#include + +int main() +{ + static_assert((std::is_convertible::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 + +// + +// class future_error + +// const char* what() const throw(); + +#include +#include +#include + +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 + +// + +// enum class future_errc +// { +// future_already_retrieved = 1, +// promise_already_satisfied, +// no_state +// broken_promise, +// }; + +#include + +int main() +{ + static_assert(static_cast(std::future_errc::future_already_retrieved) == 1, ""); + static_assert(static_cast(std::future_errc::promise_already_satisfied) == 2, ""); + static_assert(static_cast(std::future_errc::no_state) == 3, ""); + static_assert(static_cast(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 + +// + +// enum class future_status +// { +// ready, +// timeout, +// deferred +// }; + +#include + +int main() +{ + static_assert(static_cast(std::future_status::ready) == 0, ""); + static_assert(static_cast(std::future_status::timeout) == 1, ""); + static_assert(static_cast(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 + +// + +// template <> struct is_error_code_enum : public true_type {}; + +#include + +int main() +{ + static_assert(std::is_error_code_enum::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 + +// + +// enum class launch +// { +// async = 1, +// deferred = 2, +// any = async | deferred +// }; + +#include +#include + +int main() +{ +#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS + static_assert(static_cast(std::launch::any) == + (static_cast(std::launch::async) | static_cast(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(std::launch::async) == 1, ""); + static_assert(static_cast(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 + +// + +// class promise + +// template +// promise(allocator_arg_t, const Allocator& a); + +#include +#include + +#include "../test_allocator.h" +#include "min_allocator.h" + +int main() +{ + assert(test_alloc_base::count == 0); + { + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 1); + std::future f = p.get_future(); + assert(test_alloc_base::count == 1); + assert(f.valid()); + } + assert(test_alloc_base::count == 0); + { + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 1); + std::future f = p.get_future(); + assert(test_alloc_base::count == 1); + assert(f.valid()); + } + assert(test_alloc_base::count == 0); + { + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 1); + std::future 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 p(std::allocator_arg, bare_allocator()); + std::future f = p.get_future(); + assert(f.valid()); + } + { + std::promise p(std::allocator_arg, bare_allocator()); + std::future f = p.get_future(); + assert(f.valid()); + } + { + std::promise p(std::allocator_arg, bare_allocator()); + std::future f = p.get_future(); + assert(f.valid()); + } + // Test with a minimal allocator that returns class-type pointers + { + std::promise p(std::allocator_arg, min_allocator()); + std::future f = p.get_future(); + assert(f.valid()); + } + { + std::promise p(std::allocator_arg, min_allocator()); + std::future f = p.get_future(); + assert(f.valid()); + } + { + std::promise p(std::allocator_arg, min_allocator()); + std::future 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. +// +//===----------------------------------------------------------------------===// + +// + +// class promise + +// promise& operator=(const promise& rhs) = delete; + +#include +#include + +#include "../test_allocator.h" + +int main() +{ + assert(test_alloc_base::count == 0); + { + std::promise p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + p = p0; + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + p = p0; + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + p = p0; + assert(test_alloc_base::count == 1); + std::future 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. +// +//===----------------------------------------------------------------------===// + +// + +// class promise + +// promise(const promise&) = delete; + +#include +#include + +#include "../test_allocator.h" + +int main() +{ + assert(test_alloc_base::count == 0); + { + std::promise p0(std::allocator_arg, test_allocator()); + std::promise p(p0); + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(p0); + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(p0); + assert(test_alloc_base::count == 1); + std::future 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 + +// + +// class promise + +// promise(); + +#include +#include + +int main() +{ + { + std::promise p; + std::future f = p.get_future(); + assert(f.valid()); + } + { + std::promise p; + std::future f = p.get_future(); + assert(f.valid()); + } + { + std::promise p; + std::future 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 + +// + +// class promise + +// ~promise(); + +#include +#include + +int main() +{ + { + typedef int T; + std::future f; + { + std::promise p; + f = p.get_future(); + p.set_value(3); + } + assert(f.get() == 3); + } + { + typedef int T; + std::future f; + { + std::promise 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 f; + { + std::promise p; + f = p.get_future(); + p.set_value(i); + } + assert(&f.get() == &i); + } + { + typedef int& T; + std::future f; + { + std::promise 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 f; + { + std::promise p; + f = p.get_future(); + p.set_value(); + } + f.get(); + assert(true); + } + { + typedef void T; + std::future f; + { + std::promise 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 + // 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 + +// + +// class promise + +// future get_future(); + +#include +#include + +int main() +{ + { + std::promise p; + std::future f = p.get_future(); + p.set_value(105.5); + assert(f.get() == 105.5); + } + { + std::promise p; + std::future 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 p; + std::promise p0 = std::move(p); + try + { + std::future 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 + +// + +// class promise + +// promise& operator=(promise&& rhs); + +#include +#include + +#include "../test_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(test_alloc_base::count == 0); + { + std::promise p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + p = std::move(p0); + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + p = std::move(p0); + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + p = std::move(p0); + assert(test_alloc_base::count == 1); + std::future 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 + +// + +// class promise + +// promise(promise&& rhs); + +#include +#include + +#include "../test_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(test_alloc_base::count == 0); + { + std::promise p0(std::allocator_arg, test_allocator()); + std::promise p(std::move(p0)); + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(std::move(p0)); + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(std::move(p0)); + assert(test_alloc_base::count == 1); + std::future 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 + +// + +// class promise + +// void set_exception(exception_ptr p); + +#include +#include + +int main() +{ + { + typedef int T; + std::promise p; + std::future 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 + +// + +// class promise + +// void promise::set_exception_at_thread_exit(exception_ptr p); + +#include +#include + +void func(std::promise p) +{ + const int i = 5; + p.set_exception_at_thread_exit(std::make_exception_ptr(3)); +} + +int main() +{ + { + typedef int T; + std::promise p; + std::future 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 + +// + +// class promise + +// void promise::set_value(R& r); + +#include +#include + +int main() +{ + { + typedef int& T; + int i = 3; + std::promise p; + std::future 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 + +// + +// class promise + +// void promise::set_value_at_thread_exit(R& r); + +#include +#include +#include + +int i = 0; + +void func(std::promise p) +{ + p.set_value_at_thread_exit(i); + i = 4; +} + +int main() +{ + { + std::promise p; + std::future 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 + +// + +// class promise + +// void promise::set_value(R&& r); + +#include +#include +#include + +#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 T; + T i(new int(3)); + std::promise p; + std::future 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 p; + std::future 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 + +// + +// class promise + +// void promise::set_value_at_thread_exit(R&& r); + +#include +#include +#include + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +void func(std::promise> p) +{ + p.set_value_at_thread_exit(std::unique_ptr(new int(5))); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::promise> p; + std::future> 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 + +// + +// class promise + +// void promise::set_value_at_thread_exit(const R& r); + +#include +#include + +void func(std::promise p) +{ + const int i = 5; + p.set_value_at_thread_exit(i); +} + +int main() +{ + { + std::promise p; + std::future 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 + +// + +// class promise + +// void promise::set_value_at_thread_exit(); + +#include +#include +#include + +int i = 0; + +void func(std::promise p) +{ + p.set_value_at_thread_exit(); + i = 1; +} + +int main() +{ + { + std::promise p; + std::future 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 + +// + +// class promise + +// void promise::set_value(const R& r); + +#include +#include + +struct A +{ + A() {} + A(const A&) {throw 10;} +}; + +int main() +{ + { + typedef int T; + T i = 3; + std::promise p; + std::future 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 p; + std::future 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 + +// + +// class promise + +// void promise::set_value(); + +#include +#include + +int main() +{ + { + typedef void T; + std::promise p; + std::future 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 + +// + +// class promise + +// void swap(promise& other); + +// template void swap(promise& x, promise& y); + +#include +#include + +#include "../test_allocator.h" + +int main() +{ + assert(test_alloc_base::count == 0); + { + std::promise p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + p.swap(p0); + assert(test_alloc_base::count == 2); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p(std::allocator_arg, test_allocator()); + assert(test_alloc_base::count == 2); + swap(p, p0); + assert(test_alloc_base::count == 2); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p; + assert(test_alloc_base::count == 1); + p.swap(p0); + assert(test_alloc_base::count == 1); + std::future 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 p0(std::allocator_arg, test_allocator()); + std::promise p; + assert(test_alloc_base::count == 1); + swap(p, p0); + assert(test_alloc_base::count == 1); + std::future 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 + +// + +// class promise + +// template +// struct uses_allocator, Alloc> +// : true_type { }; + +#include +#include "../test_allocator.h" + +int main() +{ + static_assert((std::uses_allocator, test_allocator >::value), ""); + static_assert((std::uses_allocator, test_allocator >::value), ""); + static_assert((std::uses_allocator, test_allocator >::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 + +// + +// class shared_future + +// shared_future& operator=(const shared_future& rhs); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef int T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f; + f = f0; + assert(f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::shared_future f0; + std::shared_future f; + f = f0; + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f; + f = f0; + assert(f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::shared_future f0; + std::shared_future f; + f = f0; + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f; + f = f0; + assert(f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::shared_future f0; + std::shared_future 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 + +// + +// class shared_future + +// shared_future(const shared_future& rhs); + +#include +#include + +int main() +{ + { + typedef int T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f = f0; + assert(f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::shared_future f0; + std::shared_future f = f0; + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f = f0; + assert(f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::shared_future f0; + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f = f0; + assert(f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::shared_future f0; + std::shared_future 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 + +// + +// class shared_future + +// shared_future(future&& rhs); + +#include +#include + +int main() +{ + { + typedef int T; + std::promise p; + std::future f0 = p.get_future(); + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::future f0; + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::future f0 = p.get_future(); + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::future f0; + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::future f0 = p.get_future(); + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::future f0; + std::shared_future 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 + +// + +// class shared_future + +// shared_future(); + +#include +#include + +int main() +{ + { + std::shared_future f; + assert(!f.valid()); + } + { + std::shared_future f; + assert(!f.valid()); + } + { + std::shared_future 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 + +// + +// class shared_future + +// ~shared_future(); + +#include +#include + +#include "../test_allocator.h" + +int main() +{ + assert(test_alloc_base::count == 0); + { + typedef int T; + std::shared_future f; + { + std::promise p(std::allocator_arg, test_allocator()); + 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 f; + { + std::promise p(std::allocator_arg, test_allocator()); + 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 f; + { + std::promise p(std::allocator_arg, test_allocator()); + 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 + +// + +// class shared_future + +// const R& shared_future::get(); +// R& shared_future::get(); +// void shared_future::get(); + +#include +#include + +void func1(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_value(3); +} + +void func2(std::promise 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 p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + j = 5; + p.set_value(j); +} + +void func4(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_exception(std::make_exception_ptr(3.5)); +} + +void func5(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_value(); +} + +void func6(std::promise 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 p; + std::shared_future f = p.get_future(); + std::thread(func1, std::move(p)).detach(); + assert(f.valid()); + assert(f.get() == 3); + assert(f.valid()); + } + { + std::promise p; + std::shared_future 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 p; + std::shared_future f = p.get_future(); + std::thread(func3, std::move(p)).detach(); + assert(f.valid()); + assert(f.get() == 5); + assert(f.valid()); + } + { + std::promise p; + std::shared_future 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 p; + std::shared_future f = p.get_future(); + std::thread(func5, std::move(p)).detach(); + assert(f.valid()); + f.get(); + assert(f.valid()); + } + { + std::promise p; + std::shared_future 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 + +// + +// class shared_future + +// shared_future& operator=(shared_future&& rhs); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef int T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f; + f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::shared_future f0; + std::shared_future f; + f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f; + f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::shared_future f0; + std::shared_future f; + f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f; + f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::shared_future f0; + std::shared_future 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 + +// + +// class shared_future + +// shared_future(shared_future&& rhs); + +#include +#include + +int main() +{ + { + typedef int T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::shared_future f0; + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::shared_future f0; + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::shared_future f0 = p.get_future(); + std::shared_future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::shared_future f0; + std::shared_future 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 + +// + +// class shared_future + +// void wait() const; + +#include +#include + +void func1(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_value(3); +} + +int j = 0; + +void func3(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + j = 5; + p.set_value(j); +} + +void func5(std::promise 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 ms; + { + typedef int T; + std::promise p; + std::shared_future 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 p; + std::shared_future 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 p; + std::shared_future 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 + +// + +// class shared_future + +// template +// future_status +// wait_for(const chrono::duration& rel_time) const; + +#include +#include + +typedef std::chrono::milliseconds ms; + +void func1(std::promise p) +{ + std::this_thread::sleep_for(ms(500)); + p.set_value(3); +} + +int j = 0; + +void func3(std::promise p) +{ + std::this_thread::sleep_for(ms(500)); + j = 5; + p.set_value(j); +} + +void func5(std::promise 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 p; + std::shared_future 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 p; + std::shared_future 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 p; + std::shared_future 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 + + // + + // class shared_future + + // template + // future_status + // wait_until(const chrono::time_point& abs_time) const; + + #include + #include + #include + + enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting }; + typedef std::chrono::milliseconds ms; + + std::atomic 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 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 p) + { + wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); + j = 5; + p.set_value(j); + set_worker_thread_state(WorkerThreadState::Exiting); + } + + void func5(std::promise 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 p; + std::shared_future 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 p; + std::shared_future 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 p; + std::shared_future 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. +// +//===----------------------------------------------------------------------===// + +// + +// class packaged_task + +// packaged_task& operator=(packaged_task&) = delete; + +#include +#include + +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 p0(A(5)); + std::packaged_task p; + p = p0; + assert(!p0.valid()); + assert(p.valid()); + std::future f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task p0; + std::packaged_task 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 + +// + +// class packaged_task + +// packaged_task& operator=(packaged_task&& other); + +#include +#include + +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 p0(A(5)); + std::packaged_task p; + p = std::move(p0); + assert(!p0.valid()); + assert(p.valid()); + std::future f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task p0; + std::packaged_task 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. +// +//===----------------------------------------------------------------------===// + +// + +// class packaged_task +// template +// packaged_task(F&& f); +// These constructors shall not participate in overload resolution if +// decay::type is the same type as std::packaged_task. + +#include +#include + +struct A {}; +typedef std::packaged_task PT; +typedef volatile std::packaged_task 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. +// +//===----------------------------------------------------------------------===// + +// + +// class packaged_task +// template +// packaged_task(allocator_arg_t, const Allocator& a, F&& f); +// These constructors shall not participate in overload resolution if +// decay::type is the same type as std::packaged_task. + +#include +#include + +#include "../../test_allocator.h" + +struct A {}; +typedef std::packaged_task PT; +typedef volatile std::packaged_task VPT; + +int main() +{ + PT p { std::allocator_arg_t{}, test_allocator{}, 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. +// +//===----------------------------------------------------------------------===// + +// + +// class packaged_task + +// packaged_task(packaged_task&) = delete; + +#include +#include + +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 p0(A(5)); + std::packaged_task p(p0); + assert(!p0.valid()); + assert(p.valid()); + std::future f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task p0; + std::packaged_task 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 + +// + +// class packaged_task + +// packaged_task(); + +#include +#include + +struct A {}; + +int main() +{ + std::packaged_task 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 + +// + +// class packaged_task + +// template +// explicit packaged_task(F&& f); + +#include +#include + +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 p(A(5)); + assert(p.valid()); + std::future 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 p(a); + assert(p.valid()); + std::future 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 p(&func); + assert(p.valid()); + std::future f = p.get_future(); + p(4); + assert(f.get() == 4); + } + { + std::packaged_task p(func); + assert(p.valid()); + std::future 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 + +// + +// class packaged_task + +// template +// explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f); + +#include +#include + +#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 p(std::allocator_arg, + test_allocator(), A(5)); + assert(test_alloc_base::count > 0); + assert(p.valid()); + std::future 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 p(std::allocator_arg, + test_allocator(), a); + assert(test_alloc_base::count > 0); + assert(p.valid()); + std::future 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 p(std::allocator_arg, test_allocator(), &func); + assert(test_alloc_base::count > 0); + assert(p.valid()); + std::future 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 p(std::allocator_arg, test_allocator(), func); + assert(test_alloc_base::count > 0); + assert(p.valid()); + std::future 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 p(std::allocator_arg, + bare_allocator(), A(5)); + assert(p.valid()); + std::future 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 p(std::allocator_arg, + min_allocator(), A(5)); + assert(p.valid()); + std::future 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 + +// + +// class packaged_task + +// packaged_task(packaged_task&& other); + +#include +#include + +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 p0(A(5)); + std::packaged_task p = std::move(p0); + assert(!p0.valid()); + assert(p.valid()); + std::future f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task p0; + std::packaged_task 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 + +// + +// class packaged_task + +// ~packaged_task(); + +#include +#include + +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 p) +{ +} + +void func2(std::packaged_task p) +{ + p(3, 'a'); +} + +int main() +{ + { + std::packaged_task p(A(5)); + std::future 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 p(A(5)); + std::future 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 + +// + +// class packaged_task + +// future get_future(); + +#include +#include + +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 p(A(5)); + std::future f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task p(A(5)); + std::future 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 p; + try + { + std::future 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 + +// + +// class packaged_task + +// void make_ready_at_thread_exit(ArgTypes... args); + +#include +#include + +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 p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.make_ready_at_thread_exit(3, 'a'); +} + +void func1(std::packaged_task p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.make_ready_at_thread_exit(3, 'z'); +} + +void func2(std::packaged_task 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 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 p(A(5)); + std::future f = p.get_future(); + std::thread(func0, std::move(p)).detach(); + assert(f.get() == 105.0); + } + { + std::packaged_task p(A(5)); + std::future 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 p(A(5)); + std::future f = p.get_future(); + std::thread(func2, std::move(p)).detach(); + assert(f.get() == 105.0); + } + { + std::packaged_task 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 + +// + +// class packaged_task + +// void operator()(ArgTypes... args); + +#include +#include + +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 p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p(3, 'a'); +} + +void func1(std::packaged_task p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p(3, 'z'); +} + +void func2(std::packaged_task 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 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 p(A(5)); + std::future f = p.get_future(); + std::thread(func0, std::move(p)).detach(); + assert(f.get() == 105.0); + } + { + std::packaged_task p(A(5)); + std::future 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 p(A(5)); + std::future f = p.get_future(); + std::thread t(func2, std::move(p)); + assert(f.get() == 105.0); + t.join(); + } + { + std::packaged_task 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 + +// + +// class packaged_task + +// void reset(); + +#include +#include + +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 p(A(5)); + std::future 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 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 + +// + +// class packaged_task + +// void swap(packaged_task& other); + +#include +#include + +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 p0(A(5)); + std::packaged_task p; + p.swap(p0); + assert(!p0.valid()); + assert(p.valid()); + std::future f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task p0; + std::packaged_task 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 + +// + +// class packaged_task + +// template +// void +// swap(packaged_task& x, packaged_task& y); + +#include +#include + +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 p0(A(5)); + std::packaged_task p; + swap(p, p0); + assert(!p0.valid()); + assert(p.valid()); + std::future f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task p0; + std::packaged_task 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 + +// + +// class packaged_task + +// template +// struct uses_allocator, Alloc> +// : true_type { }; + +#include +#include "../../test_allocator.h" + +int main() +{ + static_assert((std::uses_allocator, test_allocator >::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 + +// + +// template +// class packaged_task +// { +// public: +// typedef R result_type; + +#include +#include + +struct A {}; + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// class future + +// future& operator=(const future&) = delete; + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef int T; + std::promise p; + std::future f0 = p.get_future(); + std::future f; + f = f0; + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::future f0; + std::future f; + f = f0; + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::future f0 = p.get_future(); + std::future f; + f = f0; + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::future f0; + std::future f; + f = f0; + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::future f0 = p.get_future(); + std::future f; + f = f0; + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::future f0; + std::future 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. +// +//===----------------------------------------------------------------------===// + +// + +// class future + +// future(const future&) = delete; + +#include +#include + +int main() +{ + { + typedef int T; + std::promise p; + std::future f0 = p.get_future(); + std::future f = f0; + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::future f0; + std::future f = f0; + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::future f0 = p.get_future(); + std::future f = f0; + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::future f0; + std::future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::future f0 = p.get_future(); + std::future f = f0; + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::future f0; + std::future 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 + +// + +// class future + +// future(); + +#include +#include + +int main() +{ + { + std::future f; + assert(!f.valid()); + } + { + std::future f; + assert(!f.valid()); + } + { + std::future 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 + +// + +// class future + +// ~future(); + +#include +#include + +#include "../test_allocator.h" + +int main() +{ + assert(test_alloc_base::count == 0); + { + typedef int T; + std::future f; + { + std::promise p(std::allocator_arg, test_allocator()); + 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 f; + { + std::promise p(std::allocator_arg, test_allocator()); + 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 f; + { + std::promise p(std::allocator_arg, test_allocator()); + 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 + +// + +// class future + +// R future::get(); +// R& future::get(); +// void future::get(); + +#include +#include + +void func1(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_value(3); +} + +void func2(std::promise 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 p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + j = 5; + p.set_value(j); +} + +void func4(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_exception(std::make_exception_ptr(3.5)); +} + +void func5(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_value(); +} + +void func6(std::promise 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 p; + std::future f = p.get_future(); + std::thread(func1, std::move(p)).detach(); + assert(f.valid()); + assert(f.get() == 3); + assert(!f.valid()); + } + { + std::promise p; + std::future 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 p; + std::future f = p.get_future(); + std::thread(func3, std::move(p)).detach(); + assert(f.valid()); + assert(f.get() == 5); + assert(!f.valid()); + } + { + std::promise p; + std::future 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 p; + std::future f = p.get_future(); + std::thread(func5, std::move(p)).detach(); + assert(f.valid()); + f.get(); + assert(!f.valid()); + } + { + std::promise p; + std::future 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 + +// + +// class future + +// future& operator=(future&& rhs); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef int T; + std::promise p; + std::future f0 = p.get_future(); + std::future f; + f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::future f0; + std::future f; + f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::future f0 = p.get_future(); + std::future f; + f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::future f0; + std::future f; + f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::future f0 = p.get_future(); + std::future f; + f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::future f0; + std::future 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 + +// + +// class future + +// future(future&& rhs); + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef int T; + std::promise p; + std::future f0 = p.get_future(); + std::future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::future f0; + std::future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::future f0 = p.get_future(); + std::future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::future f0; + std::future f = std::move(f0); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::future f0 = p.get_future(); + std::future f = std::move(f0); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::future f0; + std::future 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 + +// + +// class future + +// shared_future share() &&; + +#include +#include + +int main() +{ + { + typedef int T; + std::promise p; + std::future f0 = p.get_future(); + std::shared_future f = std::move(f0.share()); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int T; + std::future f0; + std::shared_future f = std::move(f0.share()); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef int& T; + std::promise p; + std::future f0 = p.get_future(); + std::shared_future f = std::move(f0.share()); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef int& T; + std::future f0; + std::shared_future f = std::move(f0.share()); + assert(!f0.valid()); + assert(!f.valid()); + } + { + typedef void T; + std::promise p; + std::future f0 = p.get_future(); + std::shared_future f = std::move(f0.share()); + assert(!f0.valid()); + assert(f.valid()); + } + { + typedef void T; + std::future f0; + std::shared_future 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 + +// + +// class future + +// void wait() const; + +#include +#include + +void func1(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.set_value(3); +} + +int j = 0; + +void func3(std::promise p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + j = 5; + p.set_value(j); +} + +void func5(std::promise 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 ms; + { + typedef int T; + std::promise p; + std::future 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 p; + std::future 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 p; + std::future 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 + +// + +// class future + +// template +// future_status +// wait_for(const chrono::duration& rel_time) const; + +#include +#include + +typedef std::chrono::milliseconds ms; + +void func1(std::promise p) +{ + std::this_thread::sleep_for(ms(500)); + p.set_value(3); +} + +int j = 0; + +void func3(std::promise p) +{ + std::this_thread::sleep_for(ms(500)); + j = 5; + p.set_value(j); +} + +void func5(std::promise 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 p; + std::future 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 p; + std::future 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 p; + std::future 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 + + // + + // class future + + // template + // future_status + // wait_until(const chrono::time_point& abs_time) const; + + #include + #include + #include + + enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting }; + typedef std::chrono::milliseconds ms; + + std::atomic 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 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 p) + { + wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); + j = 5; + p.set_value(j); + set_worker_thread_state(WorkerThreadState::Exiting); + } + + void func5(std::promise 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 p; + std::future 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 p; + std::future 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 p; + std::future 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 +#include +#include +#include +#include +#include + +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 test_allocator + : public test_alloc_base +{ + int data_; + + template 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::type reference; + typedef typename std::add_lvalue_reference::type const_reference; + + template struct rebind {typedef test_allocator 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 test_allocator(const test_allocator& 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 + : public test_alloc_base +{ + int data_; + + template 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 struct rebind {typedef test_allocator 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 test_allocator(const test_allocator& 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 other_allocator +{ + int data_; + + template friend class other_allocator; + +public: + typedef T value_type; + + other_allocator() : data_(-1) {} + explicit other_allocator(int i) : data_(i) {} + template other_allocator(const other_allocator& 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 + +// + +#include + +#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 + +// + +// #define __STDCPP_THREADS__ __cplusplus + +#include + +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 + +// + +// enum class cv_status { no_timeout, timeout }; + +#include +#include + +int main() +{ + assert(static_cast(std::cv_status::no_timeout) == 0); + assert(static_cast(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 + +// + +// void +// notify_all_at_thread_exit(condition_variable& cond, unique_lock lk); + +#include +#include +#include +#include +#include + +std::condition_variable cv; +std::mutex mut; + +typedef std::chrono::milliseconds ms; +typedef std::chrono::high_resolution_clock Clock; + +void func() +{ + std::unique_lock lk(mut); + std::notify_all_at_thread_exit(cv, std::move(lk)); + std::this_thread::sleep_for(ms(300)); +} + +int main() +{ + std::unique_lock 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. +// +//===----------------------------------------------------------------------===// + +// + +// class condition_variable; + +// condition_variable& operator=(const condition_variable&) = delete; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class condition_variable; + +// condition_variable(const condition_variable&) = delete; + +#include +#include + +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 + +// + +// class condition_variable; + +// condition_variable(); + +#include +#include + +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 + +// + +// class condition_variable; + +// ~condition_variable(); + +#include +#include +#include +#include + +std::condition_variable* cv; +std::mutex m; +typedef std::unique_lock 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 + +// + +// class condition_variable; + +// typedef pthread_cond_t* native_handle_type; +// native_handle_type native_handle(); + +#include +#include + +int main() +{ + static_assert((std::is_same::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 + +// + +// class condition_variable; + +// void notify_all(); + +#include +#include +#include +#include + +std::condition_variable cv; +std::mutex mut; + +int test0 = 0; +int test1 = 0; +int test2 = 0; + +void f1() +{ + std::unique_lock lk(mut); + assert(test1 == 0); + while (test1 == 0) + cv.wait(lk); + assert(test1 == 1); + test1 = 2; +} + +void f2() +{ + std::unique_lock 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_locklk(mut); + test1 = 1; + test2 = 1; + } + cv.notify_all(); + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + std::unique_locklk(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 + +// + +// class condition_variable; + +// void notify_one(); + +#include +#include +#include +#include + +std::condition_variable cv; +std::mutex mut; + +int test0 = 0; +int test1 = 0; +int test2 = 0; + +void f1() +{ + std::unique_lock lk(mut); + assert(test1 == 0); + while (test1 == 0) + cv.wait(lk); + assert(test1 == 1); + test1 = 2; +} + +void f2() +{ + std::unique_lock 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_locklk(mut); + test1 = 1; + test2 = 1; + } + cv.notify_one(); + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + std::unique_locklk(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_locklk(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 + +// + +// class condition_variable; + +// void wait(unique_lock& lock); + +#include +#include +#include +#include + +std::condition_variable cv; +std::mutex mut; + +int test1 = 0; +int test2 = 0; + +void f() +{ + std::unique_lock lk(mut); + assert(test2 == 0); + test1 = 1; + cv.notify_one(); + while (test2 == 0) + cv.wait(lk); + assert(test2 != 0); +} + +int main() +{ + std::unique_locklk(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 + +// + +// class condition_variable; + +// template +// cv_status +// wait_for(unique_lock& lock, +// const chrono::duration& rel_time); + +#include +#include +#include +#include +#include + +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 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_locklk(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_locklk(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 + +// + +// class condition_variable; + +// template +// bool +// wait_for(unique_lock& lock, +// const chrono::duration& rel_time, +// Predicate pred); + +#include +#include +#include +#include +#include + +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 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_locklk(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_locklk(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 + +// + +// class condition_variable; + +// template +// void wait(unique_lock& lock, Predicate pred); + +#include +#include +#include +#include +#include + +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 lk(mut); + assert(test2 == 0); + test1 = 1; + cv.notify_one(); + cv.wait(lk, Pred(test2)); + assert(test2 != 0); +} + +int main() +{ + std::unique_locklk(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 + +// + +// class condition_variable; + +// template +// cv_status +// wait_until(unique_lock& lock, +// const chrono::time_point& abs_time); + +#include +#include +#include +#include +#include + +struct Clock +{ + typedef std::chrono::milliseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef std::chrono::time_point time_point; + static const bool is_steady = true; + + static time_point now() + { + using namespace std::chrono; + return time_point(duration_cast( + 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 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_locklk(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_locklk(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 + +// + +// class condition_variable; + +// template +// bool +// wait_until(unique_lock& lock, +// const chrono::time_point& abs_time, +// Predicate pred); + +#include +#include +#include +#include +#include + +struct Clock +{ + typedef std::chrono::milliseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef std::chrono::time_point time_point; + static const bool is_steady = true; + + static time_point now() + { + using namespace std::chrono; + return time_point(duration_cast( + 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 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_locklk(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_locklk(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. +// +//===----------------------------------------------------------------------===// + +// + +// class condition_variable_any; + +// condition_variable_any& operator=(const condition_variable_any&) = delete; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class condition_variable_any; + +// condition_variable_any(const condition_variable_any&) = delete; + +#include +#include + +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 + +// + +// class condition_variable_any; + +// condition_variable_any(); + +#include +#include + +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 + +// + +// class condition_variable_any; + +// ~condition_variable_any(); + +#include +#include +#include +#include + +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 + +// + +// class condition_variable_any; + +// void notify_all(); + +#include +#include +#include +#include + +std::condition_variable_any cv; + +typedef std::timed_mutex L0; +typedef std::unique_lock 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 + +// + +// class condition_variable_any; + +// void notify_one(); + +#include +#include +#include +#include + +std::condition_variable_any cv; + +typedef std::timed_mutex L0; +typedef std::unique_lock 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 +#include +#include +#include +#include +#include + +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 + +// + +// class condition_variable_any; + +// template +// void wait(Lock& lock); + +#include +#include +#include +#include + +std::condition_variable_any cv; + +typedef std::timed_mutex L0; +typedef std::unique_lock 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 +#include +#include +#include +#include +#include + +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 + +// + +// class condition_variable_any; + +// template +// cv_status +// wait_for(Lock& lock, const chrono::duration& rel_time); + +#include +#include +#include +#include +#include + +std::condition_variable_any cv; + +typedef std::timed_mutex L0; +typedef std::unique_lock 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 + +// + +// class condition_variable_any; + +// template +// bool +// wait_for(Lock& lock, const chrono::duration& rel_time, +// Predicate pred); + +#include +#include +#include +#include +#include + +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 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 + +// + +// class condition_variable_any; + +// template +// void wait(Lock& lock, Predicate pred); + +#include +#include +#include +#include +#include + +std::condition_variable_any cv; + +typedef std::timed_mutex L0; +typedef std::unique_lock 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 + +// + +// class condition_variable_any; + +// template +// cv_status +// wait_until(Lock& lock, const chrono::time_point& abs_time); + +#include +#include +#include +#include +#include + +struct Clock +{ + typedef std::chrono::milliseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef std::chrono::time_point time_point; + static const bool is_steady = true; + + static time_point now() + { + using namespace std::chrono; + return time_point(duration_cast( + steady_clock::now().time_since_epoch() + )); + } +}; + +std::condition_variable_any cv; + +typedef std::timed_mutex L0; +typedef std::unique_lock 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 + +// + +// class condition_variable_any; + +// template +// bool +// wait_until(Lock& lock, +// const chrono::time_point& abs_time, +// Predicate pred); + +#include +#include +#include +#include +#include + +struct Clock +{ + typedef std::chrono::milliseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef std::chrono::time_point time_point; + static const bool is_steady = true; + + static time_point now() + { + using namespace std::chrono; + return time_point(duration_cast( + 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 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 + +// + +#include + +#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 + +// + +// template +// void lock(L1&, L2&, L3&...); + +#include +#include + +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 + +// + +// template +// int try_lock(L1&, L2&, L3&...); + +#include +#include + +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 + +// + +// template class lock_guard; + +// lock_guard(mutex_type& m, adopt_lock_t); + +#include +#include +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class lock_guard; + +// lock_guard& operator=(lock_guard const&) = delete; + +#include + +int main() +{ + std::mutex m0; + std::mutex m1; + std::lock_guard lg0(m0); + std::lock_guard 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class lock_guard; + +// lock_guard(lock_guard const&) = delete; + +#include + +int main() +{ + std::mutex m; + std::lock_guard lg0(m); + std::lock_guard 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class lock_guard; + +// explicit lock_guard(mutex_type& m); + +#include +#include +#include +#include + +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 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 + +// + +// template class lock_guard; + +// explicit lock_guard(mutex_type& m); + +#include +#include +#include +#include + +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 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 + +// + +// template +// class lock_guard +// { +// public: +// typedef Mutex mutex_type; +// ... +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class shared_lock; + +// shared_lock& operator=(shared_lock const&) = delete; + +#include + +#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 lk0(m0); + std::shared_lock 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class shared_lock; + +// shared_lock(shared_lock const&) = delete; + +#include + +#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 lk0(m); + std::shared_lock 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 + +// + +// template class shared_lock; + +// shared_lock(); + +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_lock 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 + +// + +// template class shared_lock; + +// shared_lock& operator=(shared_lock&& u); + +#include +#include + +#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 lk0(m0); + std::shared_lock 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 + +// + +// template class shared_lock; + +// shared_lock(shared_lock&& u); + +#include +#include + +#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 lk0(m); + std::shared_lock 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 + +// + +// template class shared_lock; + +// explicit shared_lock(mutex_type& m); + +#include +#include +#include +#include +#include + +#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 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 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 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 + +// + +// template class shared_lock; + +// shared_lock(mutex_type& m, adopt_lock_t); + +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_timed_mutex m; + m.lock_shared(); + std::shared_lock 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 + +// + +// template class shared_lock; + +// shared_lock(mutex_type& m, defer_lock_t); + +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::shared_timed_mutex m; + std::shared_lock 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 + +// + +// class timed_mutex; + +// template +// shared_lock(mutex_type& m, const chrono::duration& rel_time); + +#include +#include +#include +#include +#include + +#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 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 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 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 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 + +// + +// class shared_timed_mutex; + +// template +// shared_lock(mutex_type& m, const chrono::time_point& abs_time); + +#include +#include +#include +#include +#include + +#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 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 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 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 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 + +// + +// template class shared_lock; + +// shared_lock(mutex_type& m, try_to_lock_t); + +#include +#include +#include +#include +#include + +#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 lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + { + std::shared_lock lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + { + std::shared_lock lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + while (true) + { + std::shared_lock 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 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 + +// + +// template class shared_lock; + +// void lock(); + +#include +#include +#include +#include +#include + +#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 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 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 + +// + +// template class shared_lock; + +// bool try_lock(); + +#include +#include + +#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 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 + +// + +// template class shared_lock; + +// template +// bool try_lock_for(const chrono::duration& rel_time); + +#include +#include + +#if _LIBCPP_STD_VER > 11 + +bool try_lock_for_called = false; + +typedef std::chrono::milliseconds ms; + +struct mutex +{ + template + bool try_lock_shared_for(const std::chrono::duration& 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 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 + +// + +// template class shared_lock; + +// template +// bool try_lock_until(const chrono::time_point& abs_time); + +#include +#include + +#if _LIBCPP_STD_VER > 11 + +bool try_lock_until_called = false; + +struct mutex +{ + template + bool try_lock_shared_until(const std::chrono::time_point& 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 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 + +// + +// template class shared_lock; + +// void unlock(); + +#include +#include + +#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 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 + +// + +// template class shared_lock; + +// void swap(shared_lock& u) noexcept; + +#include +#include + +#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 lk1(m); + std::shared_lock 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 + +// + +// template class shared_lock; + +// template +// void swap(shared_lock& x, shared_lock& y) noexcept; + +#include +#include + +#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 lk1(m); + std::shared_lock 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 + +// + +// template class shared_lock; + +// mutex_type* release() noexcept; + +#include +#include + +#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 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 + +// + +// template class shared_lock; + +// mutex_type *mutex() const noexcept; + +#include +#include + +#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 lk0; + assert(lk0.mutex() == nullptr); + std::shared_lock 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 + +// + +// template class shared_lock; + +// explicit operator bool() const noexcept; + +#include +#include + +#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 lk0; + assert(static_cast(lk0) == false); + std::shared_lock lk1(m); + assert(static_cast(lk1) == true); + lk1.unlock(); + assert(static_cast(lk1) == false); + static_assert(noexcept(static_cast(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 + +// + +// template class shared_lock; + +// bool owns_lock() const noexcept; + +#include +#include + +#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 lk0; + assert(lk0.owns_lock() == false); + std::shared_lock 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 + +// + +// template +// class shared_lock +// { +// public: +// typedef Mutex mutex_type; +// ... +// }; + +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class unique_lock; + +// unique_lock& operator=(unique_lock const&) = delete; + +#include +#include + +std::mutex m0; +std::mutex m1; + +int main() +{ + std::unique_lock lk0(m0); + std::unique_lock 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class unique_lock; + +// unique_lock(unique_lock const&) = delete; + +#include +#include + +std::mutex m; + +int main() +{ + std::unique_lock lk0(m); + std::unique_lock 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 + +// + +// template class unique_lock; + +// unique_lock(); + +#include +#include + +int main() +{ + std::unique_lock 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 + +// + +// template class unique_lock; + +// unique_lock& operator=(unique_lock&& u); + +#include +#include + +std::mutex m0; +std::mutex m1; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::unique_lock lk0(m0); + std::unique_lock 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 + +// + +// template class unique_lock; + +// unique_lock(unique_lock&& u); + +#include +#include + +std::mutex m; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::unique_lock lk0(m); + std::unique_lock 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 + +// + +// template class unique_lock; + +// explicit unique_lock(mutex_type& m); + +#include +#include +#include +#include + +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 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 + +// + +// template class unique_lock; + +// unique_lock(mutex_type& m, adopt_lock_t); + +#include +#include + +int main() +{ + std::mutex m; + m.lock(); + std::unique_lock 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 + +// + +// template class unique_lock; + +// unique_lock(mutex_type& m, defer_lock_t); + +#include +#include + +int main() +{ + std::mutex m; + std::unique_lock 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 + +// + +// class timed_mutex; + +// template +// unique_lock(mutex_type& m, const chrono::duration& rel_time); + +#include +#include +#include +#include + +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 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 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 + +// + +// class timed_mutex; + +// template +// unique_lock(mutex_type& m, const chrono::time_point& abs_time); + +#include +#include +#include +#include + +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 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 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 + +// + +// template class unique_lock; + +// unique_lock(mutex_type& m, try_to_lock_t); + +#include +#include +#include +#include + +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 lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + { + std::unique_lock lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + { + std::unique_lock lk(m, std::try_to_lock); + assert(lk.owns_lock() == false); + } + while (true) + { + std::unique_lock 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 + +// + +// template class unique_lock; + +// void lock(); + +#include +#include +#include +#include + +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 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 + +// + +// template class unique_lock; + +// bool try_lock(); + +#include +#include + +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 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 + +// + +// template class unique_lock; + +// template +// bool try_lock_for(const chrono::duration& rel_time); + +#include +#include + +bool try_lock_for_called = false; + +typedef std::chrono::milliseconds ms; + +struct mutex +{ + template + bool try_lock_for(const std::chrono::duration& 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 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 + +// + +// template class unique_lock; + +// template +// bool try_lock_until(const chrono::time_point& abs_time); + +#include +#include + +bool try_lock_until_called = false; + +struct mutex +{ + template + bool try_lock_until(const std::chrono::time_point& 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 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 + +// + +// template class unique_lock; + +// void unlock(); + +#include +#include + +bool unlock_called = false; + +struct mutex +{ + void lock() {} + void unlock() {unlock_called = true;} +}; + +mutex m; + +int main() +{ + std::unique_lock 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 + +// + +// template class unique_lock; + +// void swap(unique_lock& u); + +#include +#include + +struct mutex +{ + void lock() {} + void unlock() {} +}; + +mutex m; + +int main() +{ + std::unique_lock lk1(m); + std::unique_lock 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 + +// + +// template class unique_lock; + +// template +// void swap(unique_lock& x, unique_lock& y); + +#include +#include + +struct mutex +{ + void lock() {} + void unlock() {} +}; + +mutex m; + +int main() +{ + std::unique_lock lk1(m); + std::unique_lock 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 + +// + +// template class unique_lock; + +// mutex_type* release() noexcept; + +#include +#include + +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 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 + +// + +// template class unique_lock; + +// mutex_type *mutex() const; + +#include +#include + +std::mutex m; + +int main() +{ + std::unique_lock lk0; + assert(lk0.mutex() == nullptr); + std::unique_lock 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 + +// + +// template class unique_lock; + +// explicit operator bool() const; + +#include +#include + +std::mutex m; + +int main() +{ + std::unique_lock lk0; + assert(static_cast(lk0) == false); + std::unique_lock lk1(m); + assert(static_cast(lk1) == true); + lk1.unlock(); + assert(static_cast(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 + +// + +// template class unique_lock; + +// bool owns_lock() const; + +#include +#include + +std::mutex m; + +int main() +{ + std::unique_lock lk0; + assert(lk0.owns_lock() == false); + std::unique_lock 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 + +// + +// template +// class unique_lock +// { +// public: +// typedef Mutex mutex_type; +// ... +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::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 + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class mutex; + +// mutex& operator=(const mutex&) = delete; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class mutex; + +// mutex(const mutex&) = delete; + +#include + +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 + +// + +// class mutex; + +// mutex(); + +#include + +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 + +// + +// class mutex; + +// void lock(); + +#include +#include +#include +#include + +#include + +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 + +// + +// class mutex; + +// typedef pthread_mutex_t* native_handle_type; +// native_handle_type native_handle(); + +#include +#include + +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 + +// + +// class mutex; + +// bool try_lock(); + +#include +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class recursive_mutex; + +// recursive_mutex& operator=(const recursive_mutex&) = delete; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class recursive_mutex; + +// recursive_mutex(const recursive_mutex&) = delete; + +#include + +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 + +// + +// class recursive_mutex; + +// recursive_mutex(); + +#include + +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 + +// + +// class recursive_mutex; + +// void lock(); + +#include +#include +#include +#include + +#include + +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 + +// + +// class recursive_mutex; + +// typedef pthread_mutex_t* native_handle_type; +// native_handle_type native_handle(); + +#include +#include + +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 + +// + +// class recursive_mutex; + +// bool try_lock(); + +#include +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class shared_mutex; + +// shared_mutex& operator=(const shared_mutex&) = delete; + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// class shared_mutex; + +// shared_mutex(const shared_mutex&) = delete; + +#include + +#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 + +// + +// class shared_mutex; + +// shared_mutex(); + +#include + +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 + +// + +// class shared_mutex; + +// void lock(); + +#include +#include +#include +#include + + +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 + +// + +// class shared_mutex; + +// void lock_shared(); + +#include +#include +#include +#include +#include + +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 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 + +// + +// class shared_mutex; + +// bool try_lock(); + +#include +#include +#include +#include + +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 + +// + +// class shared_mutex; + +// bool try_lock_shared(); + +#include +#include +#include +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class shared_timed_mutex; + +// shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class shared_timed_mutex; + +// shared_timed_mutex(const shared_timed_mutex&) = delete; + +#include + +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 + +// + +// class shared_timed_mutex; + +// shared_timed_mutex(); + +#include + +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 + +// + +// class shared_timed_mutex; + +// void lock(); + +#include +#include +#include +#include + +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 + +// + +// class shared_timed_mutex; + +// void lock_shared(); + +#include +#include +#include +#include +#include + +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 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 + +// + +// class shared_timed_mutex; + +// bool try_lock(); + +#include +#include +#include +#include + +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 + +// + +// class shared_timed_mutex; + +// template +// bool try_lock_for(const chrono::duration& rel_time); + +#include +#include +#include +#include + +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 + +// + +// class shared_timed_mutex; + +// bool try_lock_shared(); + +#include +#include +#include +#include +#include + +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 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 + +// + +// class shared_timed_mutex; + +// template +// bool try_lock_shared_for(const chrono::duration& rel_time); + +#include +#include +#include +#include +#include + +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 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 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 + +// + +// class shared_timed_mutex; + +// template +// bool try_lock_shared_until(const chrono::time_point& abs_time); + +#include +#include +#include +#include +#include + +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 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 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 + +// + +// class shared_timed_mutex; + +// template +// bool try_lock_until(const chrono::time_point& abs_time); + +#include +#include +#include +#include + +#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 + +// + +// class shared_timed_mutex; + +#include + +#include +#include +#include +#include +#include + +std::shared_timed_mutex m; + +const int total_readers = 2; +std::atomic readers_started(0); +std::atomic 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. +// +//===----------------------------------------------------------------------===// + +// + +// class timed_mutex; + +// timed_mutex& operator=(const timed_mutex&) = delete; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class timed_mutex; + +// timed_mutex(const timed_mutex&) = delete; + +#include + +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 + +// + +// class timed_mutex; + +// timed_mutex(); + +#include + +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 + +// + +// class timed_mutex; + +// void lock(); + +#include +#include +#include +#include + +#include + +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 + +// + +// class timed_mutex; + +// bool try_lock(); + +#include +#include +#include +#include + +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 + +// + +// class timed_mutex; + +// template +// bool try_lock_for(const chrono::duration& rel_time); + +#include +#include +#include +#include + +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 + +// + +// class timed_mutex; + +// template +// bool try_lock_until(const chrono::time_point& abs_time); + +#include +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class recursive_timed_mutex; + +// recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class recursive_timed_mutex; + +// recursive_timed_mutex(const recursive_timed_mutex&) = delete; + +#include + +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 + +// + +// class recursive_timed_mutex; + +// recursive_timed_mutex(); + +#include + +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 + +// + +// class recursive_timed_mutex; + +// void lock(); + +#include +#include +#include +#include + +#include + +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 + +// + +// class recursive_timed_mutex; + +// bool try_lock(); + +#include +#include +#include +#include + +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 + +// + +// class recursive_timed_mutex; + +// template +// bool try_lock_for(const chrono::duration& rel_time); + +#include +#include +#include +#include + +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 + +// + +// class recursive_timed_mutex; + +// template +// bool try_lock_until(const chrono::time_point& abs_time); + +#include +#include +#include +#include + +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 + +// + +// struct once_flag; + +// template +// void call_once(once_flag& flag, Callable&& func, Args&&... args); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// struct once_flag; + +// once_flag& operator=(const once_flag&) = delete; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// struct once_flag; + +// once_flag(const once_flag&) = delete; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// struct once_flag; + +// constexpr once_flag() noexcept; + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +// + +// class thread + +// void swap(thread& x, thread& y); + +#include +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class thread + +// thread& operator=(thread&& t); + +#include +#include +#include +#include + +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 + +// + +// class thread + +// thread& operator=(thread&& t); + +#include +#include + +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 + +// + +// class thread + +// thread& operator=(thread&& t); + +#include +#include +#include +#include + +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 + +// + +// class thread + +// template thread(F&& f, Args&&... args); + +// UNSUPPORTED: sanitizer-new-delete + +#include +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class thread +// template ::type is the same type as std::thread. + + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class thread + +// thread(const thread&) = delete; + +#include +#include +#include +#include + +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 + +// + +// class thread + +// thread(); + +#include +#include + +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 + +// + +// class thread + +// thread(thread&& t); + +#include +#include +#include +#include + +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 + +// + +// class thread + +// ~thread(); + +#include +#include +#include +#include + +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 + +// + +// class thread::id + +// id& operator=(const id&) = default; + +#include +#include + +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 + +// + +// class thread::id + +// id(const id&) = default; + +#include +#include + +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 + +// + +// class thread::id + +// id(); + +#include +#include + +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 + +// + +// class thread::id + +// bool operator==(thread::id x, thread::id y); +// bool operator!=(thread::id x, thread::id y); + +#include +#include + +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 + +// + +// 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 +#include + +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 + +// + +// class thread::id + +// template +// basic_ostream& +// operator<<(basic_ostream& out, thread::id id); + +#include +#include +#include + +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 + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include + +int main() +{ + std::thread::id id1; + std::thread::id id2 = std::this_thread::get_id(); + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 + +// + +// class thread + +// void detach(); + +#include +#include +#include + +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 + +// + +// class thread + +// id get_id() const; + +#include +#include +#include +#include + +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 + +// + +// class thread + +// void join(); + +#include +#include +#include +#include + +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 + +// + +// class thread + +// bool joinable() const; + +#include +#include +#include +#include + +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 + +// + +// class thread + +// native_handle_type native_handle(); + +#include +#include +#include +#include + +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 + +// + +// class thread + +// void swap(thread& t); + +#include +#include +#include +#include + +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 + +// + +// class thread + +// unsigned hardware_concurrency(); + +#include +#include + +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 + +// + +// class thread +// { +// public: +// typedef pthread_t native_handle_type; +// ... +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::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::id this_thread::get_id(); + +#include +#include + +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 + +// + +// template +// void sleep_for(const chrono::duration& rel_time); + +#include +#include +#include +#include +#include +#include + +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 + +// + +// template +// void sleep_until(const chrono::time_point& abs_time); + +#include +#include +#include + +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 + +// + +// void this_thread::yield(); + +#include +#include + +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 + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// template +// scoped_allocator_adaptor(OuterA2&& outerAlloc, +// const InnerAllocs& ...innerAllocs); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A1 a3(3); + A a(a3); + assert(a.outer_allocator() == A1(3)); + assert(a.inner_allocator() == a); + assert(A1::copy_called == true); + assert(A1::move_called == false); + } + A1::copy_called = false; + { + typedef std::scoped_allocator_adaptor> A; + A a(A1(3)); + assert(a.outer_allocator() == A1(3)); + assert(a.inner_allocator() == a); + assert(A1::copy_called == false); + assert(A1::move_called == true); + } + A1::move_called = false; + { + typedef std::scoped_allocator_adaptor, A2> A; + A1 a4(4); + A a(a4, A2(5)); + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(a.outer_allocator() == A1(4)); + assert(a.inner_allocator() == std::scoped_allocator_adaptor>(A2(5))); + } + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + { + typedef std::scoped_allocator_adaptor, A2> A; + A a(A1(4), A2(5)); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(a.outer_allocator() == A1(4)); + assert(a.inner_allocator() == std::scoped_allocator_adaptor>(A2(5))); + } + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A1::move_called = false; + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A1 a4(4); + A a(a4, A2(5), A3(6)); + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(A3::copy_called == true); + assert(A3::move_called == false); + assert(a.outer_allocator() == A1(4)); + assert((a.inner_allocator() == + std::scoped_allocator_adaptor, A3>(A2(5), A3(6)))); + } + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A3::copy_called = false; + A3::move_called = false; + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a(A1(4), A2(5), A3(6)); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(A3::copy_called == true); + assert(A3::move_called == false); + assert(a.outer_allocator() == A1(4)); + assert((a.inner_allocator() == + std::scoped_allocator_adaptor, A3>(A2(5), A3(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// template +// scoped_allocator_adaptor(const scoped_allocator_adaptor& other); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> B; + typedef std::scoped_allocator_adaptor> A; + B a1(A1(3)); + A1::copy_called = false; + A1::move_called = false; + A a2 = a1; + assert(A1::copy_called == true); + assert(a2 == a1); + } + { + typedef std::scoped_allocator_adaptor, A2> B; + typedef std::scoped_allocator_adaptor, A2> A; + B a1(A1(4), A2(5)); + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A a2 = a1; + assert(A1::copy_called == true); + assert(A2::copy_called == true); + assert(a2 == a1); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> B; + typedef std::scoped_allocator_adaptor, A2, A3> A; + B a1(A1(4), A2(5), A3(6)); + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A3::copy_called = false; + A3::move_called = false; + A a2 = a1; + assert(A1::copy_called == true); + assert(A2::copy_called == true); + assert(A3::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// template +// scoped_allocator_adaptor(scoped_allocator_adaptor&& other); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> B; + typedef std::scoped_allocator_adaptor> A; + B a1(A1(3)); + A1::copy_called = false; + A1::move_called = false; + A a2 = std::move(a1); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(a2 == a1); + } + { + typedef std::scoped_allocator_adaptor, A2> B; + typedef std::scoped_allocator_adaptor, A2> A; + B a1(A1(4), A2(5)); + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A a2 = std::move(a1); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(A2::copy_called == false); + assert(A2::move_called == true); + assert(a2 == a1); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> B; + typedef std::scoped_allocator_adaptor, A2, A3> A; + B a1(A1(4), A2(5), A3(6)); + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A3::copy_called = false; + A3::move_called = false; + A a2 = std::move(a1); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(A2::copy_called == false); + assert(A2::move_called == true); + assert(A3::copy_called == false); + assert(A3::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// scoped_allocator_adaptor(const scoped_allocator_adaptor& other); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a1(A1(3)); + A1::copy_called = false; + A1::move_called = false; + A a2 = a1; + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(a2 == a1); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a1(A1(4), A2(5)); + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A a2 = a1; + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(a2 == a1); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a1(A1(4), A2(5), A3(6)); + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A3::copy_called = false; + A3::move_called = false; + A a2 = a1; + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(A3::copy_called == true); + assert(A3::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// scoped_allocator_adaptor(); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a; + assert(a.outer_allocator() == A1()); + assert(a.inner_allocator() == a); + assert(A1::copy_called == false); + assert(A1::move_called == false); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a; + assert(a.outer_allocator() == A1()); + assert(a.inner_allocator() == std::scoped_allocator_adaptor>()); + assert(A1::copy_called == false); + assert(A1::move_called == false); + assert(A2::copy_called == false); + assert(A2::move_called == false); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a; + assert(a.outer_allocator() == A1()); + assert((a.inner_allocator() == std::scoped_allocator_adaptor, A3>())); + assert(A1::copy_called == false); + assert(A1::move_called == false); + assert(A2::copy_called == false); + assert(A2::move_called == false); + assert(A3::copy_called == false); + assert(A3::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// pointer allocate(size_type n); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a; + A1::allocate_called = false; + assert(a.allocate(10) == (int*)10); + assert(A1::allocate_called == true); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a; + A1::allocate_called = false; + assert(a.allocate(10) == (int*)10); + assert(A1::allocate_called == true); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a; + A1::allocate_called = false; + assert(a.allocate(10) == (int*)10); + assert(A1::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// pointer allocate(size_type n, const_void_pointer hint); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a; + A1::allocate_called = false; + assert(a.allocate(10, (const void*)0) == (int*)10); + assert(A1::allocate_called == true); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a; + A1::allocate_called = false; + assert(a.allocate(10, (const void*)10) == (int*)10); + assert(A1::allocate_called == true); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a; + A1::allocate_called = false; + assert(a.allocate(10, (const void*)20) == (int*)10); + assert(A1::allocate_called == true); + } + + { + typedef std::scoped_allocator_adaptor> A; + A a; + A2::allocate_called = false; + assert(a.allocate(10, (const void*)0) == (int*)0); + assert(A2::allocate_called == true); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a; + A2::allocate_called = false; + assert(a.allocate(10, (const void*)10) == (int*)10); + assert(A2::allocate_called == true); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a; + A2::allocate_called = false; + assert(a.allocate(10, (const void*)20) == (int*)20); + assert(A2::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// template void construct(T* p, Args&&... args); + +#include +#include +#include + +#include "allocators.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +struct B +{ + static bool constructed; + + typedef A1 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> 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> 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> 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> 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> 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> A; + A a(A1(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, A2> A; + A a(A1(5), A2(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, A2> A; + A a(A1(5), A2(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, A2> K; + typedef std::scoped_allocator_adaptor> A; + A a(K(), A1(50)); + char buf[100]; + typedef E S; + S* s = (S*)buf; + A3::constructed = false; + a.construct(s, 1, 2); + assert(S::constructed); + assert(A3::constructed); + s->~S(); + } + + { + typedef std::scoped_allocator_adaptor, A2> K; + typedef std::scoped_allocator_adaptor> A; + A a(K(), A1(50)); + char buf[100]; + typedef F S; + S* s = (S*)buf; + A3::constructed = false; + a.construct(s, 1, 2); + assert(!S::constructed); + assert(A3::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// void deallocate(pointer p, size_type n); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a; + a.deallocate((int*)10, 20); + assert((A1::deallocate_called == std::pair((int*)10, 20))); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a; + a.deallocate((int*)10, 20); + assert((A1::deallocate_called == std::pair((int*)10, 20))); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a; + a.deallocate((int*)10, 20); + assert((A1::deallocate_called == std::pair((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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// template void destroy(T* p); + +#include +#include +#include + +#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> 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, A1> A; + A a; + char buf[100]; + typedef B S; + S* s = (S*)buf; + assert(!S::constructed); + assert(!A3::constructed); + assert(!A3::destroy_called); + a.construct(s); + assert(S::constructed); + assert(A3::constructed); + assert(!A3::destroy_called); + a.destroy(s); + assert(!S::constructed); + assert(A3::constructed); + assert(A3::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// inner_allocator_type& inner_allocator(); +// const inner_allocator_type& inner_allocator() const; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a(A1(5)); + assert(a.inner_allocator() == a); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a(A1(5), A2(6)); + assert(a.inner_allocator() == std::scoped_allocator_adaptor>(A2(6))); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a(A1(5), A2(6), A3(8)); + assert((a.inner_allocator() == + std::scoped_allocator_adaptor, A3>(A2(6), A3(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// size_type max_size() const; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + const A a(A1(100)); + assert(a.max_size() == 100); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + const A a(A1(20), A2()); + assert(a.max_size() == 20); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + const A a(A1(200), A2(), A3()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// outer_allocator_type& outer_allocator(); +// const outer_allocator_type& outer_allocator() const; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a(A1(5)); + assert(a.outer_allocator() == A1(5)); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a(A1(5), A2(6)); + assert(a.outer_allocator() == A1(5)); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a(A1(5), A2(6), A3(8)); + assert(a.outer_allocator() == A1(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// scoped_allocator_adaptor select_on_container_copy_construction() const; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a1(A1(3)); + assert(a1.outer_allocator().id() == 3); + A a2 = std::allocator_traits::select_on_container_copy_construction(a1); + assert(a2.outer_allocator().id() == 3); + } + + { + typedef std::scoped_allocator_adaptor> A; + A a1(A3(3)); + assert(a1.outer_allocator().id() == 3); + A a2 = std::allocator_traits::select_on_container_copy_construction(a1); + assert(a2.outer_allocator().id() == -1); + } + + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a1(A1(1), A2(2), A3(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::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 +#include +#include + +#if __cplusplus >= 201103L +// #include +// +// template +// 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::rebind +// const_pointer; +// typedef Alloc::void_pointer +// | pointer_traits::rebind +// void_pointer; +// typedef Alloc::const_void_pointer +// | pointer_traits::rebind +// const_void_pointer; + +template +void test_pointer() +{ + typename std::allocator_traits::pointer vp; + typename std::allocator_traits::const_pointer cvp; + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); +} + +template +void test_void_pointer() +{ + typename std::allocator_traits::void_pointer vp; + typename std::allocator_traits::const_void_pointer cvp; + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); +} + +struct Foo { int x; }; + +int main() +{ + test_pointer>> (); + test_pointer>> (); + test_pointer>> (); + + test_void_pointer>> (); + test_void_pointer>> (); + test_void_pointer>> (); +} +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// typedef see below inner_allocator_type; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::inner_allocator_type, + std::scoped_allocator_adaptor>>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2>::inner_allocator_type, + std::scoped_allocator_adaptor>>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2, A3>::inner_allocator_type, + std::scoped_allocator_adaptor, A3>>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// typedef see below is_always_equal; + +#include +#include + +#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>::is_always_equal, std::false_type>::value + ), "" ); + + static_assert( (std::is_same< + std::allocator_traits>::is_always_equal, std::true_type>::value + ), "" ); + + // wrapping one allocator + static_assert( + (std::is_same< + std::scoped_allocator_adaptor>::is_always_equal, + std::allocator_traits>::is_always_equal + >::value), ""); + + // wrapping one allocator + static_assert( + (std::is_same< + std::scoped_allocator_adaptor>::is_always_equal, + std::allocator_traits>::is_always_equal + >::value), ""); + + // wrapping two allocators (check the values instead of the types) + static_assert(( + std::scoped_allocator_adaptor, A2>::is_always_equal::value == + ( std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::is_always_equal::value) + ), ""); + + // wrapping two allocators (check the values instead of the types) + static_assert(( + std::scoped_allocator_adaptor, min_allocator>::is_always_equal::value == + ( std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::is_always_equal::value) + ), ""); + + + // wrapping three allocators (check the values instead of the types) + static_assert(( + std::scoped_allocator_adaptor, A2, A3>::is_always_equal::value == + ( std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// typedef see below propagate_on_container_copy_assignment; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::propagate_on_container_copy_assignment, + std::false_type>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2>::propagate_on_container_copy_assignment, + std::false_type>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2, A3>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// typedef see below propagate_on_container_move_assignment; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::propagate_on_container_move_assignment, + std::false_type>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2>::propagate_on_container_move_assignment, + std::true_type>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2, A3>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// typedef see below propagate_on_container_swap; + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::propagate_on_container_swap, + std::false_type>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2>::propagate_on_container_swap, + std::false_type>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A2, A3>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// template +// bool +// operator==(const scoped_allocator_adaptor& a, +// const scoped_allocator_adaptor& b); +// +// template +// bool +// operator!=(const scoped_allocator_adaptor& a, +// const scoped_allocator_adaptor& b); + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + { + typedef std::scoped_allocator_adaptor> A; + A a1(A1(3)); + A a2 = a1; + assert(a2 == a1); + assert(!(a2 != a1)); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a1(A1(4), A2(5)); + A a2 = a1; + assert(a2 == a1); + assert(!(a2 != a1)); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a1(A1(4), A2(5), A3(6)); + A a2 = a1; + assert(a2 == a1); + assert(!(a2 != a1)); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a1(A1(4), A2(5), A3(6)); + A a2(A1(4), A2(5), A3(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + static_assert((std::is_base_of< + A1, + std::scoped_allocator_adaptor> + >::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::outer_allocator_type, + A1>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::size_type, + std::make_unsigned::type>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::difference_type, + std::ptrdiff_t>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::pointer, + int*>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::const_pointer, + const int*>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::void_pointer, + void*>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor>::const_void_pointer, + const void*>::value), ""); + + static_assert((std::is_base_of< + A2, + std::scoped_allocator_adaptor, A1> + >::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A1>::outer_allocator_type, + A2>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A1>::size_type, + unsigned>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A1>::difference_type, + int>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A1>::pointer, + int*>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A1>::const_pointer, + const int*>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A1>::void_pointer, + void*>::value), ""); + + static_assert((std::is_same< + std::scoped_allocator_adaptor, A1>::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 + +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 + +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 + +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 + +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 +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// divides + +#include +#include +#include + +int main() +{ + typedef std::divides F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// minus + +#include +#include +#include + +int main() +{ + typedef std::minus F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// modulus + +#include +#include +#include + +int main() +{ + typedef std::modulus F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// multiplies + +#include +#include +#include + +int main() +{ + typedef std::multiplies F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// negate + +#include +#include +#include + +int main() +{ + typedef std::negate F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// plus + +#include +#include +#include + +int main() +{ + typedef std::plus F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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 +#include + +template +struct is_transparent +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template 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>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified bind(Fn, Types...); +// template +// unspecified bind(Fn, Types...); + +// http://llvm.org/bugs/show_bug.cgi?id=16385 + +#include +#include +#include + +float _pow(float a, float b) +{ + return std::pow(a, b); +} + +int main() +{ + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified bind(Fn, Types...); +// template +// unspecified bind(Fn, Types...); + +// http://llvm.org/bugs/show_bug.cgi?id=22003 + +#include + +struct DummyUnaryFunction +{ + template + int operator()(S const & s) const { return 0; } +}; + +struct BadUnaryFunction +{ + template + 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. + static_assert(!std::is_same::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(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified bind(Fn, Types...); +// template +// unspecified bind(Fn, Types...); + +#include +#include + +template +void +test(F f, R expected) +{ + assert(f() == expected); +} + +template +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(f), 1); + test(std::bind(&f), 1); + test(std::bind(A_int_0()), 4); + test_const(std::bind(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified bind(Fn, Types...); +// template +// unspecified bind(Fn, Types...); + +#include + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified bind(Fn, Types...); +// template +// unspecified bind(Fn, Types...); + +#include + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified bind(Fn, Types...); +// template +// unspecified bind(Fn, Types...); + +#include +#include + +int count = 0; + +template +void +test(F f) +{ + int save_count = count; + f(); + assert(count == save_count + 1); +} + +template +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(f)); + test(std::bind(&f)); + test(std::bind(A_void_0())); + test_const(std::bind(A_void_0())); + + test(std::bind(g)); + test(std::bind(&g)); + test(std::bind(A_int_0())); + test_const(std::bind(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified bind(Fn, Types...); +// template +// unspecified bind(Fn, Types...); + +// http://llvm.org/bugs/show_bug.cgi?id=16343 + +#include +#include +#include + +struct power +{ + template + T + operator()(T a, T b) + { + return std::pow(a, b); + } +}; + +struct plus_one +{ + template + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct is_bind_expression + +#include + +template +void +test(const T&) +{ + static_assert(std::is_bind_expression::value == Expected, ""); +} + +struct C {}; + +int main() +{ + test(std::bind(C())); + test(std::bind(C(), std::placeholders::_2)); + test(std::bind(C())); + test(1); + test(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. +// +//===----------------------------------------------------------------------===// + +// + +// struct is_placeholder + +#include + +template +void +test(const T&) +{ + static_assert(std::is_placeholder::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. +// +//===----------------------------------------------------------------------===// + +// + +// placeholders + +#include +#include + +template +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::value, ""); + static_assert(std::is_nothrow_move_constructible::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. +// +//===----------------------------------------------------------------------===// + +// + +// bit_and + +#include +#include +#include + +int main() +{ + typedef std::bit_and F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// bit_not + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::bit_not F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// bit_or + +#include +#include +#include + +int main() +{ + typedef std::bit_or F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// bit_xor + +#include +#include +#include + +int main() +{ + { + typedef std::bit_xor F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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 +#include + +template +struct is_transparent +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template 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>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::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. +// +//===----------------------------------------------------------------------===// + +// + +// equal_to + +#include +#include +#include + +int main() +{ + typedef std::equal_to F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// greater + +#include +#include +#include + +int main() +{ + typedef std::greater F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// greater_equal + +#include +#include +#include + +int main() +{ + typedef std::greater_equal F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// less + +#include +#include +#include + +int main() +{ + typedef std::less F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// less_equal + +#include +#include +#include + +int main() +{ + typedef std::less_equal F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// not_equal_to + +#include +#include +#include + +int main() +{ + typedef std::not_equal_to F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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 +#include + +template +struct is_transparent +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template 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>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::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 + +// + +// template +// result_of_t 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 +#include +#include + +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 +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(f), std::move(arg)) + ) DeducedReturnType; + static_assert((std::is_same::value), ""); + + // Check that result_of_t matches Expect. + typedef typename std::result_of::type + ResultOfReturnType; + static_assert((std::is_same::value), ""); + + // Run invoke and check the return value. + DeducedReturnType ret = + std::invoke(func_ptr, std::forward(f), std::move(arg)); + assert(ret == 42); +} + +template +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(f)) + ) DeducedReturnType; + static_assert((std::is_same::value), ""); + + // Check that result_of_t matches Expect. + typedef typename std::result_of::type + ResultOfReturnType; + static_assert((std::is_same::value), ""); + + // Run invoke and check the return value. + DeducedReturnType ret = + std::invoke(func_ptr, std::forward(f)); + assert(ret == 42); +} + +template +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(f), std::move(arg)) + ) DeducedReturnType; + static_assert((std::is_same::value), ""); + + // Check that result_of_t matches Expect. + typedef typename std::result_of::type + ResultOfReturnType; + static_assert((std::is_same::value), ""); + + // Run invoke and check the return value. + DeducedReturnType ret = std::invoke(std::forward(f), std::move(arg)); + assert(ret == 42); +} + +void bullet_one_two_tests() { + { + TestClass cl(42); + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + } + { + DerivedFromTestClass cl(42); + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + } + { + TestClass cl_obj(42); + TestClass *cl = &cl_obj; + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + } + { + DerivedFromTestClass cl_obj(42); + DerivedFromTestClass *cl = &cl_obj; + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + } +} + +void bullet_three_four_tests() { + { + typedef TestClass Fn; + Fn cl(42); + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } + { + typedef DerivedFromTestClass Fn; + Fn cl(42); + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } + { + typedef TestClass Fn; + Fn cl_obj(42); + Fn* cl = &cl_obj; + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } + { + typedef DerivedFromTestClass Fn; + Fn cl_obj(42); + Fn* cl = &cl_obj; + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } +} + +void bullet_five_tests() { + using FooType = int&(NonCopyable&&); + { + FooType& fn = foo; + test_b5(fn); + } + { + FooType* fn = foo; + test_b5(fn); + } + { + typedef TestClass Fn; + Fn cl(42); + test_b5(cl); + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + test_b5(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// template unspecified mem_fn(R T::* pm); + +#include +#include + +struct A +{ + double data_; +}; + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template unspecified mem_fn(R T::* pm); + +#include +#include + +struct A +{ + double data_; +}; + +template +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified mem_fn(R (T::* pm)(Args...)); + +#include +#include + +struct A +{ + char test0() {return 'a';} + char test1(int) {return 'b';} + char test2(int, double) {return 'c';} +}; + +template +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 +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 +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified mem_fn(R (T::* pm)(Args...) const); + +#include +#include + +struct A +{ + char test0() const {return 'a';} + char test1(int) const {return 'b';} + char test2(int, double) const {return 'c';} +}; + +template +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 +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 +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified mem_fn(R (T::* pm)(Args...) const volatile); + +#include +#include + +struct A +{ + char test0() const volatile {return 'a';} + char test1(int) const volatile {return 'b';} + char test2(int, double) const volatile {return 'c';} +}; + +template +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 +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 +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// unspecified mem_fn(R (T::* pm)(Args...) volatile); + +#include +#include + +struct A +{ + char test0() volatile {return 'a';} + char test1(int) volatile {return 'b';} + char test2(int, double) volatile {return 'c';} +}; + +template +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 +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 +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. +// +//===----------------------------------------------------------------------===// + +// + +// binary_function + +#include +#include + +int main() +{ + typedef std::binary_function bf; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +template +struct Array +{ + typedef T type[N]; +}; + +struct Type +{ + Array::type& f1(); + Array::type& f2() const; + + Array::type& g1() &; + Array::type& g2() const &; +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + Array::type& g3() &&; + Array::type& g4() const &&; +#endif +}; + +int main() +{ + static_assert(sizeof(std::__invoke(&Type::f1, std::declval())) == 1, ""); + static_assert(sizeof(std::__invoke(&Type::f2, std::declval())) == 2, ""); + + static_assert(sizeof(std::__invoke(&Type::g1, std::declval())) == 1, ""); + static_assert(sizeof(std::__invoke(&Type::g2, std::declval())) == 2, ""); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + static_assert(sizeof(std::__invoke(&Type::g3, std::declval())) == 3, ""); + static_assert(sizeof(std::__invoke(&Type::g4, std::declval())) == 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. +// +//===----------------------------------------------------------------------===// + +// + +// unary_function + +#include +#include + +int main() +{ + typedef std::unary_function uf; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 +#include + +int main() +{ + static_assert((std::is_base_of::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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template +// void swap(function&, function&); + + +#include +#include +#include + +#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 f1 = A(1); + std::function f2 = A(2); + assert(A::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(2)); + assert(f1.target()->id() == 1); + assert(f2.target()->id() == 2); + swap(f1, f2); + assert(A::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(2)); + assert(f1.target()->id() == 2); + assert(f2.target()->id() == 1); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f1 = A(1); + std::function f2 = g; + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f1.target()->id() == 1); + assert(*f2.target() == g); + swap(f1, f2); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(*f1.target() == g); + assert(f2.target()->id() == 1); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f1 = g; + std::function f2 = A(1); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(*f1.target() == g); + assert(f2.target()->id() == 1); + swap(f1, f2); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f1.target()->id() == 1); + assert(*f2.target() == g); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f1 = g; + std::function f2 = h; + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(*f1.target() == g); + assert(*f2.target() == h); + swap(f1, f2); + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(*f1.target() == h); + assert(*f2.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// explicit operator bool() const + +#include +#include + +int g(int) {return 0;} + +int main() +{ + { + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// function(nullptr_t); + +#include +#include + +#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 f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + assert(f.target() == 0); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f = g; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target()); + assert(f.target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f = (int (*)(int))0; + assert(!f); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() == 0); + assert(f.target() == 0); + } + { + std::function f = &A::foo; + assert(f); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() != 0); + } + { + std::function f(&g); + assert(f); + assert(f.target() != 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template +// requires CopyConstructible && Callable +// && Convertible::result_type +// operator=(F f); + +#include +#include + +#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 f; + f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + assert(f.target() == 0); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f; + f = g; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target()); + assert(f.target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f; + f = (int (*)(int))0; + assert(!f); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() == 0); + assert(f.target() == 0); + } + { + std::function f; + f = &A::foo; + assert(f); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() != 0); + } + { + std::function f; + f = &g; + assert(f); + assert(f.target() != 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(F); + +// Allow incomplete argument types in the __is_callable check + +#include + +struct X{ + typedef std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(allocator_arg_t, const A&); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + { + std::function f(std::allocator_arg, bare_allocator()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(allocator_arg_t, const A&, F); + +#include +#include + +#include "min_allocator.h" +#include "test_allocator.h" +#include "count_new.hpp" +#include "../function_types.h" + +class DummyClass {}; + +template +void test_FunctionObject(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + FunctionObject target; + assert(FunctionObject::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(0)); + std::function f2(std::allocator_arg, alloc, target); + assert(FunctionObject::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f2.template target()); + assert(f2.template target() == 0); + assert(f2.template target() == 0); + } + assert(FunctionObject::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + + +template +void test_FreeFunction(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + FuncType* target = &FreeFunction; + assert(globalMemCounter.checkOutstandingNewEq(0)); + std::function f2(std::allocator_arg, alloc, target); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.template target()); + assert(*f2.template target() == target); + assert(f2.template target() == 0); + assert(f2.template target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_MemFunClass(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + TargetType target = &MemFunClass::foo; + assert(globalMemCounter.checkOutstandingNewEq(0)); + std::function f2(std::allocator_arg, alloc, target); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.template target()); + assert(*f2.template target() == target); + assert(f2.template target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_for_alloc(Alloc& alloc) { + test_FunctionObject(alloc); + test_FunctionObject(alloc); + test_FunctionObject(alloc); + test_FunctionObject(alloc); + + test_FreeFunction(alloc); + test_FreeFunction(alloc); + test_FreeFunction(alloc); + test_FreeFunction(alloc); + + test_MemFunClass(alloc); + test_MemFunClass(alloc); + test_MemFunClass(alloc); +} + +int main() +{ + { + bare_allocator bare_alloc; + test_for_alloc(bare_alloc); + } + { + non_default_test_allocator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(allocator_arg_t, const A&, const function&); + + +#include +#include + +#include "min_allocator.h" +#include "test_allocator.h" +#include "count_new.hpp" +#include "../function_types.h" + +class DummyClass {}; + +template +void test_FunctionObject(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + // Construct function from FunctionObject. + std::function f = FunctionObject(); + assert(FunctionObject::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.template target()); + assert(f.template target() == 0); + assert(f.template target() == 0); + // Copy function with allocator + std::function f2(std::allocator_arg, alloc, f); + assert(FunctionObject::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(2)); + assert(f2.template target()); + assert(f2.template target() == 0); + assert(f2.template target() == 0); + } + assert(FunctionObject::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_FreeFunction(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + // Construct function from function pointer. + FuncType* target = &FreeFunction; + std::function f = target; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.template target()); + assert(*f.template target() == target); + assert(f.template target() == 0); + // Copy function with allocator + std::function f2(std::allocator_arg, alloc, f); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.template target()); + assert(*f2.template target() == target); + assert(f2.template target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_MemFunClass(AllocType& alloc) +{ + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + // Construct function from function pointer. + TargetType target = &MemFunClass::foo; + std::function f = target; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.template target()); + assert(*f.template target() == target); + assert(f.template target() == 0); + // Copy function with allocator + std::function f2(std::allocator_arg, alloc, f); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.template target()); + assert(*f2.template target() == target); + assert(f2.template target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_for_alloc(Alloc& alloc) +{ + // Large FunctionObject -- Allocation should occur + test_FunctionObject(alloc); + test_FunctionObject(alloc); + test_FunctionObject(alloc); + test_FunctionObject(alloc); + // Free function -- No allocation should occur + test_FreeFunction(alloc); + test_FreeFunction(alloc); + test_FreeFunction(alloc); + test_FreeFunction(alloc); + // Member function -- No allocation should occur. + test_MemFunClass(alloc); + test_MemFunClass(alloc); + test_MemFunClass(alloc); +} + +int main() +{ + { + bare_allocator alloc; + test_for_alloc(alloc); + } + { + non_default_test_allocator 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(allocator_arg_t, const A&, nullptr_t); + +#include +#include + +#include "min_allocator.h" + +int main() +{ + std::function f(std::allocator_arg, bare_allocator(), 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(allocator_arg_t, const A&, function&&); + +#include +#include + +#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 f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + assert(f.target() == 0); + std::function f2(std::allocator_arg, bare_allocator(), std::move(f)); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f2.target()); + assert(f2.target() == 0); + assert(f.target() == 0); + assert(f.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// function(const function& f); + +#include +#include +#include + +#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 f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + assert(f.target() == 0); + std::function f2 = f; + assert(A::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(2)); + assert(f2.target()); + assert(f2.target() == 0); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f = g; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target()); + assert(f.target() == 0); + std::function f2 = f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.target()); + assert(f2.target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() == 0); + assert(f.target() == 0); + std::function f2 = f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.target() == 0); + assert(f2.target() == 0); + } + { + std::function f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() == 0); + assert(f.target() == 0); + assert(!f); + std::function g = f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(g.target() == 0); + assert(g.target() == 0); + assert(!g); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + assert(f.target() == 0); + std::function f2 = std::move(f); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f2.target()); + assert(f2.target() == 0); + assert(f.target() == 0); + assert(f.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// function& operator=(const function& f); + +#include +#include + +#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 f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + assert(f.target() == 0); + std::function f2; + f2 = f; + assert(A::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(2)); + assert(f2.target()); + assert(f2.target() == 0); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f = g; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target()); + assert(f.target() == 0); + std::function f2; + f2 = f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.target()); + assert(f2.target() == 0); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() == 0); + assert(f.target() == 0); + std::function f2; + f2 = f; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f2.target() == 0); + assert(f2.target() == 0); + } +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + assert(f.target() == 0); + std::function f2; + f2 = std::move(f); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f2.target()); + assert(f2.target() == 0); + assert(f.target() == 0); + assert(f.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// explicit function(); + +#include +#include + +int main() +{ + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template function(F); + +#define _LIBCPP_HAS_NO_VARIADICS +#include +#include + +int main() +{ + std::function f(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// function(nullptr_t); + +#include +#include + +int main() +{ + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// function& operator=(nullptr_t); + +#include +#include + +#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 f = A(); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f.target()); + f = nullptr; + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() == 0); + } + { + std::function f = g; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target()); + assert(f.target() == 0); + f = nullptr; + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(f.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// R operator()(ArgTypes... args) const + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// R operator()(ArgTypes... args) const + +#include +#include + +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 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 r1(fp); + int i = 3; + r1(i); + assert(count == save_count+3); + save_count = count; + } + // functor + { + A_void_1 a0; + std::function 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 r1(fp); + A_void_1 a; + r1(a); + assert(count == save_count+1); + save_count = count; + A_void_1* ap = &a; + std::function 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 r1(fp); + A_void_1 a; + r1(a); + assert(count == save_count+1); + save_count = count; + std::function 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 r1(f_int_1); + int i = 2; + assert(r1(i) == 3); + } + // function pointer + { + int (*fp)(int) = f_int_1; + std::function r1(fp); + int i = 3; + assert(r1(i) == 4); + } + // functor + { + A_int_1 a0; + std::function r1(a0); + int i = 4; + assert(r1(i) == 3); + } + // member function pointer + { + int (A_int_1::*fp)() = &A_int_1::mem1; + std::function r1(fp); + A_int_1 a; + assert(r1(a) == 3); + std::function 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 r1(fp); + A_int_1 a; + assert(r1(a) == 4); + std::function 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 r1(fp); + A_int_1 a; + assert(r1(a) == 5); + r1(a) = 6; + assert(r1(a) == 6); + std::function 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 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 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 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 r1(fp); + A_void_2 a; + int i = 3; + r1(a, i); + assert(count == save_count+3); + save_count = count; + std::function 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 r1(fp); + A_void_2 a; + int i = 4; + r1(a, i); + assert(count == save_count+4); + save_count = count; + std::function 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 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 r1(fp); + int i = 3; + int j = 4; + assert(r1(i, j) == i+j); + } + // functor + { + A_int_2 a0; + std::function 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 r1(fp); + A_int_2 a; + int i = 3; + assert(r1(a, i) == i+1); + std::function 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 r1(fp); + A_int_2 a; + int i = 4; + assert(r1(a, i) == i+2); + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// R operator()(ArgTypes... args) const + +#include +#include + +// 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 r1(f_int_0); + assert(r1() == 3); + } + // function pointer + { + int (*fp)() = f_int_0; + std::function r1(fp); + assert(r1() == 3); + } + // functor + { + A_int_0 a0; + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// Test that we properly return both values and void for all non-variadic +// overloads of function::operator()(...) + +#define _LIBCPP_HAS_NO_VARIADICS +#include +#include + +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 f(&foo0); + assert(f() == 42); + } + { + std::function f(&foo1); + assert(f(1) == 42); + } + { + std::function f(&foo2); + assert(f(1, 1) == 42); + } + { + std::function f(&foo3); + assert(f(1, 1, 1) == 42); + } + { + std::function f(&foo0); + f(); + } + { + std::function f(&foo1); + f(1); + } + { + std::function f(&foo2); + f(1, 1); + } + { + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// R operator()(ArgTypes... args) const + +#include +#include +#include +#include + +// 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 r1(f_void_0); + r1(); + assert(count == save_count+1); + save_count = count; + } + // function pointer + { + void (*fp)() = f_void_0; + std::function r1(fp); + r1(); + assert(count == save_count+1); + save_count = count; + } + // functor + { + A_void_0 a0; + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template void assign(F&&, const A&); + +#include +#include + +#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 f; + f.assign(A(), test_allocator()); + assert(A::count == 1); + assert(f.target()); + assert(f.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// void swap(function& other); + +#include +#include + +#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 f1 = A(1); + std::function f2 = A(2); + assert(A::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(2)); + assert(f1.target()->id() == 1); + assert(f2.target()->id() == 2); + f1.swap(f2); + assert(A::count == 2); + assert(globalMemCounter.checkOutstandingNewEq(2)); + assert(f1.target()->id() == 2); + assert(f2.target()->id() == 1); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f1 = A(1); + std::function f2 = g; + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f1.target()->id() == 1); + assert(*f2.target() == g); + f1.swap(f2); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(*f1.target() == g); + assert(f2.target()->id() == 1); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f1 = g; + std::function f2 = A(1); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(*f1.target() == g); + assert(f2.target()->id() == 1); + f1.swap(f2); + assert(A::count == 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + assert(f1.target()->id() == 1); + assert(*f2.target() == g); + } + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + { + std::function f1 = g; + std::function f2 = h; + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(*f1.target() == g); + assert(*f2.target() == h); + f1.swap(f2); + assert(A::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + assert(*f1.target() == h); + assert(*f2.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template +// bool operator==(const function&, nullptr_t); +// +// template +// bool operator==(nullptr_t, const function&); +// +// template +// bool operator!=(const function&, nullptr_t); +// +// template +// bool operator!=(nullptr_t, const function&); + +#include +#include + +int g(int) {return 0;} + +int main() +{ + { + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// template +// requires Callable && Convertible::result_type, R> +// T* +// target(); +// template +// requires Callable && Convertible::result_type, R> +// const T* +// target() const; + +#include +#include +#include +#include + +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 f = A(); + assert(A::count == 1); + assert(f.target()); + assert(f.target() == 0); + } + assert(A::count == 0); + { + std::function f = g; + assert(A::count == 0); + assert(f.target()); + assert(f.target() == 0); + } + assert(A::count == 0); + { + const std::function f = A(); + assert(A::count == 1); + assert(f.target()); + assert(f.target() == 0); + } + assert(A::count == 0); + { + const std::function f = g; + assert(A::count == 0); + assert(f.target()); + assert(f.target() == 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// const std::type_info& target_type() const; + +#include +#include +#include + +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 f = A(); + assert(f.target_type() == typeid(A)); + } + { + std::function 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class function { +// 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 +#include + + +template +class has_argument_type +{ + typedef char yes; + typedef long no; + + template static yes check( typename C::argument_type * ); + template static no check(...); +public: + enum { value = sizeof(check(0)) == sizeof(yes) }; +}; + +template +class has_first_argument_type +{ + typedef char yes; + typedef long no; + + template static yes check( typename C::first_argument_type * ); + template static no check(...); +public: + enum { value = sizeof(check(0)) == sizeof(yes) }; +}; + + +template +class has_second_argument_type +{ + typedef char yes; + typedef long no; + + template static yes check( typename C::second_argument_type *); + template static no check(...); +public: + enum { value = sizeof(check(0)) == sizeof(yes) }; +}; + +template +void test_nullary_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((!has_argument_type::value), "" ); + static_assert((!has_first_argument_type::value), "" ); + static_assert((!has_second_argument_type::value), "" ); +} + +template +void test_unary_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((!has_first_argument_type::value), "" ); + static_assert((!has_second_argument_type::value), "" ); +} + +template +void test_binary_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((!has_argument_type::value), "" ); +} + +template +void test_other_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((!has_argument_type::value), "" ); + static_assert((!has_first_argument_type::value), "" ); + static_assert((!has_second_argument_type::value), "" ); +} + +int main() +{ + test_nullary_function, int>(); + test_unary_function , double, int>(); + test_binary_function , double, int, char>(); + test_other_function , 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. +// +//===----------------------------------------------------------------------===// + +// + +// logical_and + +#include +#include +#include + +int main() +{ + typedef std::logical_and F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// logical_not + +#include +#include +#include + +int main() +{ + typedef std::logical_not F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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. +// +//===----------------------------------------------------------------------===// + +// + +// logical_or + +#include +#include +#include + +int main() +{ + typedef std::logical_or F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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 () (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 +#include + +template +struct is_transparent +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template 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>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::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. +// +//===----------------------------------------------------------------------===// + +// + +// binary_negate + +#include +#include +#include + +int main() +{ + typedef std::binary_negate > F; + const F f = F(std::logical_and()); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// not1 + +#include +#include + +int main() +{ + typedef std::logical_not 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. +// +//===----------------------------------------------------------------------===// + +// + +// not2 + +#include +#include + +int main() +{ + typedef std::logical_and 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. +// +//===----------------------------------------------------------------------===// + +// + +// unary_negate + +#include +#include +#include + +int main() +{ + typedef std::unary_negate > F; + const F f = F(std::logical_not()); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// check for deriving from binary_function + +#include +#include + +class functor1 + : public std::unary_function +{ +}; + +class functor2 + : public std::binary_function +{ +}; + +class functor3 + : public std::unary_function, + public std::binary_function +{ +public: + typedef float result_type; +}; + +class functor4 + : public std::unary_function, + public std::binary_function +{ +public: +}; + +struct C +{ + typedef int argument_type; + typedef int result_type; +}; + +int main() +{ + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// operator T& () const; + +#include +#include + +class functor1 + : public std::unary_function +{ +}; + +template +void +test(T& t) +{ + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// reference_wrapper& operator=(const reference_wrapper& x); + +#include +#include + +class functor1 + : public std::unary_function +{ +}; + +template +void +test(T& t) +{ + std::reference_wrapper r(t); + T t2 = t; + std::reference_wrapper r2(t2); + r2 = r; + assert(&r2.get() == &t); +} + +void f() {} +void g() {} + +void +test_function() +{ + std::reference_wrapper r(f); + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// reference_wrapper(const reference_wrapper& x); + +#include +#include + +class functor1 + : public std::unary_function +{ +}; + +template +void +test(T& t) +{ + std::reference_wrapper r(t); + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// reference_wrapper(T&&) = delete; + +#include +#include + +int main() +{ + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// reference_wrapper(T& t); + +#include +#include + +class functor1 + : public std::unary_function +{ +}; + +template +void +test(T& t) +{ + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template reference_wrapper cref(const T& t); + +#include +#include + +int main() +{ + int i = 0; + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template reference_wrapper cref(reference_wrapper t); + +#include +#include + +int main() +{ + const int i = 0; + std::reference_wrapper r1 = std::cref(i); + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template reference_wrapper ref(T& t); + +// Don't allow binding to a temp + +#include + +struct A {}; + +const A source() {return A();} + +int main() +{ + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template reference_wrapper ref(T& t); + +#include +#include + +int main() +{ + int i = 0; + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template reference_wrapper ref(reference_wrappert); + +#include +#include + +#include "counting_predicates.hpp" + +bool is5 ( int i ) { return i == 5; } + +template +bool call_pred ( T pred ) { return pred(5); } + +int main() +{ + { + int i = 0; + std::reference_wrapper r1 = std::ref(i); + std::reference_wrapper r2 = std::ref(r1); + assert(&r2.get() == &i); + } + { + unary_counting_predicate 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template +// requires Callable +// Callable::result_type +// operator()(ArgTypes&&... args) const; + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template +// requires Callable +// Callable::result_type +// operator()(ArgTypes&&... args) const; + +#include +#include + +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 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 r1(fp); + int i = 3; + r1(i); + assert(count == save_count+3); + save_count = count; + } + // functor + { + A_void_1 a0; + std::reference_wrapper 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 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 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 r1(f_int_1); + int i = 2; + assert(r1(i) == 3); + } + // function pointer + { + int (*fp)(int) = f_int_1; + std::reference_wrapper r1(fp); + int i = 3; + assert(r1(i) == 4); + } + // functor + { + A_int_1 a0; + std::reference_wrapper r1(a0); + int i = 4; + assert(r1(i) == 3); + } + // member function pointer + { + int (A_int_1::*fp)() = &A_int_1::mem1; + std::reference_wrapper 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 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 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 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 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 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 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 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 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 r1(fp); + int i = 3; + int j = 4; + assert(r1(i, j) == i+j); + } + // functor + { + A_int_2 a0; + std::reference_wrapper 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template +// requires Callable +// Callable::result_type +// operator()(ArgTypes&&... args) const; + +#include +#include + +// 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 r1(f_int_0); + assert(r1() == 3); + } + // function pointer + { + int (*fp)() = f_int_0; + std::reference_wrapper r1(fp); + assert(r1() == 3); + } + // functor + { + A_int_0 a0; + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// template +// requires Callable +// Callable::result_type +// operator()(ArgTypes&&... args) const; + +#include +#include + +// 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 r1(f_void_0); + r1(); + assert(count == save_count+1); + save_count = count; + } + // function pointer + { + void (*fp)() = f_void_0; + std::reference_wrapper r1(fp); + r1(); + assert(count == save_count+1); + save_count = count; + } + // functor + { + A_void_0 a0; + std::reference_wrapper 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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// check for member typedef type + +#include +#include + +class C {}; + +int main() +{ + static_assert((std::is_same::type, + C>::value), ""); + static_assert((std::is_same::type, + void ()>::value), ""); + static_assert((std::is_same::type, + int* (double*)>::value), ""); + static_assert((std::is_same::type, + void(*)()>::value), ""); + static_assert((std::is_same::type, + int*(*)(double*)>::value), ""); + static_assert((std::is_same::type, + int*(C::*)(double*)>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// Test that reference wrapper meets the requirements of TriviallyCopyable, +// CopyConstructible and CopyAssignable. + +#include +#include +#include + +#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 +void test() +{ + typedef std::reference_wrapper Wrap; + static_assert(std::is_copy_constructible::value, ""); + static_assert(std::is_copy_assignable::value, ""); + // Extension up for standardization: See N4151. + static_assert(std::is_trivially_copyable::value, ""); +} + +int main() +{ + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// check for deriving from unary_function + +#include +#include + +class functor1 + : public std::unary_function +{ +}; + +class functor2 + : public std::binary_function +{ +}; + +class functor3 + : public std::unary_function, + public std::binary_function +{ +public: + typedef float result_type; +}; + +class functor4 + : public std::unary_function, + public std::binary_function +{ +public: +}; + +struct C +{ + typedef int argument_type; + typedef int result_type; +}; + +int main() +{ + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((std::is_base_of, + std::reference_wrapper >::value), ""); + static_assert((!std::is_base_of, + std::reference_wrapper >::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. +// +//===----------------------------------------------------------------------===// + +// + +// reference_wrapper + +// has weak result type + +#include +#include + +class functor1 + : public std::unary_function +{ +}; + +class functor2 + : public std::binary_function +{ +}; + +class functor3 + : public std::unary_function, + public std::binary_function +{ +public: + typedef float result_type; +}; + +class functor4 + : public std::unary_function, + public std::binary_function +{ +public: +}; + +class C {}; + +template +struct has_result_type +{ +private: + struct two {char _; char __;}; + template static two test(...); + template static char test(typename U::result_type* = 0); +public: + static const bool value = sizeof(test(0)) == 1; +}; + +int main() +{ + static_assert((std::is_same::result_type, + char>::value), ""); + static_assert((std::is_same::result_type, + double>::value), ""); + static_assert((std::is_same::result_type, + float>::value), ""); + static_assert((std::is_same::result_type, + void>::value), ""); + static_assert((std::is_same::result_type, + int*>::value), ""); + static_assert((std::is_same::result_type, + void>::value), ""); + static_assert((std::is_same::result_type, + int*>::value), ""); + static_assert((std::is_same::result_type, + int*>::value), ""); + static_assert((std::is_same::result_type, + int>::value), ""); + static_assert((std::is_same::result_type, + C>::value), ""); + static_assert(has_result_type >::value, ""); + static_assert(!has_result_type >::value, ""); + static_assert(!has_result_type >::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. +// +//===----------------------------------------------------------------------===// + +// + +// Hashing a struct w/o a defined hash should fail. + +#include +#include +#include + +struct X {}; + +int main() +{ + X x; + size_t h = std::hash{} ( 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. +// +//===----------------------------------------------------------------------===// + +// + +// make sure that we can hash enumeration values +// Not very portable + +#if __cplusplus >= 201402L + +#include +#include +#include +#include + +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 +void +test() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + typedef typename std::underlying_type::type under_type; + + H h1; + std::hash h2; + for (int i = 0; i <= 5; ++i) + { + T t(static_cast (i)); + if (sizeof(T) <= sizeof(std::size_t)) + assert(h1(t) == h2(static_cast(i))); + } +} + +int main() +{ + test(); + + test(); + test(); + test(); + test(); + + test(); +} +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include +#include +#include + +template +void +test() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include +#include + +template +void +test() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include +#include + +template +void +test() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + H h; + + typedef typename std::remove_pointer::type type; + type i; + type j; + assert(h(&i) != h(&j)); +} + +int main() +{ + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// class make_integer_sequence + +#include +#include +#include +#include + +#if _LIBCPP_STD_VER > 11 + +template +auto extract ( const AtContainer &t, const std::integer_sequence idx ) +-> decltype ( std::make_tuple ( std::get(t)... )) +{ return std::make_tuple ( std::get(t)... ); } + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + +// Make a couple of sequences + using int3 = std::make_integer_sequence; // generates int: 0,1,2 + using size7 = std::make_integer_sequence; // 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; // generates size_t: 0,1 + using intmix = std::integer_sequence; // 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::value, "int3 type wrong" ); + static_assert ( int3::size () == 3, "int3 size wrong" ); + + static_assert ( std::is_same::value, "size7 type wrong" ); + static_assert ( size7::size () == 7, "size7 size wrong" ); + + static_assert ( std::is_same::value, "size4 type wrong" ); + static_assert ( size4::size () == 4, "size4 size wrong" ); + + static_assert ( std::is_same::value, "size2 type wrong" ); + static_assert ( size2::size () == 2, "size2 size wrong" ); + + static_assert ( std::is_same::value, "intmix type wrong" ); + static_assert ( intmix::size () == 4, "intmix size wrong" ); + + static_assert ( std::is_same::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::value == int3::size (), "t3 size wrong"); + assert ( t3 == std::make_tuple ( 10, 11, 12 )); + + auto t7 = extract ( tup, size7 ()); + static_assert ( std::tuple_size::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::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::value == size2::size (), "t2 size wrong"); + assert ( t2 == std::make_tuple ( 10, 11 )); + + auto tintmix = extract ( tup, intmix ()); + static_assert ( std::tuple_size::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::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// 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 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + +// Should fail to compile, since float is not an integral type + using floatmix = std::integer_sequence; + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct integer_sequence +// { +// typedef T type; +// +// static constexpr size_t size() noexcept; +// }; + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + +// Make a few of sequences + using int3 = std::integer_sequence; + using size1 = std::integer_sequence; + using ushort2 = std::integer_sequence; + using bool0 = std::integer_sequence; + +// Make sure they're what we expect + static_assert ( std::is_same::value, "int3 type wrong" ); + static_assert ( int3::size() == 3, "int3 size wrong" ); + + static_assert ( std::is_same::value, "size1 type wrong" ); + static_assert ( size1::size() == 1, "size1 size wrong" ); + + static_assert ( std::is_same::value, "ushort2 type wrong" ); + static_assert ( ushort2::size() == 2, "ushort2 size wrong" ); + + static_assert ( std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// using make_integer_sequence = integer_sequence; + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + + std::make_integer_sequence::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// using make_integer_sequence = integer_sequence; + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + + static_assert(std::is_same, std::integer_sequence>::value, ""); + static_assert(std::is_same, std::integer_sequence>::value, ""); + static_assert(std::is_same, std::integer_sequence>::value, ""); + static_assert(std::is_same, std::integer_sequence>::value, ""); + + static_assert(std::is_same, std::integer_sequence>::value, ""); + static_assert(std::is_same, std::integer_sequence>::value, ""); + static_assert(std::is_same, std::integer_sequence>::value, ""); + static_assert(std::is_same, std::integer_sequence>::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. +// +//===----------------------------------------------------------------------===// + +// + +// struct allocator_arg_t { }; +// const allocator_arg_t allocator_arg = allocator_arg_t(); + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// static pointer allocate(allocator_type& a, size_type n); +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + + value_type* allocate(std::size_t n) + { + assert(n == 10); + return (value_type*)0xDEADBEEF; + } +}; + +int main() +{ + A a; + assert(std::allocator_traits >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + + value_type* allocate(std::size_t n) + { + assert(n == 10); + return (value_type*)0xDEADBEEF; + } +}; + +template +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 a; + assert(std::allocator_traits >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF); +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE + B b; + assert(std::allocator_traits >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// template +// static void construct(allocator_type& a, Ptr p, Args&&... args); +// ... +// }; + +#include +#include +#include +#include + +template +struct A +{ + typedef T value_type; + +}; + +int b_construct = 0; + +template +struct B +{ + typedef T value_type; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + template + void construct(U* p, Args&& ...args) + { + ++b_construct; + ::new ((void*)p) U(std::forward(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 a; + std::aligned_storage::type a0; + assert(A0::count == 0); + std::allocator_traits >::construct(a, (A0*)&a0); + assert(A0::count == 1); + } + { + A1::count = 0; + A a; + std::aligned_storage::type a1; + assert(A1::count == 0); + std::allocator_traits >::construct(a, (A1*)&a1, 'c'); + assert(A1::count == 1); + } + { + A2::count = 0; + A a; + std::aligned_storage::type a2; + assert(A2::count == 0); + std::allocator_traits >::construct(a, (A2*)&a2, 'd', 5); + assert(A2::count == 1); + } +#ifndef _LIBCPP_HAS_NO_VARIADICS + { + A0::count = 0; + b_construct = 0; + B b; + std::aligned_storage::type a0; + assert(A0::count == 0); + assert(b_construct == 0); + std::allocator_traits >::construct(b, (A0*)&a0); + assert(A0::count == 1); + assert(b_construct == 1); + } + { + A1::count = 0; + b_construct = 0; + B b; + std::aligned_storage::type a1; + assert(A1::count == 0); + assert(b_construct == 0); + std::allocator_traits >::construct(b, (A1*)&a1, 'c'); + assert(A1::count == 1); + assert(b_construct == 1); + } + { + A2::count = 0; + b_construct = 0; + B b; + std::aligned_storage::type a2; + assert(A2::count == 0); + assert(b_construct == 0); + std::allocator_traits >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// static void deallocate(allocator_type& a, pointer p, size_type n); +// ... +// }; + +#include +#include + +int called = 0; + +template +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 a; + std::allocator_traits >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// template +// static void destroy(allocator_type& a, Ptr p); +// ... +// }; + +#include +#include +#include +#include + +template +struct A +{ + typedef T value_type; + +}; + +int b_destroy = 0; + +template +struct B +{ + typedef T value_type; + + template + 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 a; + std::aligned_storage::type a0; + std::allocator_traits >::construct(a, (A0*)&a0); + assert(A0::count == 0); + std::allocator_traits >::destroy(a, (A0*)&a0); + assert(A0::count == 1); + } +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + { + A0::count = 0; + b_destroy = 0; + B b; + std::aligned_storage::type a0; + std::allocator_traits >::construct(b, (A0*)&a0); + assert(A0::count == 0); + assert(b_destroy == 0); + std::allocator_traits >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// static size_type max_size(const allocator_type& a) noexcept; +// ... +// }; + +#include +#include +#include +#include + +template +struct A +{ + typedef T value_type; + +}; + +template +struct B +{ + typedef T value_type; + + size_t max_size() const + { + return 100; + } +}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + { + A a; + assert(std::allocator_traits >::max_size(a) == + std::numeric_limits::max()); + } + { + const A a = {}; + assert(std::allocator_traits >::max_size(a) == + std::numeric_limits::max()); + } +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE + { + B b; + assert(std::allocator_traits >::max_size(b) == 100); + } + { + const B b = {}; + assert(std::allocator_traits >::max_size(b) == 100); + } +#if __cplusplus >= 201103 + { + std::allocator a; + static_assert(noexcept(std::allocator_traits>::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// static allocator_type +// select_on_container_copy_construction(const allocator_type& a); +// ... +// }; + +#include +#include +#include +#include + +template +struct A +{ + typedef T value_type; + int id; + explicit A(int i = 0) : id(i) {} + +}; + +template +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 a; + assert(std::allocator_traits >::select_on_container_copy_construction(a).id == 0); + } + { + const A a(0); + assert(std::allocator_traits >::select_on_container_copy_construction(a).id == 0); + } +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + { + B b; + assert(std::allocator_traits >::select_on_container_copy_construction(b).id == 100); + } + { + const B b(0); + assert(std::allocator_traits >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::const_pointer +// | pointer_traits::rebind +// ... +// }; + +#include +#include + +template +struct Ptr {}; + +template +struct A +{ + typedef T value_type; + typedef Ptr pointer; +}; + +template +struct B +{ + typedef T value_type; +}; + +template +struct CPtr {}; + +template +struct C +{ + typedef T value_type; + typedef CPtr pointer; + typedef CPtr const_pointer; +}; + +int main() +{ + static_assert((std::is_same >::const_pointer, Ptr >::value), ""); + static_assert((std::is_same >::const_pointer, const char*>::value), ""); + static_assert((std::is_same >::const_pointer, CPtr >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::const_void_pointer +// | pointer_traits::rebind +// const_void_pointer; +// ... +// }; + +#include +#include + +template +struct Ptr {}; + +template +struct A +{ + typedef T value_type; + typedef Ptr pointer; +}; + +template +struct B +{ + typedef T value_type; +}; + +template +struct CPtr {}; + +template +struct C +{ + typedef T value_type; + typedef CPtr const_void_pointer; +}; + +int main() +{ + static_assert((std::is_same >::const_void_pointer, Ptr >::value), ""); + static_assert((std::is_same >::const_void_pointer, const void*>::value), ""); + static_assert((std::is_same >::const_void_pointer, CPtr >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::difference_type +// | pointer_traits::difference_type difference_type; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + typedef short difference_type; +}; + +template +struct B +{ + typedef T value_type; +}; + +template +struct C +{ + typedef T value_type; + struct pointer {}; + struct const_pointer {}; + struct void_pointer {}; + struct const_void_pointer {}; +}; + +namespace std +{ + +template <> +struct pointer_traits::pointer> +{ + typedef signed char difference_type; +}; + +} + +int main() +{ + static_assert((std::is_same >::difference_type, short>::value), ""); + static_assert((std::is_same >::difference_type, std::ptrdiff_t>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::is_always_equal +// | is_empty is_always_equal; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + typedef std::true_type is_always_equal; +}; + +template +struct B +{ + typedef T value_type; +}; + +template +struct C +{ + typedef T value_type; + int not_empty_; // some random member variable +}; + +int main() +{ + static_assert((std::is_same >::is_always_equal, std::true_type>::value), ""); + static_assert((std::is_same >::is_always_equal, std::true_type>::value), ""); + static_assert((std::is_same >::is_always_equal, std::false_type>::value), ""); + + static_assert((std::is_same >::is_always_equal, std::true_type>::value), ""); + static_assert((std::is_same >::is_always_equal, std::true_type>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::pointer | value_type* pointer; +// ... +// }; + +#include +#include + +template +struct Ptr {}; + +template +struct A +{ + typedef T value_type; + typedef Ptr pointer; +}; + +template +struct B +{ + typedef T value_type; +}; + +int main() +{ + static_assert((std::is_same >::pointer, Ptr >::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::propagate_on_container_copy_assignment +// | false_type propagate_on_container_copy_assignment; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + typedef std::true_type propagate_on_container_copy_assignment; +}; + +template +struct B +{ + typedef T value_type; +}; + +int main() +{ + static_assert((std::is_same >::propagate_on_container_copy_assignment, std::true_type>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::propagate_on_container_move_assignment +// | false_type propagate_on_container_move_assignment; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + typedef std::true_type propagate_on_container_move_assignment; +}; + +template +struct B +{ + typedef T value_type; +}; + +int main() +{ + static_assert((std::is_same >::propagate_on_container_move_assignment, std::true_type>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::propagate_on_container_swap +// | false_type propagate_on_container_swap; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + typedef std::true_type propagate_on_container_swap; +}; + +template +struct B +{ + typedef T value_type; +}; + +int main() +{ + static_assert((std::is_same >::propagate_on_container_swap, std::true_type>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// template using rebind_alloc = Alloc::rebind::other | Alloc; +// ... +// }; + +#include +#include + +template +struct ReboundA {}; + +template +struct A +{ + typedef T value_type; + + template struct rebind {typedef ReboundA other;}; +}; + +template +struct ReboundB {}; + +template +struct B +{ + typedef T value_type; + + template struct rebind {typedef ReboundB other;}; +}; + +template +struct C +{ + typedef T value_type; +}; + +template +struct D +{ + typedef T value_type; +}; + +template +struct E +{ + typedef T value_type; + + template struct rebind {typedef ReboundA otter;}; +}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind_alloc, ReboundA >::value), ""); + static_assert((std::is_same >::rebind_alloc, ReboundB >::value), ""); + static_assert((std::is_same >::rebind_alloc, C >::value), ""); + static_assert((std::is_same >::rebind_alloc, D >::value), ""); + static_assert((std::is_same >::rebind_alloc, E >::value), ""); +#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind_alloc::other, ReboundA >::value), ""); + static_assert((std::is_same >::rebind_alloc::other, ReboundB >::value), ""); + static_assert((std::is_same >::rebind_alloc::other, C >::value), ""); + static_assert((std::is_same >::rebind_alloc::other, D >::value), ""); + static_assert((std::is_same >::rebind_alloc::other, E >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::size_type | size_t size_type; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; + typedef unsigned short size_type; +}; + +template +struct B +{ + typedef T value_type; +}; + +template +struct C +{ + typedef T value_type; + struct pointer {}; + struct const_pointer {}; + struct void_pointer {}; + struct const_void_pointer {}; +}; + +namespace std +{ + +template <> +struct pointer_traits::pointer> +{ + typedef signed char difference_type; +}; + +} + +int main() +{ + static_assert((std::is_same >::size_type, unsigned short>::value), ""); + static_assert((std::is_same >::size_type, + std::make_unsigned::type>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc::void_pointer +// | pointer_traits::rebind +// void_pointer; +// ... +// }; + +#include +#include + +template +struct Ptr {}; + +template +struct A +{ + typedef T value_type; + typedef Ptr pointer; +}; + +template +struct B +{ + typedef T value_type; +}; + +template +struct CPtr {}; + +template +struct C +{ + typedef T value_type; + typedef CPtr void_pointer; +}; + +int main() +{ + static_assert((std::is_same >::void_pointer, Ptr >::value), ""); + static_assert((std::is_same >::void_pointer, void*>::value), ""); + static_assert((std::is_same >::void_pointer, CPtr >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef Alloc allocator_type; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; +}; + +int main() +{ + static_assert((std::is_same >::allocator_type, A >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// template using rebind_traits = allocator_traits>; +// ... +// }; + +#include +#include + +template +struct ReboundA {}; + +template +struct A +{ + typedef T value_type; + + template struct rebind {typedef ReboundA other;}; +}; + +template +struct ReboundB {}; + +template +struct B +{ + typedef T value_type; + + template struct rebind {typedef ReboundB other;}; +}; + +template +struct C +{ + typedef T value_type; +}; + +template +struct D +{ + typedef T value_type; +}; + +template +struct E +{ + typedef T value_type; + + template struct rebind {typedef ReboundA otter;}; +}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind_traits, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits, std::allocator_traits > >::value), ""); +#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind_traits::other, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits::other, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits::other, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits::other, std::allocator_traits > >::value), ""); + static_assert((std::is_same >::rebind_traits::other, std::allocator_traits > >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct allocator_traits +// { +// typedef typename Alloc::value_type value_type; +// ... +// }; + +#include +#include + +template +struct A +{ + typedef T value_type; +}; + +int main() +{ + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct uses_allocator; + +#include +#include + +struct A +{ +}; + +struct B +{ + typedef int allocator_type; +}; + +int main() +{ + static_assert((!std::uses_allocator >::value), ""); + static_assert(( std::uses_allocator, std::allocator >::value), ""); + static_assert((!std::uses_allocator >::value), ""); + static_assert((!std::uses_allocator >::value), ""); + static_assert(( std::uses_allocator::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. +// +//===----------------------------------------------------------------------===// + +// and 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. +// +//===----------------------------------------------------------------------===// + +// + +// allocator: + +// template +// bool +// operator==(const allocator&, const allocator&) throw(); +// +// template +// bool +// operator!=(const allocator&, const allocator&) throw(); + +#include +#include + +int main() +{ + std::allocator a1; + std::allocator 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. +// +//===----------------------------------------------------------------------===// + +// + +// allocator: +// pointer address(reference x) const; +// const_pointer address(const_reference x) const; + +#include +#include + +template +void test_address() +{ + T* tp = new T(); + const T* ctp = tp; + const std::allocator a; + assert(a.address(*tp) == tp); + assert(a.address(*ctp) == tp); + delete tp; +} + +struct A +{ + void operator&() const {} +}; + +int main() +{ + test_address(); + test_address(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// allocator: +// pointer allocate(size_type n, allocator::const_pointer hint=0); + +#include +#include + +#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; + 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. +// +//===----------------------------------------------------------------------===// + +// + +// allocator: +// template void construct(pointer p, Args&&... args); + +#include +#include + +#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 () {return std::__rv(*this);} + move_only(std::__rv) {++move_only_constructed;} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + + move_only() {++move_only_constructed;} + ~move_only() {--move_only_constructed;} +}; + +int main() +{ + { + std::allocator 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// allocator: +// size_type max_size() const throw(); + +#include +#include +#include +#include + +int new_called = 0; + +int main() +{ + const std::allocator a; + std::size_t M = a.max_size() * sizeof(int); + assert(M > 0xFFFF && M <= std::numeric_limits::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 +#include + +#if __cplusplus >= 201103L +// #include +// +// template +// 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::rebind +// const_pointer; +// typedef Alloc::void_pointer +// | pointer_traits::rebind +// void_pointer; +// typedef Alloc::const_void_pointer +// | pointer_traits::rebind +// const_void_pointer; + +template +void test_pointer() +{ + typename std::allocator_traits::pointer vp; + typename std::allocator_traits::const_pointer cvp; + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); +} + +template +void test_void_pointer() +{ + typename std::allocator_traits::void_pointer vp; + typename std::allocator_traits::const_void_pointer cvp; + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same vp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same= vp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same cvp)>::value, ""); + static_assert(std::is_same= cvp)>::value, ""); + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); +} + +struct Foo { int x; }; + +int main() +{ + test_pointer> (); + test_pointer> (); + test_pointer> (); + + test_void_pointer> (); + test_void_pointer> (); + test_void_pointer> (); +} +#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. +// +//===----------------------------------------------------------------------===// + +// + +// check nested types: + +// template +// 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::type reference; +// typedef typename add_lvalue_reference::type const_reference; +// typedef T value_type; +// typedef true_type is_always_equal; +// +// template struct rebind {typedef allocator other;}; +// ... +// }; + +#include +#include +#include + +int main() +{ + static_assert((std::is_same::size_type, std::size_t>::value), ""); + static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); + static_assert((std::is_same::pointer, char*>::value), ""); + static_assert((std::is_same::const_pointer, const char*>::value), ""); + static_assert((std::is_same::value_type, char>::value), ""); + static_assert((std::is_same::reference, char&>::value), ""); + static_assert((std::is_same::const_reference, const char&>::value), ""); + static_assert((std::is_same::rebind::other, + std::allocator >::value), ""); + + static_assert((std::is_same::is_always_equal, std::true_type>::value), ""); + static_assert((std::is_same::is_always_equal, std::true_type>::value), ""); + + std::allocator a; + std::allocator a2 = a; + a2 = a; + std::allocator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template <> +// class allocator +// { +// public: +// typedef void* pointer; +// typedef const void* const_pointer; +// typedef void value_type; +// +// template struct rebind {typedef allocator<_Up> other;}; +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::pointer, void*>::value), ""); + static_assert((std::is_same::const_pointer, const void*>::value), ""); + static_assert((std::is_same::value_type, void>::value), ""); + static_assert((std::is_same::rebind::other, + std::allocator >::value), ""); + std::allocator a; + std::allocator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// typedef ptrdiff_t difference_type; +// ... +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// typedef T element_type; +// ... +// }; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// typedef Ptr pointer; +// ... +// }; + +#include +#include + +struct A +{ + typedef short element_type; + typedef char difference_type; +}; + +int main() +{ + static_assert((std::is_same::pointer, A>::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// static pointer pointer_to(

); +// ... +// }; + +#include +#include + +template +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::value, + nat, element_type>::type& et) + {return A(&et);} +}; + +int main() +{ + { + int i = 0; + A a = std::pointer_traits >::pointer_to(i); + assert(a.t_ == &i); + } + { + (std::pointer_traits >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// typedef
difference_type; +// ... +// }; + +#include +#include + +struct A +{ + typedef short element_type; + typedef char difference_type; +}; + +struct B +{ + typedef short element_type; +}; + +template +struct C {}; + +template +struct D +{ + typedef char difference_type; +}; + +int main() +{ + static_assert((std::is_same::difference_type, char>::value), ""); + static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); + static_assert((std::is_same >::difference_type, std::ptrdiff_t>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// typedef
element_type; +// ... +// }; + +#include +#include + +struct A +{ + typedef char element_type; +}; + +template +struct B +{ + typedef char element_type; +}; + +template +struct C +{ +}; + +template +struct D +{ +}; + +int main() +{ + static_assert((std::is_same::element_type, char>::value), ""); + static_assert((std::is_same >::element_type, char>::value), ""); + static_assert((std::is_same >::element_type, int>::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// template using rebind =
; +// ... +// }; + +#include +#include + +template +struct A +{ +}; + +template struct B1 {}; + +template +struct B +{ +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + template using rebind = B1; +#else + template struct rebind {typedef B1 other;}; +#endif +}; + +template +struct C +{ +}; + +template struct D1 {}; + +template +struct D +{ +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + template using rebind = D1; +#else + template struct rebind {typedef D1 other;}; +#endif +}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind, A >::value), ""); + static_assert((std::is_same >::rebind, B1 >::value), ""); + static_assert((std::is_same >::rebind, C >::value), ""); + static_assert((std::is_same >::rebind, D1 >::value), ""); +#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind::other, A >::value), ""); + static_assert((std::is_same >::rebind::other, B1 >::value), ""); + static_assert((std::is_same >::rebind::other, C >::value), ""); + static_assert((std::is_same >::rebind::other, D1 >::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// static pointer pointer_to(
); +// ... +// }; + +#include +#include + +int main() +{ + { + int i = 0; + int* a = std::pointer_traits::pointer_to(i); + assert(a == &i); + } + { + (std::pointer_traits::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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pointer_traits +// { +// template using rebind = U*; +// ... +// }; + +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same::rebind, double*>::value), ""); +#else + static_assert((std::is_same::rebind::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 + +// void* align(size_t alignment, size_t size, void*& ptr, size_t& space); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template T* addressof(T& r); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// ForwardIterator +// uninitialized_copy(InputIterator first, InputIterator last, +// ForwardIterator result); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// ForwardIterator +// uninitialized_copy_n(InputIterator first, Size n, +// ForwardIterator result); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// ForwardIterator +// uninitialized_fill_n(ForwardIterator first, Size n, const T& x); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void +// uninitialized_fill(ForwardIterator first, ForwardIterator last, +// const T& x); + +#include +#include + +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 +#include +#include + +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::value>::type + Storage; + Storage buffer; + std::raw_storage_iterator 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 +#include +#include + +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::value>::type + Storage; + Storage buffer; + std::raw_storage_iterator 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// pair +// get_temporary_buffer(ptrdiff_t n); +// +// template +// void +// return_temporary_buffer(T* p); + +#include +#include + +int main() +{ + std::pair ip = std::get_temporary_buffer(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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Example move-only deleter + +#ifndef DELETER_H +#define DELETER_H + +#include +#include +#include + +template +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() {return std::__rv(*this);} + Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} + Deleter& operator=(std::__rv 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 + Deleter(Deleter&& d, + typename std::enable_if::value>::type* = 0) + : state_(d.state()) {d.set_state(0);} + +private: + template + Deleter(const Deleter& d, + typename std::enable_if::value>::type* = 0); +#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + template + Deleter(Deleter d, + typename std::enable_if::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 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() {return std::__rv(*this);} + Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} + Deleter& operator=(std::__rv 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 +void +swap(Deleter& x, Deleter& y) +{ + Deleter t(std::move(x)); + x = std::move(y); + y = std::move(t); +} + +template +class CDeleter +{ + int state_; + +public: + + CDeleter() : state_(0) {} + explicit CDeleter(int s) : state_(s) {} + ~CDeleter() {assert(state_ >= 0); state_ = -1;} + + template + CDeleter(const CDeleter& d) + : state_(d.state()) {} + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {delete p;} +}; + +template +class CDeleter +{ + 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 +void +swap(CDeleter& x, CDeleter& y) +{ + CDeleter 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 +#include +#include + +// The only way to create an unique_ptr 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(5); + for ( int i = 0; i < 5; ++i ) + assert ( p1[i] == 0 ); + } + + { + auto p2 = std::make_unique(5); + for ( int i = 0; i < 5; ++i ) + assert ( p2[i].size () == 0 ); + } + + { + auto p3 = std::make_unique(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 +#include +#include + +int main() +{ + auto up1 = std::make_unique("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 +#include +#include + +int main() +{ + auto up2 = std::make_unique(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 +#include +#include + +int main() +{ + auto up3 = std::make_unique(); // 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 +#include +#include + +int main() +{ + auto up4 = std::make_unique(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 +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + { + std::unique_ptr p1 = std::make_unique(1); + assert ( *p1 == 1 ); + p1 = std::make_unique (); + assert ( *p1 == 0 ); + } + + { + std::unique_ptr p2 = std::make_unique ( "Meow!" ); + assert ( *p2 == "Meow!" ); + p2 = std::make_unique (); + assert ( *p2 == "" ); + p2 = std::make_unique ( 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +#include +#include + +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 d2; + std::default_delete 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +#include +#include + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + std::default_delete 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete's operator() requires a complete type + +#include +#include + +struct A; + +int main() +{ + std::default_delete 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete's operator() requires a complete type + +#include +#include + +int main() +{ + std::default_delete 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete does not have a working converting constructor + +#include +#include + +struct A +{ +}; + +struct B + : public A +{ +}; + +int main() +{ + std::default_delete d2; + std::default_delete 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete has a working default constructor + +#include +#include + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + std::default_delete 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. +// +//===----------------------------------------------------------------------===// + +// + +// default_delete + +// Test that default_delete's operator() requires a complete type + +#include +#include + +struct A; + +int main() +{ + std::default_delete 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include +#include + +// 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 s(new A); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#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 s1(new A[3]); + A* p = s1.get(); + assert(A::count == 3); + std::unique_ptr 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 > s1(new A[4], Deleter(5)); + A* p = s1.get(); + assert(A::count == 4); + std::unique_ptr > 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 d1(5); + std::unique_ptr&> s1(new A[6], d1); + A* p = s1.get(); + assert(A::count == 6); + CDeleter d2(6); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include +#include + +// 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 s(new A[3]); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Can't assign from lvalue + +#include +#include +#include + +#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 > s(new B); + A* p = s.get(); + boost::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Can't assign from lvalue + +#include +#include +#include + +#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 db(5); + boost::unique_ptr&> s(new B, db); + A* p = s.get(); + Deleter da(6); + boost::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + boost::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Can't assign from const lvalue + +#include +#include +#include + +#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 > s(new B); + A* p = s.get(); + boost::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Can't assign from const lvalue + +#include +#include +#include + +#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 db(5); + const boost::unique_ptr&> s(new B, db); + A* p = s.get(); + Deleter da(6); + boost::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +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 s(new B); + A* p = s.get(); + boost::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +#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 > s(new B); + A* p = s.get(); + boost::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// test converting move assignment with reference deleters + +#include +#include +#include + +#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 db(5); + boost::unique_ptr&> s(new B, db); + A* p = s.get(); + Deleter da(6); + boost::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// The deleter is not called if get() == 0 + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr::pointer type + +#include +#include + +struct Deleter +{ + struct pointer {}; +}; + +int main() +{ + { + typedef std::unique_ptr P; + static_assert((std::is_same::value), ""); + } + { + typedef std::unique_ptr P; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +// default unique_ptr ctor should require default Deleter ctor + + +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +// default unique_ptr ctor should only require default Deleter ctor + +#include +#include + +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 p; + assert(p.get() == 0); + } + { + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +// default unique_ptr ctor should require non-reference Deleter ctor + +#include + +class Deleter +{ +public: + + void operator()(void*) {} +}; + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test default unique_ptr ctor + +// default unique_ptr ctor shouldn't require complete type + +#include +#include + +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 > +struct B +{ + std::unique_ptr 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 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 +B::B() {} + +template +B::~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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +// default unique_ptr ctor should require non-pointer Deleter + +#include + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include + +// 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 s(new A[3]); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#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 s(new A[3]); + A* p = s.get(); + std::unique_ptr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == 3); + } + assert(A::count == 0); + { + std::unique_ptr > s(new A[3], Deleter(5)); + A* p = s.get(); + std::unique_ptr > 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 s(new A[3], d); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +// test move ctor. Can't copy from const lvalue + +#include +#include + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + const std::unique_ptr s(new A[3]); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 +source1() +{ + return std::unique_ptr(new A[3]); +} + +void sink1(std::unique_ptr p) +{ +} + +std::unique_ptr > +source2() +{ + return std::unique_ptr >(new A[3]); +} + +void sink2(std::unique_ptr > p) +{ +} + +std::unique_ptr +source3() +{ + static NCDeleter d; + return std::unique_ptr(new A[3], d); +} + +void sink3(std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +// test move ctor. Can't copy from lvalue + +#include +#include + +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 s(new A[3]); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +// test move ctor. Can't copy from const lvalue + +#include +#include + +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 s(new A[3]); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 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 d; + const std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 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 d; + const std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// unique_ptr(nullptr_t); + +#include +#include + +// 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 p(nullptr); + assert(p.get() == 0); + } + { + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +// unique_ptr(pointer) ctor should require default Deleter ctor + +#include + +class Deleter +{ + + Deleter() {} + +public: + + Deleter(Deleter&) {} + Deleter& operator=(Deleter&) {} + + void operator()(void*) const {} +}; + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +// unique_ptr(pointer) ctor should only require default Deleter ctor + +#include +#include + +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 s(p); + assert(s.get() == p); + } + assert(A::count == 0); + { + A* p = new A[3]; + assert(A::count == 3); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include + +// unique_ptr(pointer) ctor should require non-reference Deleter ctor +class Deleter +{ +public: + + void operator()(void*) {} +}; + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +// unique_ptr(pointer) ctor shouldn't require complete type + +#include +#include + +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 > +struct B +{ + std::unique_ptr 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 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 +B::B(A* a) : a_(a) {} + +template +B::~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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +// unique_ptr(pointer) ctor should require non-pointer Deleter + +#include + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +// unique_ptr(pointer) ctor should not work with derived pointers + +#include +#include + +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 s(p); + } + { + B* p = new B[3]; + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter + +#include +#include + +#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 > s(p, Deleter()); + 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +// unique_ptr(pointer, d) requires CopyConstructible deleter + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +// unique_ptr(pointer, d) does not requires CopyConstructible deleter + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +// unique_ptr(pointer, D()) should not compile + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +// unique_ptr(pointer, d) does not requires CopyConstructible deleter + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +// unique_ptr(pointer, deleter) should not work with derived pointers + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test release + +#include +#include + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset + +#include +#include + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + std::unique_ptr 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test swap + +#include +#include + +#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 > s1(p1, Deleter(1)); + A* p2 = new A[3]; + std::unique_ptr > s2(p2, Deleter(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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op*() + +#include +#include + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op*() + +#include +#include + +int main() +{ + { + std::unique_ptr p(new int [3]); + if (p) + ; + else + assert(false); + if (!p) + assert(false); + } + { + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test get + +#include +#include + +int main() +{ + int* p = new int[3]; + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test get_deleter() + +#include +#include + +struct Deleter +{ + void operator()(void*) {} + + int test() {return 5;} + int test() const {return 6;} +}; + +int main() +{ + { + std::unique_ptr p; + assert(p.get_deleter().test() == 5); + } + { + const std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op[](size_t) + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op->() + +#include +#include + +struct A +{ + int i_; + + A() : i_(7) {} +}; + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr::pointer type + +#include +#include + +struct Deleter +{ + struct pointer {}; +}; + +int main() +{ + { + typedef std::unique_ptr P; + static_assert((std::is_same::value), ""); + } + { + typedef std::unique_ptr P; + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +// 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 s(new A); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#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 s1(new A); + A* p = s1.get(); + std::unique_ptr 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 > s1(new A, Deleter(5)); + A* p = s1.get(); + std::unique_ptr > 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 d1(5); + std::unique_ptr&> s1(new A, d1); + A* p = s1.get(); + CDeleter d2(6); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +// 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 s(new A); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +#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 > s(new B, Deleter(5)); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Can't assign from lvalue + +#include +#include +#include + +#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 db(5); + std::unique_ptr&> s(new B, db); + A* p = s.get(); + Deleter da(6); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// test converting move assignment with reference deleters + +#include +#include +#include + +#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 db(5); + std::unique_ptr&> s(new B, db); + A* p = s.get(); + CDeleter da(6); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Can't assign from const lvalue + +#include +#include +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Can't assign from const lvalue + +#include +#include +#include + +#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 db(5); + const std::unique_ptr&> s(new B, db); + A* p = s.get(); + Deleter da(6); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +// Do not convert from an array unique_ptr + +#include +#include +#include + +struct A +{ +}; + +struct Deleter +{ + void operator()(void*) {} +}; + +int main() +{ + std::unique_ptr s; + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move assignment + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include +#include + +// template explicit unique_ptr(auto_ptr&); + +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 ap(p); + std::unique_ptr 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 ap(p); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// template explicit unique_ptr(auto_ptr&); + +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 ap(p); + std::unique_ptr 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 ap(p); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// template explicit unique_ptr(auto_ptr&); + +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 + void operator()(T*) {} +}; + +int main() +{ + { + B* p = new B; + std::auto_ptr ap(p); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +#include +#include + +// 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 p; + assert(p.get() == 0); + } + { + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +#include + +// default unique_ptr ctor should require non-reference Deleter ctor +class Deleter +{ +public: + + void operator()(void*) {} +}; + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test default unique_ptr ctor + +#include +#include + +// 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 > +struct B +{ + std::unique_ptr 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 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 +B::~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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr default ctor + +#include + +// default unique_ptr ctor should require non-pointer Deleter + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include +#include + +// 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 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() {return std::__rv(*this);} + Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} + Deleter& operator=(std::__rv 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 + Deleter(Deleter&& d, + typename std::enable_if::value>::type* = 0) + : state_(d.state()) {d.set_state(0);} + +private: + template + Deleter(const Deleter& d, + typename std::enable_if::value>::type* = 0); +#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + template + Deleter(Deleter d, + typename std::enable_if::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 s(new A); + A* p = s.get(); + std::unique_ptr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == 1); + } + assert(A::count == 0); + { + std::unique_ptr > s(new A); + A* p = s.get(); + std::unique_ptr > 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 s(new A, d); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include + +// 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 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() {return std::__rv(*this);} + Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} + Deleter& operator=(std::__rv 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 + Deleter(Deleter&& d, + typename std::enable_if::value>::type* = 0) + : state_(d.state()) {d.set_state(0);} + +private: + template + Deleter(const Deleter& d, + typename std::enable_if::value>::type* = 0); +#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + template + Deleter(Deleter d, + typename std::enable_if::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 +source1() +{ + return std::unique_ptr(new A); +} + +void sink1(std::unique_ptr p) +{ +} + +std::unique_ptr > +source2() +{ + return std::unique_ptr >(new A); +} + +void sink2(std::unique_ptr > p) +{ +} + +std::unique_ptr +source3() +{ + static CDeleter d; + return std::unique_ptr(new A, d); +} + +void sink3(std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include + +// 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 s(new A); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include +#include + +#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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +#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 > s(new B, Deleter(5)); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +#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 > s(new B); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +#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 > s(new B, Deleter(5)); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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 d; + std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +#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(5); + std::unique_ptr&> s(new B, b); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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() {return std::__rv(*this);} + Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} + Deleter& operator=(std::__rv 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 + Deleter(Deleter&& d, + typename std::enable_if::value>::type* = 0) + : state_(d.state()) {d.set_state(0);} + +private: + template + Deleter(const Deleter& d, + typename std::enable_if::value>::type* = 0); +#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + template + Deleter(Deleter d, + typename std::enable_if::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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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 d; + const std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 s(new B); + A* p = s.get(); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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() {return std::__rv(*this);} + Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} + Deleter& operator=(std::__rv 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 + Deleter(Deleter&& d, + typename std::enable_if::value>::type* = 0) + : state_(d.state()) {d.set_state(0);} + +private: + template + Deleter(const Deleter& d, + typename std::enable_if::value>::type* = 0); +#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + template + Deleter(Deleter d, + typename std::enable_if::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 > s(new B); + A* p = s.get(); + std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include +#include +#include + +// 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 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 d; + const std::unique_ptr&> s(new B, d); + A* p = s.get(); + std::unique_ptr&> 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +// Do not convert from an array unique_ptr + +#include +#include +#include + +struct A +{ +}; + +struct Deleter +{ + void operator()(void*) {} +}; + +int main() +{ + std::unique_ptr s; + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// unique_ptr(nullptr_t); + +#include +#include + +// 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 p(nullptr); + assert(p.get() == 0); + } + { + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// 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 s(p); + assert(s.get() == p); + } + assert(A::count == 0); + { + A* p = new A; + assert(A::count == 1); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include + +// unique_ptr(pointer) ctor should require non-reference Deleter ctor +class Deleter +{ +public: + + void operator()(void*) {} +}; + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// 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 > +struct B +{ + std::unique_ptr 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 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 +B::B(A* a) : a_(a) {} + +template +B::~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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include + +// unique_ptr(pointer) ctor should require non-pointer Deleter + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// 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 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() {return std::__rv(*this);} + Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} + Deleter& operator=(std::__rv 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 + Deleter(Deleter&& d, + typename std::enable_if::value>::type* = 0) + : state_(d.state()) {d.set_state(0);} + +private: + template + Deleter(const Deleter& d, + typename std::enable_if::value>::type* = 0); +#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + template + Deleter(Deleter d, + typename std::enable_if::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 > 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_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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// unique_ptr(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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// unique_ptr(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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer) ctor + +#include +#include + +// unique_ptr(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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +#include +#include + +// 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr(pointer, deleter) ctor + +#include +#include + +// unique_ptr(pointer, deleter) should work with function pointers +// unique_ptr should work + +bool my_free_called = false; + +void my_free(void*) +{ + my_free_called = true; +} + +int main() +{ + { + int i = 0; + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// The deleter is not called if get() == 0 + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test release + +#include +#include + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset + +#include +#include + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + std::unique_ptr 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test reset against resetting self + +#include + +struct A +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test swap + +#include +#include + +#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 > s1(p1, Deleter(1)); + A* p2 = new A(2); + std::unique_ptr > s2(p2, Deleter(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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op*() + +#include +#include + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op*() + +#include +#include + +int main() +{ + { + std::unique_ptr p(new int(3)); + if (p) + ; + else + assert(false); + if (!p) + assert(false); + } + { + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test get + +#include +#include + +int main() +{ + int* p = new int; + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test get_deleter() + +#include +#include + +struct Deleter +{ + void operator()(void*) {} + + int test() {return 5;} + int test() const {return 6;} +}; + +int main() +{ + { + std::unique_ptr p; + assert(p.get_deleter().test() == 5); + } + { + const std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op[](size_t) + +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// test op->() + +#include +#include + +struct A +{ + int i_; + + A() : i_(7) {} +}; + +int main() +{ + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template +// bool operator==(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator==(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator!=(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator!=(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator<(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator<(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator<=(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator<=(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator>(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator>(nullptr_t, const unique_ptr& y) noexcept; +// template +// bool operator>=(const unique_ptr& x, nullptr_t) noexcept; +// template +// bool operator>=(nullptr_t, const unique_ptr& y) noexcept; + +#include +#include + +void do_nothing(int*) {} + +int main() +{ + const std::unique_ptr 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// template +// bool +// operator==(const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator!=(const unique_ptr& x, const unique_ptr& y); + +#include +#include + +#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 > p1(new A); + const std::unique_ptr > p2(new A); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1(new A); + const std::unique_ptr > p2(new B); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new A[3]); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new B[3]); + assert(!(p1 == p2)); + assert(p1 != p2); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > p2; + assert(p1 == p2); + assert(!(p1 != p2)); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// template +// bool +// operator< (const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator> (const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator<=(const unique_ptr& x, const unique_ptr& y); + +// template +// bool +// operator>=(const unique_ptr& x, const unique_ptr& y); + +#include +#include + +#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 > p1(new A); + const std::unique_ptr > p2(new A); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1(new A); + const std::unique_ptr > p2(new B); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new A[3]); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1(new A[3]); + const std::unique_ptr > p2(new B[3]); + assert((p1 < p2) == !(p1 > p2)); + assert((p1 < p2) == (p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > p2; + assert((p1 < p2) == (p1 > p2)); + assert((p1 < p2) == !(p1 <= p2)); + assert((p1 < p2) == !(p1 >= p2)); + } + { + const std::unique_ptr > p1; + const std::unique_ptr > 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. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test swap + +#include +#include + +#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 > s1(p1, Deleter(1)); + A* p2 = new A(2); + std::unique_ptr > s2(p2, Deleter(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 > s1(p1, Deleter(1)); + A* p2 = new A[3]; + std::unique_ptr > s2(p2, Deleter(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. +// +//===----------------------------------------------------------------------===// + +// + +// void declare_no_pointers(char* p, size_t n); +// void undeclare_no_pointers(char* p, size_t n); + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// void declare_reachable(void* p); +// template T* undeclare_reachable(T* p); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// pointer_safety get_pointer_safety(); + +#include +#include + +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 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 shared_from_this(); +// shared_ptr shared_from_this() const; +// }; + +#include +#include + +struct T + : public std::enable_shared_from_this +{ +}; + +struct Y : T {}; + +struct Z : Y {}; + +int main() +{ + { // https://llvm.org/bugs/show_bug.cgi?id=18843 + std::shared_ptr t1(new T); + std::shared_ptr t2(std::make_shared()); + } + { + std::shared_ptr p(new Z); + std::shared_ptr 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 p = std::make_shared(); + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash> +// { +// typedef shared_ptr argument_type; +// typedef size_t result_type; +// size_t operator()(const shared_ptr& p) const; +// }; + +#include +#include + +int main() +{ + int* ptr = new int; + std::shared_ptr p(ptr); + std::hash > f; + std::size_t h = f(p); + assert(h == std::hash()(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash> +// { +// typedef unique_ptr argument_type; +// typedef size_t result_type; +// size_t operator()(const unique_ptr& p) const; +// }; + +#include +#include + +int main() +{ + int* ptr = new int; + std::unique_ptr p(ptr); + std::hash > f; + std::size_t h = f(p); + assert(h == std::hash()(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 + +// + +// shared_ptr + +// template +// bool +// atomic_compare_exchange_strong(shared_ptr* p, shared_ptr* v, +// shared_ptr w); + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p(new int(4)); + std::shared_ptr v(new int(3)); + std::shared_ptr 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 p(new int(4)); + std::shared_ptr v = p; + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// bool +// atomic_compare_exchange_strong_explicit(shared_ptr* p, shared_ptr* v, +// shared_ptr w, memory_order success, +// memory_order failure); + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p(new int(4)); + std::shared_ptr v(new int(3)); + std::shared_ptr 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 p(new int(4)); + std::shared_ptr v = p; + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// bool +// atomic_compare_exchange_weak(shared_ptr* p, shared_ptr* v, +// shared_ptr w); + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p(new int(4)); + std::shared_ptr v(new int(3)); + std::shared_ptr 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 p(new int(4)); + std::shared_ptr v = p; + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// bool +// atomic_compare_exchange_weak_explicit(shared_ptr* p, shared_ptr* v, +// shared_ptr w, memory_order success, +// memory_order failure); + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p(new int(4)); + std::shared_ptr v(new int(3)); + std::shared_ptr 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 p(new int(4)); + std::shared_ptr v = p; + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// shared_ptr +// atomic_exchange(shared_ptr* p, shared_ptr r) + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p(new int(4)); + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// shared_ptr +// atomic_exchange_explicit(shared_ptr* p, shared_ptr r) + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p(new int(4)); + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// bool +// atomic_is_lock_free(const shared_ptr* p); + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + const std::shared_ptr 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 + +// + +// shared_ptr + +// template +// shared_ptr +// atomic_load(const shared_ptr* p) + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p(new int(3)); + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// shared_ptr +// atomic_load_explicit(const shared_ptr* p, memory_order mo) + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + const std::shared_ptr p(new int(3)); + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// void +// atomic_store(shared_ptr* p, shared_ptr r) + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p; + std::shared_ptr 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 + +// + +// shared_ptr + +// template +// void +// atomic_store_explicit(shared_ptr* p, shared_ptr r, memory_order mo) + +#include +#include + +int main() +{ +#if __has_feature(cxx_atomic) + { + std::shared_ptr p; + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// Example move-only deleter + +#ifndef DELETER_H +#define DELETER_H + +#include +#include + +#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 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 +void +swap(test_deleter& x, test_deleter& y) +{ + test_deleter 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class shared_ptr +// { +// public: +// typedef T element_type; +// ... +// }; + +#include + +struct A; // purposefully incomplete + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template D* get_deleter(const shared_ptr& p); + +#include +#include +#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 p(ptr, test_deleter(3)); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + } + test_deleter::dealloc_count = 0; + { + { + std::shared_ptr p(nullptr, test_deleter(3)); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + } + test_deleter::dealloc_count = 0; + { + std::shared_ptr p(nullptr, test_deleter(3)); + std::default_delete* d = std::get_deleter >(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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr& operator=(auto_ptr&& r); + +#include +#include +#include + +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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// shared_ptr& operator=(const shared_ptr& r); + +#include +#include +#include + +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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr& operator=(const shared_ptr& r); + +#include +#include +#include + +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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr& operator=(shared_ptr&& r); + +#include +#include +#include + +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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// shared_ptr& operator=(shared_ptr&& r); + +#include +#include +#include + +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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr& operator=(unique_ptr&& r); + +#include +#include +#include + +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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA(new A); + A* ptrA = pA.get(); + { + std::shared_ptr 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 pA; + A* ptrA = pA.get(); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr const_pointer_cast(const shared_ptr& r); + +#include +#include +#include + +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 pA(new A); + std::shared_ptr pB = std::const_pointer_cast(pA); + assert(pB.get() == pA.get()); + assert(!pB.owner_before(pA) && !pA.owner_before(pB)); + } + { + const std::shared_ptr pA; + std::shared_ptr pB = std::const_pointer_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr dynamic_pointer_cast(const shared_ptr& r); + +#include +#include +#include + +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 pB(new A); + std::shared_ptr pA = std::dynamic_pointer_cast(pB); + assert(pA.get() == pB.get()); + assert(!pB.owner_before(pA) && !pA.owner_before(pB)); + } + { + const std::shared_ptr pB(new B); + std::shared_ptr pA = std::dynamic_pointer_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr static_pointer_cast(const shared_ptr& r); + +#include +#include +#include + +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 pA(new A); + std::shared_ptr pB = std::static_pointer_cast(pA); + assert(pB.get() == pA.get()); + assert(!pB.owner_before(pA) && !pA.owner_before(pB)); + } + { + const std::shared_ptr pA(new A); + std::shared_ptr pB = std::static_pointer_cast(pA); + assert(pB.get() == pA.get()); + assert(!pB.owner_before(pA) && !pA.owner_before(pB)); + } + { + const std::shared_ptr pA; + std::shared_ptr pB = std::static_pointer_cast(pA); + assert(pB.get() == pA.get()); + assert(!pB.owner_before(pA) && !pA.owner_before(pB)); + } + { + const std::shared_ptr pA; + std::shared_ptr pB = std::static_pointer_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template +// bool operator==(const shared_ptr& x, nullptr_t) noexcept; +// template +// bool operator==(nullptr_t, const shared_ptr& y) noexcept; +// template +// bool operator!=(const shared_ptr& x, nullptr_t) noexcept; +// template +// bool operator!=(nullptr_t, const shared_ptr& y) noexcept; +// template +// bool operator<(const shared_ptr& x, nullptr_t) noexcept; +// template +// bool operator<(nullptr_t, const shared_ptr& y) noexcept; +// template +// bool operator<=(const shared_ptr& x, nullptr_t) noexcept; +// template +// bool operator<=(nullptr_t, const shared_ptr& y) noexcept; +// template +// bool operator>(const shared_ptr& x, nullptr_t) noexcept; +// template +// bool operator>(nullptr_t, const shared_ptr& y) noexcept; +// template +// bool operator>=(const shared_ptr& x, nullptr_t) noexcept; +// template +// bool operator>=(nullptr_t, const shared_ptr& y) noexcept; + +#include +#include + +void do_nothing(int*) {} + +int main() +{ + const std::shared_ptr 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template bool operator==(const shared_ptr& a, const shared_ptr& b); +// template bool operator!=(const shared_ptr& a, const shared_ptr& b); + +#include +#include + +void do_nothing(int*) {} + +int main() +{ + int* ptr1(new int); + int* ptr2(new int); + const std::shared_ptr p1(ptr1); + const std::shared_ptr p2(ptr2); + const std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template bool operator<(const shared_ptr& a, const shared_ptr& b); + +#include +#include + +void do_nothing(int*) {} + +int main() +{ + int* ptr1(new int); + int* ptr2(new int); + const std::shared_ptr p1(ptr1); + const std::shared_ptr p2(ptr2); + const std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template explicit shared_ptr(auto_ptr&& r); + +// UNSUPPORTED: sanitizer-new-delete + +#include +#include +#include +#include + +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 ptr(new A); + A* raw_ptr = ptr.get(); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::shared_ptr p(std::move(ptr)); +#else + std::shared_ptr 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 ptr(new A); + A* raw_ptr = ptr.get(); + throw_next = true; + try + { +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::shared_ptr p(std::move(ptr)); +#else + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr(); + +#include +#include + +int main() +{ + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr(nullptr_t) + +#include +#include + +int main() +{ + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr(nullptr_t, D d); + +#include +#include +#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 p(nullptr, test_deleter(3)); + assert(A::count == 0); + assert(p.use_count() == 1); + assert(p.get() == 0); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::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. +// +//===----------------------------------------------------------------------===// + +// + +// template shared_ptr(nullptr_t, D d, A a); + +#include +#include +#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 p(nullptr, test_deleter(3), test_allocator(5)); + assert(A::count == 0); + assert(p.use_count() == 1); + assert(p.get() == 0); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + assert(test_allocator::count == 1); + assert(test_allocator::alloc_count == 1); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + assert(test_allocator::count == 0); + assert(test_allocator::alloc_count == 0); + test_deleter::dealloc_count = 0; + // Test an allocator with a minimal interface + { + std::shared_ptr p(nullptr, test_deleter(1), bare_allocator()); + assert(A::count == 0); + assert(p.use_count() == 1); + assert(p.get() == 0); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count ==1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 1); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + test_deleter::dealloc_count = 0; +#if __cplusplus >= 201103L + // Test an allocator that returns class-type pointers + { + std::shared_ptr p(nullptr, test_deleter(1), min_allocator()); + assert(A::count == 0); + assert(p.use_count() == 1); + assert(p.get() == 0); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count ==1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 1); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::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. +// +//===----------------------------------------------------------------------===// + +// + +// template shared_ptr(nullptr_t, D d, A a); + +#include +#include +#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::throw_after = 0; + std::shared_ptr p(nullptr, test_deleter(3), test_allocator(5)); + assert(false); + } + catch (std::bad_alloc&) + { + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + assert(test_allocator::count == 0); + assert(test_allocator::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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr(nullptr_t, D d); + +// UNSUPPORTED: sanitizer-new-delete + +#include +#include +#include +#include +#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 p(nullptr, test_deleter(3)); + assert(false); + } + catch (std::bad_alloc&) + { + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::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. +// +//===----------------------------------------------------------------------===// + +// + +// template explicit shared_ptr(Y* p); + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr(Y* p, D d); + +#include +#include +#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 p(ptr, test_deleter(3)); + assert(A::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::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. +// +//===----------------------------------------------------------------------===// + +// + +// template shared_ptr(Y* p, D d, A a); + +#include +#include +#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 p(ptr, test_deleter(3), test_allocator(5)); + assert(A::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + assert(test_allocator::count == 1); + assert(test_allocator::alloc_count == 1); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + assert(test_allocator::count == 0); + assert(test_allocator::alloc_count == 0); + test_deleter::dealloc_count = 0; + // Test an allocator with a minimal interface + { + A* ptr = new A; + std::shared_ptr p(ptr, test_deleter(3), bare_allocator()); + assert(A::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + test_deleter::dealloc_count = 0; +#if __cplusplus >= 201103L + // Test an allocator that returns class-type pointers + { + A* ptr = new A; + std::shared_ptr p(ptr, test_deleter(3), min_allocator()); + assert(A::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::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. +// +//===----------------------------------------------------------------------===// + +// + +// template shared_ptr(Y* p, D d, A a); + +#include +#include +#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::throw_after = 0; + std::shared_ptr p(ptr, test_deleter(3), test_allocator(5)); + assert(false); + } + catch (std::bad_alloc&) + { + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + assert(test_allocator::count == 0); + assert(test_allocator::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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr(Y* p, D d); + +// UNSUPPORTED: sanitizer-new-delete + +#include +#include +#include +#include +#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 p(ptr, test_deleter(3)); + assert(false); + } + catch (std::bad_alloc&) + { + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::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. +// +//===----------------------------------------------------------------------===// + +// + +// template explicit shared_ptr(Y* p); + +// UNSUPPORTED: sanitizer-new-delete + +#include +#include +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// shared_ptr(const shared_ptr& r); + +#include +#include + +struct A +{ + static int count; + + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + std::shared_ptr pA(new A); + assert(pA.use_count() == 1); + assert(A::count == 1); + { + std::shared_ptr 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 pA; + assert(pA.use_count() == 0); + assert(A::count == 0); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr(const shared_ptr& r); + +#include +#include +#include + +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 >::value), ""); + static_assert((!std::is_convertible, std::shared_ptr >::value), ""); + static_assert((!std::is_convertible, std::shared_ptr >::value), ""); + { + const std::shared_ptr pA(new A); + assert(pA.use_count() == 1); + assert(B::count == 1); + assert(A::count == 1); + { + std::shared_ptr 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 pA; + assert(pA.use_count() == 0); + assert(B::count == 0); + assert(A::count == 0); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr(shared_ptr&& r); + +#include +#include +#include + +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 >::value), ""); + static_assert((!std::is_convertible, std::shared_ptr >::value), ""); + static_assert((!std::is_convertible, std::shared_ptr >::value), ""); + { + std::shared_ptr pA(new A); + assert(pA.use_count() == 1); + assert(B::count == 1); + assert(A::count == 1); + { + B* p = pA.get(); + std::shared_ptr 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 pA; + assert(pA.use_count() == 0); + assert(B::count == 0); + assert(A::count == 0); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr(const shared_ptr& r, T *p); + +#include +#include + +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 pA(new A); + assert(pA.use_count() == 1); + { + B b; + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// shared_ptr(shared_ptr&& r); + +#include +#include + +struct A +{ + static int count; + + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + std::shared_ptr pA(new A); + assert(pA.use_count() == 1); + assert(A::count == 1); + { + A* p = pA.get(); + std::shared_ptr 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 pA; + assert(pA.use_count() == 0); + assert(A::count == 0); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template explicit shared_ptr(unique_ptr&&r); + +// UNSUPPORTED: sanitizer-new-delete + +#include +#include +#include +#include + +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 &) {} +void fn ( const std::shared_ptr &) { assert (false); } + +template +void assert_deleter ( T * ) { assert(false); } + +int main() +{ + { + std::unique_ptr ptr(new A); + A* raw_ptr = ptr.get(); + std::shared_ptr 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 ptr(new A); + A* raw_ptr = ptr.get(); + throw_next = true; + try + { + std::shared_ptr 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(new int)); + } + +#if __cplusplus >= 201402L + // LWG 2415 + { + std::unique_ptr p(nullptr, assert_deleter); + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template explicit shared_ptr(const weak_ptr& r); + +#include +#include + +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 wp; + try + { + std::shared_ptr sp(wp); + assert(false); + } + catch (std::bad_weak_ptr&) + { + } + assert(A::count == 0); + } + { + std::shared_ptr sp0(new A); + std::weak_ptr wp(sp0); + std::shared_ptr sp(wp); + assert(sp.use_count() == 2); + assert(sp.get() == sp0.get()); + assert(A::count == 1); + } + assert(A::count == 0); + { + std::shared_ptr sp0(new A); + std::weak_ptr wp(sp0); + sp0.reset(); + try + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template +// shared_ptr allocate_shared(const A& a, Args&&... args); + +#include +#include +#include +#include +#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 p = std::allocate_shared(test_allocator(54), i, c); + assert(test_allocator::alloc_count == 1); + assert(A::count == 1); + assert(p->get_int() == 67); + assert(p->get_char() == 'e'); + } + assert(A::count == 0); + assert(test_allocator::alloc_count == 0); +#if __cplusplus >= 201103L + { + int i = 67; + char c = 'e'; + std::shared_ptr p = std::allocate_shared(min_allocator(), 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 p = std::allocate_shared(bare_allocator(), 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template +// shared_ptr allocate_shared(const A& a, Args&&... args); + +#define _LIBCPP_HAS_NO_VARIADICS +#include +#include +#include +#include +#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 +void test() +{ + int const bad = -1; + { + std::shared_ptr p = std::allocate_shared(Alloc()); + assert(Zero::count == 1); + } + assert(Zero::count == 0); + { + int const i = 42; + std::shared_ptr p = std::allocate_shared(Alloc(), i); + assert(One::count == 1); + assert(p->value == i); + } + assert(One::count == 0); + { + int const i = 42; + std::shared_ptr p = std::allocate_shared(Alloc(), i, bad); + assert(Two::count == 1); + assert(p->value == i); + } + assert(Two::count == 0); + { + int const i = 42; + std::shared_ptr p = std::allocate_shared(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 p = std::allocate_shared(test_allocator(54), i, bad); + assert(test_allocator::alloc_count == 1); + assert(Two::count == 1); + assert(p->value == 67); + } + assert(Two::count == 0); + assert(test_allocator::alloc_count == 0); + + test >(); +#if __cplusplus >= 201103L + test >(); +#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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr make_shared(Args&&... args); + +#include +#include + +#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 p = std::make_shared(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 p1 = std::make_shared(); + assert(p1.get()); + std::shared_ptr p2 = std::make_shared(); + assert(p2.get()); + } + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + nc = globalMemCounter.outstanding_new; + { + char c = 'e'; + std::shared_ptr p = std::make_shared(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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template shared_ptr make_shared(Args&&... args); + +#include +#include + +template +void test(const T &t0) +{ + { + T t1 = t0; + std::shared_ptr p0 = std::make_shared(t0); + std::shared_ptr p1 = std::make_shared(t1); + assert(*p0 == t0); + assert(*p1 == t1); + } + + { + const T t1 = t0; + std::shared_ptr p0 = std::make_shared(t0); + std::shared_ptr p1 = std::make_shared(t1); + assert(*p0 == t0); + assert(*p1 == t1); + } + + { + volatile T t1 = t0; + std::shared_ptr p0 = std::make_shared(t0); + std::shared_ptr p1 = std::make_shared(t1); + assert(*p0 == t0); + assert(*p1 == t1); + } + + { + const volatile T t1 = t0; + std::shared_ptr p0 = std::make_shared(t0); + std::shared_ptr p1 = std::make_shared(t1); + assert(*p0 == t0); + assert(*p1 == t1); + } + +} + +int main() +{ + test(true); + test(3); + test(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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template +// basic_ostream& +// operator<<(basic_ostream& os, shared_ptr const& p); + +#include +#include +#include + +int main() +{ + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// void reset(); + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template void reset(Y* p); + +#include +#include + +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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template void reset(Y* p, D d); + +#include +#include +#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 p(new B); + A* ptr = new A; + p.reset(ptr, test_deleter(3)); + assert(A::count == 1); + assert(B::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + { + std::shared_ptr p; + A* ptr = new A; + p.reset(ptr, test_deleter(3)); + assert(A::count == 1); + assert(B::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 1); + assert(d); + assert(d->state() == 3); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template void reset(Y* p, D d, A a); + +#include +#include +#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 p(new B); + A* ptr = new A; + p.reset(ptr, test_deleter(3), test_allocator(4)); + assert(A::count == 1); + assert(B::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 0); + assert(d); + assert(d->state() == 3); + assert(test_allocator::count == 1); + assert(test_allocator::alloc_count == 1); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 1); + assert(test_allocator::count == 0); + assert(test_allocator::alloc_count == 0); + { + std::shared_ptr p; + A* ptr = new A; + p.reset(ptr, test_deleter(3), test_allocator(4)); + assert(A::count == 1); + assert(B::count == 1); + assert(p.use_count() == 1); + assert(p.get() == ptr); + test_deleter* d = std::get_deleter >(p); + assert(test_deleter::count == 1); + assert(test_deleter::dealloc_count == 1); + assert(d); + assert(d->state() == 3); + assert(test_allocator::count == 1); + assert(test_allocator::alloc_count == 1); + } + assert(A::count == 0); + assert(test_deleter::count == 0); + assert(test_deleter::dealloc_count == 2); + assert(test_allocator::count == 0); + assert(test_allocator::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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// void swap(shared_ptr& r); + +#include +#include + +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 p1(ptr1); + { + std::shared_ptr 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 p1(ptr1); + { + std::shared_ptr 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 p1; + { + std::shared_ptr 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 p1; + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// T* operator->() const; + +#include +#include +#include + +int main() +{ + const std::shared_ptr > p(new std::pair(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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// T& operator*() const; + +#include +#include + +int main() +{ + const std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// explicit operator bool() const; + +#include +#include + +int main() +{ + { + const std::shared_ptr p(new int(32)); + assert(p); + } + { + const std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template bool owner_before(shared_ptr const& b) const; + +#include +#include + +int main() +{ + const std::shared_ptr p1(new int); + const std::shared_ptr p2 = p1; + const std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template bool owner_before(weak_ptr const& b) const; + +#include +#include + +int main() +{ + const std::shared_ptr p1(new int); + const std::shared_ptr p2 = p1; + const std::shared_ptr p3(new int); + const std::weak_ptr w1(p1); + const std::weak_ptr w2(p2); + const std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// bool unique() const; + +#include +#include + +int main() +{ + const std::shared_ptr p(new int(32)); + assert(p.unique()); + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template void swap(shared_ptr& a, shared_ptr& b); + +#include +#include + +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 p1(ptr1); + { + std::shared_ptr 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 p1(ptr1); + { + std::shared_ptr 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 p1; + { + std::shared_ptr 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 p1; + { + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class weak_ptr +// { +// public: +// typedef T element_type; +// ... +// }; + +#include + +struct A; // purposefully incomplete + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct owner_less; +// +// template +// struct owner_less > +// : binary_function, shared_ptr, bool> +// { +// typedef bool result_type; +// bool operator()(shared_ptr const&, shared_ptr const&) const; +// bool operator()(shared_ptr const&, weak_ptr const&) const; +// bool operator()(weak_ptr const&, shared_ptr const&) const; +// }; +// +// template +// struct owner_less > +// : binary_function, weak_ptr, bool> +// { +// typedef bool result_type; +// bool operator()(weak_ptr const&, weak_ptr const&) const; +// bool operator()(shared_ptr const&, weak_ptr const&) const; +// bool operator()(weak_ptr const&, shared_ptr const&) const; +// }; + +#include +#include + +int main() +{ + const std::shared_ptr p1(new int); + const std::shared_ptr p2 = p1; + const std::shared_ptr p3(new int); + const std::weak_ptr w1(p1); + const std::weak_ptr w2(p2); + const std::weak_ptr w3(p3); + + { + typedef std::owner_less > CS; + CS cs; + + static_assert((std::is_same, CS::first_argument_type>::value), "" ); + static_assert((std::is_same, CS::second_argument_type>::value), "" ); + static_assert((std::is_same::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 > CS; + CS cs; + + static_assert((std::is_same, CS::first_argument_type>::value), "" ); + static_assert((std::is_same, CS::second_argument_type>::value), "" ); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// template weak_ptr& operator=(const shared_ptr& r); + +#include +#include +#include + +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 pA(new A); + { + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// weak_ptr& operator=(const weak_ptr& r); + +#include +#include +#include + +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 ps(new A); + const std::weak_ptr pA(ps); + { + std::weak_ptr 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 ps(new A); + std::weak_ptr pA(ps); + { + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// template weak_ptr& operator=(const weak_ptr& r); + +#include +#include +#include + +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 ps(new A); + const std::weak_ptr pA(ps); + { + std::weak_ptr 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 ps(new A); + std::weak_ptr pA(ps); + { + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class weak_ptr + +// weak_ptr(); + +#include +#include + +struct A; + +int main() +{ + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// template weak_ptr(const shared_ptr& r); + +#include +#include +#include + +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::weak_ptr >::value), ""); + static_assert((!std::is_convertible, std::shared_ptr >::value), ""); + static_assert((!std::is_convertible, std::weak_ptr >::value), ""); + { + const std::shared_ptr pA(new A); + assert(pA.use_count() == 1); + assert(B::count == 1); + assert(A::count == 1); + { + std::weak_ptr 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 pA; + assert(pA.use_count() == 0); + assert(B::count == 0); + assert(A::count == 0); + { + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// weak_ptr(const weak_ptr& r); +// weak_ptr(weak_ptr &&r) + +#include +#include +#include + +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 +std::weak_ptr source (std::shared_ptr p) { return std::weak_ptr(p); } + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +template +void sink (std::weak_ptr &&) {} +#endif + +int main() +{ + { + const std::shared_ptr ps(new A); + const std::weak_ptr pA(ps); + assert(pA.use_count() == 1); + assert(B::count == 1); + assert(A::count == 1); + { + std::weak_ptr 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 pA; + assert(pA.use_count() == 0); + assert(B::count == 0); + assert(A::count == 0); + { + std::weak_ptr 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 ps(new A); + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// template weak_ptr(const weak_ptr& r); +// template weak_ptr(weak_ptr &&r); + +#include +#include +#include + +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 +std::weak_ptr source (std::shared_ptr p) { return std::weak_ptr(p); } + +int main() +{ + static_assert(( std::is_convertible, std::weak_ptr >::value), ""); + static_assert((!std::is_convertible, std::weak_ptr >::value), ""); + static_assert((!std::is_convertible, std::weak_ptr >::value), ""); + { + const std::weak_ptr pA(std::shared_ptr(new A)); + assert(pA.use_count() == 0); + assert(B::count == 0); + assert(A::count == 0); + { + std::weak_ptr 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 pA; + assert(pA.use_count() == 0); + assert(B::count == 0); + assert(A::count == 0); + { + std::weak_ptr 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 ps(new A); + std::weak_ptr pA = source(ps); + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// void swap(weak_ptr& r); + +#include +#include + +struct A +{ + static int count; + + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + std::shared_ptr p1(new A); + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// void swap(weak_ptr& r); + +#include +#include + +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 p1(ptr1); + std::weak_ptr w1(p1); + { + std::shared_ptr p2(ptr2); + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// bool expired() const; + +#include +#include + +struct A +{ + static int count; + + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + std::weak_ptr wp; + assert(wp.use_count() == 0); + assert(wp.expired() == (wp.use_count() == 0)); + } + { + std::shared_ptr sp0(new A); + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// shared_ptr lock() const; + +#include +#include + +struct A +{ + static int count; + + A() {++count;} + A(const A&) {++count;} + ~A() {--count;} +}; + +int A::count = 0; + +int main() +{ + { + std::weak_ptr wp; + std::shared_ptr sp = wp.lock(); + assert(sp.use_count() == 0); + assert(sp.get() == 0); + assert(A::count == 0); + } + { + std::shared_ptr sp0(new A); + std::weak_ptr wp(sp0); + std::shared_ptr sp = wp.lock(); + assert(sp.use_count() == 2); + assert(sp.get() == sp0.get()); + assert(A::count == 1); + } + assert(A::count == 0); + { + std::shared_ptr sp0(new A); + std::weak_ptr wp(sp0); + sp0.reset(); + std::shared_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class weak_ptr; +// +// not less than comparable + +#include +#include + +int main() +{ + const std::shared_ptr p1(new int); + const std::shared_ptr p2(new int); + const std::weak_ptr w1(p1); + const std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// template bool owner_before(const shared_ptr& b); + +#include +#include + +int main() +{ + const std::shared_ptr p1(new int); + const std::shared_ptr p2 = p1; + const std::shared_ptr p3(new int); + const std::weak_ptr w1(p1); + const std::weak_ptr w2(p2); + const std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// template bool owner_before(const weak_ptr& b); + +#include +#include + +int main() +{ + const std::shared_ptr p1(new int); + const std::shared_ptr p2 = p1; + const std::shared_ptr p3(new int); + const std::weak_ptr w1(p1); + const std::weak_ptr w2(p2); + const std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// weak_ptr + +// template void swap(weak_ptr& a, weak_ptr& b) + +#include +#include + +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 p1(ptr1); + std::weak_ptr w1(p1); + { + std::shared_ptr p2(ptr2); + std::weak_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// class bad_weak_ptr +// : public std::exception +// { +// public: +// bad_weak_ptr(); +// }; + +#include +#include +#include +#include + +int main() +{ + static_assert((std::is_base_of::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include + +int main() +{ +#if __cplusplus > 201402L + typedef std::bool_constant _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 _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 +#include + +int main() +{ + typedef std::integral_constant _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::value), ""); + static_assert((std::is_same::value), ""); + + static_assert(std::true_type::value == true, ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +template +void test_is_base_of() +{ + static_assert((std::is_base_of::value), ""); + static_assert((std::is_base_of::value), ""); + static_assert((std::is_base_of::value), ""); + static_assert((std::is_base_of::value), ""); +} + +template +void test_is_not_base_of() +{ + static_assert((!std::is_base_of::value), ""); +} + +struct B {}; +struct B1 : B {}; +struct B2 : B {}; +struct D : private B1, private B2 {}; + +int main() +{ + test_is_base_of(); + test_is_base_of(); + test_is_base_of(); + test_is_base_of(); + test_is_base_of(); + test_is_base_of(); + + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); + test_is_not_base_of(); +} 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 + +template +void test_is_convertible() +{ + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); +} + +template +void test_is_not_convertible() +{ + static_assert((!std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); +} + +typedef void Function(); +typedef char Array[1]; + +class NonCopyable { + NonCopyable(NonCopyable&); +}; + +int main() +{ + // void + test_is_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + // Function + test_is_not_convertible (); + test_is_not_convertible (); + test_is_convertible (); + test_is_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + // Function& + test_is_not_convertible (); + test_is_not_convertible (); + test_is_convertible (); + + test_is_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + // Function* + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_convertible (); + + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + // Array + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + + test_is_not_convertible (); + test_is_not_convertible (); + + static_assert(( std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + + // Array& + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + static_assert(( std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + + test_is_not_convertible (); + test_is_not_convertible (); + + static_assert(( std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + + // char + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + test_is_convertible (); + + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + + test_is_not_convertible (); + + // char& + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + test_is_convertible (); + + static_assert(( std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + + test_is_not_convertible (); + + // char* + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + test_is_not_convertible (); + + test_is_not_convertible (); + test_is_not_convertible (); + + static_assert(( std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + static_assert((!std::is_convertible::value), ""); + static_assert(( std::is_convertible::value), ""); + + // NonCopyable + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((std::is_convertible::value), ""); + static_assert((!std::is_convertible::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(); +#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 + +template +void test_is_same() +{ + static_assert((std::is_same::value), ""); + static_assert((!std::is_same::value), ""); + static_assert((!std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +template +void test_is_same_ref() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +template +void test_is_not_same() +{ + static_assert((!std::is_same::value), ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_same(); + test_is_same(); + test_is_same(); + test_is_same(); + test_is_same_ref(); + + test_is_not_same(); + test_is_not_same(); + test_is_not_same(); + test_is_not_same(); + test_is_not_same(); +} 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 + +enum Enum {zero, one_}; + +template +void test_remove_all_extents() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); + test_remove_all_extents (); +} 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 + +enum Enum {zero, one_}; + +template +void test_remove_extent() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + + +int main() +{ + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); + test_remove_extent (); +} 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 + +template +void test_add_const_imp() +{ + static_assert((std::is_same::type, const U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +template +void test_add_const() +{ + test_add_const_imp(); + test_add_const_imp(); + test_add_const_imp(); + test_add_const_imp(); +} + +int main() +{ + test_add_const(); + test_add_const(); + test_add_const(); + test_add_const(); + test_add_const(); + test_add_const(); + test_add_const(); +} 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 + +template +void test_add_cv_imp() +{ + static_assert((std::is_same::type, const volatile U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +template +void test_add_cv() +{ + test_add_cv_imp(); + test_add_cv_imp(); + test_add_cv_imp(); + test_add_cv_imp(); +} + +int main() +{ + test_add_cv(); + test_add_cv(); + test_add_cv(); + test_add_cv(); + test_add_cv(); + test_add_cv(); + test_add_cv(); +} 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 + +template +void test_add_volatile_imp() +{ + static_assert((std::is_same::type, volatile U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +template +void test_add_volatile() +{ + test_add_volatile_imp(); + test_add_volatile_imp(); + test_add_volatile_imp(); + test_add_volatile_imp(); +} + +int main() +{ + test_add_volatile(); + test_add_volatile(); + test_add_volatile(); + test_add_volatile(); + test_add_volatile(); + test_add_volatile(); + test_add_volatile(); +} 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 + +template +void test_remove_const_imp() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +template +void test_remove_const() +{ + test_remove_const_imp(); + test_remove_const_imp(); + test_remove_const_imp(); + test_remove_const_imp(); +} + +int main() +{ + test_remove_const(); + test_remove_const(); + test_remove_const(); + test_remove_const(); + test_remove_const(); + test_remove_const(); + test_remove_const(); +} 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 + +template +void test_remove_cv_imp() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +template +void test_remove_cv() +{ + test_remove_cv_imp(); + test_remove_cv_imp(); + test_remove_cv_imp(); + test_remove_cv_imp(); +} + +int main() +{ + test_remove_cv(); + test_remove_cv(); + test_remove_cv(); + test_remove_cv(); + test_remove_cv(); + test_remove_cv(); + test_remove_cv(); +} 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 + +template +void test_remove_volatile_imp() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +template +void test_remove_volatile() +{ + test_remove_volatile_imp(); + test_remove_volatile_imp(); + test_remove_volatile_imp(); + test_remove_volatile_imp(); +} + +int main() +{ + test_remove_volatile(); + test_remove_volatile(); + test_remove_volatile(); + test_remove_volatile(); + test_remove_volatile(); + test_remove_volatile(); + test_remove_volatile(); +} 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 + +int main() +{ + { + typedef std::aligned_storage<10, 1 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 16, ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_storage<1>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 1, ""); + static_assert(sizeof(T1) == 1, ""); + } + { + typedef std::aligned_storage<2>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 2, ""); + static_assert(sizeof(T1) == 2, ""); + } + { + typedef std::aligned_storage<3>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 2, ""); + static_assert(sizeof(T1) == 4, ""); + } + { + typedef std::aligned_storage<4>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 4, ""); + static_assert(sizeof(T1) == 4, ""); + } + { + typedef std::aligned_storage<5>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 4, ""); + static_assert(sizeof(T1) == 8, ""); + } + { + typedef std::aligned_storage<7>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 4, ""); + static_assert(sizeof(T1) == 8, ""); + } + { + typedef std::aligned_storage<8>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 8, ""); + static_assert(sizeof(T1) == 8, ""); + } + { + typedef std::aligned_storage<9>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::value == 8, ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_storage<15>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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 + +#include + +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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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, T1>::value, "" ); +#endif + static_assert(std::alignment_of::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 + +int main() +{ + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, char>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, int>::value), ""); + static_assert((std::is_same, char>::value), ""); +#endif + + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + + static_assert((std::is_same::type, double>::value), ""); + static_assert((std::is_same::type, int>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, double>::value), ""); + static_assert((std::is_same, int>::value), ""); +#endif + + static_assert((std::is_same::type, double>::value), ""); + static_assert((std::is_same::type, long long>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, double>::value), ""); + static_assert((std::is_same, 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 + +int main() +{ + static_assert((std::is_same::type, char>::value), ""); + static_assert((std::is_same::type, int>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, char>::value), ""); + static_assert((std::is_same, 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 + +template +void test_decay() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + test_decay(); + test_decay(); + test_decay(); + test_decay(); + test_decay(); + test_decay(); + test_decay(); +} 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 + +int main() +{ + typedef std::enable_if::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 + +int main() +{ + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, int>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, void>::value), ""); + static_assert((std::is_same, 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 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::enable_if_t 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. +// +//===----------------------------------------------------------------------===// + +// + +// result_of + +#include +#include +#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 +struct Voider { + typedef void type; +}; + +template +struct HasType : std::false_type {}; + +template +struct HasType::type> : std::true_type {}; + +template +void test_result_of() +{ + static_assert((std::is_same::type, U>::value), ""); +} + +template +void test_no_result() +{ +#if TEST_STD_VER >= 11 + static_assert((!HasType >::value), ""); +#endif +} + +int main() +{ + { // functor object + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + } + { // 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(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of(); + } + { // pointer to member function + + typedef int (S::*PMS0)(); + typedef int* (S::*PMS1)(long); + typedef int& (S::*PMS2)(long, int); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of), int> (); + test_no_result(); + test_no_result(); + test_no_result(); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int), int*> (); + test_no_result(); + test_no_result(); + test_no_result(); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int, int), int&> (); + test_no_result(); + test_no_result(); + test_no_result(); + + typedef int (S::*PMS0C)() const; + typedef int* (S::*PMS1C)(long) const; + typedef int& (S::*PMS2C)(long, int) const; + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of), int> (); + test_no_result(); + test_no_result(); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int), int*> (); + test_no_result(); + test_no_result(); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int, int), int&> (); + test_no_result(); + test_no_result(); + + typedef int (S::*PMS0V)() volatile; + typedef int* (S::*PMS1V)(long) volatile; + typedef int& (S::*PMS2V)(long, int) volatile; + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of), int> (); + test_no_result(); + test_no_result(); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int), int*> (); + test_no_result(); + test_no_result(); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int, int), int&> (); + test_no_result(); + test_no_result(); + + typedef int (S::*PMS0CV)() const volatile; + typedef int* (S::*PMS1CV)(long) const volatile; + typedef int& (S::*PMS2CV)(long, int) const volatile; + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of), int> (); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int), int*> (); + + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of, int, int), int&> (); + } + { // pointer to member data + typedef char S::*PMD; + test_result_of(); + test_result_of(); + test_result_of(); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + test_result_of (); + } +} 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 +// +// +// +// result_of + +#include +#include "test_macros.h" + +struct wat +{ + wat& operator*() { return *this; } + void foo(); +}; + +struct F {}; + +template +void test_result_of_imp() +{ + static_assert((std::is_same::type, U>::value), ""); +#if TEST_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + { + typedef char F::*PMD; + test_result_of_imp(); + test_result_of_imp(); + test_result_of_imp(); + test_result_of_imp(); + + test_result_of_imp(); + test_result_of_imp(); + test_result_of_imp(); + test_result_of_imp(); + + test_result_of_imp(); + test_result_of_imp(); + test_result_of_imp(); + test_result_of_imp(); + } + { + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + test_result_of_imp (); + } + + test_result_of_imp(); +} 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 +#include + +enum E { V = INT_MIN }; +enum F { W = UINT_MAX }; + +int main() +{ + static_assert((std::is_same::type, int>::value), + "E has the wrong underlying type"); + static_assert((std::is_same::type, unsigned>::value), + "F has the wrong underlying type"); + +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, int>::value), ""); + static_assert((std::is_same, unsigned>::value), ""); +#endif + +#if __has_feature(cxx_strong_enums) + enum G : char { }; + + static_assert((std::is_same::type, char>::value), + "G has the wrong underlying type"); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, 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 + +template +void test_add_pointer() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + test_add_pointer(); + test_add_pointer(); + test_add_pointer(); + test_add_pointer(); + test_add_pointer(); + test_add_pointer(); + test_add_pointer(); +} 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 + +template +void test_remove_pointer() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); + test_remove_pointer(); +} 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 + +template +void test_add_lvalue_reference() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + test_add_lvalue_reference(); + test_add_lvalue_reference(); + test_add_lvalue_reference(); + test_add_lvalue_reference(); + test_add_lvalue_reference(); + test_add_lvalue_reference(); + test_add_lvalue_reference(); +} 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 + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +void test_add_rvalue_reference() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_add_rvalue_reference(); + test_add_rvalue_reference(); + test_add_rvalue_reference(); + test_add_rvalue_reference(); + test_add_rvalue_reference(); + test_add_rvalue_reference(); + test_add_rvalue_reference(); +#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 + +template +void test_remove_reference() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); + test_remove_reference(); +#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 + +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 +void test_make_signed() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, 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::type >(); + test_make_signed< const wchar_t, std::conditional::type >(); + test_make_signed< const Enum, std::conditional::type >(); + test_make_signed< BigEnum, std::conditional::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 + +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 +void test_make_unsigned() +{ + static_assert((std::is_same::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); +#endif +} + +int main() +{ + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned (); + test_make_unsigned::type> (); + test_make_unsigned::type> (); + test_make_unsigned::type >(); + test_make_unsigned::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(); +# 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 +#include + +template +void test_alignment_of() +{ + static_assert( std::alignment_of::value == A, ""); + static_assert( std::alignment_of::value == A, ""); + static_assert( std::alignment_of::value == A, ""); + static_assert( std::alignment_of::value == A, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_alignment_of(); + test_alignment_of(); + test_alignment_of(); + test_alignment_of(); + test_alignment_of(); + test_alignment_of(); + test_alignment_of(); +#if (defined(__ppc__) && !defined(__ppc64__)) + test_alignment_of(); // 32-bit PPC has four byte bool +#else + test_alignment_of(); +#endif + test_alignment_of(); +} 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 + +template +void test_extent() +{ + static_assert((std::extent::value == A), ""); + static_assert((std::extent::value == A), ""); + static_assert((std::extent::value == A), ""); + static_assert((std::extent::value == A), ""); +} + +template +void test_extent1() +{ + static_assert((std::extent::value == A), ""); + static_assert((std::extent::value == A), ""); + static_assert((std::extent::value == A), ""); + static_assert((std::extent::value == A), ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_extent(); + test_extent(); + test_extent(); + test_extent(); + test_extent(); + test_extent(); + test_extent(); + test_extent(); + test_extent(); + + test_extent(); + test_extent(); + test_extent(); + + test_extent1(); + test_extent1(); + test_extent1(); + test_extent1(); +} 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 + +template +void test_rank() +{ + static_assert( std::rank::value == A, ""); + static_assert( std::rank::value == A, ""); + static_assert( std::rank::value == A, ""); + static_assert( std::rank::value == A, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_rank(); + test_rank(); + test_rank(); + test_rank(); + test_rank(); + test_rank(); + test_rank(); + test_rank(); + test_rank(); + + test_rank(); + test_rank(); + test_rank(); +} 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 + +#if _LIBCPP_STD_VER <= 14 +int main () {} +#else + +template +void test1() +{ + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); +} + +template +void test2() +{ + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); + + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); + static_assert( std::is_same>::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + static_assert( std::is_same>::value, ""); + + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + test1(); + + test2(); + test2(); + test2(); + test2(); + test2(); + + static_assert( std::is_same>::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 + +template +void test_array_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert( std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_array() +{ + test_array_imp(); + test_array_imp(); + test_array_imp(); + test_array_imp(); +} + +typedef char array[3]; +typedef const char const_array[3]; +typedef char incomplete_array[]; + +int main() +{ + test_array(); + test_array(); + test_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 + +template +void test_class_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert( std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_class() +{ + test_class_imp(); + test_class_imp(); + test_class_imp(); + test_class_imp(); +} + +class Class +{ +}; + +int main() +{ + test_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 + +template +void test_enum_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert( std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_enum() +{ + test_enum_imp(); + test_enum_imp(); + test_enum_imp(); + test_enum_imp(); +} + +enum Enum {zero, one}; + +int main() +{ + test_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 + +template +void test_floating_point_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert( std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_floating_point() +{ + test_floating_point_imp(); + test_floating_point_imp(); + test_floating_point_imp(); + test_floating_point_imp(); +} + +int main() +{ + test_floating_point(); + test_floating_point(); + test_floating_point(); +} 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 + +using namespace std; + +class Class {}; + +enum Enum1 {}; +#if __cplusplus >= 201103L +enum class Enum2 : int {}; +#else +enum Enum2 {}; +#endif + +template +void test() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert( std::is_function::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 + +template +void test_integral_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert( std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_integral() +{ + test_integral_imp(); + test_integral_imp(); + test_integral_imp(); + test_integral_imp(); +} + +int main() +{ + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); +#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 + +template +void test_lvalue_ref() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert( std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +int main() +{ + test_lvalue_ref(); + test_lvalue_ref(); +} 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 +#include "test_macros.h" + +template +void test_member_function_pointer_imp() +{ + static_assert(!std::is_void::value, ""); +#if TEST_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert( std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_member_function_pointer() +{ + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); +} + +class Class +{ +}; + +int main() +{ + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + +// reference qualifiers on functions are a C++11 extension +#if TEST_STD_VER >= 11 + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + // RValue qualifiers + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); +#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 + +template +void test_member_function_pointer_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert( std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_member_function_pointer() +{ + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); +} + +class Class +{ +}; + +int main() +{ + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); + + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); +} 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 + +template +void test_member_object_pointer_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert( std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_member_object_pointer() +{ + test_member_object_pointer_imp(); + test_member_object_pointer_imp(); + test_member_object_pointer_imp(); + test_member_object_pointer_imp(); +} + +class Class +{ +}; + +int main() +{ + test_member_object_pointer(); +} 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 + +#if _LIBCPP_STD_VER > 11 +template +void test_nullptr_imp() +{ + static_assert(!std::is_void::value, ""); + static_assert( std::is_null_pointer::value, ""); + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_nullptr() +{ + test_nullptr_imp(); + test_nullptr_imp(); + test_nullptr_imp(); + test_nullptr_imp(); +} + +int main() +{ + test_nullptr(); +} +#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 + +template +void test_pointer_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert( std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_pointer() +{ + test_pointer_imp(); + test_pointer_imp(); + test_pointer_imp(); + test_pointer_imp(); +} + +int main() +{ + test_pointer(); + test_pointer(); + test_pointer(); + test_pointer(); +} 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 + +template +void test_rvalue_ref() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert( std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_rvalue_ref(); + test_rvalue_ref(); +#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 + +template +void test_union_imp() +{ + static_assert(!std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert( std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_union() +{ + test_union_imp(); + test_union_imp(); + test_union_imp(); + test_union_imp(); +} + +union Union +{ + int _; + double __; +}; + +int main() +{ + test_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 + +template +void test_void_imp() +{ + static_assert( std::is_void::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer::value, ""); +#endif + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_function_pointer::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_function::value, ""); +} + +template +void test_void() +{ + test_void_imp(); + test_void_imp(); + test_void_imp(); + test_void_imp(); +} + +int main() +{ + test_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 + +template +void test_array_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_array() +{ + test_array_imp(); + test_array_imp(); + test_array_imp(); + test_array_imp(); +} + +typedef char array[3]; +typedef const char const_array[3]; +typedef char incomplete_array[]; + +int main() +{ + test_array(); + test_array(); + test_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 + +template +void test_class_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_class() +{ + test_class_imp(); + test_class_imp(); + test_class_imp(); + test_class_imp(); +} + +class Class +{ +}; + +int main() +{ + test_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 + +template +void test_enum_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_enum() +{ + test_enum_imp(); + test_enum_imp(); + test_enum_imp(); + test_enum_imp(); +} + +enum Enum {zero, one}; + +int main() +{ + test_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 + +template +void test_floating_point_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert( std::is_arithmetic::value, ""); + static_assert( std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert(!std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_floating_point() +{ + test_floating_point_imp(); + test_floating_point_imp(); + test_floating_point_imp(); + test_floating_point_imp(); +} + +int main() +{ + test_floating_point(); + test_floating_point(); + test_floating_point(); +} 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 + +template +void test_function_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert(!std::is_object::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_function() +{ + test_function_imp(); + test_function_imp(); + test_function_imp(); + test_function_imp(); +} + +int main() +{ + test_function(); + test_function(); + test_function(); + test_function(); +} 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 + +template +void test_integral_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert( std::is_arithmetic::value, ""); + static_assert( std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert(!std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_integral() +{ + test_integral_imp(); + test_integral_imp(); + test_integral_imp(); + test_integral_imp(); +} + +int main() +{ + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); + test_integral(); +#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 + +template +void test_lvalue_ref() +{ + static_assert( std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert(!std::is_object::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +int main() +{ + test_lvalue_ref(); + test_lvalue_ref(); +} 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 + +template +void test_member_function_pointer_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert( std::is_member_pointer::value, ""); +} + +template +void test_member_function_pointer() +{ + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); + test_member_function_pointer_imp(); +} + +class Class +{ +}; + +int main() +{ + test_member_function_pointer(); + test_member_function_pointer(); + test_member_function_pointer(); +} 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 + +template +void test_member_object_pointer_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert( std::is_member_pointer::value, ""); +} + +template +void test_member_object_pointer() +{ + test_member_object_pointer_imp(); + test_member_object_pointer_imp(); + test_member_object_pointer_imp(); + test_member_object_pointer_imp(); +} + +class Class +{ +}; + +int main() +{ + test_member_object_pointer(); +} 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 + +template +void test_pointer_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_pointer() +{ + test_pointer_imp(); + test_pointer_imp(); + test_pointer_imp(); + test_pointer_imp(); +} + +int main() +{ + test_pointer(); + test_pointer(); + test_pointer(); + test_pointer(); +} 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 + +template +void test_rvalue_ref() +{ + static_assert( std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert(!std::is_object::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_rvalue_ref(); + test_rvalue_ref(); +#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 + +template +void test_union_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert( std::is_object::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert( std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_union() +{ + test_union_imp(); + test_union_imp(); + test_union_imp(); + test_union_imp(); +} + +union Union +{ + int _; + double __; +}; + +int main() +{ + test_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 + +template +void test_void_imp() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert( std::is_fundamental::value, ""); + static_assert(!std::is_object::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert(!std::is_compound::value, ""); + static_assert(!std::is_member_pointer::value, ""); +} + +template +void test_void() +{ + test_void_imp(); + test_void_imp(); + test_void_imp(); + test_void_imp(); +} + +int main() +{ + test_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 struct __has_operator_addressof + + +#include + +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + +struct A +{ +}; + +struct B +{ + constexpr B* operator&() const; +}; + +struct D; + +struct C +{ + template + 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::value == false, ""); + static_assert(std::__has_operator_addressof::value == false, ""); + static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::value == true, ""); + static_assert(std::__has_operator_addressof::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 + +template +void test_has_virtual_destructor() +{ + static_assert( std::has_virtual_destructor::value, ""); + static_assert( std::has_virtual_destructor::value, ""); + static_assert( std::has_virtual_destructor::value, ""); + static_assert( std::has_virtual_destructor::value, ""); +} + +template +void test_has_not_virtual_destructor() +{ + static_assert(!std::has_virtual_destructor::value, ""); + static_assert(!std::has_virtual_destructor::value, ""); + static_assert(!std::has_virtual_destructor::value, ""); + static_assert(!std::has_virtual_destructor::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(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + test_has_not_virtual_destructor(); + + test_has_virtual_destructor(); + test_has_virtual_destructor(); +} 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 + +template +void test_is_abstract() +{ + static_assert( std::is_abstract::value, ""); + static_assert( std::is_abstract::value, ""); + static_assert( std::is_abstract::value, ""); + static_assert( std::is_abstract::value, ""); +} + +template +void test_is_not_abstract() +{ + static_assert(!std::is_abstract::value, ""); + static_assert(!std::is_abstract::value, ""); + static_assert(!std::is_abstract::value, ""); + static_assert(!std::is_abstract::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(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + test_is_not_abstract(); + + test_is_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 + +struct A +{ +}; + +struct B +{ + void operator=(A); +}; + +template +void test_is_assignable() +{ + static_assert(( std::is_assignable::value), ""); +} + +template +void test_is_not_assignable() +{ + static_assert((!std::is_assignable::value), ""); +} + +struct D; + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +struct C +{ + template + D operator,(U&&); +}; + +struct E +{ + C operator=(int); +}; +#endif + +template +struct X { T t; }; + +int main() +{ + test_is_assignable (); + test_is_assignable (); + test_is_assignable (); + test_is_assignable (); + test_is_assignable (); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_assignable (); + + test_is_not_assignable (); + test_is_not_assignable (); +#endif + test_is_not_assignable (); + test_is_not_assignable (); + test_is_not_assignable (); + test_is_not_assignable (); + +// pointer to incomplete template type + test_is_assignable*&, X*> (); +} 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 + +template +void test_is_const() +{ + static_assert(!std::is_const::value, ""); + static_assert( std::is_const::value, ""); + static_assert(!std::is_const::value, ""); + static_assert( std::is_const::value, ""); +} + +int main() +{ + test_is_const(); + test_is_const(); + test_is_const(); + test_is_const(); + test_is_const(); + test_is_const(); + test_is_const(); + + static_assert(!std::is_const::value, ""); + static_assert(!std::is_const::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 +// struct is_constructible; + +#include + +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 +void test_is_constructible() +{ + static_assert( (std::is_constructible::value), ""); +} + +template +void test_is_constructible() +{ + static_assert( (std::is_constructible::value), ""); +} + +template +void test_is_constructible() +{ + static_assert( (std::is_constructible::value), ""); +} + +template +void test_is_not_constructible() +{ + static_assert((!std::is_constructible::value), ""); +} + +template +void test_is_not_constructible() +{ + static_assert((!std::is_constructible::value), ""); +} + +int main() +{ + test_is_constructible (); + test_is_constructible (); + test_is_constructible (); + test_is_constructible (); + test_is_constructible (); + + test_is_not_constructible (); +#if __has_feature(cxx_access_control_sfinae) + test_is_not_constructible (); +#else + test_is_constructible (); +#endif + test_is_not_constructible (); + test_is_not_constructible (); + test_is_not_constructible (); + test_is_not_constructible (); + test_is_not_constructible (); +} 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 + +template +void test_is_copy_assignable() +{ + static_assert(( std::is_copy_assignable::value), ""); +} + +template +void test_is_not_copy_assignable() +{ + static_assert((!std::is_copy_assignable::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 (); + test_is_copy_assignable (); + test_is_copy_assignable (); + test_is_copy_assignable (); + test_is_copy_assignable (); + test_is_copy_assignable (); + test_is_copy_assignable (); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_not_copy_assignable (); + test_is_not_copy_assignable (); + test_is_not_copy_assignable (); +#endif +#if __has_feature(cxx_access_control_sfinae) + test_is_not_copy_assignable (); +#endif + test_is_not_copy_assignable (); + test_is_not_copy_assignable (); +} 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 + +template +void test_is_copy_constructible() +{ + static_assert( std::is_copy_constructible::value, ""); +} + +template +void test_is_not_copy_constructible() +{ + static_assert(!std::is_copy_constructible::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(); + test_is_copy_constructible(); + test_is_copy_constructible(); + test_is_copy_constructible(); + test_is_copy_constructible(); + test_is_copy_constructible(); + test_is_copy_constructible(); + test_is_copy_constructible(); + test_is_copy_constructible(); + test_is_copy_constructible(); + + test_is_not_copy_constructible(); + test_is_not_copy_constructible(); + test_is_not_copy_constructible(); + test_is_not_copy_constructible(); + test_is_not_copy_constructible(); +#if __has_feature(cxx_access_control_sfinae) + test_is_not_copy_constructible(); +#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 + +template +void test_is_default_constructible() +{ + static_assert( std::is_default_constructible::value, ""); + static_assert( std::is_default_constructible::value, ""); + static_assert( std::is_default_constructible::value, ""); + static_assert( std::is_default_constructible::value, ""); +} + +template +void test_is_not_default_constructible() +{ + static_assert(!std::is_default_constructible::value, ""); + static_assert(!std::is_default_constructible::value, ""); + static_assert(!std::is_default_constructible::value, ""); + static_assert(!std::is_default_constructible::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(); + test_is_default_constructible(); + test_is_default_constructible(); + test_is_default_constructible(); + test_is_default_constructible(); + test_is_default_constructible(); + test_is_default_constructible(); + test_is_default_constructible(); + test_is_default_constructible(); + test_is_default_constructible(); + + test_is_not_default_constructible(); + test_is_not_default_constructible(); + test_is_not_default_constructible(); + test_is_not_default_constructible(); + test_is_not_default_constructible(); +#if __has_feature(cxx_access_control_sfinae) + test_is_not_default_constructible(); +#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 + +template +void test_is_destructible() +{ + static_assert( std::is_destructible::value, ""); + static_assert( std::is_destructible::value, ""); + static_assert( std::is_destructible::value, ""); + static_assert( std::is_destructible::value, ""); +} + +template +void test_is_not_destructible() +{ + static_assert(!std::is_destructible::value, ""); + static_assert(!std::is_destructible::value, ""); + static_assert(!std::is_destructible::value, ""); + static_assert(!std::is_destructible::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(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + test_is_destructible(); + + test_is_not_destructible(); + test_is_not_destructible(); + + test_is_not_destructible(); + test_is_not_destructible(); + test_is_not_destructible(); + test_is_not_destructible(); + test_is_not_destructible(); + test_is_not_destructible(); + test_is_not_destructible(); + test_is_not_destructible(); + test_is_not_destructible(); + +// test_is_not_destructible(); // currently fails due to clang bug #20268 + test_is_not_destructible(); + test_is_not_destructible(); + +#if __has_feature(cxx_access_control_sfinae) + test_is_not_destructible(); +#endif + test_is_not_destructible(); +} 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 + +template +void test_is_empty() +{ + static_assert( std::is_empty::value, ""); + static_assert( std::is_empty::value, ""); + static_assert( std::is_empty::value, ""); + static_assert( std::is_empty::value, ""); +} + +template +void test_is_not_empty() +{ + static_assert(!std::is_empty::value, ""); + static_assert(!std::is_empty::value, ""); + static_assert(!std::is_empty::value, ""); + static_assert(!std::is_empty::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +int main() +{ + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + test_is_not_empty(); + + test_is_empty(); + test_is_empty(); +} 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 + +#if _LIBCPP_STD_VER > 11 + +struct P final { }; +union U1 { }; +union U2 final { }; + +template +void test_is_final() +{ + static_assert( std::is_final::value, ""); + static_assert( std::is_final::value, ""); + static_assert( std::is_final::value, ""); + static_assert( std::is_final::value, ""); +} + +template +void test_is_not_final() +{ + static_assert(!std::is_final::value, ""); + static_assert(!std::is_final::value, ""); + static_assert(!std::is_final::value, ""); + static_assert(!std::is_final::value, ""); +} + +int main () +{ + test_is_not_final(); + test_is_not_final(); + test_is_final

(); + test_is_not_final(); + test_is_not_final(); + test_is_not_final(); + test_is_final (); + test_is_not_final(); +} +#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 + +template +void test_is_literal_type() +{ + static_assert( std::is_literal_type::value, ""); +} + +template +void test_is_not_literal_type() +{ + static_assert(!std::is_literal_type::value, ""); +} + +struct A +{ +}; + +struct B +{ + B(); +}; + +int main() +{ + test_is_literal_type (); + test_is_literal_type (); + test_is_literal_type (); + test_is_literal_type (); + test_is_literal_type (); + + test_is_not_literal_type (); +} 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 + +template +void test_is_move_assignable() +{ + static_assert( std::is_move_assignable::value, ""); +} + +template +void test_is_not_move_assignable() +{ + static_assert(!std::is_move_assignable::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(); +}; + +int main() +{ + test_is_move_assignable (); + test_is_move_assignable (); + test_is_move_assignable (); + test_is_move_assignable (); + test_is_move_assignable (); + test_is_move_assignable (); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_not_move_assignable (); + test_is_not_move_assignable (); + test_is_not_move_assignable (); +#endif + test_is_not_move_assignable (); +} 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 + +template +void test_is_move_constructible() +{ + static_assert( std::is_move_constructible::value, ""); +} + +template +void test_is_not_move_constructible() +{ + static_assert(!std::is_move_constructible::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(); + test_is_not_move_constructible(); + test_is_not_move_constructible(); + test_is_not_move_constructible(); + + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); + test_is_move_constructible(); +} 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 + +template +void test_is_nothrow_assignable() +{ + static_assert(( std::is_nothrow_assignable::value), ""); +} + +template +void test_is_not_nothrow_assignable() +{ + static_assert((!std::is_nothrow_assignable::value), ""); +} + +struct A +{ +}; + +struct B +{ + void operator=(A); +}; + +struct C +{ + void operator=(C&); // not const +}; + +int main() +{ + test_is_nothrow_assignable (); + test_is_nothrow_assignable (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_nothrow_assignable (); +#endif + + test_is_not_nothrow_assignable (); + test_is_not_nothrow_assignable (); + test_is_not_nothrow_assignable (); + test_is_not_nothrow_assignable (); + test_is_not_nothrow_assignable (); +} 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 +// struct is_nothrow_constructible; + +#include + +template +void test_is_nothrow_constructible() +{ + static_assert(( std::is_nothrow_constructible::value), ""); +} + +template +void test_is_nothrow_constructible() +{ + static_assert(( std::is_nothrow_constructible::value), ""); +} + +template +void test_is_not_nothrow_constructible() +{ + static_assert((!std::is_nothrow_constructible::value), ""); +} + +template +void test_is_not_nothrow_constructible() +{ + static_assert((!std::is_nothrow_constructible::value), ""); +} + +template +void test_is_not_nothrow_constructible() +{ + static_assert((!std::is_nothrow_constructible::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 (); + test_is_nothrow_constructible (); + test_is_nothrow_constructible (); + test_is_nothrow_constructible (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_nothrow_constructible (); // See bug #19616. +#endif + + test_is_not_nothrow_constructible (); + test_is_not_nothrow_constructible (); + test_is_not_nothrow_constructible (); + test_is_not_nothrow_constructible (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + static_assert(!std::is_constructible::value, ""); + test_is_not_nothrow_constructible (); // 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 + +template +void test_has_nothrow_assign() +{ + static_assert( std::is_nothrow_copy_assignable::value, ""); +} + +template +void test_has_not_nothrow_assign() +{ + static_assert(!std::is_nothrow_copy_assignable::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(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + + test_has_not_nothrow_assign(); + test_has_not_nothrow_assign(); + test_has_not_nothrow_assign(); + +} 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 + +template +void test_is_nothrow_copy_constructible() +{ + static_assert( std::is_nothrow_copy_constructible::value, ""); + static_assert( std::is_nothrow_copy_constructible::value, ""); +} + +template +void test_has_not_nothrow_copy_constructor() +{ + static_assert(!std::is_nothrow_copy_constructible::value, ""); + static_assert(!std::is_nothrow_copy_constructible::value, ""); + static_assert(!std::is_nothrow_copy_constructible::value, ""); + static_assert(!std::is_nothrow_copy_constructible::value, ""); +} + +class Empty +{ +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(const A&); +}; + +int main() +{ + test_has_not_nothrow_copy_constructor(); + test_has_not_nothrow_copy_constructor(); + + test_is_nothrow_copy_constructible(); + test_is_nothrow_copy_constructible(); + test_is_nothrow_copy_constructible(); + test_is_nothrow_copy_constructible(); + test_is_nothrow_copy_constructible(); + test_is_nothrow_copy_constructible(); + test_is_nothrow_copy_constructible(); + test_is_nothrow_copy_constructible(); +} 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 + +template +void test_is_nothrow_default_constructible() +{ + static_assert( std::is_nothrow_default_constructible::value, ""); + static_assert( std::is_nothrow_default_constructible::value, ""); + static_assert( std::is_nothrow_default_constructible::value, ""); + static_assert( std::is_nothrow_default_constructible::value, ""); +} + +template +void test_has_not_nothrow_default_constructor() +{ + static_assert(!std::is_nothrow_default_constructible::value, ""); + static_assert(!std::is_nothrow_default_constructible::value, ""); + static_assert(!std::is_nothrow_default_constructible::value, ""); + static_assert(!std::is_nothrow_default_constructible::value, ""); +} + +class Empty +{ +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(); +}; + +int main() +{ + test_has_not_nothrow_default_constructor(); + test_has_not_nothrow_default_constructor(); + test_has_not_nothrow_default_constructor(); + + test_is_nothrow_default_constructible(); + test_is_nothrow_default_constructible(); + test_is_nothrow_default_constructible(); + test_is_nothrow_default_constructible(); + test_is_nothrow_default_constructible(); + test_is_nothrow_default_constructible(); + test_is_nothrow_default_constructible(); + test_is_nothrow_default_constructible(); +} 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 + +template +void test_is_nothrow_destructible() +{ + static_assert( std::is_nothrow_destructible::value, ""); + static_assert( std::is_nothrow_destructible::value, ""); + static_assert( std::is_nothrow_destructible::value, ""); + static_assert( std::is_nothrow_destructible::value, ""); +} + +template +void test_is_not_nothrow_destructible() +{ + static_assert(!std::is_nothrow_destructible::value, ""); + static_assert(!std::is_nothrow_destructible::value, ""); + static_assert(!std::is_nothrow_destructible::value, ""); + static_assert(!std::is_nothrow_destructible::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(); + test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); + +#if __has_feature(cxx_noexcept) + test_is_nothrow_destructible(); +#endif + test_is_nothrow_destructible(); +#if __has_feature(cxx_unrestricted_unions) + test_is_nothrow_destructible(); +#endif +#if __has_feature(cxx_access_control_sfinae) + test_is_nothrow_destructible(); +#endif + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); +#if __has_feature(cxx_noexcept) + test_is_nothrow_destructible(); +#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 + +template +void test_has_nothrow_assign() +{ + static_assert( std::is_nothrow_move_assignable::value, ""); +} + +template +void test_has_not_nothrow_assign() +{ + static_assert(!std::is_nothrow_move_assignable::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(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + test_has_nothrow_assign(); + + test_has_not_nothrow_assign(); + test_has_not_nothrow_assign(); +} 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 + +template +void test_is_nothrow_move_constructible() +{ + static_assert( std::is_nothrow_move_constructible::value, ""); + static_assert( std::is_nothrow_move_constructible::value, ""); +} + +template +void test_has_not_nothrow_move_constructor() +{ + static_assert(!std::is_nothrow_move_constructible::value, ""); + static_assert(!std::is_nothrow_move_constructible::value, ""); + static_assert(!std::is_nothrow_move_constructible::value, ""); + static_assert(!std::is_nothrow_move_constructible::value, ""); +} + +class Empty +{ +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(const A&); +}; + +int main() +{ + test_has_not_nothrow_move_constructor(); + test_has_not_nothrow_move_constructor(); + + test_is_nothrow_move_constructible(); + test_is_nothrow_move_constructible(); + test_is_nothrow_move_constructible(); + test_is_nothrow_move_constructible(); + test_is_nothrow_move_constructible(); + test_is_nothrow_move_constructible(); + test_is_nothrow_move_constructible(); + test_is_nothrow_move_constructible(); +} 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 + +template +void test_is_pod() +{ + static_assert( std::is_pod::value, ""); + static_assert( std::is_pod::value, ""); + static_assert( std::is_pod::value, ""); + static_assert( std::is_pod::value, ""); +} + +template +void test_is_not_pod() +{ + static_assert(!std::is_pod::value, ""); + static_assert(!std::is_pod::value, ""); + static_assert(!std::is_pod::value, ""); + static_assert(!std::is_pod::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_not_pod(); + test_is_not_pod(); + test_is_not_pod(); + + test_is_pod(); + test_is_pod(); + test_is_pod(); + test_is_pod(); + test_is_pod(); + test_is_pod(); +} 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 + +template +void test_is_polymorphic() +{ + static_assert( std::is_polymorphic::value, ""); + static_assert( std::is_polymorphic::value, ""); + static_assert( std::is_polymorphic::value, ""); + static_assert( std::is_polymorphic::value, ""); +} + +template +void test_is_not_polymorphic() +{ + static_assert(!std::is_polymorphic::value, ""); + static_assert(!std::is_polymorphic::value, ""); + static_assert(!std::is_polymorphic::value, ""); + static_assert(!std::is_polymorphic::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(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + test_is_not_polymorphic(); + + test_is_polymorphic(); + test_is_polymorphic(); +} 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 + +template +void test_is_signed() +{ + static_assert( std::is_signed::value, ""); + static_assert( std::is_signed::value, ""); + static_assert( std::is_signed::value, ""); + static_assert( std::is_signed::value, ""); +} + +template +void test_is_not_signed() +{ + static_assert(!std::is_signed::value, ""); + static_assert(!std::is_signed::value, ""); + static_assert(!std::is_signed::value, ""); + static_assert(!std::is_signed::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_not_signed(); + test_is_not_signed(); + test_is_not_signed(); + test_is_not_signed(); + test_is_not_signed(); + test_is_not_signed(); + test_is_not_signed(); + test_is_not_signed(); + test_is_not_signed(); + + test_is_signed(); + test_is_signed(); + +#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 + +template +void test_is_standard_layout() +{ + static_assert( std::is_standard_layout::value, ""); + static_assert( std::is_standard_layout::value, ""); + static_assert( std::is_standard_layout::value, ""); + static_assert( std::is_standard_layout::value, ""); +} + +template +void test_is_not_standard_layout() +{ + static_assert(!std::is_standard_layout::value, ""); + static_assert(!std::is_standard_layout::value, ""); + static_assert(!std::is_standard_layout::value, ""); + static_assert(!std::is_standard_layout::value, ""); +} + +template +struct pair +{ + T1 first; + T2 second; +}; + +int main() +{ + test_is_standard_layout (); + test_is_standard_layout (); + test_is_standard_layout > (); + + test_is_not_standard_layout (); +} 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 + +template +void test_is_trivial() +{ + static_assert( std::is_trivial::value, ""); + static_assert( std::is_trivial::value, ""); + static_assert( std::is_trivial::value, ""); + static_assert( std::is_trivial::value, ""); +} + +template +void test_is_not_trivial() +{ + static_assert(!std::is_trivial::value, ""); + static_assert(!std::is_trivial::value, ""); + static_assert(!std::is_trivial::value, ""); + static_assert(!std::is_trivial::value, ""); +} + +struct A {}; + +class B +{ +public: + B(); +}; + +int main() +{ + test_is_trivial (); + test_is_trivial (); + + test_is_not_trivial (); + test_is_not_trivial (); + test_is_not_trivial (); +} 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 + +template +void test_is_trivially_assignable() +{ + static_assert(( std::is_trivially_assignable::value), ""); +} + +template +void test_is_not_trivially_assignable() +{ + static_assert((!std::is_trivially_assignable::value), ""); +} + +struct A +{ +}; + +struct B +{ + void operator=(A); +}; + +struct C +{ + void operator=(C&); // not const +}; + +int main() +{ + test_is_trivially_assignable (); + test_is_trivially_assignable (); + test_is_trivially_assignable (); + + test_is_not_trivially_assignable (); + test_is_not_trivially_assignable (); + test_is_not_trivially_assignable (); + test_is_not_trivially_assignable (); + test_is_not_trivially_assignable (); +} 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 +// struct is_trivially_constructible; + +#include + +template +void test_is_trivially_constructible() +{ + static_assert(( std::is_trivially_constructible::value), ""); +} + +template +void test_is_trivially_constructible() +{ + static_assert(( std::is_trivially_constructible::value), ""); +} + +template +void test_is_not_trivially_constructible() +{ + static_assert((!std::is_trivially_constructible::value), ""); +} + +template +void test_is_not_trivially_constructible() +{ + static_assert((!std::is_trivially_constructible::value), ""); +} + +template +void test_is_not_trivially_constructible() +{ + static_assert((!std::is_trivially_constructible::value), ""); +} + +struct A +{ + explicit A(int); + A(int, double); +}; + +int main() +{ + test_is_trivially_constructible (); + test_is_trivially_constructible (); + + test_is_not_trivially_constructible (); + test_is_not_trivially_constructible (); + test_is_not_trivially_constructible (); +} 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 + +template +void test_has_trivially_copy_assignable() +{ + static_assert( std::is_trivially_copy_assignable::value, ""); +} + +template +void test_has_not_trivially_copy_assignable() +{ + static_assert(!std::is_trivially_copy_assignable::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(); + test_has_trivially_copy_assignable(); + test_has_trivially_copy_assignable(); + test_has_trivially_copy_assignable(); + test_has_trivially_copy_assignable(); + test_has_trivially_copy_assignable(); + test_has_trivially_copy_assignable(); + test_has_trivially_copy_assignable(); + + test_has_not_trivially_copy_assignable(); + test_has_not_trivially_copy_assignable(); + test_has_not_trivially_copy_assignable(); + test_has_not_trivially_copy_assignable(); + test_has_not_trivially_copy_assignable(); + +} 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 + +template +void test_is_trivially_copy_constructible() +{ + static_assert( std::is_trivially_copy_constructible::value, ""); + static_assert( std::is_trivially_copy_constructible::value, ""); +} + +template +void test_has_not_trivial_copy_constructor() +{ + static_assert(!std::is_trivially_copy_constructible::value, ""); + static_assert(!std::is_trivially_copy_constructible::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(); + test_has_not_trivial_copy_constructor(); + test_has_not_trivial_copy_constructor(); + test_has_not_trivial_copy_constructor(); + + test_is_trivially_copy_constructible(); + test_is_trivially_copy_constructible(); + test_is_trivially_copy_constructible(); + test_is_trivially_copy_constructible(); + test_is_trivially_copy_constructible(); + test_is_trivially_copy_constructible(); + test_is_trivially_copy_constructible(); + test_is_trivially_copy_constructible(); +} 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 +#include + +template +void test_is_trivially_copyable() +{ + static_assert( std::is_trivially_copyable::value, ""); + static_assert( std::is_trivially_copyable::value, ""); + static_assert(!std::is_trivially_copyable::value, ""); + static_assert(!std::is_trivially_copyable::value, ""); +} + +template +void test_is_not_trivially_copyable() +{ + static_assert(!std::is_trivially_copyable::value, ""); + static_assert(!std::is_trivially_copyable::value, ""); + static_assert(!std::is_trivially_copyable::value, ""); + static_assert(!std::is_trivially_copyable::value, ""); +} + +struct A +{ + int i_; +}; + +struct B +{ + int i_; + ~B() {assert(i_ == 0);} +}; + +class C +{ +public: + C(); +}; + +int main() +{ + test_is_trivially_copyable (); + test_is_trivially_copyable (); + test_is_trivially_copyable (); + test_is_trivially_copyable (); + test_is_trivially_copyable (); + + test_is_not_trivially_copyable (); + test_is_not_trivially_copyable (); + test_is_not_trivially_copyable (); +} 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 + +template +void test_is_trivially_default_constructible() +{ + static_assert( std::is_trivially_default_constructible::value, ""); + static_assert( std::is_trivially_default_constructible::value, ""); + static_assert( std::is_trivially_default_constructible::value, ""); + static_assert( std::is_trivially_default_constructible::value, ""); +} + +template +void test_has_not_trivial_default_constructor() +{ + static_assert(!std::is_trivially_default_constructible::value, ""); + static_assert(!std::is_trivially_default_constructible::value, ""); + static_assert(!std::is_trivially_default_constructible::value, ""); + static_assert(!std::is_trivially_default_constructible::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(); + test_has_not_trivial_default_constructor(); + test_has_not_trivial_default_constructor(); + test_has_not_trivial_default_constructor(); + test_has_not_trivial_default_constructor(); + + test_is_trivially_default_constructible(); + test_is_trivially_default_constructible(); + test_is_trivially_default_constructible(); + test_is_trivially_default_constructible(); + test_is_trivially_default_constructible(); + test_is_trivially_default_constructible(); + test_is_trivially_default_constructible(); + test_is_trivially_default_constructible(); +} 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 + +template +void test_is_trivially_destructible() +{ + static_assert( std::is_trivially_destructible::value, ""); + static_assert( std::is_trivially_destructible::value, ""); + static_assert( std::is_trivially_destructible::value, ""); + static_assert( std::is_trivially_destructible::value, ""); +} + +template +void test_is_not_trivially_destructible() +{ + static_assert(!std::is_trivially_destructible::value, ""); + static_assert(!std::is_trivially_destructible::value, ""); + static_assert(!std::is_trivially_destructible::value, ""); + static_assert(!std::is_trivially_destructible::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(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); + test_is_trivially_destructible(); +} 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 + +template +void test_has_trivial_assign() +{ + static_assert( std::is_trivially_move_assignable::value, ""); +} + +template +void test_has_not_trivial_assign() +{ + static_assert(!std::is_trivially_move_assignable::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(); + test_has_trivial_assign(); + test_has_trivial_assign(); + test_has_trivial_assign(); + test_has_trivial_assign(); + test_has_trivial_assign(); + test_has_trivial_assign(); + test_has_trivial_assign(); + + test_has_not_trivial_assign(); + test_has_not_trivial_assign(); + test_has_not_trivial_assign(); + test_has_not_trivial_assign(); + test_has_not_trivial_assign(); + +} 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 + +template +void test_is_trivially_move_constructible() +{ + static_assert( std::is_trivially_move_constructible::value, ""); +} + +template +void test_has_not_trivial_move_constructor() +{ + static_assert(!std::is_trivially_move_constructible::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(); + test_has_not_trivial_move_constructor(); + test_has_not_trivial_move_constructor(); + test_has_not_trivial_move_constructor(); + + test_is_trivially_move_constructible(); + test_is_trivially_move_constructible(); + test_is_trivially_move_constructible(); + test_is_trivially_move_constructible(); + test_is_trivially_move_constructible(); + test_is_trivially_move_constructible(); + test_is_trivially_move_constructible(); + +#if __has_feature(cxx_defaulted_functions) + static_assert(!std::is_trivially_move_constructible::value, ""); + static_assert( std::is_trivially_move_constructible::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 + +template +void test_is_unsigned() +{ + static_assert( std::is_unsigned::value, ""); + static_assert( std::is_unsigned::value, ""); + static_assert( std::is_unsigned::value, ""); + static_assert( std::is_unsigned::value, ""); +} + +template +void test_is_not_unsigned() +{ + static_assert(!std::is_unsigned::value, ""); + static_assert(!std::is_unsigned::value, ""); + static_assert(!std::is_unsigned::value, ""); + static_assert(!std::is_unsigned::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_not_unsigned(); + test_is_not_unsigned(); + test_is_not_unsigned(); + test_is_not_unsigned(); + test_is_not_unsigned(); + test_is_not_unsigned(); + test_is_not_unsigned(); + test_is_not_unsigned(); + test_is_not_unsigned(); + + test_is_unsigned(); + test_is_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 + +template +void test_is_volatile() +{ + static_assert(!std::is_volatile::value, ""); + static_assert(!std::is_volatile::value, ""); + static_assert( std::is_volatile::value, ""); + static_assert( std::is_volatile::value, ""); +} + +int main() +{ + test_is_volatile(); + test_is_volatile(); + test_is_volatile(); + test_is_volatile(); + test_is_volatile(); + test_is_volatile(); + test_is_volatile(); + + static_assert(!std::is_volatile::value, ""); + static_assert(!std::is_volatile::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +int main() +{ + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_add::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_add::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::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::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::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::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::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::type R; + static_assert(R::num == 127970191639601LL && R::den == 5177331081415LL, ""); + } + { + typedef std::ratio<0> R1; + typedef std::ratio<0> R2; + typedef std::ratio_add::type R; + static_assert(R::num == 0 && R::den == 1, ""); + } + { + typedef std::ratio<1> R1; + typedef std::ratio<0> R2; + typedef std::ratio_add::type R; + static_assert(R::num == 1 && R::den == 1, ""); + } + { + typedef std::ratio<0> R1; + typedef std::ratio<1> R2; + typedef std::ratio_add::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 + +int main() +{ + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<1, 2> R2; + typedef std::ratio_divide::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_divide::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::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::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::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::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::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::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 + +int main() +{ + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<2, 1> R2; + typedef std::ratio_multiply::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_multiply::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::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::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::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::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::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::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 + +int main() +{ + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_subtract::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + typedef std::ratio_subtract::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::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::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::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::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::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::type R; + static_assert(R::num == -126708206685271LL && R::den == 5177331081415LL, ""); + } + { + typedef std::ratio<0> R1; + typedef std::ratio<0> R2; + typedef std::ratio_subtract::type R; + static_assert(R::num == 0 && R::den == 1, ""); + } + { + typedef std::ratio<1> R1; + typedef std::ratio<0> R2; + typedef std::ratio_subtract::type R; + static_assert(R::num == 1 && R::den == 1, ""); + } + { + typedef std::ratio<0> R1; + typedef std::ratio<1> R2; + typedef std::ratio_subtract::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((std::ratio_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_equal::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((!std::ratio_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_equal::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((!std::ratio_greater::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_greater::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((std::ratio_greater::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_greater::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((std::ratio_greater_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_greater_equal::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((std::ratio_greater_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_greater_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_greater_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_greater_equal::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2; + static_assert((std::ratio_less::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; + static_assert((std::ratio_less::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2; + static_assert((std::ratio_less::value), ""); + } + { + typedef std::ratio<641981, 1339063> R1; + typedef std::ratio<1291640, 2694141LL> R2; + static_assert((!std::ratio_less::value), ""); + } + { + typedef std::ratio<1291640, 2694141LL> R1; + typedef std::ratio<641981, 1339063> R2; + static_assert((std::ratio_less::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((std::ratio_less_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_less_equal::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((!std::ratio_less_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_less_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_less_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_less_equal::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 + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert((!std::ratio_not_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_not_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((!std::ratio_not_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((!std::ratio_not_equal::value), ""); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert((std::ratio_not_equal::value), ""); + } + { + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_not_equal::value), ""); + } + { + typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; + typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; + static_assert((std::ratio_not_equal::value), ""); + } + { + typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; + typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; + static_assert((std::ratio_not_equal::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 + +template +void test() +{ + static_assert((std::ratio::num == eN), ""); + static_assert((std::ratio::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 +#include + +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 +#include + +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 +#include + +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 + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +// explicit bitset(const charT* str, +// typename basic_string::size_type n = basic_string::npos, +// charT zero = charT('0'), charT one = charT('1')); + +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +void test_char_pointer_ctor() +{ + { + try + { + std::bitset v("xxx1010101010xxxx"); + assert(false); + } + catch (std::invalid_argument&) + { + } + } + + { + const char str[] ="1010101010"; + std::bitset v(str); + std::size_t M = std::min(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 +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +void test_default_ctor() +{ + { + _LIBCPP_CONSTEXPR std::bitset 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 +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +void test_string_ctor() +{ + { + try + { + std::string str("xxx1010101010xxxx"); + std::bitset v(str, str.size()+1, 10); + assert(false); + } + catch (std::out_of_range&) + { + } + } + + { + try + { + std::string str("xxx1010101010xxxx"); + std::bitset v(str, 2, 10); + assert(false); + } + catch (std::invalid_argument&) + { + } + } + + { + std::string str("xxx1010101010xxxx"); + std::bitset v(str, 3, 10); + std::size_t M = std::min(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 v(str, 2, 10, 'a', 'b'); + assert(false); + } + catch (std::invalid_argument&) + { + } + } + + { + std::string str("xxxbababababaxxxx"); + std::bitset v(str, 3, 10, 'a', 'b'); + std::size_t M = std::min(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 +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +void test_val_ctor() +{ + { + _LIBCPP_CONSTEXPR std::bitset v(0xAAAAAAAAAAAAAAAAULL); + assert(v.size() == N); + unsigned M = std::min(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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include +#include +#include + +template +void +test() +{ + typedef std::bitset T; + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + H h; + T bs(static_cast(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 +#include + +template +void test_all() +{ + std::bitset 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 +#include + +template +void test_any() +{ + std::bitset 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 +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_count() +{ + const std::bitset v = make_bitset(); + 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& flip(); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_flip_all() +{ + std::bitset v1 = make_bitset(); + std::bitset 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& flip(size_t pos); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_flip_one() +{ + std::bitset v = make_bitset(); + 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::reference operator[](size_t pos); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_index_const() +{ + std::bitset v1 = make_bitset(); + if (N > 0) + { + assert(v1[N/2] == v1.test(N/2)); + typename std::bitset::reference r = v1[N/2]; + assert(r == v1.test(N/2)); + typename std::bitset::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 +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_index_const() +{ + const std::bitset v1 = make_bitset(); + 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 operator<<(size_t pos) const; + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_left_shift() +{ + for (std::size_t s = 0; s <= N+1; ++s) + { + std::bitset v1 = make_bitset(); + std::bitset 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& operator<<=(size_t pos); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_left_shift() +{ + for (std::size_t s = 0; s <= N+1; ++s) + { + std::bitset v1 = make_bitset(); + std::bitset 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 +#include + +template +void test_none() +{ + std::bitset 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 operator~() const; + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_not_all() +{ + std::bitset v1 = make_bitset(); + std::bitset 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& operator&=(const bitset& rhs); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_op_and_eq() +{ + std::bitset v1 = make_bitset(); + std::bitset v2 = make_bitset(); + std::bitset 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& rhs) const; +// bool operator!=(const bitset& rhs) const; + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_equality() +{ + const std::bitset v1 = make_bitset(); + std::bitset 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& operator|=(const bitset& rhs); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_op_or_eq() +{ + std::bitset v1 = make_bitset(); + std::bitset v2 = make_bitset(); + std::bitset 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& operator^=(const bitset& rhs); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_op_xor_eq() +{ + std::bitset v1 = make_bitset(); + std::bitset v2 = make_bitset(); + std::bitset 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& reset(); + +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +void test_reset_all() +{ + std::bitset 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& reset(size_t pos); + +#include +#include + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +void test_reset_one() +{ + std::bitset 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 operator>>(size_t pos) const; + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_right_shift() +{ + for (std::size_t s = 0; s <= N+1; ++s) + { + std::bitset v1 = make_bitset(); + std::bitset 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& operator<<=(size_t pos); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_right_shift() +{ + for (std::size_t s = 0; s <= N+1; ++s) + { + std::bitset v1 = make_bitset(); + std::bitset 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& set(); + +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +void test_set_all() +{ + std::bitset 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& set(size_t pos, bool val = true); + +#include +#include + +template +void test_set_one() +{ + std::bitset 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 +#include + +template +void test_size() +{ + const std::bitset 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 +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_test() +{ + const std::bitset v1 = make_bitset(); + 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 +// basic_string +// to_string(charT zero = charT('0'), charT one = charT('1')) const; +// +// template +// basic_string > to_string() const; +// +// template +// basic_string, allocator > to_string() const; +// +// basic_string, allocator > to_string() const; + +#include +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_to_string() +{ +{ + std::bitset v = make_bitset(); + { + std::wstring s = v.template to_string, std::allocator >(); + 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 >(); + 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(); + 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 v = make_bitset(); + { + std::wstring s = v.template to_string, std::allocator >('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 >('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('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 v = make_bitset(); + { + std::wstring s = v.template to_string, std::allocator >('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 >('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('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 +#include +#include +#include + +template +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(1, max), + std::min(2, max), + std::min(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 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 +#include +#include +#include +#include + +template +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::max()) >> X; + std::size_t tests[] = {0, + std::min(1, max), + std::min(2, max), + std::min(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 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 operator&(const bitset& lhs, const bitset& rhs); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_op_and() +{ + std::bitset v1 = make_bitset(); + std::bitset v2 = make_bitset(); + std::bitset 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 operator^(const bitset& lhs, const bitset& rhs); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_op_not() +{ + std::bitset v1 = make_bitset(); + std::bitset v2 = make_bitset(); + std::bitset 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 operator|(const bitset& lhs, const bitset& rhs); + +#include +#include +#include + +#pragma clang diagnostic ignored "-Wtautological-compare" + +template +std::bitset +make_bitset() +{ + std::bitset v; + for (std::size_t i = 0; i < N; ++i) + v[i] = static_cast(std::rand() & 1); + return v; +} + +template +void test_op_or() +{ + std::bitset v1 = make_bitset(); + std::bitset v2 = make_bitset(); + std::bitset 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 +// basic_ostream& +// operator<<(basic_ostream& os, const bitset& x); + +#include +#include +#include + +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 +// basic_istream& +// operator>>(basic_istream& is, bitset& x); + +#include +#include +#include + +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 includes , , and + +#include + +#ifndef _LIBCPP_CSTDDEF +#error has not been included +#endif + +#ifndef _LIBCPP_STRING +#error has not been included +#endif + +#ifndef _LIBCPP_STDEXCEPT +#error has not been included +#endif + +#ifndef _LIBCPP_IOSFWD +#error 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 + +class Clock +{ + typedef std::chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration> hours; + +#include +#include +#include + +int main() +{ + typedef std::chrono::hours D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 22, ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration microseconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::microseconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 54, ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration milliseconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::milliseconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 44, ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration> minutes; + +#include +#include +#include + +int main() +{ + typedef std::chrono::minutes D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 28, ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration nanoseconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::nanoseconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 63, ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration seconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::seconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 34, ""); + static_assert((std::is_same >::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 + +// + +// high_resolution_clock + +// check clock invariants + +#include + +template +void test(const _Tp &) {} + +int main() +{ + typedef std::chrono::high_resolution_clock C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// high_resolution_clock + +// static time_point now(); + +#include +#include + +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 + +// + +// steady_clock + +// check clock invariants + +#include + +template +void test(const _Tp &) {} + +int main() +{ + typedef std::chrono::steady_clock C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 + +// + +// steady_clock + +// static time_point now(); + +#include +#include + +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 + +// + +// system_clock + +// check clock invariants + +#include + +template +void test(const _Tp &) {} + +int main() +{ + typedef std::chrono::system_clock C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// static time_point from_time_t(time_t t); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// static time_point now(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// rep should be signed + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// time_t to_time_t(const time_point& t); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Test default template arg: + +// template > +// class duration; + +#include +#include + +int main() +{ + static_assert((std::is_same >, + std::chrono::duration >::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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// If a program instantiates duration with a duration type for the template +// argument Rep a diagnostic is required. + +#include + +int main() +{ + typedef std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Period::num shall be positive, diagnostic required. + +#include + +int main() +{ + typedef std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Period shall be a specialization of ratio, diagnostic required. + +#include + +template +class Ratio +{ +public: + static const int num = N; + static const int den = D; +}; + +int main() +{ + typedef std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator++(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator++(int); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator+() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator+=(const duration& d); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator--(); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator--(int); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator-() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator-=(const duration& d); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator/=(const rep& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator%=(const duration& rhs) + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator%=(const rep& rhs) + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator*=(const rep& rhs); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// ToDuration +// duration_cast(const duration& d); + +#include +#include +#include + +template +void +test(const FromDuration& f, const ToDuration& d) +{ + { + typedef decltype(std::chrono::duration_cast(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::duration_cast(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 >(7265./3600)); + test(std::chrono::duration >(9), + std::chrono::duration >(10)); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::hours h = std::chrono::duration_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// ToDuration +// duration_cast(const duration& d); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::duration_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// bool +// operator==(const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator!=(const duration& lhs, const duration& rhs); + +#include +#include + +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 > s1(9); + std::chrono::duration > s2(10); + assert(s1 == s2); + assert(!(s1 != s2)); + } + { + std::chrono::duration > s1(10); + std::chrono::duration > s2(9); + assert(!(s1 == s2)); + assert(s1 != s2); + } + { + std::chrono::duration > s1(9); + std::chrono::duration > 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 > s1(9); + constexpr std::chrono::duration > s2(10); + static_assert(s1 == s2, ""); + static_assert(!(s1 != s2), ""); + } + { + constexpr std::chrono::duration > s1(10); + constexpr std::chrono::duration > s2(9); + static_assert(!(s1 == s2), ""); + static_assert(s1 != s2, ""); + } + { + constexpr std::chrono::duration > s1(9); + constexpr std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// bool +// operator< (const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator> (const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator<=(const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator>=(const duration& lhs, const duration& rhs); + +#include +#include + +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 > s1(9); + std::chrono::duration > s2(10); + assert(!(s1 < s2)); + assert(!(s1 > s2)); + assert( (s1 <= s2)); + assert( (s1 >= s2)); + } + { + std::chrono::duration > s1(10); + std::chrono::duration > s2(9); + assert(!(s1 < s2)); + assert( (s1 > s2)); + assert(!(s1 <= s2)); + assert( (s1 >= s2)); + } + { + std::chrono::duration > s1(9); + std::chrono::duration > 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 > s1(9); + constexpr std::chrono::duration > s2(10); + static_assert(!(s1 < s2), ""); + static_assert(!(s1 > s2), ""); + static_assert( (s1 <= s2), ""); + static_assert( (s1 >= s2), ""); + } + { + constexpr std::chrono::duration > s1(10); + constexpr std::chrono::duration > s2(9); + static_assert(!(s1 < s2), ""); + static_assert( (s1 > s2), ""); + static_assert(!(s1 <= s2), ""); + static_assert( (s1 >= s2), ""); + } + { + constexpr std::chrono::duration > s1(9); + constexpr std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// exact conversions allowed for integral reps + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// conversions from floating point to integral durations disallowed + +#include + +int main() +{ + std::chrono::duration d; + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// inexact conversions disallowed for integral reps + +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// inexact conversions allowed for floating point reps + +#include +#include + +int main() +{ + { + std::chrono::duration us(1); + std::chrono::duration ms = us; + assert(ms.count() == 1./1000); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::duration us(1); + constexpr std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// conversions from integral to floating point durations allowed + +#include +#include + +int main() +{ + { + std::chrono::duration i(3); + std::chrono::duration d = i; + assert(d.count() == 3000); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::duration i(3); + constexpr std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// overflow should SFINAE instead of error out, LWG 2094 + +#include +#include + +bool called = false; + +void f(std::chrono::milliseconds); +void f(std::chrono::seconds) +{ + called = true; +} + +int main() +{ + { + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration() = default; + +// Rep must be default initialized, not initialized with 0 + +#include +#include + +#include "../../rep.h" + +template +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 >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +#include +#include + +#include "../../rep.h" + +template +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 >(5); + test > >(5); + test > >(Rep(3)); + test > >(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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// test for explicit + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// Rep2 shall be implicitly convertible to rep + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// construct double with int + +#include +#include + +int main() +{ + std::chrono::duration d(5); + assert(d.count() == 5); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + constexpr std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// treat_as_floating_point::value shall be false + +#include + +int main() +{ + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals::chrono_literals; + +// Make sure the types are right + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::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 +#include + +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 +#include + +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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// typename common_type, duration>::type +// operator+(const duration& lhs, const duration& rhs); + +#include +#include + +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 > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > r = s1 + s2; + assert(r.count() == 75); + } + { + std::chrono::duration > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > 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 > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > r = s1 + s2; + static_assert(r.count() == 75, ""); + } + { + constexpr std::chrono::duration > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// typename common_type, duration>::type +// operator-(const duration& lhs, const duration& rhs); + +#include +#include + +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 > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > r = s1 - s2; + assert(r.count() == -15); + } + { + std::chrono::duration > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > 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 > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > r = s1 - s2; + static_assert(r.count() == -15, ""); + } + { + constexpr std::chrono::duration > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// typename common_type::type +// operator/(const duration& lhs, const duration& rhs); + +#include +#include + +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 > s1(30); + std::chrono::duration > s2(5); + assert(s1 / s2 == 6); + } + { + std::chrono::duration > s1(30); + std::chrono::duration > 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 > s1(30); + constexpr std::chrono::duration > s2(5); + static_assert(s1 / s2 == 6, ""); + } + { + constexpr std::chrono::duration > s1(30); + constexpr std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator/(const duration& d, const Rep2& s); + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// duration::type, Period> +// operator/(const duration& d, const Rep2& s); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// typename common_type, duration>::type +// operator%(const duration& lhs, const duration& rhs); + +#include +#include + +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 > s1(6); + std::chrono::duration > s2(3); + std::chrono::duration > 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 > s1(6); + constexpr std::chrono::duration > s2(3); + constexpr std::chrono::duration > 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator%(const duration& d, const Rep2& s) + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// duration::type, Period> +// operator%(const duration& d, const Rep2& s) + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// duration::type, Period> +// operator*(const duration& d, const Rep2& s); + +// template +// constexpr +// duration::type, Period> +// operator*(const Rep1& s, const duration& d); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator*(const duration& d, const Rep2& s); + +// template +// duration::type, Period> +// operator*(const Rep1& s, const duration& d); + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator*(const duration& d, const Rep2& s); + +// template +// duration::type, Period> +// operator*(const Rep1& s, const duration& d); + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// static constexpr duration max(); + +#include +#include +#include + +#include "../../rep.h" + +template +void test() +{ + { + typedef typename D::rep Rep; + Rep max_rep = std::chrono::duration_values::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::max(); + static_assert(D::max().count() == max_rep, ""); + } +#endif +} + +int main() +{ + test >(); + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// static constexpr duration min(); + +#include +#include +#include + +#include "../../rep.h" + +template +void test() +{ + { + typedef typename D::rep Rep; + Rep min_rep = std::chrono::duration_values::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::min(); + static_assert(D::min().count() == min_rep, ""); + } +#endif +} + +int main() +{ + test >(); + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// static constexpr duration zero(); + +#include +#include + +#include "../../rep.h" + +template +void test() +{ + { + typedef typename D::rep Rep; + Rep zero_rep = std::chrono::duration_values::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::zero(); + static_assert(D::zero().count() == zero_rep, ""); + } +#endif +} + +int main() +{ + test >(); + test >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Test nested types + +// typedef Rep rep; +// typedef Period period; + +#include +#include + +int main() +{ + typedef std::chrono::duration > D; + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// Test default template arg: + +// template +// class time_point; + +#include +#include + +int main() +{ + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// Duration shall be an instance of duration. + +#include + +int main() +{ + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// time_point& operator+=(const duration& d); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// time_point& operator-=(const duration& d); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point +// time_point_cast(const time_point& t); + +#include +#include +#include + +template +void +test(const FromDuration& df, const ToDuration& d) +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + FromTimePoint f(df); + ToTimePoint t(d); + typedef decltype(std::chrono::time_point_cast(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::time_point_cast(f) == t); + } +} + +#if _LIBCPP_STD_VER > 11 + +template +void test_constexpr () +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + constexpr FromTimePoint f{FromDuration{From}}; + constexpr ToTimePoint t{ToDuration{To}}; + static_assert(std::chrono::time_point_cast(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 >(7265./3600)); + test(std::chrono::duration >(9), + std::chrono::duration >(10)); +#if _LIBCPP_STD_VER > 11 + { + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + typedef std::chrono::duration> T1; + test_constexpr>, 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point +// time_point_cast(const time_point& t); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + std::chrono::time_point_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator==(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator!=(const time_point& lhs, const time_point& rhs); + +// time_points with different clocks should not compare + +#include + +#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 T1; + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator==(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator!=(const time_point& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + typedef std::chrono::time_point T1; + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator< (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator> (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator<=(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator>=(const time_point& lhs, const time_point& rhs); + +// time_points with different clocks should not compare + +#include + +#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 T1; + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator< (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator> (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator<=(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator>=(const time_point& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + typedef std::chrono::time_point T1; + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point(const time_point& t); + +// Duration2 shall be implicitly convertible to duration. + +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t2(Duration2(3)); + std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point(const time_point& t); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::microseconds Duration1; + typedef std::chrono::milliseconds Duration2; + { + std::chrono::time_point t2(Duration2(3)); + std::chrono::time_point t1 = t2; + assert(t1.time_since_epoch() == Duration1(3000)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t2(Duration2(3)); + constexpr std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// time_point(); + +#include +#include + +#include "../../rep.h" + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::duration Duration; + { + std::chrono::time_point t; + assert(t.time_since_epoch() == Duration::zero()); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// explicit time_point(const duration& d); + +// test for explicit + +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// explicit time_point(const duration& d); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + { + std::chrono::time_point t(Duration(3)); + assert(t.time_since_epoch() == Duration(3)); + } + { + std::chrono::time_point t(std::chrono::seconds(3)); + assert(t.time_since_epoch() == Duration(3000)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t(Duration(3)); + static_assert(t.time_since_epoch() == Duration(3), ""); + } + { + constexpr std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point>::type> +// operator+(const time_point& lhs, const duration& rhs); + +// template +// time_point, Duration2>::type> +// operator+(const duration& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t1(Duration1(3)); + std::chrono::time_point 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 t1(Duration1(3)); + constexpr std::chrono::time_point t2 = t1 + Duration2(5); + static_assert(t2.time_since_epoch() == Duration2(3005), ""); + constexpr std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point>::type> +// operator-(const time_point& lhs, const duration& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t1(Duration1(3)); + std::chrono::time_point t2 = t1 - Duration2(5); + assert(t2.time_since_epoch() == Duration2(2995)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t1(Duration1(3)); + constexpr std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// typename common_type::type +// operator-(const time_point& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t1(Duration1(3)); + std::chrono::time_point t2(Duration2(5)); + assert((t1 - t2) == Duration2(2995)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t1(Duration1(3)); + constexpr std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// static constexpr time_point max(); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// static constexpr time_point min(); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + typedef std::chrono::time_point 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. +// +//===----------------------------------------------------------------------===// + +// + +// duration_values::max + +#include +#include +#include + +#include "../../rep.h" + +int main() +{ + assert(std::chrono::duration_values::max() == + std::numeric_limits::max()); + assert(std::chrono::duration_values::max() == + std::numeric_limits::max()); + assert(std::chrono::duration_values::max() == + std::numeric_limits::max()); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::chrono::duration_values::max() == + std::numeric_limits::max(), ""); + static_assert(std::chrono::duration_values::max() == + std::numeric_limits::max(), ""); + static_assert(std::chrono::duration_values::max() == + std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// duration_values::min + +#include +#include +#include + +#include "../../rep.h" + +int main() +{ + assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest()); + assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest()); + assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest()); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest(), ""); + static_assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest(), ""); + static_assert(std::chrono::duration_values::min() == + std::numeric_limits::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. +// +//===----------------------------------------------------------------------===// + +// + +// duration_values::zero + +#include +#include + +#include "../../rep.h" + +int main() +{ + assert(std::chrono::duration_values::zero() == 0); + assert(std::chrono::duration_values::zero() == 0); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::chrono::duration_values::zero() == 0, ""); + static_assert(std::chrono::duration_values::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. +// +//===----------------------------------------------------------------------===// + +// + +// treat_as_floating_point + +#include +#include + +template +void +test() +{ + static_assert((std::is_base_of, + std::chrono::treat_as_floating_point >::value), ""); +} + +struct A {}; + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct common_type, chrono::duration> +// { +// typedef chrono::duration::type, see below }> type; +// }; + +#include + +template +void +test() +{ + typedef typename std::common_type::type Dc; + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct common_type, chrono::time_point> +// { +// typedef chrono::time_point::type> type; +// }; + +#include + +template +void +test() +{ + typedef std::chrono::system_clock C; + typedef std::chrono::time_point T1; + typedef std::chrono::time_point T2; + typedef std::chrono::time_point Te; + typedef typename std::common_type::type Tc; + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 +#include + +int main () { + { + std::tuple> up; + std::tuple> sp; + std::tuple> wp; +// std::tuple> ap; + } + { + std::tuple> up; + std::tuple> sp; + std::tuple> wp; +// std::tuple> ap; + } + { + std::tuple> up; + std::tuple> sp; + std::tuple> wp; +// std::tuple> 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 +#include + +struct X +{ + X() {} + + template + X(T); + + void operator()() {} +}; + +int +main() +{ + X x; + std::function 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 + +#include "allocators.h" + +struct alloc_first +{ + static bool allocator_constructed; + + typedef A1 allocator_type; + + int data_; + + alloc_first() : data_(0) {} + alloc_first(int d) : data_(d) {} + alloc_first(std::allocator_arg_t, const A1& a) + : data_(0) + { + assert(a.id() == 5); + allocator_constructed = true; + } + + alloc_first(std::allocator_arg_t, const A1& a, int d) + : data_(d) + { + assert(a.id() == 5); + allocator_constructed = true; + } + + alloc_first(std::allocator_arg_t, const A1& 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 + +#include "allocators.h" + +struct alloc_last +{ + static bool allocator_constructed; + + typedef A1 allocator_type; + + int data_; + + alloc_last() : data_(0) {} + alloc_last(int d) : data_(d) {} + alloc_last(const A1& a) + : data_(0) + { + assert(a.id() == 5); + allocator_constructed = true; + } + + alloc_last(int d, const A1& a) + : data_(d) + { + assert(a.id() == 5); + allocator_constructed = true; + } + + alloc_last(const alloc_last& d, const A1& 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// UNSUPPORTED: c++98, c++03 + +// This is not a portable test + +#include + +struct A {}; + +struct B {}; + +int main() +{ + { + typedef std::tuple T; + static_assert((sizeof(T) == sizeof(int)), ""); + } + { + typedef std::tuple T; + static_assert((sizeof(T) == sizeof(int)), ""); + } + { + typedef std::tuple T; + static_assert((sizeof(T) == sizeof(int)), ""); + } + { + typedef std::tuple T; + static_assert((sizeof(T) == sizeof(int)), ""); + } + { + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple& operator=(const pair& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +int main() +{ + { + typedef std::pair T0; + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple& operator=(const tuple& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +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 T0; + typedef std::tuple T1; + T0 t0(2.5); + T1 t1; + t1 = t0; + assert(std::get<0>(t1) == 2); + } + { + typedef std::tuple T0; + typedef std::tuple 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 T0; + typedef std::tuple 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 T0; + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple& operator=(tuple&& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include +#include + +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 T0; + typedef std::tuple T1; + T0 t0(2.5); + T1 t1; + t1 = std::move(t0); + assert(std::get<0>(t1) == 2); + } + { + typedef std::tuple T0; + typedef std::tuple 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 T0; + typedef std::tuple 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 T0; + typedef std::tuple 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> T0; + typedef std::tuple> T1; + T0 t0(2.5, 'a', std::unique_ptr(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// tuple& operator=(const tuple& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#include "MoveOnly.h" + +int main() +{ + { + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// tuple& operator=(const tuple& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +int main() +{ + { + typedef std::tuple<> T; + T t0; + T t; + t = t0; + } + { + typedef std::tuple T; + T t0(2); + T t; + t = t0; + assert(std::get<0>(t) == 2); + } + { + typedef std::tuple T; + T t0(2, 'a'); + T t; + t = t0; + assert(std::get<0>(t) == 2); + assert(std::get<1>(t) == 'a'); + } + { + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// tuple& operator=(tuple&& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#include "MoveOnly.h" + +int main() +{ + { + typedef std::tuple<> T; + T t0; + T t; + t = std::move(t0); + } + { + typedef std::tuple T; + T t0(MoveOnly(0)); + T t; + t = std::move(t0); + assert(std::get<0>(t) == 0); + } + { + typedef std::tuple 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple& operator=(pair&& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +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> T0; + typedef std::tuple> T1; + T0 t0(2.5, std::unique_ptr(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 + +// + +// template class tuple; + +// template > +// 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 +#include + +// Use 1256 to try and blow the template instantiation depth for all compilers. +typedef std::array array_t; +typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// 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 +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// explicit tuple(UTypes&&... u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#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 Tuple; + + static_assert(!std::is_constructible< + Tuple, + MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + Tuple, + MoveOnly, NoDefault + >::value, ""); + } + { + typedef std::tuple 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 Tuple; + typedef std::tuple 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 Tuple; + typedef std::tuple 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 t(MoveOnly(0)); + assert(std::get<0>(t) == 0); + } + { + std::tuple t(MoveOnly(0), MoveOnly(1)); + assert(std::get<0>(t) == 0); + assert(std::get<1>(t) == 1); + } + { + std::tuple 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 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 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 t0{Empty()}; + } + { + constexpr std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#include "DefaultOnly.h" +#include "allocators.h" +#include "../alloc_first.h" +#include "../alloc_last.h" + +int main() +{ + { + std::tuple<> t(std::allocator_arg, A1()); + } + { + std::tuple t(std::allocator_arg, A1()); + assert(std::get<0>(t) == 0); + } + { + std::tuple t(std::allocator_arg, A1()); + assert(std::get<0>(t) == DefaultOnly()); + } + { + assert(!alloc_first::allocator_constructed); + std::tuple t(std::allocator_arg, A1(5)); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t) == alloc_first()); + } + { + assert(!alloc_last::allocator_constructed); + std::tuple t(std::allocator_arg, A1(5)); + assert(alloc_last::allocator_constructed); + assert(std::get<0>(t) == alloc_last()); + } + { + alloc_first::allocator_constructed = false; + std::tuple t(std::allocator_arg, A1(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 t(std::allocator_arg, + A1(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 t(std::allocator_arg, + A2(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, UTypes&&...); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#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 Tuple; + + static_assert(!std::is_constructible< + Tuple, + std::allocator_arg_t, A1, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + Tuple, + std::allocator_arg_t, A1, MoveOnly, NoDefault + >::value, ""); + } + { + typedef std::tuple Tuple; + + static_assert(!std::is_constructible< + Tuple, + std::allocator_arg_t, A1, MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + Tuple, + std::allocator_arg_t, A1, MoveOnly, MoveOnly, NoDefault + >::value, ""); + } + { + // Same idea as above but with a nested tuple + typedef std::tuple Tuple; + typedef std::tuple NestedTuple; + + static_assert(!std::is_constructible< + NestedTuple, + std::allocator_arg_t, A1, MoveOnly, MoveOnly, MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + NestedTuple, + std::allocator_arg_t, A1, MoveOnly, Tuple, MoveOnly, MoveOnly + >::value, ""); + } + { + typedef std::tuple Tuple; + typedef std::tuple NestedTuple; + + static_assert(std::is_constructible< + NestedTuple, + std::allocator_arg_t, A1, MoveOnly, MoveOnly, MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + NestedTuple, + std::allocator_arg_t, A1, MoveOnly, Tuple, MoveOnly, MoveOnly + >::value, ""); + } +} + +int main() +{ + { + std::tuple t(std::allocator_arg, A1(), MoveOnly(0)); + assert(std::get<0>(t) == 0); + } + { + std::tuple t(std::allocator_arg, A1(), + MoveOnly(0), MoveOnly(1)); + assert(std::get<0>(t) == 0); + assert(std::get<1>(t) == 1); + } + { + std::tuple t(std::allocator_arg, A1(), + 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 t(std::allocator_arg, + A1(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 t(std::allocator_arg, A1(), + 0, 1); + assert(std::get<0>(t) == 0); + assert(std::get<1>(t) == 1); + assert(std::get<2>(t) == MoveOnly()); + } + { + std::tuple t(std::allocator_arg, A1(), + 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, const Types&...); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#include "allocators.h" +#include "../alloc_first.h" +#include "../alloc_last.h" + +int main() +{ + { + std::tuple t(std::allocator_arg, A1(), 3); + assert(std::get<0>(t) == 3); + } + { + assert(!alloc_first::allocator_constructed); + std::tuple t(std::allocator_arg, A1(5), alloc_first(3)); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t) == alloc_first(3)); + } + { + assert(!alloc_last::allocator_constructed); + std::tuple t(std::allocator_arg, A1(5), alloc_last(3)); + assert(alloc_last::allocator_constructed); + assert(std::get<0>(t) == alloc_last(3)); + } + { + alloc_first::allocator_constructed = false; + std::tuple t(std::allocator_arg, A1(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 t(std::allocator_arg, + A1(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 t(std::allocator_arg, + A2(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, const pair&); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#include "allocators.h" +#include "../alloc_first.h" +#include "../alloc_last.h" + +int main() +{ + { + typedef std::pair T0; + typedef std::tuple T1; + T0 t0(2, 3); + T1 t1(std::allocator_arg, A1(5), t0); + assert(std::get<0>(t1) == 2); + assert(std::get<1>(t1) == 3); + } + { + typedef std::pair T0; + typedef std::tuple T1; + T0 t0(2, 3); + alloc_first::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(5), t0); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t1) == 2); + assert(std::get<1>(t1) == 3); + } + { + typedef std::pair T0; + typedef std::tuple T1; + T0 t0(2, 3); + alloc_first::allocator_constructed = false; + alloc_last::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, const tuple&); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#include "allocators.h" +#include "../alloc_first.h" +#include "../alloc_last.h" + +int main() +{ + { + typedef std::tuple T0; + typedef std::tuple T1; + T0 t0(2.5); + T1 t1(std::allocator_arg, A1(), t0); + assert(std::get<0>(t1) == 2); + } + { + typedef std::tuple T0; + typedef std::tuple T1; + T0 t0(2); + alloc_first::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(5), t0); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t1) == 2); + } + { + typedef std::tuple T0; + typedef std::tuple T1; + T0 t0(2, 3); + alloc_first::allocator_constructed = false; + alloc_last::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(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 T0; + typedef std::tuple T1; + T0 t0(1.5, 2, 3); + alloc_first::allocator_constructed = false; + alloc_last::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, tuple&&); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +#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 T0; + typedef std::tuple T1; + T0 t0(2); + alloc_first::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(5), std::move(t0)); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t1) == 2); + } + { + typedef std::tuple> T0; + typedef std::tuple> T1; + T0 t0(std::unique_ptr(new D(3))); + T1 t1(std::allocator_arg, A1(5), std::move(t0)); + assert(std::get<0>(t1)->id_ == 3); + } + { + typedef std::tuple> T0; + typedef std::tuple> T1; + T0 t0(2, std::unique_ptr(new D(3))); + alloc_first::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(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> T0; + typedef std::tuple> T1; + T0 t0(1, 2, std::unique_ptr(new D(3))); + alloc_first::allocator_constructed = false; + alloc_last::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, const tuple&); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#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(), t0); + } + { + typedef std::tuple T; + T t0(2); + T t(std::allocator_arg, A1(), t0); + assert(std::get<0>(t) == 2); + } + { + typedef std::tuple T; + T t0(2); + alloc_first::allocator_constructed = false; + T t(std::allocator_arg, A1(5), t0); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t) == 2); + } + { + typedef std::tuple T; + T t0(2); + alloc_last::allocator_constructed = false; + T t(std::allocator_arg, A1(5), t0); + assert(alloc_last::allocator_constructed); + assert(std::get<0>(t) == 2); + } + { + typedef std::tuple T; + T t0(2, 3); + alloc_first::allocator_constructed = false; + alloc_last::allocator_constructed = false; + T t(std::allocator_arg, A1(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 T; + T t0(1, 2, 3); + alloc_first::allocator_constructed = false; + alloc_last::allocator_constructed = false; + T t(std::allocator_arg, A1(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, tuple&&); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#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(), std::move(t0)); + } + { + typedef std::tuple T; + T t0(MoveOnly(0)); + T t(std::allocator_arg, A1(), std::move(t0)); + assert(std::get<0>(t) == 0); + } + { + typedef std::tuple T; + T t0(1); + alloc_first::allocator_constructed = false; + T t(std::allocator_arg, A1(5), std::move(t0)); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t) == 1); + } + { + typedef std::tuple T; + T t0(1); + alloc_last::allocator_constructed = false; + T t(std::allocator_arg, A1(5), std::move(t0)); + assert(alloc_last::allocator_constructed); + assert(std::get<0>(t) == 1); + } + { + typedef std::tuple T; + T t0(0 ,1); + alloc_first::allocator_constructed = false; + T t(std::allocator_arg, A1(5), std::move(t0)); + assert(alloc_first::allocator_constructed); + assert(std::get<0>(t) == 0); + assert(std::get<1>(t) == 1); + } + { + typedef std::tuple T; + T t0(1, 2, 3); + alloc_first::allocator_constructed = false; + alloc_last::allocator_constructed = false; + T t(std::allocator_arg, A1(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple(allocator_arg_t, const Alloc& a, pair&&); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +#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> T0; + typedef std::tuple> T1; + T0 t0(2, std::unique_ptr(new D(3))); + alloc_first::allocator_constructed = false; + T1 t1(std::allocator_arg, A1(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// explicit tuple(const T&...); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +int main() +{ + { + std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// explicit tuple(const T&...); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + + +template +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 + constexpr explicit NoValueCtor(T) + { static_assert(never::value, "This should not be instantiated"); } + + static int count; + int id; +}; + +int NoValueCtor::count = 0; + + +struct NoValueCtorEmpty +{ + NoValueCtorEmpty() {} + NoValueCtorEmpty(NoValueCtorEmpty const &) {} + + template + constexpr explicit NoValueCtorEmpty(T) + { static_assert(never::value, "This should not be instantiated"); } +}; + +int main() +{ + { + std::tuple t(2); + assert(std::get<0>(t) == 2); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::tuple t(2); + static_assert(std::get<0>(t) == 2, ""); + } + { + constexpr std::tuple t; + static_assert(std::get<0>(t) == 0, ""); + } +#endif + { + std::tuple t(2, 0); + assert(std::get<0>(t) == 2); + assert(std::get<1>(t) == nullptr); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::tuple t(2, nullptr); + static_assert(std::get<0>(t) == 2, ""); + static_assert(std::get<1>(t) == nullptr, ""); + } +#endif + { + std::tuple t(2, nullptr); + assert(std::get<0>(t) == 2); + assert(std::get<1>(t) == nullptr); + } + { + std::tuple t(2, nullptr, "text"); + assert(std::get<0>(t) == 2); + assert(std::get<1>(t) == nullptr); + assert(std::get<2>(t) == "text"); + } + // __tuple_leaf uses is_constructible 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 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 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 t(2); + assert(std::get<0>(t) == 2); + assert(std::get<1>(t) == nullptr); + assert(std::get<2>(t) == ""); + } + { + std::tuple t(2, nullptr); + assert(std::get<0>(t) == 2); + assert(std::get<1>(t) == nullptr); + assert(std::get<2>(t) == ""); + } + { + std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// explicit tuple(const T&...); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +int main() +{ + { + std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template tuple(const pair& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +int main() +{ + { + typedef std::pair T0; + typedef std::tuple 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 P0; + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template tuple(const tuple& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +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 T0; + typedef std::tuple T1; + T0 t0(2.5); + T1 t1 = t0; + assert(std::get<0>(t1) == 2); + } +#if _LIBCPP_STD_VER > 11 + { + typedef std::tuple T0; + typedef std::tuple T1; + constexpr T0 t0(2.5); + constexpr T1 t1 = t0; + static_assert(std::get<0>(t1) == 2, ""); + } + { + typedef std::tuple T0; + typedef std::tuple T1; + constexpr T0 t0(2); + constexpr T1 t1{t0}; + static_assert(std::get<0>(t1) == C(2), ""); + } +#endif + { + typedef std::tuple T0; + typedef std::tuple 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 T0; + typedef std::tuple 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 T0; + typedef std::tuple 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 T0; + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template tuple(tuple&& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +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 T0; + typedef std::tuple T1; + T0 t0(2.5); + T1 t1 = std::move(t0); + assert(std::get<0>(t1) == 2); + } + { + typedef std::tuple T0; + typedef std::tuple 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 T0; + typedef std::tuple 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 T0; + typedef std::tuple 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> T0; + typedef std::tuple> T1; + T0 t0(2.5, 'a', std::unique_ptr(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// tuple(const tuple& u) = default; + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#include "MoveOnly.h" + +int main() +{ + { + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// tuple(const tuple& u) = default; + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +struct Empty {}; + +int main() +{ + { + typedef std::tuple<> T; + T t0; + T t = t0; + ((void)t); // Prevent unused warning + } + { + typedef std::tuple T; + T t0(2); + T t = t0; + assert(std::get<0>(t) == 2); + } + { + typedef std::tuple T; + T t0(2, 'a'); + T t = t0; + assert(std::get<0>(t) == 2); + assert(std::get<1>(t) == 'a'); + } + { + typedef std::tuple 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 T; + constexpr T t0(2); + constexpr T t = t0; + static_assert(std::get<0>(t) == 2, ""); + } + { + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// constexpr tuple(); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +#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 + constexpr IllFormedDefault() { + static_assert(Pred, + "The default constructor should not be instantiated"); + } + int value; +}; + +int main() +{ + { + std::tuple<> t; + } + { + std::tuple t; + assert(std::get<0>(t) == 0); + } + { + std::tuple t; + assert(std::get<0>(t) == 0); + assert(std::get<1>(t) == nullptr); + } + { + std::tuple t; + assert(std::get<0>(t) == 0); + assert(std::get<1>(t) == nullptr); + assert(std::get<2>(t) == ""); + } + { + std::tuple 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>(), ""); + static_assert(!std::is_default_constructible>(), ""); + static_assert(!std::is_default_constructible>(), ""); + } + { + static_assert(noexcept(std::tuple()), ""); + static_assert(noexcept(std::tuple()), ""); + + static_assert(!noexcept(std::tuple()), ""); + static_assert(!noexcept(std::tuple()), ""); + static_assert(!noexcept(std::tuple()), ""); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::tuple<> t; + } + { + constexpr std::tuple t; + assert(std::get<0>(t) == 0); + } + { + constexpr std::tuple 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// tuple(tuple&& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#include "MoveOnly.h" + +struct ConstructsWithTupleLeaf +{ + ConstructsWithTupleLeaf() {} + + ConstructsWithTupleLeaf(ConstructsWithTupleLeaf const &) { assert(false); } + ConstructsWithTupleLeaf(ConstructsWithTupleLeaf &&) {} + + template + 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 T; + T t0(MoveOnly(0)); + T t = std::move(t0); + assert(std::get<0>(t) == 0); + } + { + typedef std::tuple 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 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 d_t; + d_t d((ConstructsWithTupleLeaf())); + d_t d2(static_cast(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template tuple(pair&& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +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> T0; + typedef std::tuple> T1; + T0 t0(2.5, std::unique_ptr(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 + +// + +// template class tuple; + +// template > +// tuple(Tuple &&); +// +// template > +// tuple(Tuple &&); + +// This test checks that we do not evaluate __make_tuple_types +// on the array. + +#include +#include + +// Use 1256 to try and blow the template instantiation depth for all compilers. +typedef std::array array_t; +typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// tuple forward_as_tuple(Types&&... t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +template +void +test0(const Tuple& t) +{ + static_assert(std::tuple_size::value == 0, ""); +} + +template +void +test1a(const Tuple& t) +{ + static_assert(std::tuple_size::value == 1, ""); + static_assert(std::is_same::type, int&&>::value, ""); + assert(std::get<0>(t) == 1); +} + +template +void +test1b(const Tuple& t) +{ + static_assert(std::tuple_size::value == 1, ""); + static_assert(std::is_same::type, int&>::value, ""); + assert(std::get<0>(t) == 2); +} + +template +void +test2a(const Tuple& t) +{ + static_assert(std::tuple_size::value == 2, ""); + static_assert(std::is_same::type, double&>::value, ""); + static_assert(std::is_same::type, char&>::value, ""); + assert(std::get<0>(t) == 2.5); + assert(std::get<1>(t) == 'a'); +} + +#if _LIBCPP_STD_VER > 11 +template +constexpr int +test3(const Tuple& t) +{ + return std::tuple_size::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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple make_tuple(Types&&... t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +int main() +{ + { + int i = 0; + float j = 0; + std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// tuple tie(Types&... t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template tuple tuple_cat(Tuples&&... tpls); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include +#include + +#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()); + ((void)t); // Prevent unused warning + } + { + std::tuple t1(1); + std::tuple 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()); + ((void)t); // Prevent unused warning + } + { + constexpr std::tuple t1(1); + constexpr std::tuple t = std::tuple_cat(t1); + static_assert(std::get<0>(t) == 1, ""); + } + { + constexpr std::tuple t1(1); + constexpr std::tuple t = std::tuple_cat(t1, t1); + static_assert(std::get<0>(t) == 1, ""); + static_assert(std::get<1>(t) == 1, ""); + } +#endif + { + std::tuple t = + std::tuple_cat(std::tuple(1, 2)); + assert(std::get<0>(t) == 1); + assert(std::get<1>(t) == 2); + } + { + std::tuple t = std::tuple_cat(std::array()); + assert(std::get<0>(t) == 0); + assert(std::get<1>(t) == 0); + assert(std::get<2>(t) == 0); + } + { + std::tuple t = std::tuple_cat(std::pair(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 t2(2); + std::tuple t3 = std::tuple_cat(t1, t2); + assert(std::get<0>(t3) == 2); + } + { + std::tuple<> t1; + std::tuple t2(2); + std::tuple t3 = std::tuple_cat(t2, t1); + assert(std::get<0>(t3) == 2); + } + { + std::tuple t1; + std::tuple t2(2); + std::tuple t3 = std::tuple_cat(t1, t2); + assert(std::get<0>(t3) == nullptr); + assert(std::get<1>(t3) == 2); + } + { + std::tuple t1; + std::tuple t2(2); + std::tuple t3 = std::tuple_cat(t2, t1); + assert(std::get<0>(t3) == 2); + assert(std::get<1>(t3) == nullptr); + } + { + std::tuple t1; + std::tuple t2(2, 3.5); + std::tuple 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 t1; + std::tuple t2(2, 3.5); + std::tuple 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 t1(nullptr, 1); + std::tuple t2(2, 3.5); + std::tuple 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 t1(nullptr, 1); + std::tuple t2(2, 3.5); + std::tuple 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 t1(1, 2); + std::tuple t2(nullptr, 4); + std::tuple 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 t1(1, 2); + std::tuple t2(nullptr, 4); + std::tuple 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 t1(1, 2); + std::tuple t2(nullptr, 4); + std::tuple 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 t1(1, 2); + std::tuple t2(nullptr, 4); + std::tuple 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 t1(1, 2); + std::tuple t2(nullptr, 4); + std::tuple t3 = + std::tuple_cat(std::move(t1), + std::move(t2), + std::tuple(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// typename tuple_element >::type const& +// get(const tuple& t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +int main() +{ + { + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// typename tuple_element >::type const& +// get(const tuple& t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +struct Empty {}; + +int main() +{ + { + typedef std::tuple T; + const T t(3); + assert(std::get<0>(t) == 3); + } + { + typedef std::tuple 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 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 T; + constexpr T t{Empty()}; + constexpr Empty e = std::get<0>(t); + ((void)e); // Prevent unused warning + } +#endif + { + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// typename tuple_element >::type& +// get(tuple& t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#if __cplusplus > 201103L + +struct Empty {}; + +struct S { + std::tuple a; + int k; + Empty e; + constexpr S() : a{1,Empty{}}, k(std::get<0>(a)), e(std::get<1>(a)) {} + }; + +constexpr std::tuple getP () { return { 3, 4 }; } +#endif + +int main() +{ + { + typedef std::tuple T; + T t(3); + assert(std::get<0>(t) == 3); + std::get<0>(t) = 2; + assert(std::get<0>(t) == 2); + } + { + typedef std::tuple 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// typename tuple_element >::type&& +// get(tuple&& t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +int main() +{ + { + typedef std::tuple > T; + T t(std::unique_ptr(new int(3))); + std::unique_ptr 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 +#include +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::complex cf; + { + auto t1 = std::tuple { 42, "Hi", { 1,2 }}; + assert ( std::get(t1) == 42 ); // find at the beginning + assert ( std::get(t1) == "Hi" ); // find in the middle + assert ( std::get(t1).real() == 1 ); // find at the end + assert ( std::get(t1).imag() == 2 ); + } + + { + auto t2 = std::tuple { 42, "Hi", 23, { 1,2 }}; +// get would fail! + assert ( std::get(t2) == "Hi" ); + assert (( std::get(t2) == cf{ 1,2 } )); + } + + { + constexpr std::tuple p5 { 1, 2, 3.4, 5.6 }; + static_assert ( std::get(p5) == 1, "" ); + static_assert ( std::get(p5) == 2, "" ); + } + + { + const std::tuple p5 { 1, 2, 3.4, 5.6 }; + const int &i1 = std::get(p5); + const int &i2 = std::get(p5); + assert ( i1 == 1 ); + assert ( i2 == 2 ); + } + + { + typedef std::unique_ptr upint; + std::tuple t(upint(new int(4))); + upint p = std::get(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 +#include +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::complex cf; + auto t1 = std::make_tuple ( 42, "Hi" ); + assert (( std::get(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 +#include +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::complex cf; + auto t1 = std::make_tuple ( 42, 21, "Hi", { 1,2 } ); + assert ( std::get(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 +#include +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::complex cf; + auto t1 = std::make_tuple ( 42, 21, "Hi", { 1,2 } ); + assert ( std::get(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 +#include +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::unique_ptr upint; + std::tuple t(upint(new int(4))); + upint p = std::get(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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// class tuple_element > +// { +// public: +// typedef Ti type; +// }; +// +// LWG #2212 says that tuple_size and tuple_element must be +// available after including + +#include +#include + +template +void test() +{ + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_same::type, U>::value), ""); + static_assert((std::is_same::type, const U>::value), ""); + static_assert((std::is_same::type, volatile U>::value), ""); + static_assert((std::is_same::type, const volatile U>::value), ""); +} + +int main() +{ + test, 5, int, 0>(); + test, 5, int, 1>(); + test, 4, const char *, 3>(); + test, 4, volatile int, 3>(); + test, 3, char *, 1>(); + test, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// class tuple_size> +// : public integral_constant { }; +// +// LWG #2212 says that tuple_size and tuple_element must be +// available after including + +#include +#include + +template +void test() +{ + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_same::type, U>::value), ""); + static_assert((std::is_same::type, const U>::value), ""); + static_assert((std::is_same::type, volatile U>::value), ""); + static_assert((std::is_same::type, const volatile U>::value), ""); +} + +int main() +{ + test, 2, int, 0>(); + test, 2, int, 1>(); + test, 2, int, 1>(); + test, 2, volatile int, 1>(); + test, 2, char *, 0>(); + test, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// class tuple_element > +// { +// public: +// typedef Ti type; +// }; + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +template +void test() +{ + static_assert((std::is_same::type, U>::value), ""); + static_assert((std::is_same::type, const U>::value), ""); + static_assert((std::is_same::type, volatile U>::value), ""); + static_assert((std::is_same::type, const volatile U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); + static_assert((std::is_same, const U>::value), ""); + static_assert((std::is_same, volatile U>::value), ""); + static_assert((std::is_same, const volatile U>::value), ""); +#endif +} + +int main() +{ + test, 0, int>(); + test, 0, char>(); + test, 1, int>(); + test, 0, int*>(); + test, 1, char>(); + test, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// class tuple_size> +// : public integral_constant { }; + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +template +void test() +{ + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); +} + +int main() +{ + test, 0>(); + test, 1>(); + test, 2>(); + test, 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// bool +// operator==(const tuple& t, const tuple& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +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 T1; + typedef std::tuple T2; + const T1 t1(1); + const T2 t2(1.1); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1); + const T2 t2(1); + assert(t1 == t2); + assert(!(t1 != t2)); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2); + const T2 t2(1, char(2)); + assert(t1 == t2); + assert(!(t1 != t2)); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2); + const T2 t2(1, char(3)); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2); + const T2 t2(1.1, char(2)); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2); + const T2 t2(1.1, char(3)); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2, 3); + const T2 t2(1, 2, 3); + assert(t1 == t2); + assert(!(t1 != t2)); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2, 3); + const T2 t2(1.1, 2, 3); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2, 3); + const T2 t2(1, 3, 3); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2, 3); + const T2 t2(1, 2, 4); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2, 3); + const T2 t2(1, 3, 2); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2, 3); + const T2 t2(1.1, 2, 2); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple T2; + const T1 t1(1, 2, 3); + const T2 t2(1.1, 3, 3); + assert(!(t1 == t2)); + assert(t1 != t2); + } + { + typedef std::tuple T1; + typedef std::tuple 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 T1; + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// bool +// operator<(const tuple& t, const tuple& u); +// +// template +// bool +// operator>(const tuple& t, const tuple& u); +// +// template +// bool +// operator<=(const tuple& t, const tuple& u); +// +// template +// bool +// operator>=(const tuple& t, const tuple& u); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +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 T1; + typedef std::tuple T2; + const T1 t1(1); + const T2 t2(1); + assert(!(t1 < t2)); + assert( (t1 <= t2)); + assert(!(t1 > t2)); + assert( (t1 >= t2)); + } + { + typedef std::tuple T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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 T1; + typedef std::tuple 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// void swap(tuple& x, tuple& y); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#include "MoveOnly.h" + +int main() +{ + { + typedef std::tuple<> T; + T t0; + T t1; + swap(t0, t1); + } + { + typedef std::tuple 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// void swap(tuple& rhs); + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#include "MoveOnly.h" + +int main() +{ + { + typedef std::tuple<> T; + T t0; + T t1; + t0.swap(t1); + } + { + typedef std::tuple 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// struct uses_allocator, Alloc> : true_type { }; + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +struct A {}; + +int main() +{ + { + typedef std::tuple<> T; + static_assert((std::is_base_of>::value), ""); + } + { + typedef std::tuple T; + static_assert((std::is_base_of>::value), ""); + } + { + typedef std::tuple T; + static_assert((std::is_base_of>::value), ""); + } + { + typedef std::tuple T; + static_assert((std::is_base_of>::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// class type_index + +// template <> +// struct hash +// : public unary_function +// { +// size_t operator()(type_index index) const; +// }; + +#include +#include + +int main() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + + std::type_index t1 = typeid(int); + assert(std::hash()(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. +// +//===----------------------------------------------------------------------===// + +// + +// class type_index + +// type_index(const type_info& rhs); + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class type_index + +// bool operator==(const type_index& rhs) const; +// bool operator!=(const type_index& rhs) const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class type_index + +// size_t hash_code() const; + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// 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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class type_index + +// const char* name() const; + +#include +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class type_index + +// type_index& operator=(const type_index& ti); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// class type_index + +// type_index(const type_index& ti); + +#include +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// struct hash +// : public unary_function +// { +// size_t operator()(type_index index) const; +// }; + +#include +#include + +int main() +{ + typedef std::hash H; + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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. +// +//===----------------------------------------------------------------------===// + +// + +// template typename add_rvalue_reference::type declval() noexcept; + +#include +#include + +class A +{ + A(const A&); + A& operator=(const A&); +}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + static_assert((std::is_same()), A&&>::value), ""); +#else + static_assert((std::is_same()), 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 +#include +#include + +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 ( 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 +#include + +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))) == 1, ""); + static_assert(sizeof(test(std::forward(a))) == 4, ""); + static_assert(sizeof(test(std::forward(source()))) == 4, ""); + + static_assert(sizeof(test(std::forward(a))) == 2, ""); +// static_assert(sizeof(test(std::forward(source()))) == 2, ""); + static_assert(sizeof(test(std::forward(a))) == 8, ""); + static_assert(sizeof(test(std::forward(source()))) == 8, ""); + + static_assert(sizeof(test(std::forward(ca))) == 2, ""); +// static_assert(sizeof(test(std::forward(csource()))) == 2, ""); + static_assert(sizeof(test(std::forward(ca))) == 8, ""); + static_assert(sizeof(test(std::forward(csource()))) == 8, ""); + +#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + + static_assert(sizeof(test(std::forward(a))) == 1, ""); + static_assert(sizeof(test(std::forward(a))) == 1, ""); +// static_assert(sizeof(test(std::forward(source()))) == 2, ""); + + static_assert(sizeof(test(std::forward(a))) == 2, ""); + static_assert(sizeof(test(std::forward(source()))) == 2, ""); + static_assert(sizeof(test(std::forward(a))) == 2, ""); + static_assert(sizeof(test(std::forward(source()))) == 2, ""); + + static_assert(sizeof(test(std::forward(ca))) == 2, ""); + static_assert(sizeof(test(std::forward(csource()))) == 2, ""); + static_assert(sizeof(test(std::forward(ca))) == 2, ""); + static_assert(sizeof(test(std::forward(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(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 + +struct A +{ +}; + +A source() {return A();} +const A csource() {return A();} + +int main() +{ + std::forward(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 + +struct A +{ +}; + +A source() {return A();} +const A csource() {return A();} + +int main() +{ + const A ca = A(); + std::forward(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 + +struct A +{ +}; + +A source() {return A();} +const A csource() {return A();} + +int main() +{ + std::forward(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 + +struct A +{ +}; + +A source() {return A();} +const A csource() {return A();} + +int main() +{ + const A ca = A(); + std::forward(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 + +struct A +{ +}; + +A source() {return A();} +const A csource() {return A();} + +int main() +{ + const A ca = A(); + std::forward(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 + +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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// typename conditional +// < +// !is_nothrow_move_constructible::value && is_copy_constructible::value, +// const T&, +// T&& +// >::type +// move_if_noexcept(T& x); + +#include + +#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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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 +#include + +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 +#include + +#include +#include + +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 () {return std::__rv(*this);} + move_only(std::__rv) {} +#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 +#include + +#include +#include + +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 () {return std::__rv(*this);} + move_only(std::__rv) {} +#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 +#include + +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 () {return std::__rv(*this);} + move_only(std::__rv) {} +#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 +#include + +#include +#include + +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 () {return std::__rv(*this);} + move_only(std::__rv) {} +#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 +#include + +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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template +// const typename tuple_element >::type& +// get(const pair&); + +#include +#include + +int main() +{ + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template +// const typename tuple_element >::type& +// get(const pair&); + +#include +#include + +int main() +{ + { + typedef std::pair P; + const P p(3, 4); + assert(std::get<0>(p) == 3); + assert(std::get<1>(p) == 4); + } + +#if __cplusplus > 201103L + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template +// typename tuple_element >::type& +// get(pair&); + +#include +#include + +#if __cplusplus > 201103L +struct S { + std::pair a; + int k; + constexpr S() : a{1,2}, k(std::get<0>(a)) {} + }; + +constexpr std::pair getP () { return { 3, 4 }; } +#endif + +int main() +{ + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template +// typename tuple_element >::type&& +// get(pair&&); + +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::pair, short> P; + P p(std::unique_ptr(new int(3)), 4); + std::unique_ptr 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 +#include +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::complex cf; + { + auto t1 = std::make_pair ( 42, { 1,2 } ); + assert ( std::get(t1) == 42 ); + assert ( std::get(t1).real() == 1 ); + assert ( std::get(t1).imag() == 2 ); + } + + { + const std::pair p1 { 1, 2 }; + const int &i1 = std::get(p1); + const int &i2 = std::get(p1); + assert ( i1 == 1 ); + assert ( i2 == 2 ); + } + + { + typedef std::unique_ptr upint; + std::pair 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 +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::complex cf; + auto t1 = std::make_pair ( 42, 3.4 ); + assert (( std::get(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 +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::complex cf; + auto t1 = std::make_pair ( 42, 43 ); + assert ( std::get(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 +#include + +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::unique_ptr upint; + std::pair t(upint(new int(4)), 23); + upint p = std::get(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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// tuple_element >::type + +#include + +template +void test() +{ + { + typedef T1 Exp1; + typedef T2 Exp2; + typedef std::pair P; + static_assert((std::is_same::type, Exp1>::value), ""); + static_assert((std::is_same::type, Exp2>::value), ""); + } + { + typedef T1 const Exp1; + typedef T2 const Exp2; + typedef std::pair const P; + static_assert((std::is_same::type, Exp1>::value), ""); + static_assert((std::is_same::type, Exp2>::value), ""); + } + { + typedef T1 volatile Exp1; + typedef T2 volatile Exp2; + typedef std::pair volatile P; + static_assert((std::is_same::type, Exp1>::value), ""); + static_assert((std::is_same::type, Exp2>::value), ""); + } + { + typedef T1 const volatile Exp1; + typedef T2 const volatile Exp2; + typedef std::pair const volatile P; + static_assert((std::is_same::type, Exp1>::value), ""); + static_assert((std::is_same::type, Exp2>::value), ""); + } +} + +int main() +{ + test(); + test(); +} 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// tuple_size >::value + +#include + +int main() +{ + { + typedef std::pair P1; + static_assert((std::tuple_size::value == 2), ""); + } + { + typedef std::pair const P1; + static_assert((std::tuple_size::value == 2), ""); + } + { + typedef std::pair volatile P1; + static_assert((std::tuple_size::value == 2), ""); + } + { + typedef std::pair const volatile P1; + static_assert((std::tuple_size::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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// struct piecewise_construct_t { }; +// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); + +#include +#include +#include + +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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template pair(U&& x, V&& y); + +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::pair, short*> P; + P p(std::unique_ptr(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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template pair& operator=(const pair& p); + +#include +#include + +int main() +{ + { + typedef std::pair P1; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// pair& operator=(pair&& p); + +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::pair, short> P; + P p1(std::unique_ptr(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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template pair& operator=(pair&& p); + +#include +#include +#include + +struct Base +{ + virtual ~Base() {} +}; + +struct Derived + : public Base +{ +}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::pair, short> P1; + typedef std::pair, long> P2; + P1 p1(std::unique_ptr(), 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// pair(const T1& x, const T2& y); + +#include +#include + +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 P; + P p(3.5f, 0); + assert(p.first == 3.5f); + assert(p.second == nullptr); + } + { + typedef std::pair P; + P p(1, 2); + assert(p.first == A(1)); + assert(p.second == 2); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair P; + constexpr P p(3.5f, 0); + static_assert(p.first == 3.5f, ""); + static_assert(p.second == nullptr, ""); + } + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template pair(const pair& p); + +#include +#include + +int main() +{ + { + typedef std::pair P1; + typedef std::pair P2; + P1 p1(3, 4); + P2 p2 = p1; + assert(p2.first == 3); + assert(p2.second == 4); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair P1; + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// pair(const pair&) = default; + +#include +#include + +int main() +{ + { + typedef std::pair P1; + P1 p1(3, 4); + P1 p2 = p1; + assert(p2.first == 3); + assert(p2.second == 4); + } + + static_assert((std::is_trivially_copy_constructible >::value), ""); + +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// constexpr pair(); + +#include +#include + +int main() +{ + { + typedef std::pair P; + P p; + assert(p.first == 0.0f); + assert(p.second == nullptr); + } + +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template +// pair(piecewise_construct_t, tuple first_args, +// tuple second_args); + +#include +#include +#include + +int main() +{ +#ifndef _LIBCPP_HAS_NO_VARIADICS + { + typedef std::pair P1; + typedef std::pair P2; + typedef std::pair P3; + P3 p3(std::piecewise_construct, std::tuple(3, nullptr), + std::tuple(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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template pair(pair&& p); + +#include +#include +#include + +struct Base +{ + virtual ~Base() {} +}; + +struct Derived + : public Base +{ +}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::pair, short> P1; + typedef std::pair, long> P2; + P1 p1(std::unique_ptr(), 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// void swap(pair& p); + +#include +#include + +int main() +{ + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct pair +// { +// typedef T1 first_type; +// typedef T2 second_type; + +#include +#include + +int main() +{ + typedef std::pair P; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template bool operator==(const pair&, const pair&); +// template bool operator!=(const pair&, const pair&); +// template bool operator< (const pair&, const pair&); +// template bool operator> (const pair&, const pair&); +// template bool operator>=(const pair&, const pair&); +// template bool operator<=(const pair&, const pair&); + +#include +#include + +int main() +{ + { + typedef std::pair 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 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 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 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 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template pair make_pair(T1&&, T2&&); + +#include +#include +#include + +int main() +{ + { + typedef std::pair 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, short> P1; + P1 p1 = std::make_pair(std::unique_ptr(new int(3)), 4); + assert(*p1.first == 3); + assert(p1.second == 4); + } + { + typedef std::pair, 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 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. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template void swap(pair& x, pair& y); + +#include +#include + +int main() +{ + { + typedef std::pair 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires MoveAssignable && MoveConstructible +// void +// swap(T& a, T& b); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#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 i(new int(1)); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// requires Swappable +// void +// swap(T (&a)[N], T (&b)[N]); + +#include +#include +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#include +#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 i[3]; + for (int k = 0; k < 3; ++k) + i[k].reset(new int(k+1)); + std::unique_ptr 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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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 // for std::hash + +struct Counter_base { static int gConstructed; }; + +template +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 +struct hash > + : public std::unary_function, std::size_t> +{ + std::size_t operator()(const Counter& x) const {return std::hash(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 + +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 +#include + +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 + : public std::unary_function +{ + 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 +#include + +#include "test_macros.h" + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template +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 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 + A1(const A1& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} + template + A1(A1&& 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(p, n); + } + + std::size_t max_size() const {return id_;} +}; + +template bool A1::copy_called = false; +template bool A1::move_called = false; +template bool A1::allocate_called = false; +template std::pair A1::deallocate_called; + +template +inline +bool operator==(const A1& x, const A1& y) +{ + return x.id() == y.id(); +} + +template +inline +bool operator!=(const A1& x, const A1& y) +{ + return !(x == y); +} + +template +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 bool A2::copy_called = false; +template bool A2::move_called = false; +template bool A2::allocate_called = false; + +template +inline +bool operator==(const A2& x, const A2& y) +{ + return x.id() == y.id(); +} + +template +inline +bool operator!=(const A2& x, const A2& y) +{ + return !(x == y); +} + +template +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 + void construct(U* p, Args&& ...args) + { + ::new (p) U(std::forward(args)...); + constructed = true; + } + + template + void destroy(U* p) + { + p->~U(); + destroy_called = true; + } + + A3 select_on_container_copy_construction() const {return A3(-1);} +}; + +template bool A3::copy_called = false; +template bool A3::move_called = false; +template bool A3::constructed = false; +template bool A3::destroy_called = false; + +template +inline +bool operator==(const A3& x, const A3& y) +{ + return x.id() == y.id(); +} + +template +inline +bool operator!=(const A3& x, const A3& 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 +bool is_contiguous_container_asan_correct ( const std::vector &c ) +{ + if ( std::is_same >::value && c.data() != NULL) + return __sanitizer_verify_contiguous_container ( + c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0; + return true; +} + +#else +template +bool is_contiguous_container_asan_correct ( const std::vector &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 + +template +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 +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 +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 +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 + + +template +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 +_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 +_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 +_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 +_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 +_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 +_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 +# include +# include + +#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 +struct unary_counting_predicate : public std::unary_function { +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 +struct binary_counting_predicate : public std::binary_function { +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(0x10, 0xF5, -10) + +#ifndef HEXFLOAT_H +#define HEXFLOAT_H + +#include +#include +#include + +template +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(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 + constexpr auto operator()(T&& t, U&& u) const + noexcept(noexcept(std::forward(t) < std::forward(u))) + -> decltype (std::forward(t) < std::forward(u)) + { return std::forward(t) < std::forward(u); } + typedef void is_transparent; // correct +}; + +struct transparent_less_no_type +{ + template + constexpr auto operator()(T&& t, U&& u) const + noexcept(noexcept(std::forward(t) < std::forward(u))) + -> decltype (std::forward(t) < std::forward(u)) + { return std::forward(t) < std::forward(u); } +private: +// typedef void is_transparent; // error - should exist +}; + +struct transparent_less_private +{ + template + constexpr auto operator()(T&& t, U&& u) const + noexcept(noexcept(std::forward(t) < std::forward(u))) + -> decltype (std::forward(t) < std::forward(u)) + { return std::forward(t) < std::forward(u); } +private: + typedef void is_transparent; // error - should be accessible +}; + +struct transparent_less_not_a_type +{ + template + constexpr auto operator()(T&& t, U&& u) const + noexcept(noexcept(std::forward(t) < std::forward(u))) + -> decltype (std::forward(t) < std::forward(u)) + { return std::forward(t) < std::forward(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 + +#include "test_macros.h" + +template +class bare_allocator +{ +public: + typedef T value_type; + + bare_allocator() TEST_NOEXCEPT {} + + template + bare_allocator(bare_allocator) TEST_NOEXCEPT {} + + T* allocate(std::size_t n) + { + return static_cast(::operator new(n*sizeof(T))); + } + + void deallocate(T* p, std::size_t) + { + return ::operator delete(static_cast(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 + +template class min_pointer; +template class min_pointer; +template <> class min_pointer; +template <> class min_pointer; +template class min_allocator; + +template <> +class min_pointer +{ + const void* ptr_; +public: + min_pointer() TEST_NOEXCEPT = default; + min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {} + template + min_pointer(min_pointer 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 friend class min_pointer; +}; + +template <> +class min_pointer +{ + void* ptr_; +public: + min_pointer() TEST_NOEXCEPT = default; + min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {} + template ::value + >::type + > + min_pointer(min_pointer 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 friend class min_pointer; +}; + +template +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 p) TEST_NOEXCEPT : ptr_(static_cast(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 friend class min_pointer; + template friend class min_allocator; +}; + +template +class min_pointer +{ + 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 p) : ptr_(p.ptr_) {} + explicit min_pointer(min_pointer p) : ptr_(static_cast(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 friend class min_pointer; +}; + +template +inline +bool +operator==(min_pointer x, std::nullptr_t) +{ + return !static_cast(x); +} + +template +inline +bool +operator==(std::nullptr_t, min_pointer x) +{ + return !static_cast(x); +} + +template +inline +bool +operator!=(min_pointer x, std::nullptr_t) +{ + return static_cast(x); +} + +template +inline +bool +operator!=(std::nullptr_t, min_pointer x) +{ + return static_cast(x); +} + +template +class min_allocator +{ +public: + typedef T value_type; + typedef min_pointer pointer; + + min_allocator() = default; + template + min_allocator(min_allocator) {} + + pointer allocate(std::ptrdiff_t n) + { + return pointer(static_cast(::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 +#include + +template +class nasty_vector +{ +public: + typedef typename std::vector 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 nasty_vector(InputIterator first, InputIterator last) : v_(first, last) {} +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + nasty_vector(std::initializer_list il) : v_(il) {} +#endif + ~nasty_vector() {} + + template + 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 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(x)); } +#ifndef _LIBCPP_HAS_NO_VARIADICS + template + void emplace_back(Args&&... args) { v_.emplace_back(std::forward(args)...); } +#endif +#endif + void pop_back() { v_.pop_back(); } + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_HAS_NO_VARIADICS + template iterator emplace(const_iterator pos, Args&&... args) + { return v_.emplace(pos, std::forward(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(x)); } +#endif + iterator insert(const_iterator pos, size_type n, const value_type& x) { return v_.insert(pos, n, x); } + template + 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 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::value) + { v_.swap(nv.v_); } + + nasty_vector *operator &() { return nullptr; } // nasty + const nasty_vector *operator &() const { return nullptr; } // nasty + + nested_container v_; +}; + +template +bool operator==(const nasty_vector& x, const nasty_vector& y) { return x.v_ == y.v_; } + +template +class nasty_list +{ +public: + + typedef typename std::list 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 + nasty_list(Iter first, Iter last) : l_(first, last) {} +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + nasty_list(std::initializer_list il) : l_(il) {} +#endif + + ~nasty_list() {} + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + nasty_list& operator=(std::initializer_list il) { l_ = il; return *this; } +#endif + template + 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 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(x)); } + void push_front(value_type&& x) { l_.push_back(std::forward(x)); } +#ifndef _LIBCPP_HAS_NO_VARIADICS + template + void emplace_back(Args&&... args) { l_.emplace_back(std::forward(args)...); } + template + void emplace_front(Args&&... args) { l_.emplace_front(std::forward(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 iterator emplace(const_iterator pos, Args&&... args) + { return l_.emplace(pos, std::forward(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(x)); } +#endif + iterator insert(const_iterator pos, size_type n, const value_type& x) { return l_.insert(pos, n, x); } + template + 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 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::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 void remove_if(Pred pred); +// void unique(); +// template +// void unique(BinaryPredicate binary_pred); +// void merge(list& x); +// void merge(list&& x); +// template +// void merge(list& x, Compare comp); +// template +// void merge(list&& x, Compare comp); +// void sort(); +// template +// 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 +bool operator==(const nasty_list& x, const nasty_list& 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 +#include +#include +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#include // _mktemp +#else +#include // 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 + +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 +#include +#include +#include +#include +#include + +#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 test_allocator + : public test_alloc_base +{ + int data_; + + template 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::type reference; + typedef typename std::add_lvalue_reference::type const_reference; + + template struct rebind {typedef test_allocator 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 test_allocator(const test_allocator& 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 non_default_test_allocator + : public test_alloc_base +{ + int data_; + + template 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::type reference; + typedef typename std::add_lvalue_reference::type const_reference; + + template struct rebind {typedef non_default_test_allocator 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 non_default_test_allocator(const non_default_test_allocator& 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 + : public test_alloc_base +{ + int data_; + + template 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 struct rebind {typedef test_allocator 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 test_allocator(const test_allocator& 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 other_allocator +{ + int data_; + + template friend class other_allocator; + +public: + typedef T value_type; + + other_allocator() : data_(-1) {} + explicit other_allocator(int i) : data_(i) {} + template other_allocator(const other_allocator& 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 +#include + +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define DELETE_FUNCTION = delete +#else +#define DELETE_FUNCTION +#endif + +template +class output_iterator +{ + It it_; + + template friend class output_iterator; +public: + typedef std::output_iterator_tag iterator_category; + typedef void value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef It pointer; + typedef typename std::iterator_traits::reference reference; + + It base() const {return it_;} + + output_iterator () {} + explicit output_iterator(It it) : it_(it) {} + template + output_iterator(const output_iterator& 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 + void operator,(T const &) DELETE_FUNCTION; +}; + +template +class input_iterator +{ + It it_; + + template friend class input_iterator; +public: + typedef std::input_iterator_tag iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef It pointer; + typedef typename std::iterator_traits::reference reference; + + It base() const {return it_;} + + input_iterator() : it_() {} + explicit input_iterator(It it) : it_(it) {} + template + input_iterator(const input_iterator& 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 + void operator,(T const &) DELETE_FUNCTION; +}; + +template +inline +bool +operator==(const input_iterator& x, const input_iterator& y) +{ + return x.base() == y.base(); +} + +template +inline +bool +operator!=(const input_iterator& x, const input_iterator& y) +{ + return !(x == y); +} + +template +class forward_iterator +{ + It it_; + + template friend class forward_iterator; +public: + typedef std::forward_iterator_tag iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef It pointer; + typedef typename std::iterator_traits::reference reference; + + It base() const {return it_;} + + forward_iterator() : it_() {} + explicit forward_iterator(It it) : it_(it) {} + template + forward_iterator(const forward_iterator& 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 + void operator,(T const &) DELETE_FUNCTION; +}; + +template +inline +bool +operator==(const forward_iterator& x, const forward_iterator& y) +{ + return x.base() == y.base(); +} + +template +inline +bool +operator!=(const forward_iterator& x, const forward_iterator& y) +{ + return !(x == y); +} + +template +class bidirectional_iterator +{ + It it_; + + template friend class bidirectional_iterator; +public: + typedef std::bidirectional_iterator_tag iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef It pointer; + typedef typename std::iterator_traits::reference reference; + + It base() const {return it_;} + + bidirectional_iterator() : it_() {} + explicit bidirectional_iterator(It it) : it_(it) {} + template + bidirectional_iterator(const bidirectional_iterator& 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 + void operator,(T const &) DELETE_FUNCTION; +}; + +template +inline +bool +operator==(const bidirectional_iterator& x, const bidirectional_iterator& y) +{ + return x.base() == y.base(); +} + +template +inline +bool +operator!=(const bidirectional_iterator& x, const bidirectional_iterator& y) +{ + return !(x == y); +} + +template +class random_access_iterator +{ + It it_; + + template friend class random_access_iterator; +public: + typedef std::random_access_iterator_tag iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef It pointer; + typedef typename std::iterator_traits::reference reference; + + It base() const {return it_;} + + random_access_iterator() : it_() {} + explicit random_access_iterator(It it) : it_(it) {} + template + random_access_iterator(const random_access_iterator& 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 + void operator,(T const &) DELETE_FUNCTION; +}; + +template +inline +bool +operator==(const random_access_iterator& x, const random_access_iterator& y) +{ + return x.base() == y.base(); +} + +template +inline +bool +operator!=(const random_access_iterator& x, const random_access_iterator& y) +{ + return !(x == y); +} + +template +inline +bool +operator<(const random_access_iterator& x, const random_access_iterator& y) +{ + return x.base() < y.base(); +} + +template +inline +bool +operator<=(const random_access_iterator& x, const random_access_iterator& y) +{ + return !(y < x); +} + +template +inline +bool +operator>(const random_access_iterator& x, const random_access_iterator& y) +{ + return y < x; +} + +template +inline +bool +operator>=(const random_access_iterator& x, const random_access_iterator& y) +{ + return !(x < y); +} + +template +inline +typename std::iterator_traits::difference_type +operator-(const random_access_iterator& x, const random_access_iterator& y) +{ + return x.base() - y.base(); +} + +template +inline Iter base(output_iterator i) { return i.base(); } + +template +inline Iter base(input_iterator i) { return i.base(); } + +template +inline Iter base(forward_iterator i) { return i.base(); } + +template +inline Iter base(bidirectional_iterator i) { return i.base(); } + +template +inline Iter base(random_access_iterator i) { return i.base(); } + +template // 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)> \ + TEST_CONCAT(test_assert, __LINE__) +# +#endif + +namespace test_detail { + +template struct static_assert_incomplete_test; +template <> struct static_assert_incomplete_test {}; +template 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 + +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 +struct UserDefinedIntegral +{ + UserDefinedIntegral() : value(0) {} + UserDefinedIntegral(T v) : value(v) {} + operator T() const { return value; } + T value; +}; + +// Poison the arithmetic and comparison operations +template +void operator+(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator-(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator*(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator/(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator==(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator!=(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator<(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator>(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator<=(UserDefinedIntegral, UserDefinedIntegral); + +template +void operator>=(UserDefinedIntegral, UserDefinedIntegral); + +#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 diff --git a/utils/not/not.py b/utils/not/not.py new file mode 100644 index 000000000000..96e4ea7eee18 --- /dev/null +++ b/utils/not/not.py @@ -0,0 +1,35 @@ +"""not.py is a utility for inverting the return code of commands. +It acts similar to llvm/utils/not. +ex: python /path/to/not.py ' echo hello + echo $? // (prints 1) +""" + +import distutils.spawn +import subprocess +import sys + + +def main(): + argv = list(sys.argv) + del argv[0] + if len(argv) > 0 and argv[0] == '--crash': + del argv[0] + expectCrash = True + else: + expectCrash = False + if len(argv) == 0: + return 1 + prog = distutils.spawn.find_executable(argv[0]) + if prog is None: + sys.stderr.write('Failed to find program %s' % argv[0]) + return 1 + rc = subprocess.call(argv) + if rc < 0: + return 0 if expectCrash else 1 + if expectCrash: + return 1 + return rc == 0 + + +if __name__ == '__main__': + exit(main()) diff --git a/utils/sym_check/linux_blacklist.txt b/utils/sym_check/linux_blacklist.txt new file mode 100644 index 000000000000..4d9d1d4b9e30 --- /dev/null +++ b/utils/sym_check/linux_blacklist.txt @@ -0,0 +1,19 @@ +# all guard variables +_ZGVNSt3__ +# all vtables +_ZTV +# all VTT +_ZTT +# all non-virtual thunks +_ZTh +# all virtual thunks +_ZTv +# typeinfo for std::__1::__types +# There are no std::__types +_ZTINSt3__1[0-9][0-9]*__ +# typeinfo name for std::__1::__types +_ZTSNSt3__1[0-9][0-9]*__ +# anything using __hidden_allocator +.*__hidden_allocator +# anything using __sso_allocator +.*__sso_allocator diff --git a/utils/sym_check/osx_blacklist.txt b/utils/sym_check/osx_blacklist.txt new file mode 100644 index 000000000000..cfa911ed74e5 --- /dev/null +++ b/utils/sym_check/osx_blacklist.txt @@ -0,0 +1,19 @@ +# all guard variables +__ZGVNSt3__ +# all vtables +__ZTV +# all VTT +__ZTT +# all non-virtual thunks +__ZTh +# all virtual thunks +__ZTv +# typeinfo for std::__1::__types +# There are no std::__types +__ZTINSt3__1[0-9][0-9]*__ +# typeinfo name for std::__1::__types +__ZTSNSt3__1[0-9][0-9]*__ +# anything using __hidden_allocator +.*__hidden_allocator +# anything using __sso_allocator +.*__sso_allocator diff --git a/utils/sym_check/sym_check/__init__.py b/utils/sym_check/sym_check/__init__.py new file mode 100644 index 000000000000..3c668036e47c --- /dev/null +++ b/utils/sym_check/sym_check/__init__.py @@ -0,0 +1,8 @@ +"""libcxx abi symbol checker""" + +__author__ = 'Eric Fiselier' +__email__ = 'eric@efcs.ca' +__versioninfo__ = (0, 1, 0) +__version__ = ' '.join(str(v) for v in __versioninfo__) + 'dev' + +__all__ = ['diff', 'extract', 'util'] diff --git a/utils/sym_check/sym_check/diff.py b/utils/sym_check/sym_check/diff.py new file mode 100644 index 000000000000..a16e54d34e01 --- /dev/null +++ b/utils/sym_check/sym_check/diff.py @@ -0,0 +1,93 @@ +# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: +""" +diff - A set of functions for diff-ing two symbol lists. +""" + +from sym_check import util + + +def _symbol_difference(lhs, rhs): + lhs_names = set((n['name'] for n in lhs)) + rhs_names = set((n['name'] for n in rhs)) + diff_names = lhs_names - rhs_names + return [n for n in lhs if n['name'] in diff_names] + + +def _find_by_key(sym_list, k): + for sym in sym_list: + if sym['name'] == k: + return sym + return None + + +def added_symbols(old, new): + return _symbol_difference(new, old) + + +def removed_symbols(old, new): + return _symbol_difference(old, new) + + +def changed_symbols(old, new): + changed = [] + for old_sym in old: + if old_sym in new: + continue + new_sym = _find_by_key(new, old_sym['name']) + if (new_sym is not None and not new_sym in old + and cmp(old_sym, new_sym) != 0): + changed += [(old_sym, new_sym)] + return changed + + +def diff(old, new): + added = added_symbols(old, new) + removed = removed_symbols(old, new) + changed = changed_symbols(old, new) + return added, removed, changed + + +def report_diff(added_syms, removed_syms, changed_syms, names_only=False, + demangle=True): + def maybe_demangle(name): + return util.demangle_symbol(name) if demangle else name + + report = '' + for sym in added_syms: + report += 'Symbol added: %s\n' % maybe_demangle(sym['name']) + if not names_only: + report += ' %s\n\n' % sym + if added_syms and names_only: + report += '\n' + for sym in removed_syms: + report += 'SYMBOL REMOVED: %s\n' % maybe_demangle(sym['name']) + if not names_only: + report += ' %s\n\n' % sym + if removed_syms and names_only: + report += '\n' + if not names_only: + for sym_pair in changed_syms: + old_sym, new_sym = sym_pair + old_str = '\n OLD SYMBOL: %s' % old_sym + new_str = '\n NEW SYMBOL: %s' % new_sym + report += ('SYMBOL CHANGED: %s%s%s\n\n' % + (maybe_demangle(old_sym['name']), + old_str, new_str)) + + added = bool(len(added_syms) != 0) + abi_break = bool(len(removed_syms)) + if not names_only: + abi_break = abi_break or len(changed_syms) + if added or abi_break: + report += 'Summary\n' + report += ' Added: %d\n' % len(added_syms) + report += ' Removed: %d\n' % len(removed_syms) + if not names_only: + report += ' Changed: %d\n' % len(changed_syms) + if not abi_break: + report += 'Symbols added.' + else: + report += 'ABI BREAKAGE: SYMBOLS ADDED OR REMOVED!' + else: + report += 'Symbols match.' + return report, int(abi_break) diff --git a/utils/sym_check/sym_check/extract.py b/utils/sym_check/sym_check/extract.py new file mode 100644 index 000000000000..b4f4cee2dc55 --- /dev/null +++ b/utils/sym_check/sym_check/extract.py @@ -0,0 +1,177 @@ +# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: +""" +extract - A set of function that extract symbol lists from shared libraries. +""" +import distutils.spawn +import sys + +from sym_check import util + + +class NMExtractor(object): + """ + NMExtractor - Extract symbol lists from libraries using nm. + """ + + @staticmethod + def find_tool(): + """ + Search for the nm executable and return the path. + """ + return distutils.spawn.find_executable('nm') + + def __init__(self): + """ + Initialize the nm executable and flags that will be used to extract + symbols from shared libraries. + """ + self.nm_exe = self.find_tool() + if self.nm_exe is None: + # ERROR no NM found + print("ERROR: Could not find nm") + sys.exit(1) + self.flags = ['-P', '-g'] + + def extract(self, lib): + """ + Extract symbols from a library and return the results as a dict of + parsed symbols. + """ + cmd = [self.nm_exe] + self.flags + [lib] + out, _, exit_code = util.execute_command_verbose(cmd) + if exit_code != 0: + raise RuntimeError('Failed to run %s on %s' % (self.nm_exe, lib)) + fmt_syms = (self._extract_sym(l) + for l in out.splitlines() if l.strip()) + # Cast symbol to string. + final_syms = (repr(s) for s in fmt_syms if self._want_sym(s)) + # Make unique and sort strings. + tmp_list = list(sorted(set(final_syms))) + # Cast string back to symbol. + return util.read_syms_from_list(tmp_list) + + def _extract_sym(self, sym_str): + bits = sym_str.split() + # Everything we want has at least two columns. + if len(bits) < 2: + return None + new_sym = { + 'name': bits[0], + 'type': bits[1] + } + new_sym['name'] = new_sym['name'].replace('@@', '@') + new_sym = self._transform_sym_type(new_sym) + # NM types which we want to save the size for. + if new_sym['type'] == 'OBJECT' and len(bits) > 3: + new_sym['size'] = int(bits[3], 16) + return new_sym + + @staticmethod + def _want_sym(sym): + """ + Check that s is a valid symbol that we want to keep. + """ + if sym is None or len(sym) < 2: + return False + bad_types = ['t', 'b', 'r', 'd', 'w'] + return (sym['type'] not in bad_types + and sym['name'] not in ['__bss_start', '_end', '_edata']) + + @staticmethod + def _transform_sym_type(sym): + """ + Map the nm single letter output for type to either FUNC or OBJECT. + If the type is not recognized it is left unchanged. + """ + func_types = ['T', 'W'] + obj_types = ['B', 'D', 'R', 'V', 'S'] + if sym['type'] in func_types: + sym['type'] = 'FUNC' + elif sym['type'] in obj_types: + sym['type'] = 'OBJECT' + return sym + +class ReadElfExtractor(object): + """ + ReadElfExtractor - Extract symbol lists from libraries using readelf. + """ + + @staticmethod + def find_tool(): + """ + Search for the readelf executable and return the path. + """ + return distutils.spawn.find_executable('readelf') + + def __init__(self): + """ + Initialize the readelf executable and flags that will be used to + extract symbols from shared libraries. + """ + self.tool = self.find_tool() + if self.tool is None: + # ERROR no NM found + print("ERROR: Could not find readelf") + sys.exit(1) + self.flags = ['--wide', '--symbols'] + + def extract(self, lib): + """ + Extract symbols from a library and return the results as a dict of + parsed symbols. + """ + cmd = [self.tool] + self.flags + [lib] + out, _, exit_code = util.execute_command_verbose(cmd) + if exit_code != 0: + raise RuntimeError('Failed to run %s on %s' % (self.nm_exe, lib)) + dyn_syms = self.get_dynsym_table(out) + return self.process_syms(dyn_syms) + + def process_syms(self, sym_list): + new_syms = [] + for s in sym_list: + parts = s.split() + if not parts: + continue + assert len(parts) == 7 or len(parts) == 8 or len(parts) == 9 + if len(parts) == 7: + continue + new_sym = { + 'name': parts[7], + 'size': int(parts[2]), + 'type': parts[3], + } + assert new_sym['type'] in ['OBJECT', 'FUNC', 'NOTYPE'] + if new_sym['type'] == 'NOTYPE': + continue + if new_sym['type'] == 'FUNC': + del new_sym['size'] + new_syms += [new_sym] + return new_syms + + def get_dynsym_table(self, out): + lines = out.splitlines() + start = -1 + end = -1 + for i in range(len(lines)): + if lines[i].startswith("Symbol table '.dynsym'"): + start = i + 2 + if start != -1 and end == -1 and not lines[i].strip(): + end = i + 1 + assert start != -1 + if end == -1: + end = len(lines) + return lines[start:end] + + +def extract_symbols(lib_file): + """ + Extract and return a list of symbols extracted from a dynamic library. + The symbols are extracted using NM. They are then filtered and formated. + Finally they symbols are made unique. + """ + if ReadElfExtractor.find_tool(): + extractor = ReadElfExtractor() + else: + extractor = NMExtractor() + return extractor.extract(lib_file) diff --git a/utils/sym_check/sym_check/match.py b/utils/sym_check/sym_check/match.py new file mode 100644 index 000000000000..9f496427e372 --- /dev/null +++ b/utils/sym_check/sym_check/match.py @@ -0,0 +1,32 @@ +# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: +""" +match - A set of functions for matching symbols in a list to a list of regexs +""" + +import re + + +def find_and_report_matching(symbol_list, regex_list): + report = '' + found_count = 0 + for regex_str in regex_list: + report += 'Matching regex "%s":\n' % regex_str + matching_list = find_matching_symbols(symbol_list, regex_str) + if not matching_list: + report += ' No matches found\n\n' + continue + # else + found_count += len(matching_list) + for m in matching_list: + report += ' MATCHES: %s\n' % m['name'] + report += '\n' + return found_count, report + + +def find_matching_symbols(symbol_list, regex_str): + regex = re.compile(regex_str) + matching_list = [] + for s in symbol_list: + if regex.match(s['name']): + matching_list += [s] + return matching_list diff --git a/utils/sym_check/sym_check/util.py b/utils/sym_check/sym_check/util.py new file mode 100644 index 000000000000..1d3b424f6f30 --- /dev/null +++ b/utils/sym_check/sym_check/util.py @@ -0,0 +1,128 @@ +import ast +import distutils.spawn +import signal +import subprocess +import sys + + +def execute_command(cmd, input_str=None): + """ + Execute a command, capture and return its output. + """ + kwargs = { + 'stdin': subprocess.PIPE, + 'stdout': subprocess.PIPE, + 'stderr': subprocess.PIPE, + } + p = subprocess.Popen(cmd, **kwargs) + out, err = p.communicate(input=input_str) + exitCode = p.wait() + if exitCode == -signal.SIGINT: + raise KeyboardInterrupt + return out, err, exitCode + + +def execute_command_verbose(cmd, input_str=None): + """ + Execute a command and print its output on failure. + """ + out, err, exitCode = execute_command(cmd, input_str=input_str) + if exitCode != 0: + report = "Command: %s\n" % ' '.join(["'%s'" % a for a in cmd]) + report += "Exit Code: %d\n" % exitCode + if out: + report += "Standard Output:\n--\n%s--" % out + if err: + report += "Standard Error:\n--\n%s--" % err + report += "\n\nFailed!" + sys.stderr.write('%s\n' % report) + return out, err, exitCode + + +def read_syms_from_list(slist): + """ + Read a list of symbols from a list of strings. + Each string is one symbol. + """ + return [ast.literal_eval(l) for l in slist] + + +def read_syms_from_file(filename): + """ + Read a list of symbols in from a file. + """ + with open(filename, 'r') as f: + data = f.read() + return read_syms_from_list(data.splitlines()) + + +def read_blacklist(filename): + with open(filename, 'r') as f: + data = f.read() + lines = [l.strip() for l in data.splitlines() if l.strip()] + lines = [l for l in lines if not l.startswith('#')] + return lines + + +def write_syms(sym_list, out=None, names_only=False): + """ + Write a list of symbols to the file named by out. + """ + out_str = '' + out_list = sym_list + if names_only: + out_list = [sym['name'] for sym in sym_list] + out_list.sort() + for sym in out_list: + out_str += '%s\n' % sym + if out is None: + sys.stdout.write(out_str) + else: + with open(out, 'w') as f: + f.write(out_str) + + +_cppfilt_exe = distutils.spawn.find_executable('c++filt') + + +def demangle_symbol(symbol): + if _cppfilt_exe is None: + return symbol + out, _, exit_code = execute_command_verbose( + [_cppfilt_exe], input_str=symbol) + if exit_code != 0: + return symbol + return out + + +def is_elf(filename): + with open(filename, 'r') as f: + magic_bytes = f.read(4) + return magic_bytes == '\x7fELF' + + +def is_mach_o(filename): + with open(filename, 'r') as f: + magic_bytes = f.read(4) + return magic_bytes in [ + '\xfe\xed\xfa\xce', # MH_MAGIC + '\xce\xfa\xed\xfe', # MH_CIGAM + '\xfe\xed\xfa\xcf', # MH_MAGIC_64 + '\xcf\xfa\xed\xfe', # MH_CIGAM_64 + '\xca\xfe\xba\xbe', # FAT_MAGIC + '\xbe\xba\xfe\xca' # FAT_CIGAM + ] + + +def is_library_file(filename): + if sys.platform == 'darwin': + return is_mach_o(filename) + else: + return is_elf(filename) + + +def extract_or_load(filename): + import sym_check.extract + if is_library_file(filename): + return sym_check.extract.extract_symbols(filename) + return read_syms_from_file(filename) diff --git a/utils/sym_check/sym_diff.py b/utils/sym_check/sym_diff.py new file mode 100755 index 000000000000..054c6c18e3e3 --- /dev/null +++ b/utils/sym_check/sym_diff.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +""" +sym_diff - Compare two symbol lists and output the differences. +""" +from argparse import ArgumentParser +import sys +from sym_check import diff, util + + +def main(): + parser = ArgumentParser( + description='Extract a list of symbols from a shared library.') + parser.add_argument( + '--names-only', dest='names_only', + help='Only print symbol names', + action='store_true', default=False) + parser.add_argument( + '-o', '--output', dest='output', + help='The output file. stdout is used if not given', + type=str, action='store', default=None) + parser.add_argument( + '--demangle', dest='demangle', action='store_true', default=False) + parser.add_argument( + 'old_syms', metavar='old-syms', type=str, + help='The file containing the old symbol list or a library') + parser.add_argument( + 'new_syms', metavar='new-syms', type=str, + help='The file containing the new symbol list or a library') + args = parser.parse_args() + + old_syms_list = util.extract_or_load(args.old_syms) + new_syms_list = util.extract_or_load(args.new_syms) + + added, removed, changed = diff.diff(old_syms_list, new_syms_list) + report, is_break = diff.report_diff(added, removed, changed, + names_only=args.names_only, + demangle=args.demangle) + if args.output is None: + print(report) + else: + with open(args.output, 'w') as f: + f.write(report + '\n') + sys.exit(is_break) + + +if __name__ == '__main__': + main() diff --git a/utils/sym_check/sym_extract.py b/utils/sym_check/sym_extract.py new file mode 100755 index 000000000000..5d8953986b28 --- /dev/null +++ b/utils/sym_check/sym_extract.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +""" +sym_extract - Extract and output a list of symbols from a shared library. +""" +from argparse import ArgumentParser +from sym_check import extract, util + + +def main(): + parser = ArgumentParser( + description='Extract a list of symbols from a shared library.') + parser.add_argument('library', metavar='shared-lib', type=str, + help='The library to extract symbols from') + parser.add_argument('-o', '--output', dest='output', + help='The output file. stdout is used if not given', + type=str, action='store', default=None) + parser.add_argument('--names-only', dest='names_only', + help='Output only the name of the symbol', + action='store_true', default=False) + args = parser.parse_args() + if args.output is not None: + print('Extracting symbols from %s to %s.' + % (args.library, args.output)) + syms = extract.extract_symbols(args.library) + util.write_syms(syms, out=args.output, names_only=args.names_only) + + +if __name__ == '__main__': + main() diff --git a/utils/sym_check/sym_match.py b/utils/sym_check/sym_match.py new file mode 100755 index 000000000000..c60b24629353 --- /dev/null +++ b/utils/sym_check/sym_match.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +""" +sym_match - Match all symbols in a list against a list of regexes. +""" +from argparse import ArgumentParser +import sys +from sym_check import util, match, extract + + +def main(): + parser = ArgumentParser( + description='Extract a list of symbols from a shared library.') + parser.add_argument( + '--blacklist', dest='blacklist', + type=str, action='store', default=None) + parser.add_argument( + 'symbol_list', metavar='symbol_list', type=str, + help='The file containing the old symbol list') + parser.add_argument( + 'regexes', metavar='regexes', default=[], nargs='*', + help='The file containing the new symbol list or a library') + args = parser.parse_args() + + if not args.regexes and args.blacklist is None: + sys.stderr.write('Either a regex or a blacklist must be specified.\n') + sys.exit(1) + if args.blacklist: + search_list = util.read_blacklist(args.blacklist) + else: + search_list = args.regexes + + symbol_list = util.extract_or_load(args.symbol_list) + + matching_count, report = match.find_and_report_matching( + symbol_list, search_list) + sys.stdout.write(report) + if matching_count != 0: + print('%d matching symbols found...' % matching_count) + + +if __name__ == '__main__': + main() diff --git a/www/atomic_design.html b/www/atomic_design.html new file mode 100644 index 000000000000..67021b8736e6 --- /dev/null +++ b/www/atomic_design.html @@ -0,0 +1,92 @@ + + + + + + <atomic> design + + + + + +

+ +
+ +

<atomic> design

+ + +

+There are currently 3 designs under consideration. They differ in where most +of the implementation work is done. The functionality exposed to the customer +should be identical (and conforming) for all three designs. +

+ +
    +
  1. +Minimal work for the library +
  2. +
  3. +Something in between +
  4. +
  5. +Minimal work for the front end +
  6. +
+ +

+With any design, the (back end) compiler writer should note: +

+ +
+

+The decision to implement lock-free operations on any given type (or not) is an +ABI-binding decision. One can not change from treating a type as not lock free, +to lock free (or vice-versa) without breaking your ABI. +

+ +

+Example: +

+ +
+TU1.cc
+-----------
+extern atomic<long long> A;
+int foo() { return A.compare_exchange_strong(w, x); }
+
+TU2.cc
+-----------
+extern atomic<long long> A;
+void bar() { return A.compare_exchange_strong(y, z); }
+
+
+ +

+If only one of these calls to compare_exchange_strong is +implemented with mutex-locked code, then that mutex-locked code will not be +executed mutually exclusively of the one implemented in a lock-free manner. +

+ +
+ + diff --git a/www/atomic_design_a.html b/www/atomic_design_a.html new file mode 100644 index 000000000000..8e9fef23f7ea --- /dev/null +++ b/www/atomic_design_a.html @@ -0,0 +1,309 @@ + + + + + + <atomic> design + + + + + + + +
+ +

<atomic> design

+ + +

+The compiler supplies all of the intrinsics as described below. This list of +intrinsics roughly parallels the requirements of the C and C++ atomics +proposals. The C and C++ library implementations simply drop through to these +intrinsics. Anything the platform does not support in hardware, the compiler +arranges for a (compiler-rt) library call to be made which will do the job with +a mutex, and in this case ignoring the memory ordering parameter (effectively +implementing memory_order_seq_cst). +

+ +

+Ultimate efficiency is preferred over run time error checking. Undefined +behavior is acceptable when the inputs do not conform as defined below. +

+ +
+// In every intrinsic signature below, type* atomic_obj may be a pointer to a
+//    volatile-qualified type.
+// Memory ordering values map to the following meanings:
+//   memory_order_relaxed == 0
+//   memory_order_consume == 1
+//   memory_order_acquire == 2
+//   memory_order_release == 3
+//   memory_order_acq_rel == 4
+//   memory_order_seq_cst == 5
+
+// type must be trivially copyable
+// type represents a "type argument"
+bool __atomic_is_lock_free(type);
+
+// type must be trivially copyable
+// Behavior is defined for mem_ord = 0, 1, 2, 5
+type __atomic_load(const type* atomic_obj, int mem_ord);
+
+// type must be trivially copyable
+// Behavior is defined for mem_ord = 0, 3, 5
+void __atomic_store(type* atomic_obj, type desired, int mem_ord);
+
+// type must be trivially copyable
+// Behavior is defined for mem_ord = [0 ... 5]
+type __atomic_exchange(type* atomic_obj, type desired, int mem_ord);
+
+// type must be trivially copyable
+// Behavior is defined for mem_success = [0 ... 5],
+//   mem_failure <= mem_success
+//   mem_failure != 3
+//   mem_failure != 4
+bool __atomic_compare_exchange_strong(type* atomic_obj,
+                                      type* expected, type desired,
+                                      int mem_success, int mem_failure);
+
+// type must be trivially copyable
+// Behavior is defined for mem_success = [0 ... 5],
+//   mem_failure <= mem_success
+//   mem_failure != 3
+//   mem_failure != 4
+bool __atomic_compare_exchange_weak(type* atomic_obj,
+                                    type* expected, type desired,
+                                    int mem_success, int mem_failure);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+// Behavior is defined for mem_ord = [0 ... 5]
+type __atomic_fetch_add(type* atomic_obj, type operand, int mem_ord);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+// Behavior is defined for mem_ord = [0 ... 5]
+type __atomic_fetch_sub(type* atomic_obj, type operand, int mem_ord);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+// Behavior is defined for mem_ord = [0 ... 5]
+type __atomic_fetch_and(type* atomic_obj, type operand, int mem_ord);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+// Behavior is defined for mem_ord = [0 ... 5]
+type __atomic_fetch_or(type* atomic_obj, type operand, int mem_ord);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+// Behavior is defined for mem_ord = [0 ... 5]
+type __atomic_fetch_xor(type* atomic_obj, type operand, int mem_ord);
+
+// Behavior is defined for mem_ord = [0 ... 5]
+void* __atomic_fetch_add(void** atomic_obj, ptrdiff_t operand, int mem_ord);
+void* __atomic_fetch_sub(void** atomic_obj, ptrdiff_t operand, int mem_ord);
+
+// Behavior is defined for mem_ord = [0 ... 5]
+void __atomic_thread_fence(int mem_ord);
+void __atomic_signal_fence(int mem_ord);
+
+ +

+If desired the intrinsics taking a single mem_ord parameter can default +this argument to 5. +

+ +

+If desired the intrinsics taking two ordering parameters can default +mem_success to 5, and mem_failure to +translate_memory_order(mem_success) where +translate_memory_order(mem_success) is defined as: +

+ +
+int
+translate_memory_order(int o)
+{
+    switch (o)
+    {
+    case 4:
+        return 2;
+    case 3:
+        return 0;
+    }
+    return o;
+}
+
+ +

+Below are representative C++ implementations of all of the operations. Their +purpose is to document the desired semantics of each operation, assuming +memory_order_seq_cst. This is essentially the code that will be called +if the front end calls out to compiler-rt. +

+ +
+template <class T>
+T
+__atomic_load(T const volatile* obj)
+{
+    unique_lock<mutex> _(some_mutex);
+    return *obj;
+}
+
+template <class T>
+void
+__atomic_store(T volatile* obj, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    *obj = desr;
+}
+
+template <class T>
+T
+__atomic_exchange(T volatile* obj, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj = desr;
+    return r;
+}
+
+template <class T>
+bool
+__atomic_compare_exchange_strong(T volatile* obj, T* exp, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    if (std::memcmp(const_cast<T*>(obj), exp, sizeof(T)) == 0) // if (*obj == *exp)
+    {
+        std::memcpy(const_cast<T*>(obj), &desr, sizeof(T)); // *obj = desr;
+        return true;
+    }
+    std::memcpy(exp, const_cast<T*>(obj), sizeof(T)); // *exp = *obj;
+    return false;
+}
+
+// May spuriously return false (even if *obj == *exp)
+template <class T>
+bool
+__atomic_compare_exchange_weak(T volatile* obj, T* exp, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    if (std::memcmp(const_cast<T*>(obj), exp, sizeof(T)) == 0) // if (*obj == *exp)
+    {
+        std::memcpy(const_cast<T*>(obj), &desr, sizeof(T)); // *obj = desr;
+        return true;
+    }
+    std::memcpy(exp, const_cast<T*>(obj), sizeof(T)); // *exp = *obj;
+    return false;
+}
+
+template <class T>
+T
+__atomic_fetch_add(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj += operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_sub(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj -= operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_and(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj &= operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_or(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj |= operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_xor(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj ^= operand;
+    return r;
+}
+
+void*
+__atomic_fetch_add(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    void* r = *obj;
+    (char*&)(*obj) += operand;
+    return r;
+}
+
+void*
+__atomic_fetch_sub(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    void* r = *obj;
+    (char*&)(*obj) -= operand;
+    return r;
+}
+
+void __atomic_thread_fence()
+{
+    unique_lock<mutex> _(some_mutex);
+}
+
+void __atomic_signal_fence()
+{
+    unique_lock<mutex> _(some_mutex);
+}
+
+ + +
+ + diff --git a/www/atomic_design_b.html b/www/atomic_design_b.html new file mode 100644 index 000000000000..17ba9b3c1e37 --- /dev/null +++ b/www/atomic_design_b.html @@ -0,0 +1,250 @@ + + + + + + <atomic> design + + + + + + + +
+ +

<atomic> design

+ + +

+This is a variation of design A which puts the burden on the library to arrange +for the correct manipulation of the run time memory ordering arguments, and only +calls the compiler for well-defined memory orderings. I think of this design as +the worst of A and C, instead of the best of A and C. But I offer it as an +option in the spirit of completeness. +

+ +
+// type must be trivially copyable
+bool __atomic_is_lock_free(const type* atomic_obj);
+
+// type must be trivially copyable
+type __atomic_load_relaxed(const volatile type* atomic_obj);
+type __atomic_load_consume(const volatile type* atomic_obj);
+type __atomic_load_acquire(const volatile type* atomic_obj);
+type __atomic_load_seq_cst(const volatile type* atomic_obj);
+
+// type must be trivially copyable
+type __atomic_store_relaxed(volatile type* atomic_obj, type desired);
+type __atomic_store_release(volatile type* atomic_obj, type desired);
+type __atomic_store_seq_cst(volatile type* atomic_obj, type desired);
+
+// type must be trivially copyable
+type __atomic_exchange_relaxed(volatile type* atomic_obj, type desired);
+type __atomic_exchange_consume(volatile type* atomic_obj, type desired);
+type __atomic_exchange_acquire(volatile type* atomic_obj, type desired);
+type __atomic_exchange_release(volatile type* atomic_obj, type desired);
+type __atomic_exchange_acq_rel(volatile type* atomic_obj, type desired);
+type __atomic_exchange_seq_cst(volatile type* atomic_obj, type desired);
+
+// type must be trivially copyable
+bool __atomic_compare_exchange_strong_relaxed_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_consume_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_consume_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acquire_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acquire_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acquire_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_release_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_release_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_release_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acq_rel_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acq_rel_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acq_rel_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_seq_cst(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+
+// type must be trivially copyable
+bool __atomic_compare_exchange_weak_relaxed_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_consume_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_consume_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acquire_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acquire_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acquire_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_release_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_release_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_release_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acq_rel_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acq_rel_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acq_rel_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_seq_cst(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+type __atomic_fetch_add_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_seq_cst(volatile type* atomic_obj, type operand);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+type __atomic_fetch_sub_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_seq_cst(volatile type* atomic_obj, type operand);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+type __atomic_fetch_and_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_seq_cst(volatile type* atomic_obj, type operand);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+type __atomic_fetch_or_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_seq_cst(volatile type* atomic_obj, type operand);
+
+// type is one of: char, signed char, unsigned char, short, unsigned short, int,
+//      unsigned int, long, unsigned long, long long, unsigned long long,
+//      char16_t, char32_t, wchar_t
+type __atomic_fetch_xor_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_seq_cst(volatile type* atomic_obj, type operand);
+
+void* __atomic_fetch_add_relaxed(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_consume(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_acquire(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_release(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand);
+
+void* __atomic_fetch_sub_relaxed(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_consume(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_acquire(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_release(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand);
+
+void __atomic_thread_fence_relaxed();
+void __atomic_thread_fence_consume();
+void __atomic_thread_fence_acquire();
+void __atomic_thread_fence_release();
+void __atomic_thread_fence_acq_rel();
+void __atomic_thread_fence_seq_cst();
+
+void __atomic_signal_fence_relaxed();
+void __atomic_signal_fence_consume();
+void __atomic_signal_fence_acquire();
+void __atomic_signal_fence_release();
+void __atomic_signal_fence_acq_rel();
+void __atomic_signal_fence_seq_cst();
+
+ +
+ + diff --git a/www/atomic_design_c.html b/www/atomic_design_c.html new file mode 100644 index 000000000000..9c92b8847045 --- /dev/null +++ b/www/atomic_design_c.html @@ -0,0 +1,458 @@ + + + + + + <atomic> design + + + + + + + +
+ +

<atomic> design

+ + +

+The <atomic> header is one of the most closely coupled headers to +the compiler. Ideally when you invoke any function from +<atomic>, it should result in highly optimized assembly being +inserted directly into your application ... assembly that is not otherwise +representable by higher level C or C++ expressions. The design of the libc++ +<atomic> header started with this goal in mind. A secondary, but +still very important goal is that the compiler should have to do minimal work to +facilitate the implementation of <atomic>. Without this second +goal, then practically speaking, the libc++ <atomic> header would +be doomed to be a barely supported, second class citizen on almost every +platform. +

+ +

Goals:

+ +
    +
  • Optimal code generation for atomic operations
  • +
  • Minimal effort for the compiler to achieve goal 1 on any given platform
  • +
  • Conformance to the C++0X draft standard
  • +
+ +

+The purpose of this document is to inform compiler writers what they need to do +to enable a high performance libc++ <atomic> with minimal effort. +

+ +

The minimal work that must be done for a conforming <atomic>

+ +

+The only "atomic" operations that must actually be lock free in +<atomic> are represented by the following compiler intrinsics: +

+ +
+__atomic_flag__
+__atomic_exchange_seq_cst(__atomic_flag__ volatile* obj, __atomic_flag__ desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    __atomic_flag__ result = *obj;
+    *obj = desr;
+    return result;
+}
+
+void
+__atomic_store_seq_cst(__atomic_flag__ volatile* obj, __atomic_flag__ desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    *obj = desr;
+}
+
+ +

+Where: +

+ +
    +
  • +If __has_feature(__atomic_flag) evaluates to 1 in the preprocessor then +the compiler must define __atomic_flag__ (e.g. as a typedef to +int). +
  • +
  • +If __has_feature(__atomic_flag) evaluates to 0 in the preprocessor then +the library defines __atomic_flag__ as a typedef to bool. +
  • +
  • +

    +To communicate that the above intrinsics are available, the compiler must +arrange for __has_feature to return 1 when fed the intrinsic name +appended with an '_' and the mangled type name of __atomic_flag__. +

    +

    +For example if __atomic_flag__ is unsigned int: +

    +
    +__has_feature(__atomic_flag) == 1
    +__has_feature(__atomic_exchange_seq_cst_j) == 1
    +__has_feature(__atomic_store_seq_cst_j) == 1
    +
    +typedef unsigned int __atomic_flag__; 
    +
    +unsigned int __atomic_exchange_seq_cst(unsigned int volatile*, unsigned int)
    +{
    +   // ...
    +}
    +
    +void __atomic_store_seq_cst(unsigned int volatile*, unsigned int)
    +{
    +   // ...
    +}
    +
    +
  • +
+ +

+That's it! Compiler writers do the above and you've got a fully conforming +(though sub-par performance) <atomic> header! +

+ +

Recommended work for a higher performance <atomic>

+ +

+It would be good if the above intrinsics worked with all integral types plus +void*. Because this may not be possible to do in a lock-free manner for +all integral types on all platforms, a compiler must communicate each type that +an intrinsic works with. For example if __atomic_exchange_seq_cst works +for all types except for long long and unsigned long long +then: +

+ +
+__has_feature(__atomic_exchange_seq_cst_b) == 1  // bool
+__has_feature(__atomic_exchange_seq_cst_c) == 1  // char
+__has_feature(__atomic_exchange_seq_cst_a) == 1  // signed char
+__has_feature(__atomic_exchange_seq_cst_h) == 1  // unsigned char
+__has_feature(__atomic_exchange_seq_cst_Ds) == 1 // char16_t
+__has_feature(__atomic_exchange_seq_cst_Di) == 1 // char32_t
+__has_feature(__atomic_exchange_seq_cst_w) == 1  // wchar_t
+__has_feature(__atomic_exchange_seq_cst_s) == 1  // short
+__has_feature(__atomic_exchange_seq_cst_t) == 1  // unsigned short
+__has_feature(__atomic_exchange_seq_cst_i) == 1  // int
+__has_feature(__atomic_exchange_seq_cst_j) == 1  // unsigned int
+__has_feature(__atomic_exchange_seq_cst_l) == 1  // long
+__has_feature(__atomic_exchange_seq_cst_m) == 1  // unsigned long
+__has_feature(__atomic_exchange_seq_cst_Pv) == 1 // void*
+
+ +

+Note that only the __has_feature flag is decorated with the argument +type. The name of the compiler intrinsic is not decorated, but instead works +like a C++ overloaded function. +

+ +

+Additionally there are other intrinsics besides +__atomic_exchange_seq_cst and __atomic_store_seq_cst. They +are optional. But if the compiler can generate faster code than provided by the +library, then clients will benefit from the compiler writer's expertise and +knowledge of the targeted platform. +

+ +

+Below is the complete list of sequentially consistent intrinsics, and +their library implementations. Template syntax is used to indicate the desired +overloading for integral and void* types. The template does not represent a +requirement that the intrinsic operate on any type! +

+ +
+T is one of:  bool, char, signed char, unsigned char, short, unsigned short,
+              int, unsigned int, long, unsigned long,
+              long long, unsigned long long, char16_t, char32_t, wchar_t, void*
+
+template <class T>
+T
+__atomic_load_seq_cst(T const volatile* obj)
+{
+    unique_lock<mutex> _(some_mutex);
+    return *obj;
+}
+
+template <class T>
+void
+__atomic_store_seq_cst(T volatile* obj, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    *obj = desr;
+}
+
+template <class T>
+T
+__atomic_exchange_seq_cst(T volatile* obj, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj = desr;
+    return r;
+}
+
+template <class T>
+bool
+__atomic_compare_exchange_strong_seq_cst_seq_cst(T volatile* obj, T* exp, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    if (std::memcmp(const_cast<T*>(obj), exp, sizeof(T)) == 0)
+    {
+        std::memcpy(const_cast<T*>(obj), &desr, sizeof(T));
+        return true;
+    }
+    std::memcpy(exp, const_cast<T*>(obj), sizeof(T));
+    return false;
+}
+
+template <class T>
+bool
+__atomic_compare_exchange_weak_seq_cst_seq_cst(T volatile* obj, T* exp, T desr)
+{
+    unique_lock<mutex> _(some_mutex);
+    if (std::memcmp(const_cast<T*>(obj), exp, sizeof(T)) == 0)
+    {
+        std::memcpy(const_cast<T*>(obj), &desr, sizeof(T));
+        return true;
+    }
+    std::memcpy(exp, const_cast<T*>(obj), sizeof(T));
+    return false;
+}
+
+T is one of:  char, signed char, unsigned char, short, unsigned short,
+              int, unsigned int, long, unsigned long,
+              long long, unsigned long long, char16_t, char32_t, wchar_t
+
+template <class T>
+T
+__atomic_fetch_add_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj += operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_sub_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj -= operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_and_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj &= operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_or_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj |= operand;
+    return r;
+}
+
+template <class T>
+T
+__atomic_fetch_xor_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    T r = *obj;
+    *obj ^= operand;
+    return r;
+}
+
+void*
+__atomic_fetch_add_seq_cst(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    void* r = *obj;
+    (char*&)(*obj) += operand;
+    return r;
+}
+
+void*
+__atomic_fetch_sub_seq_cst(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock<mutex> _(some_mutex);
+    void* r = *obj;
+    (char*&)(*obj) -= operand;
+    return r;
+}
+
+void __atomic_thread_fence_seq_cst()
+{
+    unique_lock<mutex> _(some_mutex);
+}
+
+void __atomic_signal_fence_seq_cst()
+{
+    unique_lock<mutex> _(some_mutex);
+}
+
+ +

+One should consult the (currently draft) +C++ standard +for the details of the definitions for these operations. For example +__atomic_compare_exchange_weak_seq_cst_seq_cst is allowed to fail +spuriously while __atomic_compare_exchange_strong_seq_cst_seq_cst is +not. +

+ +

+If on your platform the lock-free definition of +__atomic_compare_exchange_weak_seq_cst_seq_cst would be the same as +__atomic_compare_exchange_strong_seq_cst_seq_cst, you may omit the +__atomic_compare_exchange_weak_seq_cst_seq_cst intrinsic without a +performance cost. The library will prefer your implementation of +__atomic_compare_exchange_strong_seq_cst_seq_cst over its own +definition for implementing +__atomic_compare_exchange_weak_seq_cst_seq_cst. That is, the library +will arrange for __atomic_compare_exchange_weak_seq_cst_seq_cst to call +__atomic_compare_exchange_strong_seq_cst_seq_cst if you supply an +intrinsic for the strong version but not the weak. +

+ +

Taking advantage of weaker memory synchronization

+ +

+So far all of the intrinsics presented require a sequentially +consistent memory ordering. That is, no loads or stores can move across +the operation (just as if the library had locked that internal mutex). But +<atomic> supports weaker memory ordering operations. In all, +there are six memory orderings (listed here from strongest to weakest): +

+ +
+memory_order_seq_cst
+memory_order_acq_rel
+memory_order_release
+memory_order_acquire
+memory_order_consume
+memory_order_relaxed
+
+ +

+(See the +C++ standard +for the detailed definitions of each of these orderings). +

+ +

+On some platforms, the compiler vendor can offer some or even all of the above +intrinsics at one or more weaker levels of memory synchronization. This might +lead for example to not issuing an mfence instruction on the x86. +

+ +

+If the compiler does not offer any given operation, at any given memory ordering +level, the library will automatically attempt to call the next highest memory +ordering operation. This continues up to seq_cst, and if that doesn't +exist, then the library takes over and does the job with a mutex. This +is a compile-time search & selection operation. At run time, the +application will only see the few inlined assembly instructions for the selected +intrinsic. +

+ +

+Each intrinsic is appended with the 7-letter name of the memory ordering it +addresses. For example a load with relaxed ordering is +defined by: +

+ +
+T __atomic_load_relaxed(const volatile T* obj);
+
+ +

+And announced with: +

+ +
+__has_feature(__atomic_load_relaxed_b) == 1  // bool
+__has_feature(__atomic_load_relaxed_c) == 1  // char
+__has_feature(__atomic_load_relaxed_a) == 1  // signed char
+...
+
+ +

+The __atomic_compare_exchange_strong(weak) intrinsics are parameterized +on two memory orderings. The first ordering applies when the operation returns +true and the second ordering applies when the operation returns +false. +

+ +

+Not every memory ordering is appropriate for every operation. exchange +and the fetch_op operations support all 6. But load +only supports relaxed, consume, acquire and seq_cst. +store +only supports relaxed, release, and seq_cst. The +compare_exchange operations support the following 16 combinations out +of the possible 36: +

+ +
+relaxed_relaxed
+consume_relaxed
+consume_consume
+acquire_relaxed
+acquire_consume
+acquire_acquire
+release_relaxed
+release_consume
+release_acquire
+acq_rel_relaxed
+acq_rel_consume
+acq_rel_acquire
+seq_cst_relaxed
+seq_cst_consume
+seq_cst_acquire
+seq_cst_seq_cst
+
+ +

+Again, the compiler supplies intrinsics only for the strongest orderings where +it can make a difference. The library takes care of calling the weakest +supplied intrinsic that is as strong or stronger than the customer asked for. +

+ +
+ + diff --git a/www/content.css b/www/content.css new file mode 100644 index 000000000000..dca6a3291436 --- /dev/null +++ b/www/content.css @@ -0,0 +1,27 @@ +html { margin: 0px; } body { margin: 8px; } + +html, body { + padding:0px; + font-size:small; font-family:"Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, Helvetica, sans-serif; background-color: #fff; color: #222; + line-height:1.5; +} + +h1, h2, h3, tt { color: #000 } + +h1 { padding-top:0px; margin-top:0px;} +h2 { color:#333333; padding-top:0.5em; } +h3 { padding-top: 0.5em; margin-bottom: -0.25em; color:#2d58b7} +li { padding-bottom: 0.5em; } +ul { padding-left:1.5em; } + +/* Slides */ +IMG.img_slide { + display: block; + margin-left: auto; + margin-right: auto +} + +.itemTitle { color:#2d58b7 } + +/* Tables */ +tr { vertical-align:top } diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html new file mode 100644 index 000000000000..2b9c05ae1e2f --- /dev/null +++ b/www/cxx1y_status.html @@ -0,0 +1,277 @@ + + + + + + libc++ C++1Y Status + + + + + + + +
+ +

libc++ C++1Y Status

+ + +

In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, known as "C++1Y" (probably to be C++14)

+

The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol)

+

This page shows the status of libc++; the status of clang's support of the language features is here.

+ +

The groups that have contributed papers: +

    +
  • CWG - Core Language Working group
  • +
  • LWG - Library working group
  • +
  • SG1 - Study group #1 (Concurrency working group)
  • +
+

+ +

Paper Status

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Paper #GroupPaper NameMeetingStatusFirst released version
3346LWGTerminology for Container Element Requirements - Rev 1KonaComplete3.4
3421LWGMaking Operator Functors greater<>PortlandComplete3.4
3462LWGstd::result_of and SFINAEPortlandComplete3.4
3469LWGConstexpr Library Additions: chrono, v3PortlandComplete3.4
3470LWGConstexpr Library Additions: containers, v2PortlandComplete3.4
3471LWGConstexpr Library Additions: utilities, v3PortlandComplete3.4
3302LWGConstexpr Library Additions: complex, v2PortlandComplete3.4
3545LWGAn Incremental Improvement to integral_constantBristolComplete3.4
3644LWGNull Forward IteratorsBristolComplete3.4
3668LWGstd::exchange()BristolComplete3.4
3658LWGCompile-time integer sequencesBristolComplete3.4
3670LWGAddressing Tuples by TypeBristolComplete3.4
3671LWGMaking non-modifying sequence operations more robustBristolComplete3.4
3656LWGmake_uniqueBristolComplete3.4
3654LWGQuoted StringsBristolComplete3.4
3642LWGUser-defined LiteralsBristolComplete3.4
3655LWGTransformationTraits Redux (excluding part 4)BristolComplete3.4
3657LWGAdding heterogeneous comparison lookup to associative containersBristolComplete3.4
3672LWGA proposal to add a utility class to represent optional objectsBristolRemoved from Draft Standardn/a
3669LWGFixing constexpr member functions without constBristolComplete3.4
3662LWGC++ Dynamic Arrays (dynarray)BristolRemoved from Draft Standardn/a
3659SG1Shared Locking in C++BristolComplete3.4
3779LWGUser-defined Literals for std::complexChicagoComplete3.4
3789LWGConstexpr Library Additions: functionalChicagoComplete3.4
3924LWGDiscouraging rand() in C++14IssaquahComplete3.5
3887LWGConsistent Metafunction AliasesIssaquahComplete3.5
3891SG1A proposal to rename shared_mutex to shared_timed_mutexIssaquahComplete3.5
+ +

Library Working group Issues Status

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Issue #Issue NameMeetingStatus
1214Insufficient/inconsistent key immutability requirements for associative containersKonaComplete
2009Reporting out-of-bound values on numeric string conversionsKonaComplete
2010is_* traits for binding operations can't be meaningfully specializedKonaComplete
2015Incorrect pre-conditions for some type traitsKonaComplete
2021Further incorrect usages of result_ofKonaComplete
2028messages_base::catalog overspecifiedKonaComplete
2033Preconditions of reserve, shrink_to_fit, and resize functionsKonaComplete
2039Issues with std::reverse and std::copy_ifKonaComplete
2044No definition of "Stable" for copy algorithmsKonaComplete
2045forward_list::merge and forward_list::splice_after with unequal allocatorsKonaComplete
2047Incorrect "mixed" move-assignment semantics of unique_ptrKonaComplete
2050Unordered associative containers do not use allocator_traits to define member typesKonaComplete
2053Errors in regex bitmask typesKonaComplete
2061make_move_iterator and arraysKonaComplete
2064More noexcept issues in basic_stringKonaComplete
2065Minimal allocator interfaceKonaComplete
2067packaged_task should have deleted copy c'tor with const parameterKonaComplete
2069Inconsistent exception spec for basic_string move constructorKonaComplete
2096Incorrect constraints of future::get in regard to MoveAssignableKonaComplete
2102Why is std::launch an implementation-defined type?KonaComplete
2071std::valarray move-assignmentPortlandComplete
2074Off by one error in std::reverse_copyPortlandComplete
2081Allocator requirements should include CopyConstructiblePortlandComplete
2083const-qualification on weak_ptr::owner_beforePortlandComplete
2086Overly generic type support for math functionsPortlandComplete
2099Unnecessary constraints of va_start() usagePortlandComplete
2103std::allocator_traits<std::allocator<T>>::propagate_on_container_move_assignmentPortlandComplete
2105Inconsistent requirements on const_iterator's value_typePortlandComplete
2110remove can't swap but note says it mightPortlandComplete
2123merge() allocator requirements for lists versus forward listsPortlandComplete
2005unordered_map::insert(T&&) protection should apply to map tooPortlandComplete
2011Unexpected output required of stringsPortlandComplete
2048Unnecessary mem_fn overloadsPortlandComplete
2049is_destructible is underspecifiedPortlandComplete
2056future_errc enums start with value 0 (invalid value for broken_promise)PortlandComplete
2058valarray and begin/endPortlandComplete
2091Misplaced effect in m.try_lock_for()BristolComplete
2092Vague Wording for condition_variable_anyBristolComplete
2093Throws clause of condition_variable::wait with predicateBristolComplete
2094duration conversion overflow shouldn't participate in overload resolutionBristolComplete
2122merge() stability for lists versus forward listsBristolComplete
2128Absence of global functions cbegin/cendBristolComplete
2145error_category default constructorBristolComplete
2147Unclear hint type in Allocator's allocate functionBristolComplete
2148Hashing enums should be supported directly by std::hashBristolComplete
2149Concerns about 20.8/5BristolComplete
2162allocator_traits::max_size missing noexceptBristolComplete
2163nth_element requires inconsistent post-conditionsBristolComplete
2169Missing reset() requirements in unique_ptr specializationBristolComplete
2172Does atomic_compare_exchange_* accept v == nullptr arguments?BristolComplete
2080Specify when once_flag becomes invalidBristolComplete
2098promise throws clausesBristolComplete
2109Incorrect requirements for hash specializationsBristolComplete
2130missing ordering constraints for fencesBristolComplete
2138atomic_flag::clear ordering constraintsBristolComplete
2140notify_all_at_thread_exit synchronizationBristolComplete
2144Missing noexcept specification in type_indexBristolComplete
2174wstring_convert::converted() should be noexceptBristolComplete
2175string_convert and wbuffer_convert validityBristolComplete
2176Special members for wstring_convert and wbuffer_convertBristolComplete
2177Requirements on Copy/MoveInsertableBristolComplete
2185Missing throws clause for future/shared_future::wait_for/wait_untilBristolComplete
2187vector<bool> is missing emplace and emplace_back member functionsBristolComplete
2190ordering of condition variable operations, reflects Posix discussionBristolComplete
2196Specification of is_*[copy/move]_[constructible/assignable] unclear for non-referencable typesBristolComplete
2197Specification of is_[un]signed unclear for non-arithmetic typesBristolComplete
2200Data race avoidance for all containers, not only for sequencesBristolComplete
2203scoped_allocator_adaptor uses wrong argument types for piecewise constructionBristolComplete
2207basic_string::at should not have a Requires clauseBristolComplete
2209assign() overspecified for sequence containersBristolComplete
2210Missing allocator-extended constructor for allocator-aware containersBristolComplete
2211Replace ambiguous use of "Allocator" in container requirementsBristolComplete
2222Inconsistency in description of forward_list::splice_after single-element overloadBristolComplete
2225Unrealistic header inclusion checks requiredBristolComplete
2229Standard code conversion facets underspecifiedBristolComplete
2231DR 704 removes complexity guarantee for clear()BristolComplete
2235Undefined behavior without proper requirements on basic_string constructorsBristolComplete
2141common_type trait produces reference typesChicagoComplete
2246unique_ptr assignment effects w.r.t. deleterChicagoComplete
2247Type traits and std::nullptr_tChicagoComplete
2085Wrong description of effect 1 of basic_istream::ignoreChicagoComplete
2087iostream_category() and noexceptChicagoComplete
2143ios_base::xalloc should be thread-safeChicagoComplete
2150Unclear specification of find_endChicagoComplete
2180Exceptions from std::seed_seq operationsChicagoComplete
2194Impossible container requirements for adaptor typesChicagoComplete
2013Do library implementers have the freedom to add constexpr?ChicagoComplete
2018regex_traits::isctype Returns clause is wrongChicagoComplete
2078Throw specification of async() incompleteChicagoComplete
2097packaged_task constructors should be constrainedChicagoComplete
2100Timed waiting functions cannot timeout if launch::async policy usedChicagoComplete
2120What should async do if neither 'async' nor 'deferred' is set in policy?ChicagoComplete
2159atomic_flag initializationChicagoComplete
2275Why is forward_as_tuple not constexpr?ChicagoComplete
2284Inconsistency in allocator_traits::max_sizeChicagoComplete
2298is_nothrow_constructible is always false because of create<>ChicagoComplete
2300Redundant sections for map and multimap members should be removedChicagoComplete
NB comment: GB9 Remove gets from C++14ChicagoComplete
2135Unclear requirement for exceptions thrown in condition_variable::wait()IssaquahComplete
2291std::hash is vulnerable to collision DoS attackIssaquahComplete
2142packaged_task::operator() synchronization too broad?IssaquahComplete
2240Probable misuse of term "function scope" in [thread.condition]IssaquahComplete
2252Strong guarantee on vector::push_back() still broken with C++11?IssaquahComplete
2257Simplify container requirements with the new algorithmsIssaquahComplete
2268Setting a default argument in the declaration of a member function assign of std::basic_stringIssaquahComplete
2271regex_traits::lookup_classname specification unclearIssaquahComplete
2272quoted should use char_traits::eq for character comparisonIssaquahComplete
2278User-defined literals for Standard Library typesIssaquahComplete
2280begin / end for arrays should be constexpr and noexceptIssaquahComplete
2285make_reverse_iteratorIssaquahComplete
2299Effects of inaccessible key_compare::is_transparent type are not clearIssaquahComplete
1450Contradiction in regex_constantsIssaquahComplete
2003String exception inconsistency in erase.IssaquahComplete
2112User-defined classes that cannot be derived fromIssaquahComplete
2132std::function ambiguityIssaquahComplete
2182Container::[const_]reference types are misleadingly specifiedIssaquahComplete
2188Reverse iterator does not fully support targets that overload operator&IssaquahComplete
2193Default constructors for standard library containers are explicitIssaquahComplete
2205Problematic postconditions of regex_match and regex_searchIssaquahComplete
2213Return value of std::regex_replaceIssaquahComplete
2258a.erase(q1, q2) unable to directly return q2IssaquahComplete
2263Comparing iterators and allocator pointers with different const-characterIssaquahComplete
2293Wrong facet used by num_put::do_putIssaquahComplete
2301Why is std::tie not constexpr?IssaquahComplete
2304Complexity of count in unordered associative containersIssaquahComplete
2306match_results::reference should be value_type&, not const value_type&IssaquahComplete
2308Clarify container destructor requirements w.r.t. std::arrayIssaquahComplete
2313tuple_size should always derive from integral_constantIssaquahComplete
2314apply() should return decltype(auto) and use decay_t before tuple_sizeIssaquahComplete
2315weak_ptr should be movableIssaquahComplete
2316weak_ptr::lock() should be atomicIssaquahComplete
2317The type property queries should be UnaryTypeTraits returning size_tIssaquahComplete
2320select_on_container_copy_construction() takes allocators, not containersIssaquahComplete
2322Associative(initializer_list, stuff) constructors are underspecifiedIssaquahComplete
2323vector::resize(n, t)'s specification should be simplifiedIssaquahComplete
2324Insert iterator constructors should use addressof()IssaquahComplete
2329regex_match()/regex_search() with match_results should forbid temporary stringsIssaquahComplete
2330regex("meow", regex::icase) is technically forbidden but should be permittedIssaquahComplete
2332regex_iterator/regex_token_iterator should forbid temporary regexesIssaquahComplete
2339Wording issue in nth_elementIssaquahComplete
2341Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir)IssaquahComplete
2344quoted()'s interaction with padding is unclearIssaquahComplete
2346integral_constant's member functions should be marked noexceptIssaquahComplete
2350min, max, and minmax should be constexprIssaquahComplete
2356Stability of erasure in unordered associative containersIssaquahComplete
2357Remaining "Assignable" requirementIssaquahComplete
2359How does regex_constants::nosubs affect basic_regex::mark_count()?IssaquahComplete
2360reverse_iterator::operator*() is unimplementableIssaquahComplete
2104unique_lock move-assignment should not be noexceptIssaquahComplete
2186Incomplete action on async/launch::deferredIssaquahComplete
2075Progress guarantees, lock-free property, and scheduling assumptionsIssaquahComplete
2288Inconsistent requirements for shared mutexesIssaquahComplete
+ +

Last Updated: 25-Mar-2014

+
+ + diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html new file mode 100644 index 000000000000..436981087d82 --- /dev/null +++ b/www/cxx1z_status.html @@ -0,0 +1,151 @@ + + + + + + libc++ C++1Z Status + + + + + + + +
+ +

libc++ C++1z Status

+ + +

In November 2014, the C++ standard committee created a draft for the next version of the C++ standard, known here as "C++1z" (probably to be C++17)

+

This page shows the status of libc++; the status of clang's support of the language features is here.

+ +

The groups that have contributed papers: +

    +
  • LWG - Library working group
  • +
  • CWG - Core Language Working group
  • +
  • SG1 - Study group #1 (Concurrency working group)
  • +
+

+ +

Paper Status

+ + + + + + + + + + + + + + + + + + + + + +
Paper #GroupPaper NameMeetingStatusFirst released version
N3911LWGTransformationTrait Alias void_t.UrbanaComplete3.6
N4089LWGSafe conversions in unique_ptr<T[]>.Urbana
N4169LWGA proposal to add invoke function templateUrbanaComplete3.7
N4190LWGRemoving auto_ptr, random_shuffle(), And Old Stuff.Urbana
N4258LWGCleaning-up noexcept in the Library.UrbanaIn progress3.7
N4259CWGWording for std::uncaught_exceptionsUrbanaComplete3.7
N4277LWGTriviallyCopyable reference_wrapper.UrbanaComplete3.2
N4279LWGImproved insertion interface for unique-key maps.UrbanaComplete3.7
N4280LWGNon-member size() and moreUrbanaComplete3.6
N4284LWGContiguous Iterators.UrbanaComplete3.6
N4285CWGCleanup for exception-specification and throw-expression.Urbana
N4387LWGimproving pair and tupleLenexa
N4389LWGbool_constantLenexaComplete3.7
N4508LWGshared_mutex for C++17LenexaComplete3.7
N4366LWGLWG 2228 missing SFINAE ruleLenexaComplete3.1
N4510LWGMinimal incomplete type support for standard containers, revision 4LenexaComplete3.6
+ +

Library Working group Issues Status

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Issue #Issue NameMeetingStatus
2016Allocators must be no-throw swappableUrbana
2118unique_ptr for array does not support cv qualification conversion of actual argumentUrbanaWill be resolved by N4089
2170Aggregates cannot be DefaultConstructibleUrbanaComplete
2308Clarify container destructor requirements w.r.t. std::arrayUrbanaComplete
2340Replacement allocation functions declared as inlineUrbanaComplete
2354Unnecessary copying when inserting into maps with braced-init syntaxUrbana
2377std::align requirements overly strictUrbanaComplete
2396underlying_type doesn't say what to do for an incomplete enumeration typeUrbanaComplete
2399shared_ptr's constructor from unique_ptr should be constrainedUrbanaComplete
2400shared_ptr's get_deleter() should use addressof()UrbanaComplete
2401std::function needs more noexceptUrbanaComplete
2404mismatch()'s complexity needs to be updatedUrbanaComplete
2408SFINAE-friendly common_type / iterator_traits is missing in C++14Urbanacommon_type is waiting on LWG#2465
2106move_iterator wrapping iterators returning prvaluesUrbana
2129User specializations of std::initializer_listUrbanaComplete
2212tuple_size for const pair request headerUrbanaComplete
2217operator==(sub_match, string) slices on embedded '\0'sUrbanaComplete
2230"see below" for initializer_list constructors of unordered containersUrbanaComplete
2233bad_function_call::what() unhelpfulUrbanaComplete
2266vector and deque have incorrect insert requirementsUrbanaComplete
2325minmax_element()'s behavior differing from max_element()'s should be notedUrbanaComplete
2361Apply 2299 resolution throughout libraryUrbana
2365Missing noexcept in shared_ptr::shared_ptr(nullptr_t)UrbanaComplete
2376bad_weak_ptr::what() overspecifiedUrbanaComplete
2387More nested types that must be accessible and unambiguousUrbanaComplete
2059C++0x ambiguity problem with map::eraseLenexaComplete
2063Contradictory requirements for string move assignmentLenexa
2076Bad CopyConstructible requirement in set constructorsLenexaComplete
2160Unintended destruction ordering-specification of resizeLenexaComplete
2168Inconsistent specification of uniform_real_distribution constructorLenexaComplete
2239min/max/minmax requirementsLenexaComplete
2364deque and vector pop_back don't specify iterator invalidation requirementsLenexaComplete
2369constexpr max(initializer_list) vs max_elementLenexaComplete
2378Behaviour of standard exception typesLenexaComplete
2403stof() should call strtof() and wcstof()LenexaComplete
2406negative_binomial_distribution should reject p == 1LenexaComplete
2407packaged_task(allocator_arg_t, const Allocator&, F&&) should neither be constrained nor explicitLenexaComplete
2411shared_ptr is only contextually convertible to boolLenexaComplete
2415Inconsistency between unique_ptr and shared_ptrLenexaComplete
2420function does not discard the return value of the target objectLenexaComplete
2425operator delete(void*, size_t) doesn't invalidate pointers sufficientlyLenexaComplete
2427Container adaptors as sequence containers, reduxLenexaComplete
2428"External declaration" used without being definedLenexaComplete
2433uninitialized_copy()/etc. should tolerate overloaded operator&LenexaComplete
2434shared_ptr::use_count() is efficientLenexaComplete
2437iterator_traits::reference can and can't be voidLenexaComplete
2438std::iterator inheritance shouldn't be mandatedLenexaComplete
2439unique_copy() sometimes can't fall back to reading its outputLenexaComplete
2440seed_seq::size() should be noexceptLenexaComplete
2442call_once() shouldn't DECAY_COPY()LenexaComplete
2448Non-normative Container destructor specificationLenexaComplete
2454Add raw_storage_iterator::base() memberLenexaComplete
2455Allocator default construction should be allowed to throwLenexaComplete
2458N3778 and new library deallocation signaturesLenexaComplete
2459std::polar should require a non-negative rhoLenexaComplete
2464try_emplace and insert_or_assign misspecifiedLenexaComplete
2467is_always_equal has slightly inconsistent defaultLenexaComplete
2470Allocator's destroy function should be allowed to fail to instantiateLenexaComplete
2482[c.strings] Table 73 mentions nonexistent functionsLenexaComplete
2488Placeholders should be allowed and encouraged to be constexprLenexa
+ +

Last Updated: 27-May-2015

+
+ + diff --git a/www/debug_mode.html b/www/debug_mode.html new file mode 100644 index 000000000000..943c47db011e --- /dev/null +++ b/www/debug_mode.html @@ -0,0 +1,162 @@ + + + + libc++ debug mode status + + + +

+Work is beginning on a libc++ debug mode. The purpose of this table is to +record which parts of libc++ have debug mode support. +

+ +

+Note: Debug mode is currently not functional. Defining _LIBCPP_DEBUG will result +in fairly nasty compile errors. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SectionCompleted ?
+

+vector<T>, T != bool +

+
+

+<list> +

+
+

+<unordered_set> +

+
+

+<unordered_map> +

+
+

+<string> +

+
+

+<set> +

+
+

+<map> +

+
+

+vector<bool> +

+
+

+<deque> +

+
+

+<forward_list> +

+
+

+<array> +

+
+

+<stack> +

+
+

+<queue> +

+
+

+<algorithm> +

+
+ +

+At present the table is known to not be a complete list. It is currently ordered +in approximate priority order. +

+ +

Last Updated: 3-June-2014

+ + + diff --git a/www/index.html b/www/index.html new file mode 100644 index 000000000000..8f1489e84553 --- /dev/null +++ b/www/index.html @@ -0,0 +1,487 @@ + + + + + + "libc++" C++ Standard Library + + + + + + + +
+ +

"libc++" C++ Standard Library

+ + +

libc++ is a new implementation of the C++ standard library, targeting + C++11.

+ +

All of the code in libc++ is dual licensed + under the MIT license and the UIUC License (a BSD-like license).

+ + +

Features and Goals

+ + +
    +
  • Correctness as defined by the C++11 standard.
  • +
  • Fast execution.
  • +
  • Minimal memory use.
  • +
  • Fast compile times.
  • +
  • ABI compatibility with gcc's libstdc++ for some low-level features + such as exception objects, rtti and memory allocation.
  • +
  • Extensive unit tests.
  • +
+ + +

Why a new C++ Standard Library for C++11?

+ + +

After its initial introduction, many people have asked "why start a new + library instead of contributing to an existing library?" (like Apache's + libstdcxx, GNU's libstdc++, STLport, etc). There are many contributing + reasons, but some of the major ones are:

+ +
    +
  • From years of experience (including having implemented the standard + library before), we've learned many things about implementing + the standard containers which require ABI breakage and fundamental changes + to how they are implemented. For example, it is generally accepted that + building std::string using the "short string optimization" instead of + using Copy On Write (COW) is a superior approach for multicore + machines (particularly in C++11, which has rvalue references). Breaking + ABI compatibility with old versions of the library was + determined to be critical to achieving the performance goals of + libc++.

  • + +
  • Mainline libstdc++ has switched to GPL3, a license which the developers + of libc++ cannot use. libstdc++ 4.2 (the last GPL2 version) could be + independently extended to support C++11, but this would be a fork of the + codebase (which is often seen as worse for a project than starting a new + independent one). Another problem with libstdc++ is that it is tightly + integrated with G++ development, tending to be tied fairly closely to the + matching version of G++.

    +
  • + +
  • STLport and the Apache libstdcxx library are two other popular + candidates, but both lack C++11 support. Our experience (and the + experience of libstdc++ developers) is that adding support for C++11 (in + particular rvalue references and move-only types) requires changes to + almost every class and function, essentially amounting to a rewrite. + Faced with a rewrite, we decided to start from scratch and evaluate every + design decision from first principles based on experience.

    + +

    Further, both projects are apparently abandoned: STLport 5.2.1 was + released in Oct'08, and STDCXX 4.2.1 in May'08.

    + +
+ + +

Platform Support

+ + +

+ libc++ is known to work on the following platforms, using g++-4.2 and + clang (lack of C++11 language support disables some functionality). Note + that functionality provided by <atomic> is only functional with + clang. +

+ +
    +
  • Mac OS X i386
  • +
  • Mac OS X x86_64
  • +
  • FreeBSD 10+ i386
  • +
  • FreeBSD 10+ x86_64
  • +
  • FreeBSD 10+ ARM
  • +
+ + +

Current Status

+ + +

libc++ is a 100% complete C++11 implementation on Apple's OS X.

+

LLVM and Clang can self host in C++ and C++11 mode with libc++ on Linux.

+

libc++ is also a 100% complete C++14 implementation. A list of new features and changes for + C++14 can be found here.

+

A list of features and changes for the next C++ standard, known here as + "C++1z" (probably to be C++17) can be found here.

+

Implementation of the post-c++14 Technical Specifications is in progress. A list of features and + the current status of these features can be found here.

+

+ Ports to other platforms are underway. Here are recent test + results for Windows + and Linux. +

+ + +

Build Bots

+ +

The latest libc++ build results can be found at the following locations.

+ + + +

Get it and get involved!

+ + +

First please review our + Developer's Policy. + +

+ On Mac OS 10.7 (Lion) and later, the easiest way to get this library is to install + Xcode 4.2 or later. However if you want to install tip-of-trunk from here + (getting the bleeding edge), read on. However, be warned that Mac OS + 10.7 will not boot without a valid copy of libc++.1.dylib in + /usr/lib. +

+ +

To check out the code, use:

+ +
    +
  • svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
  • +
+ +

+ Note that for an in-tree build, you should check out libcxx to + llvm/projects. +

+ +

+ The following instructions are for building libc++ on FreeBSD, Linux, or Mac + using libc++abi as the C++ ABI + library. On Linux, it is also possible to use + libsupc++ or libcxxrt. +

+ +

In-tree build:

+
    +
  • Check out libcxx and libcxxabi + into llvm/projects
  • +
  • cd llvm
  • +
  • mkdir build && cd build
  • +
  • cmake .. # Linux may require -DCMAKE_C_COMPILER=clang + -DCMAKE_CXX_COMPILER=clang++
  • +
  • make cxx
  • +
+ +

Out-of-tree build:

+
    +
  • Check out libcxx
  • +
  • If not on a Mac, also check out + libcxxabi
  • +
  • cd libcxx
  • +
  • mkdir build && cd build
  • +
  • cmake -DLIBCXX_CXX_ABI=libcxxabi + -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxabi/include + -DLIT_EXECUTABLE=path/to/llvm/utils/lit/lit.py .. # Linux may require + -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
  • +
  • make
  • +
+ +

To run the tests:

+
    +
  • make check-libcxx
  • +
+ +

If you wish to run a subset of the test suite:

+
    +
  • cd path/to/libcxx/libcxx
  • +
  • alias lit='python path/to/llvm/utils/lit/lit.py'
  • +
  • export + LIBCXX_SITE_CONFIG=path/to/build/dir/projects/libcxx/test/lit.site.cfg +
  • +
  • lit -sv test/re/ # or whichever subset of tests you're interested + in
  • +
+

The above is currently quite inconvenient. Sorry! We're working on it!

+ +

More information on using LIT can be found + here. For more + general information about the LLVM testing infrastructure, see the + LLVM Testing Infrastructure + Guide +

+ +

+ Shared libraries for libc++ should now be present in llvm/build/lib. Note + that it is safest to use this from its current location rather than + replacing your system's libc++ (if it has one, if not, go right ahead). +

+ +

+ Mac users, remember to be careful when replacing the system's libc++. + Your system will not be able to boot without a functioning + libc++. +

+ + +

Notes and Known Issues

+ + +

+

    +
  • + Building libc++ with -fno-rtti is not supported. However + linking against it with -fno-rtti is supported. +
  • +
  • + On OS X v10.8 and older the CMake option + -DLIBCXX_LIBCPPABI_VERSION="" must be used during + configuration. +
  • +
+

+ +

Send discussions to the + clang mailing list.

+ + +

Using libc++ in your programs

+ + + +

FreeBSD and Mac OS X

+ + +

+ To use your system-installed libc++ with clang you can: +

+ +
    +
  • clang++ -stdlib=libc++ test.cpp
  • +
  • clang++ -std=c++11 -stdlib=libc++ test.cpp
  • +
+ +

+ To use your tip-of-trunk libc++ on Mac OS with clang you can: +

+ +
    +
  • export DYLD_LIBRARY_PATH=path/to/build/lib +
  • clang++ -std=c++11 -stdlib=libc++ -nostdinc++ + -I<path-to-libcxx>/include -L<path-to-libcxx>/lib + test.cpp
  • +
+ + +

Linux

+ + +

+ You will need to keep the source tree of + libc++abi available on your build + machine and your copy of the libc++abi shared library must be placed where + your linker will find it. +

+ +

+ Unfortunately you can't simply run clang with "-stdlib=libc++" at this + point, as clang is set up to link for libc++ linked to libsupc++. To get + around this you'll have to set up your linker yourself (or patch clang). + For example: +

+ +
    +
  • clang++ -stdlib=libc++ helloworld.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc
  • +
+ +

+ Alternately, you could just add libc++abi to your libraries list, which in + most situations will give the same result: +

+ +
    +
  • clang++ -stdlib=libc++ helloworld.cpp -lc++abi
  • +
+ + +

Bug reports and patches

+ + +

+ If you think you've found a bug in libc++, please report it using + the LLVM Bugzilla. If you're not sure, you + can post a message to the cfe-dev + mailing list or on IRC. Please include "libc++" in your subject. +

+ +

+ If you want to contribute a patch to libc++, the best place for that is + Phabricator. Please + include [libc++] in the subject and add cfe-commits as a subscriber. +

+ + +

Build on Linux using CMake and libsupc++.

+ + +

+ You will need libstdc++ in order to provide libsupc++. +

+ +

+ Figure out where the libsupc++ headers are on your system. On Ubuntu this + is /usr/include/c++/<version> and + /usr/include/c++/<version>/<target-triple> +

+ +

+ You can also figure this out by running +

+$ echo | g++ -Wp,-v -x c++ - -fsyntax-only
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/4.7
+ /usr/include/c++/4.7/x86_64-linux-gnu
+ /usr/include/c++/4.7/backward
+ /usr/lib/gcc/x86_64-linux-gnu/4.7/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+     
+ + Note the first two entries happen to be what we are looking for. This + may not be correct on other platforms. +

+ +

+ We can now run CMake: +

    +
  • CC=clang CXX=clang++ cmake -G "Unix Makefiles" + -DLIBCXX_CXX_ABI=libstdc++ + -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/" + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_INSTALL_PREFIX=/usr + <libc++-source-dir>
  • +
  • You can also substitute -DLIBCXX_CXX_ABI=libsupc++ + above, which will cause the library to be linked to libsupc++ instead + of libstdc++, but this is only recommended if you know that you will + never need to link against libstdc++ in the same executable as libc++. + GCC ships libsupc++ separately but only as a static library. If a + program also needs to link against libstdc++, it will provide its + own copy of libsupc++ and this can lead to subtle problems. +
  • make
  • +
  • sudo make install
  • +
+

+ You can now run clang with -stdlib=libc++. +

+

+ + +

Build on Linux using CMake and libcxxrt.

+ + +

+ You will need to keep the source tree of + libcxxrt available + on your build machine and your copy of the libcxxrt shared library must + be placed where your linker will find it. +

+ +

+ We can now run CMake: +

    +
  • CC=clang CXX=clang++ cmake -G "Unix Makefiles" + -DLIBCXX_CXX_ABI=libcxxrt + -DLIBCXX_CXX_ABI_INCLUDE_PATHS="<libcxxrt-source-dir>/src" + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_INSTALL_PREFIX=/usr + <libc++-source-dir>
  • +
  • make
  • +
  • sudo make install
  • +
+

+ Unfortunately you can't simply run clang with "-stdlib=libc++" at this point, as + clang is set up to link for libc++ linked to libsupc++. To get around this + you'll have to set up your linker yourself (or patch clang). For example, +

    +
  • clang++ -stdlib=libc++ helloworld.cpp -nodefaultlibs -lc++ -lcxxrt -lm -lc -lgcc_s -lgcc
  • +
+ Alternately, you could just add libcxxrt to your libraries list, which in most + situations will give the same result: +
    +
  • clang++ -stdlib=libc++ helloworld.cpp -lcxxrt
  • +
+

+

+ + +

Using a local ABI library

+ +

+ Note: This is not recommended in almost all cases.
+ Generally these instructions should only be used when you can't install + your ABI library. +

+

+ Normally you must link libc++ against a ABI shared library that the + linker can find. If you want to build and test libc++ against an ABI + library not in the linker's path you need to set + -DLIBCXX_CXX_ABI_LIBRARY_PATH=/path/to/abi/lib when + configuring CMake. +

+

+ An example build using libc++abi would look like: +

    +
  • CC=clang CXX=clang++ cmake + -DLIBCXX_CXX_ABI=libc++abi + -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/path/to/libcxxabi/include" + -DLIBCXX_CXX_ABI_LIBRARY_PATH="/path/to/libcxxabi-build/lib" + path/to/libcxx
  • +
  • make
  • +
+

+

+ When testing libc++ LIT will automatically link against the proper ABI + library. +

+ + +

Design Documents

+ + + + +
+ + diff --git a/www/lit_usage.html b/www/lit_usage.html new file mode 100644 index 000000000000..2fcb2d0a5f97 --- /dev/null +++ b/www/lit_usage.html @@ -0,0 +1,207 @@ + + + + + + Testing libc++ using LIT + + + + + + + + +
+ +

Testing libc++ using LIT

+ +

+libc++ uses LIT to configure and run its tests. The primary way to run the +libc++ tests is by using make check-libcxx. However since libc++ +can be used in any number of possible configurations it is important to +customize the way LIT builds and runs the tests. This guide provides +information on how to use LIT directly to test libc++. +

+

+Documentation for LIT can be found +here. +

+ + +

Getting Started

+ +

+After building libc++ use the following commands before you start using LIT to +test. +

+
    +
  • alias lit='python path/to/llvm/utils/lit/lit.py'
  • +
  • export LIBCXX_SITE_CONFIG=path/to/build-libcxx/test/lit.site.cfg
  • +
+

+You can now run the libc++ tests by running: +

+
    +
  • cd path/to/libcxx
  • +
  • lit -sv ./test
  • +
+

+To only run a subsection of the tests use: +

    +
  • lit -sv test/std/numerics # Run only the numeric tests
  • +
+ + +

Customization Options

+ +

+libc++'s testsuite provides multiple options to configure the way the tests +are build and run. To use these options you pass them on the LIT command line +as --param NAME or --param NAME=VALUE. Some options +have default values specified during CMake's configuration. Passing the option +on the command line will override the default. +

+ + +

+

libcxx_site_config=<path/to/lit.site.cfg>

+
+Specify the site configuration to use when running the tests. This option +overrides the enviroment variable LIBCXX_SITE_CONFIG +
+

+ +

+

libcxx_headers=<path/to/headers>

+
+Specify the libc++ headers that are tested. By default the headers in the source +tree are used. +
+

+ +

+

libcxx_library=<path/to/libc++.so>

+
+Specify the libc++ library that is tested. By default the library in the build +directory is used. This option cannot be used when use_system_lib +is provided. +
+

+ +

+

use_system_lib=<bool>

+
+Default: False
+Enable or disable testing against the installed version of libc++ library. +Note: This does not use the installed headers. +
+

+ +

+

use_lit_shell=<bool>

+
+Enable or disable the use of LIT's internal shell in ShTests. If the enviroment +variable LIT_USE_INTERNAL_SHELL is present then that is used as the +default value. Otherwise the default value is True on Windows and +False on every other platform. +
+

+ +

+

no_default_flags=<bool>

+
+Default: False
+Disable all default compile and link flags from being added. When this option is +used only flags specified using the compile_flags and +link_flags will be used. +
+

+ +

+

compile_flags="<list-of-args>"

+
+Specify additional compile flags as a space delimited string. +Note: This options should not be used to change the standard version used. +
+

+ +

+

link_flags="<list-of-args>"

+
+Specify additional link flags as a space delimited string. +
+

+ +

+

std=<standard version>

+
+Values: c++98, c++03, c++11, c++14, c++1z
+Change the standard version used when building the tests. +
+

+ +

+

debug_level=<level>

+
+Values: 0, 1
+Enable the use of debug mode. Level 0 enables assertions and level 1 enables +assertions and debugging of iterator misuse. +
+

+ +

+

use_sanitizer=<sanitizer name>

+
+Values: Memory, MemoryWithOrigins, Address, Undefined
+Run the tests using the given sanitizer. If LLVM_USE_SANITIZER +was given when building libc++ then that sanitizer will be used by default. +
+

+ +

+

color_diagnostics

+
+Enable the use of colorized compile diagnostics. If the +color_diagnostics option is specified or the enviroment variable +LIBCXX_COLOR_DIAGNOSTICS is present then color diagnostics will be +enabled. +
+

+ +
+ + diff --git a/www/menu.css b/www/menu.css new file mode 100644 index 000000000000..4a887b1907a3 --- /dev/null +++ b/www/menu.css @@ -0,0 +1,39 @@ +/***************/ +/* page layout */ +/***************/ + +[id=menu] { + position:fixed; + width:25ex; +} +[id=content] { + /* ***** EDIT THIS VALUE IF CONTENT OVERLAPS MENU ***** */ + position:absolute; + left:29ex; + padding-right:4ex; +} + +/**************/ +/* menu style */ +/**************/ + +#menu .submenu { + padding-top:1em; + display:block; +} + +#menu label { + display:block; + font-weight: bold; + text-align: center; + background-color: rgb(192,192,192); +} +#menu a { + padding:0 .2em; + display:block; + text-align: center; + background-color: rgb(235,235,235); +} +#menu a:visited { + color:rgb(100,50,100); +} diff --git a/www/results.Linux.html b/www/results.Linux.html new file mode 100644 index 000000000000..82416a36e13e --- /dev/null +++ b/www/results.Linux.html @@ -0,0 +1,513 @@ + + + + results.Linux + + +
+All failures in the libc++ test suite will be documented here.
+Note: glibc >= 2.16 is required for full C11 compatibility.
+
+Test Suite Run Information:
+Date: 8/18/2014
+Compiler: Clang Tip-of-Tree (r215809)
+ABI: libc++abi
+C Library: eglibc 2.19
+Platform: x86_64-linux-gnu
+Kernel: 3.13.0-32-generic
+Distribution: Ubuntu 14.04
+Run By: Eric Fiselier (eric at efcs dot ca)
+
+
+Testing Time: 1187.82s
+********************
+Failing Tests (33):
+    libc++ :: localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
+        - GLIBC's locales collate strings differently. Needs investigation.
+    libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
+        - Needs Investigation.
+    libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
+        - Idem.
+    libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
+        - Idem.
+    libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
+        - Idem.
+    libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
+        - Idem
+    libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
+        - Idem
+    libc++ :: localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
+        - Differences in GLIBC locales. Needs investigation.
+    libc++ :: localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
+        - Differences in GLIBC locales. Puts '-' before 'CNY' as opposed to after.
+    libc++ :: localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
+        - Differences in GLIBC locales. Needs investigation.
+    libc++ :: localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
+        - Differences in GLIBC locales. Puts '-' before 'CNY' as opposed to after.
+    libc++ :: localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
+        - Expects ',' for ru_RU but gets '.'.
+    libc++ :: localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
+        - Expects ',' for ru_RU but gets '.'.
+    libc++ :: localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
+        - GLIBC puts "+nan" where "nan" is expected.
+    libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
+        - GLIBC has different locale data for fr_FR, ru_RU and zh_CN.
+          The is also a possible bug in zh_CN tests. Needs investigation.
+    libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
+        - Idem.
+    libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
+        - Some test cases are non-portible with GLIBC (include time zone).
+          Other failures related to GLIBC locale data. Needs investigation.
+    libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
+        - Idem.
+    libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp
+        - GLIBC starts weekdays with lowercase letters. Test case expectes upper case.
+    libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
+        - Idem.
+    libc++ :: localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
+        - GLIBC abbreviated days end with '.'. Test case expects no '.'.
+    libc++ :: localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
+        - Needs investigation.
+    libc++ :: localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
+        - Fails due to differences in GLIBC locales
+    libc++ :: localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+        - Fails due to differences in GLIBC locales
+    libc++ :: re/re.alg/re.alg.match/basic.pass.cpp
+        - Needs investigation.
+    libc++ :: re/re.alg/re.alg.match/ecma.pass.cpp
+        - Idem.
+    libc++ :: re/re.alg/re.alg.match/extended.pass.cpp
+        - Idem.
+    libc++ :: re/re.alg/re.alg.search/awk.pass.cpp
+        - Idem.
+    libc++ :: re/re.alg/re.alg.search/basic.pass.cpp
+        - Idem.
+    libc++ :: re/re.alg/re.alg.search/ecma.pass.cpp
+        - Idem.
+    libc++ :: re/re.alg/re.alg.search/extended.pass.cpp
+        - Idem.
+    libc++ :: re/re.traits/lookup_collatename.pass.cpp
+        - Idem.
+    libc++ :: re/re.traits/translate_nocase.pass.cpp
+        - Idem.
+
+********************
+Expected Failing Tests (5):
+    libc++ :: depr/depr.c.headers/math_h.pass.cpp
+        - Fails a static assert that the return type of
+          isnan(double) and isinf(double) is a bool. see PR18382.
+    libc++ :: numerics/c.math/cmath_isinf.pass.cpp
+        - Idem.
+    libc++ :: numerics/c.math/cmath_isnan.pass.cpp
+        - Idem.
+    libc++ :: strings/c.strings/cuchar.pass.cpp
+        - <cuchar> is not implemented.
+    libc++ :: strings/c.strings/version_cuchar.pass.cpp
+        - Idem.
+
+  Expected Passes    : 4716
+  Expected Failures  : 5
+  Unexpected Failures: 33
+
+********************************************************************************
+
+-- Testing: 4754 tests, 2 threads --
+FAIL: libc++ :: localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp (2073 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp4DtKocexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp4DtKocexe'
+Exit Code: -6
+Standard Error:
+--
+tmp4DtKocexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp:38: int main(): Assertion `f.compare(s2.data(), s2.data() + s2.size(), s3.data(), s3.data() + s3.size()) == 1' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp (2152 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpAfkClkexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpAfkClkexe'
+Exit Code: -6
+Standard Error:
+--
+tmpAfkClkexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp:38: int main(): Assertion `f.tolower('\xDA') == '\xFA'' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp (2153 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpGjakKeexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpGjakKeexe'
+Exit Code: -6
+Standard Error:
+--
+tmpGjakKeexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp:35: int main(): Assertion `in[0] == '\xFA'' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp (2154 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp0gK3Y6exe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp0gK3Y6exe'
+Exit Code: -6
+Standard Error:
+--
+tmp0gK3Y6exe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp:39: int main(): Assertion `f.toupper('\xFA') == '\xDA'' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp (2155 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpCoF624exe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpCoF624exe'
+Exit Code: -6
+Standard Error:
+--
+tmpCoF624exe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp:35: int main(): Assertion `in[0] == '\xDA'' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp (2157 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpjOo8fnexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpjOo8fnexe'
+Exit Code: -6
+Standard Error:
+--
+tmpjOo8fnexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp:53: int main(): Assertion `f.widen(char(-5)) == wchar_t(251)' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp (2158 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpDWZ5aNexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpDWZ5aNexe'
+Exit Code: -6
+Standard Error:
+--
+tmpDWZ5aNexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp:60: int main(): Assertion `v[6] == wchar_t(133)' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp (2184 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpfA5HOrexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpfA5HOrexe'
+Exit Code: -6
+Standard Error:
+--
+tmpfA5HOrexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp:71: int main(): Assertion `iter.base() == v.data() + v.size()' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp (2185 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpTI59qtexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpTI59qtexe'
+Exit Code: -6
+Standard Error:
+--
+tmpTI59qtexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp:314: int main(): Assertion `iter.base() == v.data() + v.size()' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp (2192 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp1psSk2exe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp1psSk2exe'
+Exit Code: -6
+Standard Error:
+--
+tmp1psSk2exe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp:70: int main(): Assertion `ex == "0,00 "' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp (2193 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpKwjbrPexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpKwjbrPexe'
+Exit Code: -6
+Standard Error:
+--
+tmpKwjbrPexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp:218: int main(): Assertion `ex == "CNY -0.01"' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp (2198 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp4UnNQ2exe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp4UnNQ2exe'
+Exit Code: -6
+Standard Error:
+--
+tmp4UnNQ2exe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp:114: int main(): Assertion `f.decimal_point() == ','' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp (2205 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp6MGZAmexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp6MGZAmexe'
+Exit Code: -6
+Standard Error:
+--
+tmp6MGZAmexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp:114: int main(): Assertion `f.thousands_sep() == ' '' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp (2229 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp7AME77exe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp7AME77exe'
+Exit Code: -6
+Standard Error:
+--
+tmp7AME77exe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp:10886: void test5(): Assertion `ex == "nan"' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp (2249 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpooRjFgexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpooRjFgexe'
+Exit Code: -6
+Standard Error:
+--
+tmpooRjFgexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp:64: int main(): Assertion `i.base() == in+sizeof(in)/sizeof(in[0])-1' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp (2250 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpcm_vb9exe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpcm_vb9exe'
+Exit Code: -6
+Standard Error:
+--
+tmpcm_vb9exe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp:64: int main(): Assertion `i.base() == in+sizeof(in)/sizeof(in[0])-1' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp (2253 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpLKJQXHexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpLKJQXHexe'
+Exit Code: -6
+Standard Error:
+--
+tmpLKJQXHexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp:51: int main(): Assertion `i.base() == in+sizeof(in)/sizeof(in[0])-1' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp (2254 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpiDgYiqexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpiDgYiqexe'
+Exit Code: -6
+Standard Error:
+--
+tmpiDgYiqexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp:51: int main(): Assertion `i.base() == in+sizeof(in)/sizeof(in[0])-1' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp (2257 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpAUaH78exe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpAUaH78exe'
+Exit Code: -6
+Standard Error:
+--
+tmpAUaH78exe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp:74: int main(): Assertion `i.base() == in+sizeof(in)/sizeof(in[0])-1' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp (2258 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp7iGNTDexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp7iGNTDexe'
+Exit Code: -6
+Standard Error:
+--
+tmp7iGNTDexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp:72: int main(): Assertion `i.base() == in+sizeof(in)/sizeof(in[0])-1' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp (2277 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpnT0vVFexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpnT0vVFexe'
+Exit Code: -6
+Standard Error:
+--
+tmpnT0vVFexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp:73: int main(): Assertion `(ex == "Today is Samedi which is abbreviated Sam.")|| (ex == "Today is samedi which is abbreviated sam." )' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp (2281 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp47THCHexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp47THCHexe'
+Exit Code: -6
+Standard Error:
+--
+tmp47THCHexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp:185: int main(): Assertion `ex == "May"' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp (2285 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpn6fLHJexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpn6fLHJexe'
+Exit Code: -6
+Standard Error:
+--
+tmpn6fLHJexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp:57: int main(): Assertion `np.grouping() == "\x7F"' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp (2286 of 4754)
+******************** TEST 'libc++ :: localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpkna8llexe' '/home/eric/workspace/staging-libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpkna8llexe'
+Exit Code: -6
+Standard Error:
+--
+tmpkna8llexe: /home/eric/workspace/staging-libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp:57: int main(): Assertion `np.thousands_sep() == ','' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.alg/re.alg.match/basic.pass.cpp (3203 of 4754)
+******************** TEST 'libc++ :: re/re.alg/re.alg.match/basic.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmp0wkTrlexe' '/home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.match/basic.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmp0wkTrlexe'
+Exit Code: -6
+Standard Error:
+--
+tmp0wkTrlexe: /home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.match/basic.pass.cpp:624: int main(): Assertion `std::regex_match(s, m, std::regex("[a[=M=]z]", std::regex_constants::basic))' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.alg/re.alg.match/ecma.pass.cpp (3204 of 4754)
+******************** TEST 'libc++ :: re/re.alg/re.alg.match/ecma.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpghcl7yexe' '/home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.match/ecma.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpghcl7yexe'
+Exit Code: -6
+Standard Error:
+--
+tmpghcl7yexe: /home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.match/ecma.pass.cpp:585: int main(): Assertion `std::regex_match(s, m, std::regex("[a[=M=]z]"))' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.alg/re.alg.match/extended.pass.cpp (3208 of 4754)
+******************** TEST 'libc++ :: re/re.alg/re.alg.match/extended.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpGVUdIMexe' '/home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.match/extended.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpGVUdIMexe'
+Exit Code: -6
+Standard Error:
+--
+tmpGVUdIMexe: /home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.match/extended.pass.cpp:622: int main(): Assertion `std::regex_match(s, m, std::regex("[a[=M=]z]", std::regex_constants::extended))' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.alg/re.alg.search/awk.pass.cpp (3218 of 4754)
+******************** TEST 'libc++ :: re/re.alg/re.alg.search/awk.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpgFuw4cexe' '/home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/awk.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpgFuw4cexe'
+Exit Code: -6
+Standard Error:
+--
+tmpgFuw4cexe: /home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/awk.pass.cpp:694: int main(): Assertion `std::regex_search(s, m, std::regex("[a[=M=]z]", std::regex_constants::awk))' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.alg/re.alg.search/basic.pass.cpp (3219 of 4754)
+******************** TEST 'libc++ :: re/re.alg/re.alg.search/basic.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpXeQuwGexe' '/home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpXeQuwGexe'
+Exit Code: -6
+Standard Error:
+--
+tmpXeQuwGexe: /home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp:696: int main(): Assertion `std::regex_search(s, m, std::regex("[a[=M=]z]", std::regex_constants::basic))' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.alg/re.alg.search/ecma.pass.cpp (3220 of 4754)
+******************** TEST 'libc++ :: re/re.alg/re.alg.search/ecma.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpvGAAImexe' '/home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/ecma.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpvGAAImexe'
+Exit Code: -6
+Standard Error:
+--
+tmpvGAAImexe: /home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/ecma.pass.cpp:675: int main(): Assertion `std::regex_search(s, m, std::regex("[a[=M=]z]"))' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.alg/re.alg.search/extended.pass.cpp (3224 of 4754)
+******************** TEST 'libc++ :: re/re.alg/re.alg.search/extended.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpGvouurexe' '/home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/extended.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpGvouurexe'
+Exit Code: -6
+Standard Error:
+--
+tmpGvouurexe: /home/eric/workspace/staging-libcxx/test/re/re.alg/re.alg.search/extended.pass.cpp:694: int main(): Assertion `std::regex_search(s, m, std::regex("[a[=M=]z]", std::regex_constants::extended))' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.traits/lookup_collatename.pass.cpp (3349 of 4754)
+******************** TEST 'libc++ :: re/re.traits/lookup_collatename.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpItXmtJexe' '/home/eric/workspace/staging-libcxx/test/re/re.traits/lookup_collatename.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpItXmtJexe'
+Exit Code: -6
+Standard Error:
+--
+tmpItXmtJexe: /home/eric/workspace/staging-libcxx/test/re/re.traits/lookup_collatename.pass.cpp:31: void test(const char_type *, const std::basic_string &) [char_type = char]: Assertion `t.lookup_collatename(F(A), F(A + t.length(A))) == expected' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+FAIL: libc++ :: re/re.traits/translate_nocase.pass.cpp (3354 of 4754)
+******************** TEST 'libc++ :: re/re.traits/translate_nocase.pass.cpp' FAILED ********************
+Compiled With: '/opt/llvm-tot/bin/clang++' '-o' '/tmp/tmpGsRNu3exe' '/home/eric/workspace/staging-libcxx/test/re/re.traits/translate_nocase.pass.cpp' '-nostdinc++' '-std=c++11' '-D__STDC_FORMAT_MACROS' '-D__STDC_LIMIT_MACROS' '-D__STDC_CONSTANT_MACROS' '-I/home/eric/workspace/staging-libcxx/test/../include' '-I/home/eric/workspace/staging-libcxx/test/../test/support' '-nodefaultlibs' '-L/home/eric/workspace/build-libcxx-staging/lib' '-lc++' '-lc++abi' '-lgcc_eh' '-lc' '-lm' '-lpthread' '-lrt' '-lgcc_s' '-Wl,-R' '/home/eric/workspace/build-libcxx-staging/lib'
+Command: '/tmp/tmpGsRNu3exe'
+Exit Code: -6
+Standard Error:
+--
+tmpGsRNu3exe: /home/eric/workspace/staging-libcxx/test/re/re.traits/translate_nocase.pass.cpp:44: int main(): Assertion `t.translate_nocase('\xDA') == '\xFA'' failed.
+--
+
+Compiled test failed unexpectedly!
+********************
+
+ + diff --git a/www/results.Windows.html b/www/results.Windows.html new file mode 100644 index 000000000000..a5ec1218a1b5 --- /dev/null +++ b/www/results.Windows.html @@ -0,0 +1,487 @@ + + + + results.Windows + + +
+All failures in the libc++ test suite will be documented here.
+
+Last run was with Clang (pre-3.1) and GCC 4.6.3 (with dw2 exception handling) and
+ mingw-w64 v2.0.3 on i686-w64-mingw32.
+
+The following line was added to ./lib/buildit to make a static libc++ library because a DLL requires "declspec(dllexport)" or a .def file:
+ar rcs libc++.a *.o
+I also deleted libc++.dll and libc++.dll.a to make sure libc++ was linked statically to prevent unrelated issues from contaminating the test results.
+The commands to build and test were (-nodefaultlibs does not work, lots of MinGW related stuff gets left out resulting in linker failures):
+TRIPLE=i686-w64-mingw32 ./buildit
+TRIPLE=i686-w64-mingw32 HEADER_INCLUDE="-I/home/Ruben/libcxx/include" LIBS="-L/home/ruben/libcxx/lib -lc++ -lpthread -lsupc++ -lmsvcr100 -Wl,--allow-multiple-definition" ./testit > test.log 2>&1
+
+Note: Some locale tests may "Need investigating", but I think most problems are
+      caused by wrong/unportable locale naming in the tests.
+Note: Some tests failed to link because "test.exe" was still running when ld.exe
+      tried to link the next test. I left these failures out of the list; they
+      account for about 10-30 failures, and are counted in the total scores below.
+      I reran some of these failures manually and they passed.
+Note: Some tests fail at runtime but pass when run manually. Usage of std::cout
+      segfaults so further investigation is difficult. These also contribute to
+      the failures total, but are left out of the failure list, as the cause is
+      probably not located in that part of libc++, not locatable due to the lack
+      of usable debug info generated by Clang at this time.
+
+TOTAL RESULTS:
+Section failures / total sections: 104 / 1064 = 9.8% failures
+Test failures / total number of tests: 292 / 4326 = 6.7% failures
+
+depr/
+ depr.c.headers/
+  inttypes_h.pass.cpp: missing macros for C++.
+  uchar_h.pass.cpp: bug in mingw-w64 headers for C++11 builtin char types.
+  wchar_h.pass.cpp: Windows does not have swprintf, should use _snwprintf.
+                    Suggest #define swprintf as _snwprintf for _WIN32.
+exception.unexpected/
+   set.unexpected/
+    get_unexpected.pass.cpp: Segmentation fault - needs investigation.
+    set_unexpected.pass.cpp: idem.
+diagnostics/
+ syserr/
+  syserr.errcat/
+   syserr.errcat.objects/
+    system_category.pass.cpp: Needs investigation.
+input.output/
+ file.streams/
+  c.files/
+   cinttypes.pass.cpp: missing macros for C++.
+  fstreams/
+   filebuf.assign/
+    member_swap.pass.cpp: Segmentation fault - needs investigation.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   filebuf.cons/
+    move.pass.cpp: idem.
+   filebuf.members/
+    open_pointers.pass.cpp: idem.
+   filebuf.virtuals/
+    overflow.pass.cpp: idem.
+    pbackfail.pass.cpp: idem.
+    seekoff.pass.cpp: idem.
+    underflow.pass.cpp: idem.
+   fstream.assign/
+    member_swap.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   fstream.cons/
+    move.pass.cpp: idem.
+    pointer.pass.cpp: idem.
+    string.pass.cpp: idem.
+   fstream.members/
+    open_pointer.pass.cpp: idem.
+    open_string.pass.cpp: idem.
+   ifstream.assign/
+    member_swap.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   ifstream.cons/
+    move.pass.cpp: idem.
+    pointer.pass.cpp: idem.
+    string.pass.cpp: idem.
+   ifstream.members/
+    open_pointer.pass.cpp: idem.
+    open_string.pass.cpp: idem.
+	  rdbuf.pass.cpp: idem.
+   ofstream.assign/
+    member_swap.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   ofstream.cons/
+    move.pass.cpp: idem.
+    pointer.pass.cpp: idem.
+    string.pass.cpp: idem.
+   ofstream.members/
+    open_pointer.pass.cpp: idem.
+    open_string.pass.cpp: idem.
+	  rdbuf.pass.cpp: idem.
+ iostream.format/
+  ext.manip
+   get_money.pass.cpp: Windows locale names don't follow UNIX convention.
+   get_time.pass.cpp: idem.
+   put_money.pass.cpp: idem.
+   put_time.pass.cpp: idem.
+  output.streams/
+   ostream.formatted/
+    ostream.inserters.arithmetic/
+     long_double.pass.cpp: Segfault - needs investigation.
+     pointer.pass.cpp: idem.
+   ostream_sentry/
+    destruct.pass.cpp: idem.
+ iostream.objects/
+  narrow.stream.objects/
+   cerr.pass.cpp: idem.
+   cin.pass.cpp: idem.
+  wide.stream.objects/
+   wcerr.pass.cpp: idem.
+   wcin.pass.cpp: idem.
+ iostreams.base/
+  ios/
+   basic.ios.members/
+    copyfmt.pass.cpp: Windows locale names don't follow UNIX convention.
+    imbue.pass.cpp: idem.
+    move.pass.cpp: idem.
+    swap.pass.cpp: Windows locale names don't follow UNIX convention.
+  ios.base/
+   ios.base.callback/
+    register_callback.pass.cpp: Windows locale names don't follow UNIX convention.
+   ios.base.locales/
+    imbue.pass.cpp: Windows locale names don't follow UNIX convention.
+ stream.buffers/
+  streambuf/
+   streambuf.cons/
+    copy.pass.cpp: Windows locale names don't follow UNIX convention.
+    default.pass.cpp: idem.
+   streambuf.members/
+    streambuf.buffer/
+     locales.pass.cpp: Windows locale names don't follow UNIX convention.
+   streambuf.protected/
+    streambuf.assign/
+	   assign.pass.cpp: Windows locale names don't follow UNIX convention.
+     swap.pass.cpp: idem.
+language.support/
+ support.exception/
+  except.nested/
+   assign.pass.cpp: Needs investigation.
+   ctor_copy.pass.cpp: idem.
+   ctor_default.pass.cpp: idem.
+   rethrow_if_nested.pass.cpp: idem.
+   rethrow_nested.pass.cpp: idem.
+   throw_with_nested.pass.cpp: idem.
+  propagation/
+   current_exception.pass.cpp: Needs investigation.
+   exception_ptr.pass.cpp: idem.
+   make_exception_ptr.pass.cpp: idem.
+   rethrow_exception.pass.cpp: idem.
+  uncaught/
+   uncaught_exception.pass.cpp: Needs investigation.
+ support.limits/
+  limits/
+   numeric.limits.members/
+    digits.pass.cpp: Needs investigation (wrong assumptions?).
+    digits10.pass.cpp: idem.
+ support.runtime/
+  support.start.term/
+   quick_exit.pass.cpp: Not declared in libc++ headers. Is it from the ABI lib?
+ support.types/
+  max_align_t.pass.cpp: needs investigation (wrong assumptions?).
+localization/
+ locale.categories/
+  category.collate/
+   locale.collate.byname/
+    compare.pass.cpp: Windows locale names don't follow UNIX convention.
+    hash.pass.cpp: idem.
+    transform.pass.cpp: getenv should be replaced by putenv for portability.
+                        Windows locale names don't follow UNIX convention.
+    types.pass.cpp: Windows locale names don't follow UNIX convention.
+ locale.categories/
+  category.ctype/
+   locale.codecvt/
+    locale.codecvt.members/
+     wchar_t_in.pass.cpp: Most likely wchar_t is assumed 4 bytes.
+     wchar_t_length.pass.cpp: idem.
+     wchar_t_out.pass.cpp: idem.
+     wchar_t_unshift.pass.cpp: idem.
+   locale.codecvt.byname/
+    ctor_wchar_t.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale.ctype.byname/
+    is_1.pass.cpp: Windows locale names don't follow UNIX convention.
+    is_many.pass.cpp: idem.
+    narrow_1.pass.cpp: idem.
+    narrow_many.pass.cpp: idem.
+    scan_is.pass.cpp: idem.
+    scan_not.pass.cpp: idem.
+    tolower_1.pass.cpp: idem.
+    tolower_many.pass.cpp: idem.
+    toupper_1.pass.cpp: idem.
+    toupper_many.pass.cpp: idem.
+    types.pass.cpp: idem.
+    widen_1.pass.cpp: idem.
+    widen_many.pass.cpp: idem.
+  category.monetary/
+   locale.money.get/
+    locale.money.get.members/
+     get_long_double_en_US.pass.cpp: Windows locale names don't follow UNIX convention.
+     get_long_double_fr_FR.pass.cpp: idem.
+     get_long_double_ru_RU.pass.cpp: idem.
+     get_long_double_zh_CN.pass.cpp: idem.
+     get_string_en_US.pass.cpp: idem.
+   locale.money.put/
+    locale.money.put.members/
+	 put_long_double_en_US.pass.cpp: Windows locale names don't follow UNIX convention.
+     put_long_double_fr_FR.pass.cpp: idem.
+     put_long_double_ru_RU.pass.cpp: idem.
+     put_long_double_zh_CN.pass.cpp: idem.
+     put_string_en_US.pass.cpp: idem.
+   locale.moneypunct.byname/
+     curr_symbol.pass.cpp: Failed constructing from C locale. Needs investigation.
+     decimal_point.pass.cpp: idem.
+     frac_digits.pass.cpp: idem.
+     grouping.pass.cpp: idem.
+     neg_format.pass.cpp: idem.
+     negative_sign.pass.cpp: idem.
+     pos_format.pass.cpp: idem.
+     positive_sign.pass.cpp: idem.
+     thousands_sep.pass.cpp: idem.
+  category.numeric/
+   locale.nm.put/
+    facet.num.put.members/
+     put_double.pass.cpp: idem. (different floating point format?)
+     put_long_double.pass.cpp: idem.
+     put_pointer.pass.cpp: idem.
+   locale.num.get/
+    facet.num.get.members/
+     get_double.pass.cpp: Needs investigating.
+     get_float.pass.cpp: idem.
+     get_long_double.pass.cpp: idem.
+     get_pointer.pass.cpp: idem.
+  category.time/
+   locale.time.get/
+    locale.time.get.byname/
+     date_order.pass.cpp: Windows locale names don't follow UNIX convention.
+     date_order_wide.pass.cpp: idem.
+     get_date.pass.cpp: idem.
+     get_date_wide.pass.cpp: idem.
+     get_monthname.pass.cpp: idem.
+     get_monthname_wide.pass.cpp: idem.
+     get_one.pass.cpp: idem.
+     get_one_wide.pass.cpp: idem.
+     get_time.pass.cpp: idem.
+     get_time_wide.pass.cpp: idem.
+     get_weekday.pass.cpp: idem.
+     get_weekday_wide.pass.cpp: idem.
+     get_year.pass.cpp: idem.
+     get_year_wide.pass.cpp: idem.
+   locale.time.put/
+    locale.time.put.members/
+     put1.pass.cpp: Needs investigating.
+     put2.pass.cpp: idem.
+    locale.time.put.byname/
+     put1.pass.cpp: Windows locale names don't follow UNIX convention.
+   facet.numpunct/
+    locale.numpunct/
+     locale.numpunct.byname/
+      decimal_point.pass.cpp: Failed constructing from C locale. Needs investigation.
+      grouping.pass.cpp: idem.
+      thousands_sep.pass.cpp: idem.
+ locale.stdcvt/
+  codecvt_utf16_in.pass.cpp: 0x40003 does not fit in a 2-byte wchar_t.
+  codecvt_utf16_out.pass.cpp: idem.
+  codecvt_utf8_in.pass.cpp: idem.
+  codecvt_utf8_out.pass.cpp: idem.
+  codecvt_utf8_utf16_in.pass: idem.
+  codecvt_utf8_utf16_out.pass.cpp: idem.
+ locales/
+  locale/
+   locale.cons/
+    assign.pass.cpp: Windows locale names don't follow UNIX convention.
+    char_pointer.pass.cpp: idem.
+    copy.pass.cpp: idem.
+    default.pass.cpp: idem.
+    locale_char_pointer_cat.pass.cpp: idem.
+    locale_facetptr.pass.cpp: idem.
+    locale_locale_cat.pass.cpp: idem.
+    locale_string_cat.pass.cpp: idem.
+    string.pass.cpp: idem.
+   locale.members/
+    name.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale.operators/
+    eq.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale/locale.statics/
+    classic.pass.cpp: Failed constructing from C locale. Needs investigation.
+    global.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale.convenience/
+    conversions/
+     conversions.buffer/
+      overflow.pass.cpp: Needs investigation.
+      pbackfail.pass.cpp: idem.
+      seekoff.pass.cpp: idem.
+      test.pass.cpp: idem.
+      underflow.pass.cpp: idem.
+     conversions.string/
+      converted.pass.cpp: out of range hex sequence due to 2-byte wchar_t.
+      from_bytes.pass.cpp: idem (This test passed while it probably shouldn't!).
+      to_bytes.pass.cpp: idem.
+numerics/
+ complex.number/
+  complex.value.ops/
+   abs.pass.cpp: Failed assertion.
+   arg.pass.cpp: idem.
+ rand/
+  rand.device/
+   ctor.pass.cpp: No such thing as /dev/urandom on Windows. Need alternative.
+   entropy.pass.cpp: idem.
+   eval.pass.cpp: idem.
+  rand.dis/
+   rand.dist.bern/
+    rand.dist.bern.bernoulli/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.bern.bin/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.bern.geo/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.bern.negbin/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.norm/
+	  rand.dist.norm.cauchy/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.chisq/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.norm.f/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.lognormal/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.normal/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.t/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.pois/
+    rand.dist.pois.exp/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.extreme/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.gamma/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.poisson/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.weibull/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.samp/
+    rand.dist.samp.discrete/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.samp.pconst/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.samp.plinear/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.uni/
+    rand.dist.uni.real/
+     io.pass.cpp: Needs investigation. (different output double format?)
+re/
+ re.alg/
+  re.alg.match/
+   awk.pass.cpp: Needs investigation.
+   basic.pass.cpp: idem.
+   ecma.pass.cpp: idem.
+   extended.pass.cpp: idem.
+  re.alg.search/
+   awk.pass.cpp: Needs investigation.
+   basic.pass.cpp: idem.
+   ecma.pass.cpp: idem.
+   extended.pass.cpp: idem.
+ re.regex/
+  re.regex.locale/
+   imbue.pass.cpp: Windows locale names don't follow UNIX convention.
+ re.traits/
+  default.pass.cpp: Windows locale names don't follow UNIX convention.
+  getloc.pass.cpp: idem.
+  imbue.pass.cpp: idem.
+  isctype.pass.cpp: Needs investigation.
+  lookup_classname.pass.cpp: idem.
+  lookup_collatename.pass.cpp: Windows locale names don't follow UNIX convention.
+  transform.pass.cpp: idem.
+  transform_primary.pass.cpp: idem
+  translate_nocase.pass.cpp: Needs investigation.
+strings/
+ c.strings/
+  cuchar.pass.cpp: see previous note about uchar.h.
+  cwchar.pass.cpp: I suggest including the win32 support header which defines
+                   (v)swprintf to the Windows equivalent.
+  version_cuchar.pass.cpp: see previous note about uchar.h.
+ string.conversions/
+  stod.pass.cpp: "no conversion". Needs investigation.
+  stof.pass.cpp: idem.
+  to_string.pass.cpp: Needs investigation.
+  to_wstring.pass.cpp: idem.
+thread/
+ futures/
+  futures.async/
+   async.pass.cpp: Needs investigation.
+  futures.promise/
+   alloc_ctor.pass.cpp: Needs investigation.
+   default.pass.cpp: idem.
+   dtor.pass.cpp: idem.
+   get_future.pass.cpp: idem.
+   move_assign.pass.cpp: idem.
+   move_ctor.pass.cpp: idem.
+   set_exception.pass.cpp: idem.
+   set_exception_at_thread_exit.pass.cpp: idem.
+   set_lvalue.pass.cpp: idem.
+   set_lvalue_at_thread_exit.pass.cpp: idem.
+   set_rvalue.pass.cpp: idem.
+   set_rvalue_at_thread_exit.pass.cpp: idem.
+   set_value_at_thread_exit_const.pass.cpp: idem.
+   set_value_at_thread_exit_void.pass.cpp: idem.
+   set_value_const.pass.cpp: idem.
+   set_value_void.pass.cpp: idem.
+   swap.pass.cpp: idem.
+  futures.shared_future/
+   copy_assign.pass.cpp: Needs investigation.
+   copy_ctor.pass.cpp: idem.
+   ctor_future.pass.cpp: idem.
+   dtor.pass.cpp: idem.
+   get.pass.cpp: idem.
+   move_assign.pass.cpp: idem.
+   move_ctor.pass.cpp: idem.
+   wait.pass.cpp: idem.
+   wait_for.pass.cpp: idem.
+   wait_until.pass.cpp: idem.
+  futures.tas/
+   futures.task.members/
+    assign_move.pass.cpp: Needs investigation.
+    ctor_func.pass.cpp: idem.
+    ctor_func_alloc.pass.cpp: idem.
+    ctor_move.pass.cpp: idem.
+    dtor.pass.cpp: idem.
+    get_future.pass.cpp: idem.
+    make_ready_at_thread_exit.pass.cpp: idem.
+    operator.pass.cpp: idem.
+    reset.pass.cpp: idem.
+    swap.pass.cpp: idem.
+   futures.task.nonmembers/
+    swap.pass.cpp: Needs investigation.
+   futures.unique_future/
+    dtor.pass.cpp: Needs investigation.
+    get.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    move_ctor.pass.cpp: idem.
+    share.pass.cpp: idem.
+    wait.pass.cpp: idem.
+    wait_for.pass.cpp: idem.
+    wait_until.pass.cpp: idem.
+ thread.condition/
+  thread.condition.condvar/
+   wait_for.pass.cpp: Needs investigation.
+  thread.condition.condvarany/
+   wait_for.pass.cpp: Needs investigation.
+ thread.mutex/
+  thread.lock/
+   thread.lock.unique/
+    thread.lock.unique.cons/
+     mutex_try_to_lock.pass.cpp: Needs investigation.
+ thread.threads/
+  thread.thread.class/
+   thread.thread.constr/
+    move.pass.cpp: Needs investigation.
+   thread.thread.id/
+    join.pass.cpp: Needs investigation.
+   thread.thread.static/
+    hardware_concurrency.pass.cpp: Needs investigation.
+utilities/
+ meta/
+  meta.trans/
+   meta.trans.other/
+    aligned_storage.pass.cpp: Probably due to sizeof(long) != 8.
+   meta.trans.sign/
+    make_signed.pass.cpp: Probably due to sizeof(wchar_t) != 4.
+    make_unsigned.pass.cpp: idem.
+   meta.unary.prop.query/
+    alignment_of.pass.cpp: Probably a Clang problem on Windows.
+
+ + diff --git a/www/ts1z_status.html b/www/ts1z_status.html new file mode 100644 index 000000000000..698996f845f0 --- /dev/null +++ b/www/ts1z_status.html @@ -0,0 +1,102 @@ + + + + + + libc++ Fundamentals TS Status + + + + + + + +
+ +

Post-C++14 TS Implementation Status

+ + +

In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, known as "C++1Y" (probably to be C++14)

+

The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol)

+

This page shows the status of libc++; the status of clang's support of the language features is here.

+ +

Technical Specifications

+ + + + + + + + + + + + + +
Paper NumberPaper TitleTS
4023C++ Extensions for Library FundamentalsLibrary Fundamentals 1
3940Technical Specification - File SystemFile System
4273Uniform Container Erasure.Library Fundamentals 2
4061Greatest Common Divisor and Least Common Multiple.Library Fundamentals 2
4257Delimited iterators.Library Fundamentals 2
4282The World's Dumbest Smart Pointer.Library Fundamentals 2
+ +

Features in Library Fundamentals 1

+ + + + + + + + + + + + + + + + + + + + + + + + +
Feature NameStatus
Uses-allocator constructionNot started
Changes to std::shared_ptr and weak_ptrNot started
Additions to std::functionNot started
Changes to std::common_typeNot started
Changes to std::iterator_traitsNot started
Additions to std::promiseNot started
Additions to std::packaged_taskNot started
Class erased_typeComplete
Calling a function with a tuple of argumentsComplete
Other type transformationsNot started
Compile-time Rational ArithmeticImplementation in progress
Time UtilitiesComplete
System Error SupportComplete
SearchersNot started
Optional ObjectsInitial implementation complete
class anyImplementation in progress
string_viewImplementation in progress
memoryImplementation in progress
Algorithms libraryImplementation in progress
+ +

Features in Library Fundamentals 2

+ + + + +
Feature NameStatus
+ +

Features in Filesystem

+ + + + +
Feature NameStatus
All featuresNot started
+ +

Last Updated: 2-June-2014

+
+ + diff --git a/www/type_traits_design.html b/www/type_traits_design.html new file mode 100644 index 000000000000..422bba4a7f5f --- /dev/null +++ b/www/type_traits_design.html @@ -0,0 +1,286 @@ + + + + + + type traits intrinsic design + + + + + + + +
+ +

Type traits intrinsic design

+ + +

+This is a survey of the type traits intrinsics clang has, and those needed. +The names and definitions of several of the needed type traits has recently +changed. Please see: +N3142. +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Legend
clang supplies it and it is absolutely necessarysome_trait(T)
clang supplies it and it is usefulsome_trait(T)
clang supplies it and it is not neededsome_trait(T)
clang does not supply it and it is not needed
clang does not supply it and it is absolutely necessarysome_trait(T)
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Needed type traits vs clang type traits
libc++ Needsclang Has
is_union<T>__is_union(T)
is_class<T>__is_class(T)
is_enum<T>__is_enum(T)
is_pod<T>__is_pod(T)
has_virtual_destructor<T>__has_virtual_destructor(T)
is_constructible<T, Args...>
is_default_constructible<T>
is_copy_constructible<T>
is_move_constructible<T>
is_assignable<T, U>
is_copy_assignable<T>
is_move_assignable<T>
is_destructible<T>
is_trivially_constructible<T, Args...>__is_trivially_constructible(T, U)
is_trivially_default_constructible<T>__has_trivial_constructor(T)
is_trivially_copy_constructible<T>__has_trivial_copy(T)
is_trivially_move_constructible<T>
is_trivially_assignable<T, U>__is_trivially_assignable(T, U)
is_trivially_copy_assignable<T>__has_trivial_assign(T)
is_trivially_move_assignable<T>
is_trivially_destructible<T>__has_trivial_destructor(T)
is_nothrow_constructible<T, Args...>
is_nothrow_default_constructible<T>__has_nothrow_constructor(T)
is_nothrow_copy_constructible<T>__has_nothrow_copy(T)
is_nothrow_move_constructible<T>
is_nothrow_assignable<T, U>
is_nothrow_copy_assignable<T>__has_nothrow_assign(T)
is_nothrow_move_assignable<T>
is_nothrow_destructible<T>
is_trivial<T>__is_trivial(T)
is_trivially_copyable<T>__is_trivially_copyable(T)
is_standard_layout<T>__is_standard_layout(T)
is_literal_type<T>__is_literal_type(T)
is_convertible<T, U>__is_convertible_to(T, U)
is_base_of<T, U>__is_base_of(T, U)
underlying_type<T>__underlying_type(T)
is_polymorphic<T>__is_polymorphic(T)
is_empty<T>__is_empty(T)
is_abstract<T>__is_abstract(T)
+
+ +
+ +