libcxx/0000755000175000017500000000000012266757735013255 5ustar sylvestresylvestrelibcxx/lib/0000755000175000017500000000000012266757731014017 5ustar sylvestresylvestrelibcxx/lib/buildit0000755000175000017500000001167012266757731015406 0ustar sylvestresylvestre#! /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 libcxx/lib/libc++abi2.exp0000644000175000017500000001243512266757731016337 0ustar sylvestresylvestre___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 libcxx/lib/libc++abi.exp0000644000175000017500000000434212266757731016253 0ustar sylvestresylvestre___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 libcxx/lib/notweak.exp0000644000175000017500000000011112266757731016176 0ustar sylvestresylvestre# Remove the weak-def bit from these external symbols __ZT* __ZN* __ZS* libcxx/lib/libc++sjlj-abi.exp0000644000175000017500000000434312266757731017214 0ustar sylvestresylvestre___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 libcxx/lib/weak.exp0000644000175000017500000000054612266757731015471 0ustar sylvestresylvestre__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 libcxx/lib/CMakeLists.txt0000644000175000017500000000625412266757731016566 0ustar sylvestresylvestre# 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}) 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 (DEFINED LIBCXX_CXX_ABI_DEPS) add_dependencies(cxx ${LIBCXX_CXX_ABI_DEPS}) endif() # Generate library list. set(libraries ${LIBCXX_CXX_ABI_LIBRARIES}) 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) target_link_libraries(cxx ${libraries}) # Setup flags. append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC) append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) if ( APPLE ) if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) list(APPEND compile_flags "-U__STRICT_ANSI__") list(APPEND link_flags "-compatibility_version 1" "-current_version ${LIBCXX_VERSION}" "-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 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 ";" " " link_flags "${link_flags}") set_target_properties(cxx PROPERTIES COMPILE_FLAGS "${compile_flags}" LINK_FLAGS "${link_flags}" OUTPUT_NAME "c++" VERSION "1.0" SOVERSION "1" ) install(TARGETS cxx LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) libcxx/lib/libc++unexp.exp0000644000175000017500000000062712266757731016661 0ustar sylvestresylvestre# 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* libcxx/LICENSE.TXT0000644000175000017500000000664512266757730014746 0ustar sylvestresylvestre============================================================================== libc++ License ============================================================================== The libc++ library is dual licensed under both the University of Illinois "BSD-Like" license and the MIT license. As a user of this code you may choose to use it under either license. As a contributor, you agree to allow your code to be used under both. 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 All rights reserved. Developed by: LLVM Team University of Illinois at Urbana-Champaign http://llvm.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. * Neither the names of the LLVM Team, University of Illinois at Urbana-Champaign, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. ============================================================================== Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. libcxx/www/0000755000175000017500000000000012266757731014075 5ustar sylvestresylvestrelibcxx/www/debug_mode.html0000644000175000017500000000363312266757731017062 0ustar sylvestresylvestre 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.

Section Completed ?

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.

libcxx/www/atomic_design.html0000644000175000017500000000504712266757731017576 0ustar sylvestresylvestre <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. Something in between
  3. Minimal work for the front end

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.

libcxx/www/type_traits_design.html0000644000175000017500000001373612266757731020675 0ustar sylvestresylvestre 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 necessary some_trait(T)
clang supplies it and it is useful some_trait(T)
clang supplies it and it is not needed some_trait(T)
clang does not supply it and it is not needed
clang does not supply it and it is absolutely necessary some_trait(T)

Needed type traits vs clang type traits
libc++ Needs clang 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)
libcxx/www/results.Linux.html0000644000175000017500000000726112266757731017570 0ustar sylvestresylvestre results.Linux

All failures in the libc++ test suite will be documented here. Last
run was with Clang (pre-3.2) on Debian unstable x86_64 with eglibc
2.13 and kernel 3.2.0-3-amd64. The ABI library used was libc++abi.

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.
 uchar_h.pass.cpp:
   My libc doesn't seem to provide uchar.h yet.
 exception.unexpected/
  set.unexpected/
   get_unexpected.pass.cpp: This seems to be a problem with libc++abi:
    its default unexpected handler does not call the terminate handler?
   set_unexpected.pass.cpp: idem.
diagnostics/
 syserr/
  syserr.errcat/
   syserr.errcat.objects/
    system_category.pass.cpp: Always maps back to generic category
     when it should stay system category, because the implementation
     dependson ELAST, which Linux lacks.
input.output/
 iostream.format/
  ext.manip/
   get_time.pass.cpp: Local representation is 'Sat 31 Dec 2061
    11:55:59 PM EST' which does not match the expected result in the
    test.
   put_time.pass.cpp: idem.
language.support/
 support.start.term/
  quick_exit.pass.cpp: Fails because it doesn't know about
   std::at_quick_exit. Interestingly my libc does seem to know about
   std::[at_]quick_exit, so this needs some investigation.
localization/
 locale.categories/
  category.collate/
   locale.collate.byname/
    compare.pass.cpp: In the C local, sorting order seems OK, but not
     in the "" and en UTF8 locals. Needs investigation.
  category.ctype/
   locale.codecvt/
    locale.codecvt.members/
     wchar_t_out.pass.cpp: Needs investigation.
    widen_1.pass.cpp: Fails due to not converting some out of bounds
     characters the same way as expected. Needs investigation.
    widen_many.pass.cpp: idem.
  category.monetary/
   locale.money.get/
    locale.money.get.members/
     get_long_double_ru_RU.pass.cpp: Needs investigation.
     get_long_double_zh_CN.pass.cpp: idem.
    locale.money.put.members/
     put_long_double_ru_RU.pass.cpp: idem.
     put_long_double_zh_CN.pass.cpp: idem.
   locale.moneypunct.byname/
    decimal_point.pass.cpp: Expects ',' for RU, but gets '.'.
    thousands_sep.pass.cpp: idem.
  category.numeric/
   locale.nm.put/
    facet.num.put.members/
     put_long_double.pass.cpp: Fails due to getting '+nan' rather
      than just 'nan'.
  category.time/
   locale.time.get.byname/
    get_date.pass.cpp: Needs investigation.
    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_weekday.pass.cpp: idem.
    get_weekday_wide.pass.cpp: idem.
   locale.time.put.byname/
    put1.pass.cpp: idem.
   locale.time.put/
    locale.time.put.members/
     put2.pass.cpp: idem.
  facet.numpunct/
   locale.numpunct.byname/
    grouping.pass.cpp: idem.
    thousands_sep.pass.cpp: idem.
numerics/
 c.math/
  cmath.pass.cpp: Fails for same reason as depr/depr.c.headers/math_h.pass.cpp
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: idem.
   basic.pass.cpp: idem.
   ecma.pass.cpp: idem.
   extended.pass.cpp: idem.
 re.traits/
  lookup_collatename.pass.cpp: idem.
strings/
 c.strings/
  cuchar.pass.cpp: Can't find cuchar header
  version_cuchar.pass.cpp: idem.
utilities/
 memory/
  unique.ptr/
   unique.ptr.runtime/
    unique.ptr.runtime.ctor/
     default02.pass.cpp:
      test previously passed, recently started crashing clang. Needs investigation.
     pointer02.pass.cpp: idem.
libcxx/www/results.Windows.html0000644000175000017500000004171512266757731020125 0ustar sylvestresylvestre 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.
libcxx/www/atomic_design_b.html0000644000175000017500000003525312266757731020101 0ustar sylvestresylvestre <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();
libcxx/www/atomic_design_c.html0000644000175000017500000003347212266757731020103 0ustar sylvestresylvestre <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.

libcxx/www/atomic_design_a.html0000644000175000017500000002501412266757731020072 0ustar sylvestresylvestre <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);
}
libcxx/www/index.html0000644000175000017500000003376412266757731016107 0ustar sylvestresylvestre "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

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:

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).

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.

C++1Y (C++14) implementation is in progress. The current status is here

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

Get it and get involved!

First please review our Developer's Policy.

To check out the code, use:

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.

Next:

That should result in a libc++.1.dylib and libc++.dylib. The safest thing to do is to use it from where your libcxx is installed instead of replacing these in your Mac OS.

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

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

To run the libc++ test suite (recommended):

Notes

Building libc++ with -fno-rtti is not supported. However linking against it with -fno-rtti is supported.

Send discussions to the (clang mailing list).

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:

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

Build on Linux using CMake and libc++abi.

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.

We can now run CMake:

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,

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

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:

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,

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

Design Documents

libcxx/www/content.css0000644000175000017500000000120312266757731016255 0ustar sylvestresylvestrehtml { 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 } libcxx/www/menu.css0000644000175000017500000000112212266757731015547 0ustar sylvestresylvestre/***************/ /* 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); } libcxx/www/cxx1y_status.html0000644000175000017500000007106612266757731017454 0ustar sylvestresylvestre 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:

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
3778CWGSized deallocationChicago

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 CopyConstructible 2083 const-qualification on weak_ptr::owner_beforePortlandComplete
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
2235Undefined behavior without proper requirements on basic_string constructorsChicagoComplete
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
National Body comment 'GB 9' Remove gets from C++14ChicagoComplete

Last Updated: 22-Oct-2013

libcxx/test/0000755000175000017500000000000012266757730014227 5ustar sylvestresylvestrelibcxx/test/atomics/0000755000175000017500000000000012266757723015670 5ustar sylvestresylvestrelibcxx/test/atomics/version.pass.cpp0000644000175000017500000000072712266757723021034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/atomics/atomics.syn/0000755000175000017500000000000012266757723020137 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.syn/nothing_to_do.pass.cpp0000644000175000017500000000060312266757723024441 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/atomics/atomics.fences/0000755000175000017500000000000012266757723020571 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp0000644000175000017500000000077312266757723026222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 atomic_signal_fence(memory_order m); #include int main() { std::atomic_signal_fence(std::memory_order_seq_cst); } libcxx/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp0000644000175000017500000000077312266757723026214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 atomic_thread_fence(memory_order m); #include int main() { std::atomic_thread_fence(std::memory_order_seq_cst); } libcxx/test/atomics/atomics.order/0000755000175000017500000000000012266757723020441 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.order/kill_dependency.pass.cpp0000644000175000017500000000106012266757723025240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 kill_dependency(T y); #include #include int main() { assert(std::kill_dependency(5) == 5); assert(std::kill_dependency(-5.5) == -5.5); } libcxx/test/atomics/atomics.order/memory_order.pass.cpp0000644000175000017500000000167712266757723024630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/atomics/atomics.lockfree/0000755000175000017500000000000012266757723021120 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.lockfree/lockfree.pass.cpp0000644000175000017500000000342012266757723024362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/atomics/atomics.types.operations/0000755000175000017500000000000012266757723022654 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.types.operations/atomics.types.operations.pointer/0000755000175000017500000000000012266757723031317 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp0000644000175000017500000000060312266757723035621 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.templ/0000755000175000017500000000000012266757723030760 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp0000644000175000017500000000060312266757723035262 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp0000644000175000017500000000060312266757723027156 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/0000755000175000017500000000000012266757723030426 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.0000644000175000017500000000575312266757723035640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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) : 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(); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_st0000644000175000017500000000503512266757723035706 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.p0000644000175000017500000000307112266757723035636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp0000644000175000017500000000277412266757723035227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.0000644000175000017500000000307512266757723035604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp0000644000175000017500000000265512266757723034362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.0000644000175000017500000000307512266757723035652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp0000644000175000017500000000500012266757723035370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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) : 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(); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_st0000644000175000017500000000401412266757723035702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.c0000644000175000017500000000244112266757723035520 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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(); } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp0000644000175000017500000000270512266757723035420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp0000644000175000017500000000500012266757723035327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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) : 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(); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.0000644000175000017500000000574712266757723035602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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) : 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(); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.0000644000175000017500000000304712266757723035554 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_we0000644000175000017500000000400012266757723035662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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 template void test() { { typedef std::atomic A; A a; T t(T(1)); std::atomic_init(&a, t); assert(std::atomic_compare_exchange_weak(&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(std::atomic_compare_exchange_weak(&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) : 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(); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.p0000644000175000017500000000321412266757723035626 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp0000644000175000017500000000270112266757723035224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp0000644000175000017500000000262112266757723034377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp0000644000175000017500000000262512266757723034574 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp0000644000175000017500000000270512266757723035352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_we0000644000175000017500000000502112266757723035666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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 template void test() { { typedef std::atomic A; A a; T t(T(1)); std::atomic_init(&a, t); assert(std::atomic_compare_exchange_weak_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_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(std::atomic_compare_exchange_weak_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_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) : 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(); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpplibcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass0000644000175000017500000000301712266757723035710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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) : 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(); } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp0000644000175000017500000000104212266757723035243 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 ATOMIC_VAR_INIT(value) #include #include #include int main() { std::atomic v = ATOMIC_VAR_INIT(5); assert(v == 5); } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.arith/0000755000175000017500000000000012266757723030746 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp0000644000175000017500000000060312266757723035250 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/atomics/atomics.types.operations/atomics.types.operations.general/0000755000175000017500000000000012266757723031254 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp0000644000175000017500000000060312266757723035556 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/atomics/atomics.flag/0000755000175000017500000000000012266757723020237 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.flag/copy_assign.fail.cpp0000644000175000017500000000106412266757723024174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp0000644000175000017500000000153312266757723026713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } } libcxx/test/atomics/atomics.flag/test_and_set.pass.cpp0000644000175000017500000000612312266757723024366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } } libcxx/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp0000644000175000017500000000547012266757723030620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } } libcxx/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp0000644000175000017500000000107512266757723026075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/atomics/atomics.flag/init.pass.cpp0000644000175000017500000000106212266757723022652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() = ATOMIC_FLAG_INIT; #include #include int main() { std::atomic_flag f = ATOMIC_FLAG_INIT; assert(f.test_and_set() == 0); } libcxx/test/atomics/atomics.flag/copy_ctor.fail.cpp0000644000175000017500000000104112266757723023652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp0000644000175000017500000000146312266757723025327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // void atomic_flag_clear(volatile atomic_flag*); // void atomic_flag_clear(atomic_flag*); #include #include int main() { { std::atomic_flag f; f.test_and_set(); atomic_flag_clear(&f); assert(f.test_and_set() == 0); } { volatile std::atomic_flag f; f.test_and_set(); atomic_flag_clear(&f); assert(f.test_and_set() == 0); } } libcxx/test/atomics/atomics.flag/default.pass.cpp0000644000175000017500000000131212266757723023331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() = 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(); } } libcxx/test/atomics/atomics.flag/clear.pass.cpp0000644000175000017500000000331212266757723022775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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; f.test_and_set(); f.clear(); assert(f.test_and_set() == 0); } { std::atomic_flag f; f.test_and_set(); f.clear(std::memory_order_relaxed); assert(f.test_and_set() == 0); } { std::atomic_flag f; f.test_and_set(); f.clear(std::memory_order_release); assert(f.test_and_set() == 0); } { std::atomic_flag f; f.test_and_set(); f.clear(std::memory_order_seq_cst); assert(f.test_and_set() == 0); } { volatile std::atomic_flag f; f.test_and_set(); f.clear(); assert(f.test_and_set() == 0); } { volatile std::atomic_flag f; f.test_and_set(); f.clear(std::memory_order_relaxed); assert(f.test_and_set() == 0); } { volatile std::atomic_flag f; f.test_and_set(); f.clear(std::memory_order_release); assert(f.test_and_set() == 0); } { volatile std::atomic_flag f; f.test_and_set(); f.clear(std::memory_order_seq_cst); assert(f.test_and_set() == 0); } } libcxx/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp0000644000175000017500000000315312266757723027226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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; f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_relaxed); assert(f.test_and_set() == 0); } { std::atomic_flag f; f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_release); assert(f.test_and_set() == 0); } { std::atomic_flag f; 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; f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_relaxed); assert(f.test_and_set() == 0); } { volatile std::atomic_flag f; f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_release); assert(f.test_and_set() == 0); } { volatile std::atomic_flag f; f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_seq_cst); assert(f.test_and_set() == 0); } } libcxx/test/atomics/atomics.general/0000755000175000017500000000000012266757723020743 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.general/nothing_to_do.pass.cpp0000644000175000017500000000060312266757723025245 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/atomics/atomics.types.generic/0000755000175000017500000000000012266757723022105 5ustar sylvestresylvestrelibcxx/test/atomics/atomics.types.generic/integral.pass.cpp0000644000175000017500000001665512266757723025400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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 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(obj.compare_exchange_weak(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(); } libcxx/test/atomics/atomics.types.generic/address.pass.cpp0000644000175000017500000001125512266757723025207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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 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(obj.compare_exchange_weak(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*>(); } libcxx/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp0000644000175000017500000000467412266757723027301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 } libcxx/test/atomics/atomics.types.generic/bool.pass.cpp0000644000175000017500000002124612266757723024516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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 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(); 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(obj.compare_exchange_weak(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(obj.compare_exchange_weak(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(); 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(obj.compare_exchange_weak(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(obj.compare_exchange_weak(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(); 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(obj.compare_exchange_weak(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(obj.compare_exchange_weak(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(); } } libcxx/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp0000644000175000017500000000751612266757723027142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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), ""); } libcxx/test/language.support/0000755000175000017500000000000012266757723017527 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/0000755000175000017500000000000012266757723022543 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723027053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/support.limits/limits/0000755000175000017500000000000012266757723024044 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/limits/version.pass.cpp0000644000175000017500000000072712266757723027210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.limits/limits/numeric.special/0000755000175000017500000000000012266757723027125 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723033435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/support.limits/limits/denorm.style/0000755000175000017500000000000012266757723026467 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/limits/denorm.style/check_values.pass.cpp0000644000175000017500000000233212266757723032574 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } libcxx/test/language.support/support.limits/limits/numeric.limits/0000755000175000017500000000000012266757723027006 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/limits/numeric.limits/default.pass.cpp0000644000175000017500000001005212266757723032101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/0000755000175000017500000000000012266757723030437 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp0000644000175000017500000000273112266757723034631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp0000644000175000017500000000345712266757723033545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp0000644000175000017500000000272012266757723034055 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp0000644000175000017500000000331012266757723034614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp0000644000175000017500000000243612266757723034455 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); test(0.5); test(0.5); test(0.5); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp0000644000175000017500000000335712266757723032703 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); test(FLT_MIN); test(DBL_MIN); test(LDBL_MIN); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp0000644000175000017500000000246512266757723034246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); test(__FLT_DENORM_MIN__); test(__DBL_DENORM_MIN__); test(__LDBL_DENORM_MIN__); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp0000644000175000017500000000276712266757723034415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp0000644000175000017500000000265212266757723034107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); 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(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp0000644000175000017500000000311312266757723033423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); test(-FLT_MAX); test(-DBL_MAX); test(-LDBL_MAX); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpplibcxx/test/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cp0000644000175000017500000001303012266757723035556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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) // 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) // 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) } libcxx/test/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp0000644000175000017500000000324412266757723033776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp0000644000175000017500000000272612266757723034765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp0000644000175000017500000000315712266757723032703 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); test(FLT_MAX); test(DBL_MAX); test(LDBL_MAX); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp0000644000175000017500000000272012266757723034575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp0000644000175000017500000000266212266757723034246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp0000644000175000017500000000275612266757723035301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp0000644000175000017500000000265712266757723034235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp0000644000175000017500000000256512266757723033227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp0000644000175000017500000000341312266757723034460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp0000644000175000017500000000272612266757723034763 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp0000644000175000017500000000266512266757723033617 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp0000644000175000017500000000250012266757723033736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); test(1./zero); test(1./zero); test(1./zero); } float zero = 0; libcxx/test/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp0000644000175000017500000000260612266757723033245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp0000644000175000017500000000267312266757723034625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp0000644000175000017500000000307712266757723033402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp0000644000175000017500000000275612266757723035320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp0000644000175000017500000000244312266757723033564 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); test(FLT_EPSILON); test(DBL_EPSILON); test(LDBL_EPSILON); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp0000644000175000017500000000267312266757723034623 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp0000644000175000017500000000330112266757723034224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp0000644000175000017500000000264012266757723033711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp0000644000175000017500000000277512266757723035465 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); } libcxx/test/language.support/support.limits/limits/is_specialized.pass.cpp0000644000175000017500000000431312266757723030505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); test(); test(); test(); static_assert(!std::numeric_limits >::is_specialized, "!std::numeric_limits >::is_specialized"); } libcxx/test/language.support/support.limits/limits/round.style/0000755000175000017500000000000012266757723026332 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/limits/round.style/check_values.pass.cpp0000644000175000017500000000176612266757723032451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } libcxx/test/language.support/support.limits/c.limits/0000755000175000017500000000000012266757723024265 5ustar sylvestresylvestrelibcxx/test/language.support/support.limits/c.limits/version_climits.pass.cpp0000644000175000017500000000073112266757723031150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.limits/c.limits/version_cfloat.pass.cpp0000644000175000017500000000072712266757723030761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.limits/c.limits/cfloat.pass.cpp0000644000175000017500000000426312266757723027213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/language.support/support.limits/c.limits/climits.pass.cpp0000644000175000017500000000263312266757723027406 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/language.support/support.initlist/0000755000175000017500000000000012266757723023101 5ustar sylvestresylvestrelibcxx/test/language.support/support.initlist/version.pass.cpp0000644000175000017500000000075312266757723026244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.initlist/types.pass.cpp0000644000175000017500000000255612266757723025726 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/language.support/support.initlist/support.initlist.range/0000755000175000017500000000000012266757723027546 5ustar sylvestresylvestrelibcxx/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp0000644000175000017500000000257312266757723033140 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/language.support/support.initlist/support.initlist.cons/0000755000175000017500000000000012266757723027414 5ustar sylvestresylvestrelibcxx/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp0000644000175000017500000000144512266757723032515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/language.support/support.initlist/support.initlist.access/0000755000175000017500000000000012266757723027713 5ustar sylvestresylvestrelibcxx/test/language.support/support.initlist/support.initlist.access/access.pass.cpp0000644000175000017500000000264612266757723032635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/language.support/support.rtti/0000755000175000017500000000000012266757723022224 5ustar sylvestresylvestrelibcxx/test/language.support/support.rtti/version.pass.cpp0000644000175000017500000000073312266757723025365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.rtti/bad.typeid/0000755000175000017500000000000012266757723024247 5ustar sylvestresylvestrelibcxx/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp0000644000175000017500000000151612266757723030027 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.rtti/type.info/0000755000175000017500000000000012266757723024137 5ustar sylvestresylvestrelibcxx/test/language.support/support.rtti/type.info/type_info.pass.cpp0000644000175000017500000000135612266757723027611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp0000644000175000017500000000124412266757723030610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/language.support/support.rtti/bad.cast/0000755000175000017500000000000012266757723023703 5ustar sylvestresylvestrelibcxx/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp0000644000175000017500000000150012266757723027110 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723024037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/support.dynamic/0000755000175000017500000000000012266757723022666 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/version.pass.cpp0000644000175000017500000000072112266757723026024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.dynamic/alloc.errors/0000755000175000017500000000000012266757723025273 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/alloc.errors/new.badlength/0000755000175000017500000000000012266757723030013 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp0000644000175000017500000000162512266757723034755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpplibcxx/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cp0000644000175000017500000000162012266757723035441 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723031603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/support.dynamic/alloc.errors/bad.alloc/0000755000175000017500000000000012266757723027112 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp0000644000175000017500000000150212266757723032461 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.dynamic/alloc.errors/set.new.handler/0000755000175000017500000000000012266757723030272 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp0000644000175000017500000000120412266757723035065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp0000644000175000017500000000104212266757723035101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.dynamic/alloc.errors/new.handler/0000755000175000017500000000000012266757723027500 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp0000644000175000017500000000070212266757723033436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/language.support/support.dynamic/new.delete/0000755000175000017500000000000012266757723024720 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/new.delete/new.delete.dataraces/0000755000175000017500000000000012266757723030700 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp0000644000175000017500000000056412266757723035041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/support.dynamic/new.delete/new.delete.placement/0000755000175000017500000000000012266757723030721 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp0000644000175000017500000000120712266757723034361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp0000644000175000017500000000117412266757723033166 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.dynamic/new.delete/new.delete.array/0000755000175000017500000000000012266757723030067 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp0000644000175000017500000000177312266757723035232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpplibcxx/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.p0000644000175000017500000000177612266757723035525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } libcxx/test/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp0000644000175000017500000000210212266757723033522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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[] #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); } libcxx/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp0000644000175000017500000000210412266757723035304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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) #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); } libcxx/test/language.support/support.dynamic/new.delete/new.delete.single/0000755000175000017500000000000012266757723030232 5ustar sylvestresylvestrelibcxx/test/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp0000644000175000017500000000171112266757723034167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } libcxx/test/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp0000644000175000017500000000206712266757723032501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpplibcxx/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.c0000644000175000017500000000176312266757723035416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } libcxx/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp0000644000175000017500000000206712266757723034261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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) #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); } libcxx/test/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723031230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/cstdint/0000755000175000017500000000000012266757723021177 5ustar sylvestresylvestrelibcxx/test/language.support/cstdint/version.pass.cpp0000644000175000017500000000073112266757723024336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/cstdint/cstdint.syn/0000755000175000017500000000000012266757723023457 5ustar sylvestresylvestrelibcxx/test/language.support/cstdint/cstdint.syn/cstdint.pass.cpp0000644000175000017500000002733012266757723026605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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 } libcxx/test/language.support/support.exception/0000755000175000017500000000000012266757723023240 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/version.pass.cpp0000644000175000017500000000073512266757723026403 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.exception/uncaught/0000755000175000017500000000000012266757723025056 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/uncaught/uncaught_exception.pass.cpp0000644000175000017500000000156312266757723032430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/language.support/support.exception/propagation/0000755000175000017500000000000012266757723025563 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/propagation/make_exception_ptr.pass.cpp0000644000175000017500000000222012266757723033110 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/language.support/support.exception/propagation/current_exception.pass.cpp0000644000175000017500000001451712266757723033004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/language.support/support.exception/propagation/rethrow_exception.pass.cpp0000644000175000017500000000237012266757723033006 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/language.support/support.exception/propagation/exception_ptr.pass.cpp0000644000175000017500000000152412266757723032121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/language.support/support.exception/exception/0000755000175000017500000000000012266757723025236 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/exception/exception.pass.cpp0000644000175000017500000000126012266757723030704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.exception/except.nested/0000755000175000017500000000000012266757723026011 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp0000644000175000017500000000327712266757723033205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } } libcxx/test/language.support/support.exception/except.nested/assign.pass.cpp0000644000175000017500000000246512266757723030755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } } } libcxx/test/language.support/support.exception/except.nested/ctor_copy.pass.cpp0000644000175000017500000000242012266757723031461 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } } } libcxx/test/language.support/support.exception/except.nested/throw_with_nested.pass.cpp0000644000175000017500000000405012266757723033221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_;} }; 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); } } } libcxx/test/language.support/support.exception/except.nested/rethrow_nested.pass.cpp0000644000175000017500000000261012266757723032515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } } libcxx/test/language.support/support.exception/except.nested/ctor_default.pass.cpp0000644000175000017500000000223512266757723032137 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } } } libcxx/test/language.support/support.exception/exception.terminate/0000755000175000017500000000000012266757723027225 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723033535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/support.exception/exception.terminate/terminate.handler/0000755000175000017500000000000012266757723032631 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpplibcxx/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handl0000644000175000017500000000072412266757723035715 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/language.support/support.exception/exception.terminate/set.terminate/0000755000175000017500000000000012266757723032007 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpplibcxx/test/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.0000644000175000017500000000115212266757723035603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpplibcxx/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.0000644000175000017500000000105012266757723035614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.exception/exception.terminate/terminate/0000755000175000017500000000000012266757723031215 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp0000644000175000017500000000105112266757723034653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.exception/bad.exception/0000755000175000017500000000000012266757723025763 5ustar sylvestresylvestrelibcxx/test/language.support/support.exception/bad.exception/bad_exception.pass.cpp0000644000175000017500000000154412266757723032244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/language.support/support.start.term/0000755000175000017500000000000012266757723023345 5ustar sylvestresylvestrelibcxx/test/language.support/support.start.term/quick_exit.pass.cpp0000644000175000017500000000103212266757723027157 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // test quick_exit and at_quick_exit #include #include void f() {} int main() { std::at_quick_exit(f); quick_exit(0); } libcxx/test/language.support/support.general/0000755000175000017500000000000012266757723022657 5ustar sylvestresylvestrelibcxx/test/language.support/support.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723027167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/language.support/support.runtime/0000755000175000017500000000000012266757723022725 5ustar sylvestresylvestrelibcxx/test/language.support/support.runtime/version_ctime.pass.cpp0000644000175000017500000000072512266757723027250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.runtime/cstdlib.pass.cpp0000644000175000017500000001035412266757723026025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); static_assert((std::is_same::value), ""); wchar_t* pw = 0; const wchar_t* pwc = 0; char* pc = 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), ""); } libcxx/test/language.support/support.runtime/version_csetjmp.pass.cpp0000644000175000017500000000073112266757723027611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.runtime/cstdarg.pass.cpp0000644000175000017500000000117212266757723026026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #ifndef va_copy #error va_copy not defined #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; } libcxx/test/language.support/support.runtime/ctime.pass.cpp0000644000175000017500000000264012266757723025501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); 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), ""); } libcxx/test/language.support/support.runtime/version_csignal.pass.cpp0000644000175000017500000000073112266757723027564 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.runtime/version_cstdarg.pass.cpp0000644000175000017500000000073112266757723027573 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.runtime/cstdbool.pass.cpp0000644000175000017500000000124012266757723026204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/language.support/support.runtime/csignal.pass.cpp0000644000175000017500000000212412266757723026015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/language.support/support.runtime/version_cstdlib.pass.cpp0000644000175000017500000000073112266757723027570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.runtime/csetjmp.pass.cpp0000644000175000017500000000123112266757723026040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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<__typeof__(std::longjmp(jb, 0)), void>::value), "std::is_same<__typeof__(std::longjmp(jb, 0)), void>::value"); } libcxx/test/language.support/support.runtime/version_cstdbool.pass.cpp0000644000175000017500000000073312266757723027757 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.types/0000755000175000017500000000000012266757723022406 5ustar sylvestresylvestrelibcxx/test/language.support/support.types/null.pass.cpp0000644000175000017500000000066512266757723025040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.types/size_t.pass.cpp0000644000175000017500000000155412266757723025361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } libcxx/test/language.support/support.types/version.pass.cpp0000644000175000017500000000073112266757723025545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/language.support/support.types/offsetof.pass.cpp0000644000175000017500000000106112266757723025670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/language.support/support.types/nullptr_t.pass.cpp0000644000175000017500000000300112266757723026074 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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) {} }; int main() { static_assert(sizeof(std::nullptr_t) == sizeof(void*), "sizeof(std::nullptr_t) == sizeof(void*)"); A* p = 0; assert(p == nullptr); void (A::*pmf)() = 0; #ifdef __clang__ // GCC 4.2 can't handle this assert(pmf == nullptr); #endif int A::*pmd = 0; assert(pmd == nullptr); A a1(nullptr); A a2(0); bool b = nullptr; assert(!b); assert(nullptr == nullptr); assert(nullptr <= nullptr); assert(nullptr >= nullptr); assert(!(nullptr != nullptr)); assert(!(nullptr < nullptr)); assert(!(nullptr > nullptr)); A* a = nullptr; assert(a == nullptr); assert(a <= nullptr); assert(a >= nullptr); assert(!(a != nullptr)); assert(!(a < nullptr)); assert(!(a > nullptr)); assert(nullptr == a); assert(nullptr <= a); assert(nullptr >= a); assert(!(nullptr != a)); assert(!(nullptr < a)); assert(!(nullptr > a)); std::ptrdiff_t i = reinterpret_cast(nullptr); assert(i == 0); } libcxx/test/language.support/support.types/ptrdiff_t.pass.cpp0000644000175000017500000000157212266757723026045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } libcxx/test/language.support/support.types/max_align_t.pass.cpp0000644000175000017500000000256112266757723026345 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } libcxx/test/nothing_to_do.pass.cpp0000644000175000017500000000060312266757726020536 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/numerics/0000755000175000017500000000000012266757726016061 5ustar sylvestresylvestrelibcxx/test/numerics/numerics.general/0000755000175000017500000000000012266757726021322 5ustar sylvestresylvestrelibcxx/test/numerics/numerics.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726025632 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/cfenv/0000755000175000017500000000000012266757726017162 5ustar sylvestresylvestrelibcxx/test/numerics/cfenv/version.pass.cpp0000644000175000017500000000072512266757726022324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/numerics/cfenv/cfenv.syn/0000755000175000017500000000000012266757726021073 5ustar sylvestresylvestrelibcxx/test/numerics/cfenv/cfenv.syn/cfenv.pass.cpp0000644000175000017500000000402512266757726023646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 = {0}; std::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), ""); } libcxx/test/numerics/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726022371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/0000755000175000017500000000000012266757727017006 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.adapt/0000755000175000017500000000000012266757727021022 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.adapt/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727025332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/0000755000175000017500000000000012266757727023757 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp0000644000175000017500000000265212266757727027437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp0000644000175000017500000000164212266757727027044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp0000644000175000017500000000302012266757727026722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp0000644000175000017500000000257312266757727026046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp0000644000175000017500000000150712266757727026362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp0000644000175000017500000000162512266757727031013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp0000644000175000017500000000206012266757727026712 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp0000644000175000017500000000167512266757727027414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp0000644000175000017500000000244512266757727031043 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp0000644000175000017500000000131512266757727030756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp0000644000175000017500000000155512266757727030015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp0000644000175000017500000000154412266757727027060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp0000644000175000017500000000201112266757727026374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp0000644000175000017500000000136012266757727030752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/0000755000175000017500000000000012266757727024002 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp0000644000175000017500000000757712266757727027475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp0000644000175000017500000000132312266757727027063 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp0000644000175000017500000000211512266757727026751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp0000644000175000017500000000217712266757727026071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp0000644000175000017500000000342312266757727026404 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp0000644000175000017500000000132012266757727031026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp0000644000175000017500000000145012266757727026737 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp0000644000175000017500000000134312266757727027427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp0000644000175000017500000000745212266757727031071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp0000644000175000017500000000141612266757727031003 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp0000644000175000017500000000337712266757727030044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp0000644000175000017500000000125712266757727027104 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp0000644000175000017500000000141712266757727026430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp0000644000175000017500000000146112266757727030777 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/0000755000175000017500000000000012266757727024147 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp0000644000175000017500000000303012266757727027616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp0000644000175000017500000000215712266757727027236 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp0000644000175000017500000000225212266757727027120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp0000644000175000017500000000300612266757727026226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp0000644000175000017500000000477512266757727026564 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp0000644000175000017500000000200012266757727031167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp0000644000175000017500000000224112266757727027103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp0000644000175000017500000000221212266757727027570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp0000644000175000017500000000262312266757727031231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp0000644000175000017500000000137012266757727031147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp0000644000175000017500000000342612266757727030204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp0000644000175000017500000000207412266757727027247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp0000644000175000017500000000217212266757727026574 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp0000644000175000017500000000143312266757727031143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726023315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.device/0000755000175000017500000000000012266757727021170 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.device/eval.pass.cpp0000644000175000017500000000104512266757727023570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/rand/rand.device/ctor.pass.cpp0000644000175000017500000000145312266757727023613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 = "/dev/urandom"); #include #include int main() { try { std::random_device r("wrong file"); assert(false); } catch (const std::system_error& e) { } { std::random_device r; } { std::random_device r("/dev/urandom");; } { std::random_device r("/dev/random");; } } libcxx/test/numerics/rand/rand.device/entropy.pass.cpp0000644000175000017500000000102212266757727024334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/rand/rand.synopsis/0000755000175000017500000000000012266757727021620 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.synopsis/version.pass.cpp0000644000175000017500000000072712266757727024764 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/numerics/rand/rand.predef/0000755000175000017500000000000012266757727021176 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.predef/knuth_b.pass.cpp0000644000175000017500000000110212266757727024273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/minstd_rand.pass.cpp0000644000175000017500000000121712266757727025152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/minstd_rand0.pass.cpp0000644000175000017500000000122212266757727025226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/mt19937.pass.cpp0000644000175000017500000000151612266757727023707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/default_random_engine.pass.cpp0000644000175000017500000000105512266757727027161 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/ranlux48_base.pass.cpp0000644000175000017500000000111612266757727025325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/ranlux24_base.pass.cpp0000644000175000017500000000110512266757727025315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/ranlux24.pass.cpp0000644000175000017500000000110012266757727024316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/mt19937_64.pass.cpp0000644000175000017500000000157412266757727024224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.predef/ranlux48.pass.cpp0000644000175000017500000000111212266757727024327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/rand/rand.util/0000755000175000017500000000000012266757727020706 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.util/rand.util.seedseq/0000755000175000017500000000000012266757727024236 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp0000644000175000017500000000115012266757726027047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp0000644000175000017500000000147212266757727031271 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp0000644000175000017500000000141712266757727027543 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp0000644000175000017500000000075712266757726027150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp0000644000175000017500000000074712266757727026636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp0000644000175000017500000004707212266757727027513 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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]); } } libcxx/test/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp0000644000175000017500000000077312266757726027341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/numerics/rand/rand.util/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727025216 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.util/rand.util.canonical/0000755000175000017500000000000012266757726024533 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp0000644000175000017500000000613312266757726032010 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)))); } } libcxx/test/numerics/rand/rand.dis/0000755000175000017500000000000012266757727020510 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.uni/0000755000175000017500000000000012266757727023170 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/0000755000175000017500000000000012266757727026572 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp0000644000175000017500000000214212266757727032371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp0000644000175000017500000000141212266757727032565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp0000644000175000017500000000117612266757727031033 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp0000644000175000017500000000140112266757727032371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp0000644000175000017500000000210112266757727030644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp0000644000175000017500000000132412266757727031407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp0000644000175000017500000004003312266757727031172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp0000644000175000017500000000420112266757727032347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp0000644000175000017500000000141412266757727032707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp0000644000175000017500000000177612266757727032751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp0000644000175000017500000000117612266757727031035 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp0000644000175000017500000000134312266757727031530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp0000644000175000017500000000126212266757727032203 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp0000644000175000017500000000165212266757727032034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp0000644000175000017500000000172112266757727030651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp0000644000175000017500000000136012266757727032372 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp0000644000175000017500000000127212266757727031217 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp0000644000175000017500000000132312266757727032215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/0000755000175000017500000000000012266757727026441 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp0000644000175000017500000000222612266757727032243 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp0000644000175000017500000000140412266757727032435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp0000644000175000017500000000117112266757727030675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp0000644000175000017500000000137312266757727032250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp0000644000175000017500000000207212266757727030522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp0000644000175000017500000000131512266757727031256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp0000644000175000017500000003644112266757727031051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp0000644000175000017500000000424512266757727032226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp0000644000175000017500000000140612266757727032557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp0000644000175000017500000000211412266757727032603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp0000644000175000017500000000117112266757727030677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp0000644000175000017500000000133312266757727031376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp0000644000175000017500000000125512266757727032054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp0000644000175000017500000000164212266757727031702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp0000644000175000017500000000170512266757727030522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp0000644000175000017500000000134612266757727032245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp0000644000175000017500000000126212266757727031065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp0000644000175000017500000000131612266757727032066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727025020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/0000755000175000017500000000000012266757727023323 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027633 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/0000755000175000017500000000000012266757727030130 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp0000644000175000017500000000146112266757727033732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp0000644000175000017500000000133012266757727034122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp0000644000175000017500000000146712266757727034112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp0000644000175000017500000000112312266757727032361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp0000644000175000017500000000126412266757727033736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp0000644000175000017500000000201512266757727032206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp0000644000175000017500000000123612266757727032747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp0000644000175000017500000000617312266757727032537 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp0000644000175000017500000000637712266757727033725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp0000644000175000017500000000127312266757727034250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp0000644000175000017500000000112312266757727032363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp0000644000175000017500000000125312266757727033066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp0000644000175000017500000000120512266757727033536 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp0000644000175000017500000000155112266757727033370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp0000644000175000017500000000161512266757727032211 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp0000644000175000017500000000124312266757727033730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp0000644000175000017500000000120212266757727032546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp0000644000175000017500000000124612266757727033557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/0000755000175000017500000000000012266757727027377 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp0000644000175000017500000000215712266757727033204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp0000644000175000017500000000141312266757727033373 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp0000644000175000017500000000120512266757727031631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp0000644000175000017500000000141012266757727033176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp0000644000175000017500000000212312266757727031455 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp0000644000175000017500000000161212266757727032214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp0000644000175000017500000002171112266757727032001 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp0000644000175000017500000001212212266757727033155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp0000644000175000017500000000175612266757727034234 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp0000644000175000017500000000141512266757727033515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp0000644000175000017500000000124412266757727031636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp0000644000175000017500000000136112266757727032335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp0000644000175000017500000000127312266757727033012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp0000644000175000017500000000166212266757727032642 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp0000644000175000017500000000220112266757727031450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp0000644000175000017500000000137512266757727033205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp0000644000175000017500000000131012266757727032015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp0000644000175000017500000000134012266757727033021 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/0000755000175000017500000000000012266757727026705 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp0000644000175000017500000000211312266757727032502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp0000644000175000017500000000137112266757727032704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp0000644000175000017500000000116312266757727031142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp0000644000175000017500000000136612266757727032516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp0000644000175000017500000000205712266757727030771 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp0000644000175000017500000000155712266757727031532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp0000644000175000017500000003602512266757727031313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } { 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp0000644000175000017500000001161712266757727032473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp0000644000175000017500000000170112266757727033530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp0000644000175000017500000000137312266757727033026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp0000644000175000017500000000116412266757727031145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp0000644000175000017500000000131512266757727031642 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp0000644000175000017500000000125112266757727032314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp0000644000175000017500000000162712266757727032151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp0000644000175000017500000000207112266757727030763 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp0000644000175000017500000000134212266757727032505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp0000644000175000017500000000124412266757727031331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp0000644000175000017500000000131612266757727032332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/0000755000175000017500000000000012266757727026707 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp0000644000175000017500000000152612266757727032513 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp0000644000175000017500000000137312266757727032710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp0000644000175000017500000000136512266757727032666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp0000644000175000017500000000116212266757727031143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp0000644000175000017500000000132712266757727032515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp0000644000175000017500000000206012266757727030765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp0000644000175000017500000000156212266757727031530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp0000644000175000017500000002155112266757727031313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp0000644000175000017500000001166112266757727032474 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp0000644000175000017500000000133612266757727033027 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp0000644000175000017500000000122112266757727031141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp0000644000175000017500000000131612266757727031645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp0000644000175000017500000000125012266757727032315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp0000644000175000017500000000161612266757727032151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp0000644000175000017500000000166212266757727030772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp0000644000175000017500000000130612266757727032507 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp0000644000175000017500000000124512266757727031334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp0000644000175000017500000000131112266757727032327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/0000755000175000017500000000000012266757727023335 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/0000755000175000017500000000000012266757727027613 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp0000644000175000017500000000141512266757727033611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp0000644000175000017500000000161312266757727035120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp0000644000175000017500000000142212266757727032046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp0000644000175000017500000000152512266757727033421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpplibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.c0000644000175000017500000000452712266757727035121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp0000644000175000017500000000360312266757727033250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp0000644000175000017500000000233512266757727031676 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp0000644000175000017500000000162012266757727032427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp0000644000175000017500000002351212266757727032216 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp0000644000175000017500000000442212266757727034273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp0000644000175000017500000000450212266757727033374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp0000644000175000017500000000154112266757727033731 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp0000644000175000017500000000142212266757727032050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp0000644000175000017500000000146712266757727032560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp0000644000175000017500000000151112266757727033221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp0000644000175000017500000000205012266757727033046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp0000644000175000017500000000242012266757727031667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp0000644000175000017500000000576012266757727034154 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp0000644000175000017500000000227012266757727033414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp0000644000175000017500000000366312266757727034436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp0000644000175000017500000000141612266757727032240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpplibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cp0000644000175000017500000000612512266757727035150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp0000644000175000017500000000145612266757727033245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp0000644000175000017500000000177012266757727033744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/0000755000175000017500000000000012266757727027763 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp0000644000175000017500000000137112266757727033762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpplibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cp0000644000175000017500000000152712266757727035114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp0000644000175000017500000000123212266757727032215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp0000644000175000017500000000136712266757727033575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp0000644000175000017500000000303712266757727033421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp0000644000175000017500000000212512266757727032043 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp0000644000175000017500000000155712266757727032610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp0000644000175000017500000002052612266757727032370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp0000644000175000017500000000225512266757727033547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp0000644000175000017500000000140212266757727034075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp0000644000175000017500000000146312266757727032225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp0000644000175000017500000000135312266757727032722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp0000644000175000017500000000131612266757727033374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp0000644000175000017500000000172212266757727033223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp0000644000175000017500000000427012266757727033431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp0000644000175000017500000000213012266757727032035 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp0000644000175000017500000000454012266757727034317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp0000644000175000017500000000153012266757727033562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp0000644000175000017500000000464212266757727034614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp0000644000175000017500000000324012266757727034575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp0000644000175000017500000000130212266757727032402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpplibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.c0000644000175000017500000000511212266757727035133 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp0000644000175000017500000000135112266757727033407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp0000644000175000017500000000127312266757727034112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/0000755000175000017500000000000012266757727027467 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp0000644000175000017500000000142112266757727033462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp0000644000175000017500000000156312266757727035000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp0000644000175000017500000000142512266757727031725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp0000644000175000017500000000153012266757727033271 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpplibcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cp0000644000175000017500000000436612266757727035156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp0000644000175000017500000000342512266757727033126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp0000644000175000017500000000234312266757727031551 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp0000644000175000017500000000162612266757727032311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp0000644000175000017500000006246212266757727032101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp0000644000175000017500000000426312266757727034152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp0000644000175000017500000000574412266757727033261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp0000644000175000017500000000154412266757727033610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp0000644000175000017500000000142512266757727031727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp0000644000175000017500000000147412266757727032432 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp0000644000175000017500000000151312266757727033077 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp0000644000175000017500000000205012266757727032722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp0000644000175000017500000000243212266757727031546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp0000644000175000017500000000555012266757727034025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp0000644000175000017500000000221612266757727033270 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp0000644000175000017500000000353012266757727034303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp0000644000175000017500000000142312266757727032112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp0000644000175000017500000000571312266757727035206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp0000644000175000017500000000145712266757727033122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp0000644000175000017500000000174212266757727033617 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/0000755000175000017500000000000012266757727023347 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/0000755000175000017500000000000012266757727027656 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp0000644000175000017500000000213112266757727033453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp0000644000175000017500000000140712266757727033655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp0000644000175000017500000000121212266757727032106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp0000644000175000017500000000140412266757727033460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp0000644000175000017500000000217312266757727031741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp0000644000175000017500000000164612266757727032502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp0000644000175000017500000001336212266757727032263 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp0000644000175000017500000001355612266757727033450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp0000644000175000017500000000141312266757727033772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp0000644000175000017500000000124712266757727032120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp0000644000175000017500000000134312266757727032614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp0000644000175000017500000000127012266757727033266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp0000644000175000017500000000165612266757727033124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp0000644000175000017500000000175512266757727035172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp0000644000175000017500000000174012266757727031736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp0000644000175000017500000000136712266757727033465 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp0000644000175000017500000000127512266757727032306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp0000644000175000017500000000133612266757727033305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/0000755000175000017500000000000012266757727027677 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp0000644000175000017500000000152012266757727033475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp0000644000175000017500000000136712266757727033703 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp0000644000175000017500000000136612266757727033657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp0000644000175000017500000000115612266757727032136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp0000644000175000017500000000132612266757727033504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp0000644000175000017500000000212612266757727031760 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp0000644000175000017500000000164712266757727032524 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp0000644000175000017500000001063512266757727032304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp0000644000175000017500000001112212266757727033454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp0000644000175000017500000000133512266757727034016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp0000644000175000017500000000125312266757727032136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp0000644000175000017500000000130612266757727032634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp0000644000175000017500000000124412266757727033310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp0000644000175000017500000000161012266757727033133 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp0000644000175000017500000000164412266757727031762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp0000644000175000017500000000130312266757727033474 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp0000644000175000017500000000123512266757727032323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp0000644000175000017500000000131212266757727033320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/0000755000175000017500000000000012266757727027001 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp0000644000175000017500000000154412266757727032605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp0000644000175000017500000000140312266757727032774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp0000644000175000017500000000141612266757727032755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp0000644000175000017500000000117212266757727031236 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp0000644000175000017500000000134412266757727032606 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp0000644000175000017500000000215412266757727031063 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp0000644000175000017500000000164012266757727031617 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp0000644000175000017500000001071012266757727031400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp0000644000175000017500000000371412266757727032566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp0000644000175000017500000000135312266757727033120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp0000644000175000017500000000130712266757727031240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp0000644000175000017500000000133212266757727031735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp0000644000175000017500000000126012266757727032410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp0000644000175000017500000000163012266757727032237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp0000644000175000017500000000170412266757727031061 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp0000644000175000017500000000132512266757727032602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp0000644000175000017500000000126112266757727031424 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp0000644000175000017500000000132212266757727032423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/0000755000175000017500000000000012266757727027267 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp0000644000175000017500000000211612266757727033067 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp0000644000175000017500000000136712266757727033273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp0000644000175000017500000000116212266757727031523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp0000644000175000017500000000137312266757727033076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp0000644000175000017500000000212712266757727031351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp0000644000175000017500000000161612266757727032110 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp0000644000175000017500000001112212266757727031664 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp0000644000175000017500000001125612266757727033054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp0000644000175000017500000000140212266757727033401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp0000644000175000017500000000122712266757727031527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp0000644000175000017500000000130612266757727032224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp0000644000175000017500000000125012266757727032675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp0000644000175000017500000000162612266757727032532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp0000644000175000017500000000174112266757727034576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp0000644000175000017500000000165012266757727031347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp0000644000175000017500000000134612266757727033073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp0000644000175000017500000000123512266757727031713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp0000644000175000017500000000131612266757727032714 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/0000755000175000017500000000000012266757727027650 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp0000644000175000017500000000210112266757727033442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp0000644000175000017500000000137312266757727033651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp0000644000175000017500000000116612266757727032110 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp0000644000175000017500000000137012266757727033454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp0000644000175000017500000000213712266757727031733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp0000644000175000017500000000162412266757727032470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp0000644000175000017500000001314212266757727032251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp0000644000175000017500000001327612266757727033441 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp0000644000175000017500000000137712266757727033775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp0000644000175000017500000000123312266757727032105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp0000644000175000017500000000131612266757727032606 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp0000644000175000017500000000125412266757727033262 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp0000644000175000017500000000163412266757727033112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp0000644000175000017500000000171712266757727035162 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp0000644000175000017500000000166612266757727031737 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp0000644000175000017500000000134512266757727033453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp0000644000175000017500000000124512266757727032275 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp0000644000175000017500000000132212266757727033272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/0000755000175000017500000000000012266757727023350 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/0000755000175000017500000000000012266757727030201 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp0000644000175000017500000000211112266757727033774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp0000644000175000017500000000137712266757727034206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp0000644000175000017500000000117212266757727032436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp0000644000175000017500000000137412266757727034011 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp0000644000175000017500000000214712266757727032265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp0000644000175000017500000000163212266757727033020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp0000644000175000017500000002026112266757727032602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp0000644000175000017500000002044012266757727033761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp0000644000175000017500000000140312266757727034314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp0000644000175000017500000000123712266757727032442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp0000644000175000017500000000132612266757727033140 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp0000644000175000017500000000126012266757727033610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp0000644000175000017500000000164212266757727033442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpplibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.c0000644000175000017500000000174112266757727035150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp0000644000175000017500000000170412266757727032261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp0000644000175000017500000000135312266757727034003 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp0000644000175000017500000000125512266757727032627 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp0000644000175000017500000000132612266757727033627 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/0000755000175000017500000000000012266757727027463 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp0000644000175000017500000000207512266757727033267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp0000644000175000017500000000137112266757727033462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp0000644000175000017500000000117412266757727031722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp0000644000175000017500000000136612266757727033274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp0000644000175000017500000000213712266757727031546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp0000644000175000017500000000162112266757727032300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp0000644000175000017500000000416712266757727032073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp0000644000175000017500000000427712266757727033255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp0000644000175000017500000000137512266757727033606 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp0000644000175000017500000000123112266757727031716 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp0000644000175000017500000000130712266757727032421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp0000644000175000017500000000125212266757727033073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp0000644000175000017500000000163112266757727032722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp0000644000175000017500000000171212266757727034770 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp0000644000175000017500000000165712266757727031552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp0000644000175000017500000000134212266757727033263 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp0000644000175000017500000000124112266757727032104 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp0000644000175000017500000000132012266757727033103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027660 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/0000755000175000017500000000000012266757727027316 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp0000644000175000017500000000153212266757727033117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp0000644000175000017500000000140312266757727033311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp0000644000175000017500000000143412266757727033272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp0000644000175000017500000000117212266757727031553 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp0000644000175000017500000000133312266757727033121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp0000644000175000017500000000215412266757727031400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp0000644000175000017500000000164012266757727032134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp0000644000175000017500000001076612266757727031730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp0000644000175000017500000001111012266757727033070 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp0000644000175000017500000000135012266757727033432 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp0000644000175000017500000000123612266757727031556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp0000644000175000017500000000133312266757727032253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp0000644000175000017500000000126012266757727032725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp0000644000175000017500000000163012266757727032554 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp0000644000175000017500000000170212266757727031374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp0000644000175000017500000000132012266757727033112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp0000644000175000017500000000126212266757727031742 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp0000644000175000017500000000132212266757727032740 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/0000755000175000017500000000000012266757727026452 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp0000644000175000017500000000152412266757727032254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp0000644000175000017500000000137712266757727032457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp0000644000175000017500000000142412266757727032425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp0000644000175000017500000000117612266757727030713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp0000644000175000017500000000132712266757727032260 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp0000644000175000017500000000214412266757727030533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp0000644000175000017500000000163212266757727031271 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp0000644000175000017500000001022512266757727031052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp0000644000175000017500000001033512266757727032234 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp0000644000175000017500000000134412266757727032571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp0000644000175000017500000000123212266757727030706 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp0000644000175000017500000000132312266757727031406 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp0000644000175000017500000000125412266757727032064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp0000644000175000017500000000162212266757727031711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp0000644000175000017500000000166412266757727030537 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp0000644000175000017500000000131212266757727032247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp0000644000175000017500000000125212266757727031075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp0000644000175000017500000000131612266757727032077 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/0000755000175000017500000000000012266757727026434 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp0000644000175000017500000000210512266757727032232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp0000644000175000017500000000137512266757727032437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp0000644000175000017500000000117012266757727030667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp0000644000175000017500000000137212266757727032242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp0000644000175000017500000000214312266757727030514 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp0000644000175000017500000000162712266757727031257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp0000644000175000017500000000522712266757727031042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp0000644000175000017500000000536312266757727032223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp0000644000175000017500000000140112266757727032545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp0000644000175000017500000000123512266757727030673 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp0000644000175000017500000000132212266757727031367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp0000644000175000017500000000125612266757727032050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp0000644000175000017500000000163712266757727031701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp0000644000175000017500000000173312266757727033744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp0000644000175000017500000000167512266757727030523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp0000644000175000017500000000135012266757727032233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp0000644000175000017500000000125112266757727031056 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp0000644000175000017500000000132412266757727032060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/0000755000175000017500000000000012266757727027477 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp0000644000175000017500000000212512266757727033277 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp0000644000175000017500000000137112266757727033476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp0000644000175000017500000000117412266757727031736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp0000644000175000017500000000137612266757727033311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp0000644000175000017500000000213312266757727031556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp0000644000175000017500000000162112266757727032314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp0000644000175000017500000000344512266757727032105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp0000644000175000017500000000352512266757727033264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp0000644000175000017500000000140512266757727033614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp0000644000175000017500000000123112266757727031732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp0000644000175000017500000000131212266757727032431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp0000644000175000017500000000125212266757727033107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp0000644000175000017500000000163112266757727032736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp0000644000175000017500000000175212266757727035010 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp0000644000175000017500000000165712266757727031566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp0000644000175000017500000000135212266757727033300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp0000644000175000017500000000124112266757727032120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp0000644000175000017500000000132012266757727033117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.req/0000755000175000017500000000000012266757727020520 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.req/rand.req.genl/0000755000175000017500000000000012266757727023156 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027466 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.req/rand.req.adapt/0000755000175000017500000000000012266757727023322 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027632 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.req/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727025030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.req/rand.req.seedseq/0000755000175000017500000000000012266757727023662 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727030172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.req/rand.req.eng/0000755000175000017500000000000012266757727023002 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.req/rand.req.urng/0000755000175000017500000000000012266757727023204 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027514 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.req/rand.req.dst/0000755000175000017500000000000012266757727023023 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.eng/0000755000175000017500000000000012266757727020502 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.eng/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727025012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/0000755000175000017500000000000012266757727023277 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp0000644000175000017500000000151412266757727026753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp0000644000175000017500000000272612266757727026370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp0000644000175000017500000000402312266757727026246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp0000644000175000017500000000247512266757727025367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp0000644000175000017500000000406712266757727025706 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp0000644000175000017500000000162012266757727030326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp0000644000175000017500000000242012266757727026232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp0000644000175000017500000000213312266757727026722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp0000644000175000017500000000654512266757727030370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp0000644000175000017500000000156012266757727027331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp0000644000175000017500000000237712266757727026405 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp0000644000175000017500000000240712266757727025725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/0000755000175000017500000000000012266757727022766 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp0000644000175000017500000000271112266757727026442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp0000644000175000017500000000171112266757727026050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp0000644000175000017500000000361612266757727025744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp0000644000175000017500000000270612266757727025053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp0000644000175000017500000000154412266757727025372 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp0000644000175000017500000000166212266757727030023 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp0000644000175000017500000000213112266757727025720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp0000644000175000017500000000174412266757727026420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp0000644000175000017500000000250412266757727030046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp0000644000175000017500000000156512266757727027025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp0000644000175000017500000000162112266757727026063 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp0000644000175000017500000000206112266757727025410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/0000755000175000017500000000000012266757727023143 5ustar sylvestresylvestrelibcxx/test/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp0000644000175000017500000003731712266757727026631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp0000644000175000017500000000212012266757727026220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp0000644000175000017500000001022312266757727026111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp0000644000175000017500000000361112266757727025224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp0000644000175000017500000000201112266757727025535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp0000644000175000017500000000205712266757727030177 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp0000644000175000017500000000232012266757727026075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp0000644000175000017500000000213012266757727026563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp0000644000175000017500000003611412266757727030227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp0000644000175000017500000000176212266757727027201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp0000644000175000017500000000202512266757727026237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp0000644000175000017500000000225012266757727025565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/numeric.ops/0000755000175000017500000000000012266757726020323 5ustar sylvestresylvestrelibcxx/test/numerics/numeric.ops/inner.product/0000755000175000017500000000000012266757726023115 5ustar sylvestresylvestrelibcxx/test/numerics/numeric.ops/inner.product/inner_product.pass.cpp0000644000175000017500000000657312266757726027454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp0000644000175000017500000000703112266757726030460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/numeric.ops/version.pass.cpp0000644000175000017500000000073112266757726023462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/numerics/numeric.ops/accumulate/0000755000175000017500000000000012266757726022446 5ustar sylvestresylvestrelibcxx/test/numerics/numeric.ops/accumulate/accumulate.pass.cpp0000644000175000017500000000264712266757726026253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp0000644000175000017500000000306412266757726026743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/numeric.ops/numeric.iota/0000755000175000017500000000000012266757726022720 5ustar sylvestresylvestrelibcxx/test/numerics/numeric.ops/numeric.iota/iota.pass.cpp0000644000175000017500000000172612266757726025333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/numeric.ops/partial.sum/0000755000175000017500000000000012266757726022562 5ustar sylvestresylvestrelibcxx/test/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp0000644000175000017500000000560512266757726027257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp0000644000175000017500000000543412266757726026561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/numeric.ops/adjacent.difference/0000755000175000017500000000000012266757726024165 5ustar sylvestresylvestrelibcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp0000644000175000017500000000730712266757726032266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp0000644000175000017500000000706412266757726031570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/numerics/numeric.requirements/0000755000175000017500000000000012266757726022245 5ustar sylvestresylvestrelibcxx/test/numerics/numeric.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/complex.number/0000755000175000017500000000000012266757726021017 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.member.ops/0000755000175000017500000000000012266757726024534 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp0000644000175000017500000000164712266757726032175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp0000644000175000017500000000213712266757726032372 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp0000644000175000017500000000141112266757726031677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp0000644000175000017500000000216012266757726032103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp0000644000175000017500000000210212266757726032251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp0000644000175000017500000000166412266757726032051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp0000644000175000017500000000212412266757726032243 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp0000644000175000017500000000152512266757726032057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp0000644000175000017500000000207612266757726032113 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp0000644000175000017500000000152212266757726031704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/cases.h0000644000175000017500000001505512266757726022274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 libcxx/test/numerics/complex.number/version.pass.cpp0000644000175000017500000000073112266757726024156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/numerics/complex.number/complex.ops/0000755000175000017500000000000012266757726023266 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp0000644000175000017500000000173112266757726031150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp0000644000175000017500000000152212266757726031134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp0000644000175000017500000000307012266757726031305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 (); } libcxx/test/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp0000644000175000017500000000173112266757726031150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp0000644000175000017500000000173112266757726031000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp0000644000175000017500000000306012266757726031304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp0000644000175000017500000001055012266757726031462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp0000644000175000017500000000305312266757726032166 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 (); } libcxx/test/numerics/complex.number/complex.ops/unary_minus.pass.cpp0000644000175000017500000000141512266757726027311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp0000644000175000017500000000234412266757726031512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 (); } libcxx/test/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp0000644000175000017500000001056712266757726031347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp0000644000175000017500000000306012266757726032164 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/unary_plus.pass.cpp0000644000175000017500000000140712266757726027142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp0000644000175000017500000000202712266757726031351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp0000644000175000017500000000202512266757726031177 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp0000644000175000017500000000151712266757726031263 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp0000644000175000017500000000152212266757726031134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/stream_input.pass.cpp0000644000175000017500000000515712266757726027461 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 // // 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()); } } libcxx/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp0000644000175000017500000000235012266757726032367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 (); } libcxx/test/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp0000644000175000017500000000152212266757726031257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp0000644000175000017500000000172712266757726031005 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.ops/stream_output.pass.cpp0000644000175000017500000000130212266757726027646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)"); } libcxx/test/numerics/complex.number/cmplx.over/0000755000175000017500000000000012266757726023114 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/cmplx.over/norm.pass.cpp0000644000175000017500000000227112266757726025542 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/cmplx.over/pow.pass.cpp0000644000175000017500000000557712266757726025410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/cmplx.over/real.pass.cpp0000644000175000017500000000302112266757726025504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/cmplx.over/arg.pass.cpp0000644000175000017500000000226212266757726025340 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/cmplx.over/conj.pass.cpp0000644000175000017500000000344612266757726025525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/cmplx.over/proj.pass.cpp0000644000175000017500000000343412266757726025543 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/cmplx.over/imag.pass.cpp0000644000175000017500000000301512266757726025501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/0000755000175000017500000000000012266757726025655 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.transcendentals/atan.pass.cpp0000644000175000017500000000306112266757726030251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/atanh.pass.cpp0000644000175000017500000001001512266757726030416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 (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(); } libcxx/test/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp0000644000175000017500000000334712266757726033420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp0000644000175000017500000000312112266757726033204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/sinh.pass.cpp0000644000175000017500000000677112266757726030302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/sin.pass.cpp0000644000175000017500000000313112266757726030115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/asinh.pass.cpp0000644000175000017500000000706312266757726030436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/exp.pass.cpp0000644000175000017500000000641012266757726030123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/acosh.pass.cpp0000644000175000017500000001030412266757726030421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/tanh.pass.cpp0000644000175000017500000000540612266757726030265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/cosh.pass.cpp0000644000175000017500000000655512266757726030275 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/acos.pass.cpp0000644000175000017500000001060112266757726030251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/log10.pass.cpp0000644000175000017500000000274112266757726030254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/asin.pass.cpp0000644000175000017500000000716112266757726030265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp0000644000175000017500000000612712266757726030325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/log.pass.cpp0000644000175000017500000000745612266757726030123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/cos.pass.cpp0000644000175000017500000000304312266757726030112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp0000644000175000017500000000323312266757726030111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp0000644000175000017500000000312012266757726033203 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.members/0000755000175000017500000000000012266757726024117 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.members/real_imag.pass.cpp0000644000175000017500000000262212266757726027512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/numerics/complex.number/complex.members/construct.pass.cpp0000644000175000017500000000302412266757726027613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex/0000755000175000017500000000000012266757726022466 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex/types.pass.cpp0000644000175000017500000000133212266757726025302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/numerics/complex.number/complex.synopsis/0000755000175000017500000000000012266757726024354 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726030664 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/complex.number/complex.value.ops/0000755000175000017500000000000012266757726024401 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.value.ops/norm.pass.cpp0000644000175000017500000000244212266757726027027 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.value.ops/real.pass.cpp0000644000175000017500000000120712266757726026775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.value.ops/arg.pass.cpp0000644000175000017500000000737212266757726026634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.value.ops/conj.pass.cpp0000644000175000017500000000164412266757726027010 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.value.ops/polar.pass.cpp0000644000175000017500000000532012266757726027167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.value.ops/proj.pass.cpp0000644000175000017500000000331212266757726027023 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.value.ops/imag.pass.cpp0000644000175000017500000000120712266757726026767 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/complex.value.ops/abs.pass.cpp0000644000175000017500000000243612266757726026624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/numerics/complex.number/ccmplx/0000755000175000017500000000000012266757726022305 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/ccmplx/ccomplex.pass.cpp0000644000175000017500000000076712266757726025602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/numerics/complex.number/layout.pass.cpp0000644000175000017500000000140112266757726024001 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/numerics/complex.number/complex.special/0000755000175000017500000000000012266757726024105 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp0000644000175000017500000000130012266757726033232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp0000644000175000017500000000166212266757726033142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp0000644000175000017500000000167612266757726033314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp0000644000175000017500000000166512266757726033312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp0000644000175000017500000000165412266757726032124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp0000644000175000017500000000127612266757726033101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp0000644000175000017500000000167312266757726033144 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp0000644000175000017500000000164512266757726032115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp0000644000175000017500000000164312266757726032122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/float_double_implicit.fail.cpp0000644000175000017500000000126412266757726032057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp0000644000175000017500000000166412266757726033135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp0000644000175000017500000000166712266757726033305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/complex.number/complex.literals/0000755000175000017500000000000012266757726024304 5ustar sylvestresylvestrelibcxx/test/numerics/complex.number/complex.literals/literals1.fail.cpp0000644000175000017500000000105512266757726027623 0ustar sylvestresylvestre// -*- 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 } libcxx/test/numerics/complex.number/complex.literals/literals2.pass.cpp0000644000175000017500000000166412266757726027665 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/numerics/complex.number/complex.literals/literals1.pass.cpp0000644000175000017500000000167612266757726027667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/numerics/complex.number/complex.literals/literals.pass.cpp0000644000175000017500000000301712266757726027575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/numerics/numarray/0000755000175000017500000000000012266757726017717 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/version.pass.cpp0000644000175000017500000000073312266757726023060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/numerics/numarray/class.slice/0000755000175000017500000000000012266757726022122 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/class.slice/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026432 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/numarray/class.slice/slice.access/0000755000175000017500000000000012266757726024461 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757726031472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/numarray/class.slice/cons.slice/0000755000175000017500000000000012266757726024162 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp0000644000175000017500000000114012266757726031370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/numerics/numarray/class.slice/cons.slice/default.pass.cpp0000644000175000017500000000105712266757726027262 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/numerics/numarray/valarray.range/0000755000175000017500000000000012266757726022633 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/valarray.range/begin_const.pass.cpp0000644000175000017500000000132612266757726026600 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/valarray.range/end_const.pass.cpp0000644000175000017500000000141412266757726026260 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/numerics/numarray/valarray.range/begin_non_const.pass.cpp0000644000175000017500000000134312266757726027451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/valarray.range/end_non_const.pass.cpp0000644000175000017500000000143512266757726027135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/numerics/numarray/template.mask.array/0000755000175000017500000000000012266757726023601 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.mask.array/types.pass.cpp0000644000175000017500000000113412266757726026415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/numerics/numarray/template.mask.array/mask.array.fill/0000755000175000017500000000000012266757726026576 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp0000644000175000017500000000241212266757726032726 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/default.fail.cpp0000644000175000017500000000101612266757726026641 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/0000755000175000017500000000000012266757726030071 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp0000644000175000017500000000267312266757726033431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp0000644000175000017500000000267712266757726033705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp0000644000175000017500000000267312266757726032172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp0000644000175000017500000000267512266757726034066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp0000644000175000017500000000267312266757726033016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp0000644000175000017500000000267312266757726032314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp0000644000175000017500000000267312266757726032362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp0000644000175000017500000000267312266757726034107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp0000644000175000017500000000267312266757726033345 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp0000644000175000017500000000267312266757726033051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.assign/0000755000175000017500000000000012266757726027134 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp0000644000175000017500000000267112266757726032434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp0000644000175000017500000000306012266757726032735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/class.gslice/0000755000175000017500000000000012266757726022271 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/class.gslice/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/numarray/class.gslice/gslice.access/0000755000175000017500000000000012266757726024777 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757726032010 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/numarray/class.gslice/gslice.cons/0000755000175000017500000000000012266757726024500 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp0000644000175000017500000000207512266757726031716 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp0000644000175000017500000000110312266757726027570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/numerics/numarray/template.slice.array/0000755000175000017500000000000012266757726023745 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.slice.array/types.pass.cpp0000644000175000017500000000113612266757726026563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/0000755000175000017500000000000012266757726030047 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp0000644000175000017500000000232012266757726033374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp0000644000175000017500000000231312266757726033646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp0000644000175000017500000000231012266757726032134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp0000644000175000017500000000231112266757726034027 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp0000644000175000017500000000231512266757726032765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp0000644000175000017500000000231012266757726032256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp0000644000175000017500000000231012266757726032324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp0000644000175000017500000000231512266757726034056 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp0000644000175000017500000000231512266757726033314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp0000644000175000017500000000231512266757726033020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.assign/0000755000175000017500000000000012266757726027112 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp0000644000175000017500000000241312266757726033060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp0000644000175000017500000000231212266757726032402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.slice.array/default.fail.cpp0000644000175000017500000000102112266757726027001 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/numerics/numarray/template.slice.array/slice.arr.fill/0000755000175000017500000000000012266757726026554 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp0000644000175000017500000000214212266757726032704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/0000755000175000017500000000000012266757726024447 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.indirect.array/indirect.array.fill/0000755000175000017500000000000012266757726030312 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp0000644000175000017500000000420512266757726034444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/types.pass.cpp0000644000175000017500000000114412266757726027264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/numerics/numarray/template.indirect.array/default.fail.cpp0000644000175000017500000000103312266757726027506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/0000755000175000017500000000000012266757726031605 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp0000644000175000017500000000454312266757726035143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp0000644000175000017500000000465112266757726035413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp0000644000175000017500000000452312266757726033702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpplibcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cp0000644000175000017500000000452512266757726035416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp0000644000175000017500000000452312266757726034526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp0000644000175000017500000000452312266757726034024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp0000644000175000017500000000452312266757726034072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpplibcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cp0000644000175000017500000000452312266757726035437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp0000644000175000017500000000452512266757726035057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp0000644000175000017500000000452312266757726034561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.assign/0000755000175000017500000000000012266757726030650 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp0000644000175000017500000000501612266757726035322 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp0000644000175000017500000000454012266757726034145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/0000755000175000017500000000000012266757726023352 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.cons/0000755000175000017500000000000012266757726026134 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp0000644000175000017500000000150112266757726032077 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp0000644000175000017500000000216712266757726033171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp0000644000175000017500000000340212266757726030552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp0000644000175000017500000000327312266757726032611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp0000644000175000017500000000171412266757726030562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp0000644000175000017500000000264112266757726032322 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } } libcxx/test/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp0000644000175000017500000000200012266757726031743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp0000644000175000017500000000177412266757726031747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp0000644000175000017500000000143512266757726031234 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp0000644000175000017500000000306012266757726030556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } } libcxx/test/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp0000644000175000017500000000332412266757726032253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/types.pass.cpp0000644000175000017500000000127312266757726026172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/0000755000175000017500000000000012266757726025763 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp0000644000175000017500000000333212266757726034514 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp0000644000175000017500000000203112266757726034344 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp0000644000175000017500000000456312266757726032120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp0000644000175000017500000000150712266757726031744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp0000644000175000017500000000332312266757726032763 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp0000644000175000017500000000200512266757726033473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp0000644000175000017500000000227712266757726032623 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp0000644000175000017500000000331112266757726033637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.unary/0000755000175000017500000000000012266757726026330 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp0000644000175000017500000000355312266757726030772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp0000644000175000017500000000305012266757726031435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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])); } } libcxx/test/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp0000644000175000017500000000216112266757726030601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp0000644000175000017500000000355312266757726031252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.assign/0000755000175000017500000000000012266757726026456 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp0000644000175000017500000000202312266757726033621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp0000644000175000017500000000152712266757726033775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp0000644000175000017500000000321712266757726035054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp0000644000175000017500000000333412266757726034142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp0000644000175000017500000000332212266757726034472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp0000644000175000017500000000342412266757726032444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp0000644000175000017500000000313312266757726032445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } } libcxx/test/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp0000644000175000017500000000142012266757726032604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/0000755000175000017500000000000012266757726026624 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.members/min.pass.cpp0000644000175000017500000000173612266757726031067 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp0000644000175000017500000000127012266757726031101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp0000644000175000017500000000265012266757726032621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/size.pass.cpp0000644000175000017500000000172512266757726031254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp0000644000175000017500000000541312266757726031252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/max.pass.cpp0000644000175000017500000000173612266757726031071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp0000644000175000017500000000215112266757726031575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp0000644000175000017500000001002212266757726031405 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp0000644000175000017500000000266612266757726032433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp0000644000175000017500000001004612266757726031556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/0000755000175000017500000000000012266757726026621 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp0000644000175000017500000000174612266757726032745 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp0000644000175000017500000000157312266757726033623 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp0000644000175000017500000000156512266757726032460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp0000644000175000017500000000177512266757726034517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp0000644000175000017500000000157112266757726032302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp0000644000175000017500000000174612266757726033447 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp0000644000175000017500000000157312266757726034006 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp0000644000175000017500000000156512266757726032774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp0000644000175000017500000000156512266757726032741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp0000644000175000017500000000174612266757726033336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp0000644000175000017500000000157112266757726032234 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp0000644000175000017500000000157112266757726032112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp0000644000175000017500000000177512266757726034334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp0000644000175000017500000000174612266757726033502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp0000644000175000017500000000174612266757726033324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp0000644000175000017500000000156512266757726032616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp0000644000175000017500000000174612266757726033166 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp0000644000175000017500000000174612266757726032623 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp0000644000175000017500000000174612266757726033013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp0000644000175000017500000000157112266757726032625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/template.valarray/valarray.access/0000755000175000017500000000000012266757726026433 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.valarray/valarray.access/access.pass.cpp0000644000175000017500000000143712266757726031352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } } libcxx/test/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp0000644000175000017500000000137412266757726032560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } } libcxx/test/numerics/numarray/valarray.syn/0000755000175000017500000000000012266757726022350 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026660 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/numarray/template.gslice.array/0000755000175000017500000000000012266757726024114 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.gslice.array/types.pass.cpp0000644000175000017500000000114012266757726026725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.fill/0000755000175000017500000000000012266757726027424 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp0000644000175000017500000000421312266757726033555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/0000755000175000017500000000000012266757726030717 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp0000644000175000017500000000457012266757726034255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp0000644000175000017500000000467612266757726034534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp0000644000175000017500000000455012266757726033014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp0000644000175000017500000000455212266757726034710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp0000644000175000017500000000455012266757726033640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp0000644000175000017500000000455012266757726033136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp0000644000175000017500000000455012266757726033204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp0000644000175000017500000000455012266757726034731 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp0000644000175000017500000000455212266757726034171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp0000644000175000017500000000455012266757726033673 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/default.fail.cpp0000644000175000017500000000102512266757726027154 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.assign/0000755000175000017500000000000012266757726027762 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp0000644000175000017500000000456412266757726033265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp0000644000175000017500000000515512266757726034105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/numerics/numarray/valarray.nonmembers/0000755000175000017500000000000012266757726023704 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726030214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/0000755000175000017500000000000012266757726027505 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp0000644000175000017500000000246312266757726035265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp0000644000175000017500000000243612266757726033650 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp0000644000175000017500000000244312266757726033644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp0000644000175000017500000000244012266757726034004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp0000644000175000017500000000261112266757726035565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp0000644000175000017500000000244512266757726034025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cp0000644000175000017500000000262412266757726035611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp0000644000175000017500000000243612266757726033660 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp0000644000175000017500000000247012266757726035263 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp0000644000175000017500000000244012266757726034013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp0000644000175000017500000000244212266757726034003 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp0000644000175000017500000000243312266757726034052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp0000644000175000017500000000244312266757726033653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp0000644000175000017500000000245512266757726035066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp0000644000175000017500000000244512266757726034007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp0000644000175000017500000000244512266757726034016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp0000644000175000017500000000245512266757726035066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp0000644000175000017500000000244212266757726034013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp0000644000175000017500000000163412266757726033630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp0000644000175000017500000000243612266757726033645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/0000755000175000017500000000000012266757726027010 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp0000644000175000017500000000161212266757726034320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp0000644000175000017500000000161212266757726034176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726035555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp0000644000175000017500000000161212266757726034320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp0000644000175000017500000000160612266757726035060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp0000644000175000017500000000161412266757726035707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp0000644000175000017500000000160612266757726035025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.0000644000175000017500000000203212266757726035704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp0000644000175000017500000000160612266757726035060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass0000644000175000017500000000203212266757726036011 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp0000644000175000017500000000160612266757726034702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp0000644000175000017500000000160612266757726034702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726035241 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726035522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp0000644000175000017500000000161212266757726034711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp0000644000175000017500000000160612266757726034544 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp0000644000175000017500000000160612266757726035025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726035377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp0000644000175000017500000000161212266757726034176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726035020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726035066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp0000644000175000017500000000161212266757726034711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cp0000644000175000017500000000161412266757726035712 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726034676 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp0000644000175000017500000000161212266757726034366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp0000644000175000017500000000160612266757726034544 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp0000644000175000017500000000161412266757726035707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cp0000644000175000017500000000161512266757726035713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp0000644000175000017500000000200312266757726035411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp0000644000175000017500000000161212266757726034366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/0000755000175000017500000000000012266757726027676 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pa0000644000175000017500000000205112266757726036007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarra0000644000175000017500000000205012266757726036047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp0000644000175000017500000000245412266757726035213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp0000644000175000017500000000244712266757726035073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp0000644000175000017500000000165312266757726035417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp0000644000175000017500000000245412266757726035213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.0000644000175000017500000000165312266757726035735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass0000644000175000017500000000204712266757726036024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.p0000644000175000017500000000205012266757726036013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.c0000644000175000017500000000205212266757726035717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp0000644000175000017500000000165612266757726035563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cp0000644000175000017500000000204712266757726035742 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp0000644000175000017500000000244712266757726035073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp0000644000175000017500000000165612266757726035563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp0000644000175000017500000000205112266757726035711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.p0000644000175000017500000000165412266757726036002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp0000644000175000017500000000165312266757726035417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp0000644000175000017500000000205012266757726035566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.p0000644000175000017500000000165412266757726036002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass0000644000175000017500000000165412266757726036026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cp0000644000175000017500000000165312266757726035722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.0000644000175000017500000000165312266757726035735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass0000644000175000017500000000165412266757726036026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpplibcxx/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cp0000644000175000017500000000165312266757726035722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/numarray/valarray.nonmembers/valarray.special/0000755000175000017500000000000012266757726027144 5ustar sylvestresylvestrelibcxx/test/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp0000644000175000017500000000547612266757726031603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } libcxx/test/numerics/c.math/0000755000175000017500000000000012266757726017233 5ustar sylvestresylvestrelibcxx/test/numerics/c.math/version_cmath.pass.cpp0000644000175000017500000000072512266757726023551 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/numerics/c.math/ctgmath.pass.cpp0000644000175000017500000000102212266757726022326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/numerics/c.math/tgmath_h.pass.cpp0000644000175000017500000000073312266757726022502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/numerics/c.math/cmath.pass.cpp0000644000175000017500000025530612266757726022013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "hexfloat.h" // convertible to int/float/double/etc template struct Value { operator T () { return T(N); } }; void test_abs() { 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); assert(std::isfinite(-1.0) == true); } void test_isinf() { #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); } void test_isnan() { #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); } 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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), ""); 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_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(); } libcxx/test/strings/0000755000175000017500000000000012266757730015720 5ustar sylvestresylvestrelibcxx/test/strings/version.pass.cpp0000644000175000017500000000072712266757730021064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/strings/c.strings/0000755000175000017500000000000012266757730017632 5ustar sylvestresylvestrelibcxx/test/strings/c.strings/version_cstring.pass.cpp0000644000175000017500000000073112266757730024522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/strings/c.strings/cuchar.pass.cpp0000644000175000017500000000065612266757730022557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // #include int main() { } libcxx/test/strings/c.strings/cstring.pass.cpp0000644000175000017500000000562412266757730022763 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } libcxx/test/strings/c.strings/version_cuchar.pass.cpp0000644000175000017500000000076112266757730024321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // #include #ifndef _LIBCPP_VERSION #error _LIBCPP_VERSION not defined #endif int main() { } libcxx/test/strings/c.strings/cwctype.pass.cpp0000644000175000017500000000551612266757730022770 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/strings/c.strings/cwchar.pass.cpp0000644000175000017500000001527112266757730022560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } libcxx/test/strings/c.strings/version_cctype.pass.cpp0000644000175000017500000000072712266757730024345 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/strings/c.strings/version_cwctype.pass.cpp0000644000175000017500000000073112266757730024527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/strings/c.strings/cctype.pass.cpp0000644000175000017500000000501212266757730022570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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'); } libcxx/test/strings/c.strings/version_cwchar.pass.cpp0000644000175000017500000000072712266757730024325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/strings/basic.string/0000755000175000017500000000000012266757730020306 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/0000755000175000017500000000000012266757727023766 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_oplt/0000755000175000017500000000000012266757727026332 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp0000644000175000017500000000443212266757727033054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp0000644000175000017500000000443212266757727033054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp0000644000175000017500000000463012266757727032702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.io/0000755000175000017500000000000012266757727025702 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp0000644000175000017500000000434012266757727031142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp0000644000175000017500000000303112266757727033017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp0000644000175000017500000000277612266757727031664 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp0000644000175000017500000000602212266757727032400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp0000644000175000017500000000515012266757727032233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp0000644000175000017500000000516312266757727032320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_operator==/0000755000175000017500000000000012266757727027401 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp0000644000175000017500000000444012266757727034122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp0000644000175000017500000000444012266757727034122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp0000644000175000017500000000463712266757727033760 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727030276 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/basic.string/string.nonmembers/string_opgt/0000755000175000017500000000000012266757727026325 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp0000644000175000017500000000443212266757727033047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp0000644000175000017500000000443212266757727033047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp0000644000175000017500000000463012266757727032675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_oplt=/0000755000175000017500000000000012266757727026427 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp0000644000175000017500000000442412266757727033152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp0000644000175000017500000000442412266757727033152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp0000644000175000017500000000462212266757727033000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_opgt=/0000755000175000017500000000000012266757727026422 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp0000644000175000017500000000442412266757727033145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp0000644000175000017500000000442412266757727033145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp0000644000175000017500000000462212266757727032773 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_op!=/0000755000175000017500000000000012266757727026130 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp0000644000175000017500000000442012266757727032647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp0000644000175000017500000000442012266757727032647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp0000644000175000017500000000461712266757727032505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.special/0000755000175000017500000000000012266757727026713 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp0000644000175000017500000000450012266757727031335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp0000644000175000017500000000253212266757727033245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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; static_assert(!noexcept(swap(c1, c2)), ""); } #endif } libcxx/test/strings/basic.string/string.nonmembers/string_op+/0000755000175000017500000000000012266757727026045 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp0000644000175000017500000000431112266757727032020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "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 } libcxx/test/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp0000644000175000017500000001272512266757727032573 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "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 } libcxx/test/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp0000644000175000017500000001272512266757727032573 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "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 } libcxx/test/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp0000644000175000017500000000430112266757727032017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "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 } libcxx/test/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp0000644000175000017500000002506112266757727032416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "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 } libcxx/test/strings/basic.string/test_traits.h0000644000175000017500000000077412266757727023042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/types.pass.cpp0000644000175000017500000000747112266757727023142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.cons/0000755000175000017500000000000012266757730022555 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp0000644000175000017500000000440612266757730030116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/move_alloc.pass.cpp0000644000175000017500000000277112266757730026355 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_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 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 } libcxx/test/strings/basic.string/string.cons/copy_assignment.pass.cpp0000644000175000017500000000465212266757730027437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/initializer_list.pass.cpp0000644000175000017500000000227412266757730027611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/move.pass.cpp0000644000175000017500000000273612266757730025204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/move_noexcept.pass.cpp0000644000175000017500000000226112266757730027102 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_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; static_assert(!std::is_nothrow_move_constructible::value, ""); } #endif } libcxx/test/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000241212266757730030444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/copy_alloc.pass.cpp0000644000175000017500000000243012266757730026351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/move_assignment.pass.cpp0000644000175000017500000000523712266757730027433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/char_assignment.pass.cpp0000644000175000017500000000235612266757730027401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp0000644000175000017500000000572712266757730027362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp0000644000175000017500000000434112266757730027062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp0000644000175000017500000000474012266757730030143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/iter_alloc.pass.cpp0000644000175000017500000000710212266757730026343 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp0000644000175000017500000000160712266757730032040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/alloc.pass.cpp0000644000175000017500000000326712266757730025330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_allocator.h" #include "min_allocator.h" template void test() { { 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()); } { 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 __cplusplus >= 201103L template void test2() { { 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()); } { 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 __cplusplus >= 201103L test2, min_allocator > >(); #endif } libcxx/test/strings/basic.string/string.cons/default_noexcept.pass.cpp0000644000175000017500000000225712266757730027565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_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 } libcxx/test/strings/basic.string/string.cons/dtor_noexcept.pass.cpp0000644000175000017500000000220312266757730027100 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/copy.pass.cpp0000644000175000017500000000237612266757730025210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.cons/substr.pass.cpp0000644000175000017500000001410512266757730025551 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/0000755000175000017500000000000012266757727023635 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.iterators/crend.pass.cpp0000644000175000017500000000153512266757727026405 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/db_iterators_2.pass.cpp0000644000175000017500000000175612266757727030221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.iterators/iterators.pass.cpp0000644000175000017500000000362212266757727027325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/cbegin.pass.cpp0000644000175000017500000000161512266757727026540 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/db_iterators_7.pass.cpp0000644000175000017500000000203512266757727030215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.iterators/db_iterators_5.pass.cpp0000644000175000017500000000212112266757727030207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.iterators/db_iterators_3.pass.cpp0000644000175000017500000000175512266757727030221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.iterators/end.pass.cpp0000644000175000017500000000205512266757727026056 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/db_iterators_4.pass.cpp0000644000175000017500000000204212266757727030210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.iterators/db_iterators_8.pass.cpp0000644000175000017500000000176012266757727030222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.iterators/rend.pass.cpp0000644000175000017500000000212512266757727026236 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/rbegin.pass.cpp0000644000175000017500000000177412266757727026565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/begin.pass.cpp0000644000175000017500000000172412266757727026376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/cend.pass.cpp0000644000175000017500000000151212266757727026216 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/crbegin.pass.cpp0000644000175000017500000000164412266757727026724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.iterators/db_iterators_6.pass.cpp0000644000175000017500000000204312266757727030213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.capacity/0000755000175000017500000000000012266757727023416 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp0000644000175000017500000000501112266757727027417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp0000644000175000017500000000377212266757727026553 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/size.pass.cpp0000644000175000017500000000171212266757727026042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp0000644000175000017500000000232312266757727026664 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp0000644000175000017500000000515512266757727030425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp0000644000175000017500000000312112266757727026703 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 test3(const S& s) { S s2(s); const size_t sz = s2.max_size() + 1; try { s2.resize(sz, 'x'); } catch ( const std::length_error & ) { return ; } assert ( false ); } template void test(const S& s) { assert(s.max_size() >= s.size()); test1(s); test2(s); test3(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 } libcxx/test/strings/basic.string/string.capacity/length.pass.cpp0000644000175000017500000000165012266757727026352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp0000644000175000017500000000220612266757727027731 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp0000644000175000017500000000172312266757727026160 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp0000644000175000017500000000165012266757727026227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/0000755000175000017500000000000012266757730022414 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_compare/0000755000175000017500000000000012266757730025430 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp0000644000175000017500000004010112266757730032641 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp0000644000175000017500000004165612266757730032507 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp0000644000175000017500000000431312266757730030562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp0000644000175000017500000020613112266757730033702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.ops/string_compare/string.pass.cpp0000644000175000017500000000443612266757730030416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp0000644000175000017500000125243212266757730034570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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) 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, 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 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); } 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(); } #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(); } #endif } libcxx/test/strings/basic.string/string.ops/string_find/0000755000175000017500000000000012266757730024722 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp0000644000175000017500000001420212266757730030732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp0000644000175000017500000000577312266757730030356 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp0000644000175000017500000004516012266757730032145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp0000644000175000017500000001401412266757730031105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/nothing_to_do.pass.cpp0000644000175000017500000000056412266757730026724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/basic.string/string.ops/string.accessors/0000755000175000017500000000000012266757730025706 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp0000644000175000017500000000227512266757730030477 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string.accessors/data.pass.cpp0000644000175000017500000000227312266757730030274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp0000644000175000017500000000223712266757730032202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.not.of/0000755000175000017500000000000012266757730027252 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp0000644000175000017500000001415212266757730033266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp0000644000175000017500000000616012266757730032675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp0000644000175000017500000004463612266757730034504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp0000644000175000017500000001356012266757730033442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.not.of/0000755000175000017500000000000012266757730027066 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp0000644000175000017500000001401412266757730033077 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp0000644000175000017500000000565212266757730032516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp0000644000175000017500000004366012266757730034314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp0000644000175000017500000001342212266757730033253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.of/0000755000175000017500000000000012266757730026267 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp0000644000175000017500000001403212266757730032300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp0000644000175000017500000000610412266757730031710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp0000644000175000017500000004477412266757730033524 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp0000644000175000017500000001344012266757730032454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_substr/0000755000175000017500000000000012266757730025324 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_substr/substr.pass.cpp0000644000175000017500000001216012266757730030317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_rfind/0000755000175000017500000000000012266757730025104 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp0000644000175000017500000001375412266757730031127 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp0000644000175000017500000000566512266757730030540 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp0000644000175000017500000004363712266757730032336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp0000644000175000017500000001364612266757730031301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.of/0000755000175000017500000000000012266757730026453 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp0000644000175000017500000001416012266757730032466 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp0000644000175000017500000000611012266757730032071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp0000644000175000017500000004545012266757730033700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp0000644000175000017500000001356612266757730032651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/0000755000175000017500000000000012266757730023574 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_op_plus_equal/0000755000175000017500000000000012266757727030040 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp0000644000175000017500000000227112266757727032430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp0000644000175000017500000000163612266757727035075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp0000644000175000017500000000546312266757727033201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp0000644000175000017500000000561512266757727033026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/0000755000175000017500000000000012266757727026474 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp0000644000175000017500000034476012266757727034607 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); #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 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")); } 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(); } #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(); } #endif } libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp0000644000175000017500000000250712266757727034552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp0000644000175000017500000000506312266757727032111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp0000644000175000017500000002634312266757727033156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp0000644000175000017500000002755312266757727032673 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp0000644000175000017500000003047112266757727032512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp0000644000175000017500000013354112266757727033720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp0000644000175000017500000002302612266757727033142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp0000644000175000017500000001722012266757727033160 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727030112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/basic.string/string.modifiers/string_copy/0000755000175000017500000000000012266757727026142 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp0000644000175000017500000001344112266757727030570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/0000755000175000017500000000000012266757730026575 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp0000644000175000017500000005354712266757730034030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp0000644000175000017500000004074612266757730034007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp0000644000175000017500000003712512266757730034273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp0000644000175000017500000000203712266757730035674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp0000644000175000017500000005530012266757730033643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp0000644000175000017500000017721312266757730035041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp0000644000175000017500000025366212266757730035062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp0000644000175000017500000016521312266757730034312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp0000644000175000017500000004211212266757730033622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp0000644000175000017500000151254412266757730035740 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); #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 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")); } 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(); } #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(); } #endif } libcxx/test/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp0000644000175000017500000005115712266757730034312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/0000755000175000017500000000000012266757727026454 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp0000644000175000017500000000163612266757727033511 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp0000644000175000017500000001515412266757727031764 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp0000644000175000017500000000336512266757727031614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp0000644000175000017500000000570712266757727033530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); #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()); } } 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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp0000644000175000017500000000514012266757727031433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp0000644000175000017500000000432112266757727032637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp0000644000175000017500000000514612266757727032150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "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 } libcxx/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp0000644000175000017500000000326612266757727032103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/0000755000175000017500000000000012266757727026437 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp0000644000175000017500000000164412266757727033473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp0000644000175000017500000000207412266757727032052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp0000644000175000017500000001631412266757727031746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp0000644000175000017500000000362312266757727031574 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp0000644000175000017500000000614512266757727033510 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); #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()); } } 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/string.pass.cpp0000644000175000017500000000560412266757727031423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp0000644000175000017500000000455712266757727032635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp0000644000175000017500000000353412266757727032064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_swap/0000755000175000017500000000000012266757727026142 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp0000644000175000017500000000426112266757727030570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_erase/0000755000175000017500000000000012266757730026261 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp0000644000175000017500000000410212266757730030672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp0000644000175000017500000000174612266757730032612 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp0000644000175000017500000000234612266757730031515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp0000644000175000017500000000212012266757730033621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp0000644000175000017500000001440512266757730031724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp0000644000175000017500000000206012266757730032601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp0000644000175000017500000000211712266757730033626 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp0000644000175000017500000002530712266757730031745 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp0000644000175000017500000000201112266757730033622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp0000644000175000017500000000211712266757730033630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.require/0000755000175000017500000000000012266757727023275 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.require/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/basic.string/input_iterator.h0000644000175000017500000000264112266757727023540 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.access/0000755000175000017500000000000012266757727023062 5ustar sylvestresylvestrelibcxx/test/strings/basic.string/string.access/db_cback.pass.cpp0000644000175000017500000000170012266757727026241 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.access/db_front.pass.cpp0000644000175000017500000000203112266757727026324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.access/db_cindex.pass.cpp0000644000175000017500000000174212266757727026456 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.access/back.pass.cpp0000644000175000017500000000236612266757727025442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.access/db_cfront.pass.cpp0000644000175000017500000000170312266757727026474 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.access/db_index.pass.cpp0000644000175000017500000000172012266757727026307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.access/index.pass.cpp0000644000175000017500000000267412266757727025653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.access/at.pass.cpp0000644000175000017500000000233012266757727025135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/basic.string/string.access/db_back.pass.cpp0000644000175000017500000000202412266757727026076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/strings/basic.string/string.access/front.pass.cpp0000644000175000017500000000235112266757727025664 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/strings/strings.general/0000755000175000017500000000000012266757727021033 5ustar sylvestresylvestrelibcxx/test/strings/strings.general/nothing_to_do.pass.cpp0000644000175000017500000000060312266757727025335 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/strings/string.classes/0000755000175000017500000000000012266757727020670 5ustar sylvestresylvestrelibcxx/test/strings/string.classes/typedefs.pass.cpp0000644000175000017500000000151412266757727024165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/strings/basic.string.literals/0000755000175000017500000000000012266757727022132 5ustar sylvestresylvestrelibcxx/test/strings/basic.string.literals/literal1.pass.cpp0000644000175000017500000000101312266757727025313 0ustar sylvestresylvestre// -*- 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 } libcxx/test/strings/basic.string.literals/literal2.fail.cpp0000644000175000017500000000104412266757727025265 0ustar sylvestresylvestre// -*- 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 } libcxx/test/strings/basic.string.literals/literal2.pass.cpp0000644000175000017500000000103412266757727025317 0ustar sylvestresylvestre// -*- 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 } libcxx/test/strings/basic.string.literals/literal3.pass.cpp0000644000175000017500000000077412266757727025332 0ustar sylvestresylvestre// -*- 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 } libcxx/test/strings/basic.string.literals/literal1.fail.cpp0000644000175000017500000000106712266757727025271 0ustar sylvestresylvestre// -*- 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 } libcxx/test/strings/basic.string.literals/literal.pass.cpp0000644000175000017500000000367512266757727025252 0ustar sylvestresylvestre// -*- 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 } libcxx/test/strings/string.conversions/0000755000175000017500000000000012266757730021575 5ustar sylvestresylvestrelibcxx/test/strings/string.conversions/stol.pass.cpp0000644000175000017500000000463112266757730024233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } } libcxx/test/strings/string.conversions/to_string.pass.cpp0000644000175000017500000000612712266757730025264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/strings/string.conversions/stoll.pass.cpp0000644000175000017500000000456512266757730024415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } } libcxx/test/strings/string.conversions/stof.pass.cpp0000644000175000017500000000661412266757730024230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } } libcxx/test/strings/string.conversions/stod.pass.cpp0000644000175000017500000000643012266757730024222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/strings/string.conversions/to_wstring.pass.cpp0000644000175000017500000000621212266757730025446 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/strings/string.conversions/stoull.pass.cpp0000644000175000017500000000463312266757730024576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } } libcxx/test/strings/string.conversions/stoi.pass.cpp0000644000175000017500000000450012266757730024223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/strings/string.conversions/stold.pass.cpp0000644000175000017500000000652512266757730024403 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/strings/string.conversions/stoul.pass.cpp0000644000175000017500000000456212266757730024423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } } libcxx/test/strings/char.traits/0000755000175000017500000000000012266757727020150 5ustar sylvestresylvestrelibcxx/test/strings/char.traits/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727024460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/char.traits/char.traits.typedefs/0000755000175000017500000000000012266757727024214 5ustar sylvestresylvestrelibcxx/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727030524 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/char.traits/char.traits.specializations/0000755000175000017500000000000012266757727025572 5ustar sylvestresylvestrelibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/0000755000175000017500000000000012266757727034561 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find0000644000175000017500000000164412266757727035431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_0000644000175000017500000000147212266757727035447 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_i0000644000175000017500000000131212266757727035433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/type0000644000175000017500000000213612266757727035467 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_c0000644000175000017500000000131612266757727035431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move0000644000175000017500000000163212266757727035454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.0000644000175000017500000000105512266757727035334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.p0000644000175000017500000000122312266757727035357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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')); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assi0000644000175000017500000000115412266757727035444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/comp0000644000175000017500000000317112266757727035444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/leng0000644000175000017500000000144712266757727035437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assi0000644000175000017500000000136712266757727035452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.p0000644000175000017500000000122212266757727035344 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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')); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_i0000644000175000017500000000163612266757727035427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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())); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy0000644000175000017500000000136412266757727035462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727032102 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/0000755000175000017500000000000012266757727034130 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pa0000644000175000017500000000160012266757727035367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof0000644000175000017500000000144112266757727035504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_0000644000175000017500000000127212266757727035510 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.p0000644000175000017500000000210012266757727035446 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char0000644000175000017500000000127612266757727035500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pa0000644000175000017500000000157112266757727035424 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pas0000644000175000017500000000104612266757727035407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass0000644000175000017500000000154612266757727035445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign20000644000175000017500000000114012266757727035415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare0000644000175000017500000000304612266757727035504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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("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); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.0000644000175000017500000000142012266757727035407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign30000644000175000017500000000133712266757727035426 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass0000644000175000017500000000120112266757727035417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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')); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_0000644000175000017500000000157612266757727035502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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())); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pa0000644000175000017500000000133712266757727035430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/0000755000175000017500000000000012266757727034620 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/fin0000644000175000017500000000177512266757727035331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not0000644000175000017500000000161612266757727035347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::not_eof(U'a') == U'a'); assert(std::char_traits::not_eof(U'A') == U'A'); 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 } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_0000644000175000017500000000143312266757727035325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::to_int_type(U'a') == U'a'); assert(std::char_traits::to_int_type(U'A') == U'A'); assert(std::char_traits::to_int_type(0) == 0); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/typ0000644000175000017500000000235012266757727035357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_0000644000175000017500000000143712266757727035331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::to_char_type(U'a') == U'a'); assert(std::char_traits::to_char_type(U'A') == U'A'); assert(std::char_traits::to_char_type(0) == 0); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/mov0000644000175000017500000000176212266757727035352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof0000644000175000017500000000116412266757727035316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.0000644000175000017500000000134412266757727035242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 char32_t c = U'\0'; assert(!std::char_traits::lt(U'a', U'a')); assert( std::char_traits::lt(U'A', U'a')); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/ass0000644000175000017500000000127412266757727035335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 char32_t c = U'\0'; std::char_traits::assign(c, U'a'); assert(c == U'a'); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/com0000644000175000017500000000332712266757727035326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::compare(U"", U"", 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 // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/len0000644000175000017500000000157212266757727035326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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 // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/ass0000644000175000017500000000151412266757727035332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.0000644000175000017500000000134312266757727035227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 char32_t c = U'\0'; assert(std::char_traits::eq(U'a', U'a')); assert(!std::char_traits::eq(U'a', U'A')); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_0000644000175000017500000000176412266757727035317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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')); assert( std::char_traits::eq_int_type(std::char_traits::eof(), std::char_traits::eof())); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/cop0000644000175000017500000000151012266757727035321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/0000755000175000017500000000000012266757727034622 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/fin0000644000175000017500000000177512266757727035333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not0000644000175000017500000000161612266757727035351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::not_eof(u'a') == u'a'); assert(std::char_traits::not_eof(u'A') == u'A'); 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 } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_0000644000175000017500000000143312266757727035327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::to_int_type(u'a') == u'a'); assert(std::char_traits::to_int_type(u'A') == u'A'); assert(std::char_traits::to_int_type(0) == 0); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/typ0000644000175000017500000000235012266757727035361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_0000644000175000017500000000143712266757727035333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::to_char_type(u'a') == u'a'); assert(std::char_traits::to_char_type(u'A') == u'A'); assert(std::char_traits::to_char_type(0) == 0); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/mov0000644000175000017500000000176212266757727035354 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof0000644000175000017500000000116412266757727035320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.0000644000175000017500000000134412266757727035244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 char16_t c = u'\0'; assert(!std::char_traits::lt(u'a', u'a')); assert( std::char_traits::lt(u'A', u'a')); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/ass0000644000175000017500000000127412266757727035337 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 char16_t c = u'\0'; std::char_traits::assign(c, u'a'); assert(c == u'a'); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/com0000644000175000017500000000332712266757727035330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 assert(std::char_traits::compare(u"", u"", 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 // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/len0000644000175000017500000000157212266757727035330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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 // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/ass0000644000175000017500000000151412266757727035334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.0000644000175000017500000000134312266757727035231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 char16_t c = u'\0'; assert(std::char_traits::eq(u'a', u'a')); assert(!std::char_traits::eq(u'a', u'A')); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_0000644000175000017500000000176412266757727035321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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')); assert( std::char_traits::eq_int_type(std::char_traits::eof(), std::char_traits::eof())); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpplibcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/cop0000644000175000017500000000151012266757727035323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } libcxx/test/strings/char.traits/char.traits.require/0000755000175000017500000000000012266757727024045 5ustar sylvestresylvestrelibcxx/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727030355 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/strings/basic.string.hash/0000755000175000017500000000000012266757730021230 5ustar sylvestresylvestrelibcxx/test/strings/basic.string.hash/strings.pass.cpp0000644000175000017500000000217112266757730024373 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_base_of, H>::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(); } libcxx/test/testit0000755000175000017500000000756612266757726015514 0ustar sylvestresylvestre#!/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 libcxx/test/algorithms/0000755000175000017500000000000012266757725016404 5ustar sylvestresylvestrelibcxx/test/algorithms/version.pass.cpp0000644000175000017500000000073512266757725021547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/algorithms/alg.modifying.operations/0000755000175000017500000000000012266757725023315 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.transform/0000755000175000017500000000000012266757725026072 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp0000644000175000017500000003547712266757725033142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp0000644000175000017500000000605112266757725032776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.reverse/0000755000175000017500000000000012266757725025532 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp0000644000175000017500000000531712266757725031716 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp0000644000175000017500000000275012266757725030662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.rotate/0000755000175000017500000000000012266757725025355 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp0000644000175000017500000003107212266757725030327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp0000644000175000017500000001035412266757725031361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.modifying.operations/alg.fill/0000755000175000017500000000000012266757725025005 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp0000644000175000017500000000602112266757725027720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" template void test_char() { const unsigned n = 4; char ca[n] = {0}; assert(std::fill_n(Iter(ca), 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), 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, 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, 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, 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], 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], 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp0000644000175000017500000000255612266757725027414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.swap/0000755000175000017500000000000012266757725025031 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp0000644000175000017500000000124212266757725030476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp0000644000175000017500000001002512266757725031011 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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 } libcxx/test/algorithms/alg.modifying.operations/alg.unique/0000755000175000017500000000000012266757725025365 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp0000644000175000017500000001064512266757725031404 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp0000644000175000017500000001246412266757725032417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp0000644000175000017500000001440412266757725031361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp0000644000175000017500000001133112266757725030343 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.modifying.operations/alg.move/0000755000175000017500000000000012266757725025025 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.move/move.pass.cpp0000644000175000017500000001425312266757725027451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp0000644000175000017500000000575612266757725031317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.modifying.operations/alg.remove/0000755000175000017500000000000012266757725025354 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp0000644000175000017500000000453012266757725031002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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)); 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); } #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 } libcxx/test/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp0000644000175000017500000000542712266757725032042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp0000644000175000017500000000416712266757725030332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp0000644000175000017500000000522512266757725031360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.copy/0000755000175000017500000000000012266757725025031 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp0000644000175000017500000000576212266757725030144 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp0000644000175000017500000000550012266757725027771 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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), 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp0000644000175000017500000000305612266757725031316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp0000644000175000017500000000546312266757725027464 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.replace/0000755000175000017500000000000012266757725025472 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp0000644000175000017500000000234012266757725031233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp0000644000175000017500000000554412266757725032276 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp0000644000175000017500000000221112266757725030552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp0000644000175000017500000000543112266757725031613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/0000755000175000017500000000000012266757725026772 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp0000644000175000017500000000152212266757725033437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp0000644000175000017500000000167612266757725034455 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp0000644000175000017500000000177112266757725034500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.modifying.operations/alg.generate/0000755000175000017500000000000012266757725025651 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp0000644000175000017500000000213312266757725031113 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp0000644000175000017500000000216212266757725031432 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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), 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(); } libcxx/test/algorithms/alg.modifying.operations/alg.partitions/0000755000175000017500000000000012266757725026253 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp0000644000175000017500000000372112266757725032744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" struct is_odd { bool operator()(const int& i) const {return i & 1;} }; int main() { { const int ia[] = {1, 2, 3, 4, 5, 6}; assert(!std::is_partitioned(input_iterator(std::begin(ia)), input_iterator(std::end(ia)), is_odd())); } { const int ia[] = {1, 3, 5, 2, 4, 6}; assert( std::is_partitioned(input_iterator(std::begin(ia)), input_iterator(std::end(ia)), is_odd())); } { const int ia[] = {2, 4, 6, 1, 3, 5}; assert(!std::is_partitioned(input_iterator(std::begin(ia)), input_iterator(std::end(ia)), is_odd())); } { const int ia[] = {1, 3, 5, 2, 4, 6, 7}; assert(!std::is_partitioned(input_iterator(std::begin(ia)), input_iterator(std::end(ia)), is_odd())); } { const int ia[] = {1, 3, 5, 2, 4, 6, 7}; assert( std::is_partitioned(input_iterator(std::begin(ia)), input_iterator(std::begin(ia)), is_odd())); } } libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp0000644000175000017500000000304612266757725032772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp0000644000175000017500000002001712266757725033267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp0000644000175000017500000000610512266757725033150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } libcxx/test/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp0000644000175000017500000000604612266757725031743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.nonmodifying/0000755000175000017500000000000012266757725021646 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.find.end/0000755000175000017500000000000012266757725024075 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp0000644000175000017500000000501012266757725027310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 >(); } libcxx/test/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp0000644000175000017500000000701412266757725030330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 >(); } libcxx/test/algorithms/alg.nonmodifying/alg.find.first.of/0000755000175000017500000000000012266757725025061 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp0000644000175000017500000000461712266757725032367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp0000644000175000017500000000415712266757725031354 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.nonmodifying/alg.foreach/0000755000175000017500000000000012266757725024017 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp0000644000175000017500000000214212266757725026446 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.nonmodifying/alg.equal/0000755000175000017500000000000012266757725023517 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp0000644000175000017500000000520612266757725026302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp0000644000175000017500000000647012266757725027320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.nonmodifying/alg.any_of/0000755000175000017500000000000012266757725023663 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp0000644000175000017500000000345612266757725026617 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.nonmodifying/alg.none_of/0000755000175000017500000000000012266757725024033 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp0000644000175000017500000000347112266757725027134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.nonmodifying/alg.count/0000755000175000017500000000000012266757725023540 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp0000644000175000017500000000206712266757725026346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp0000644000175000017500000000245012266757725027020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.nonmodifying/alg.search/0000755000175000017500000000000012266757725023655 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp0000644000175000017500000001401512266757725030123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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; } int main() { test >(); test >(); test >(); } libcxx/test/algorithms/alg.nonmodifying/alg.search/search.pass.cpp0000644000175000017500000000715212266757725026600 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 >(); } libcxx/test/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp0000644000175000017500000000635112266757725027115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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)); } int main() { test >(); test >(); test >(); } libcxx/test/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp0000644000175000017500000001155112266757725027610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 >(); } libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/0000755000175000017500000000000012266757725025452 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp0000644000175000017500000007366312266757725032204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } } libcxx/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp0000644000175000017500000011272412266757725033206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } } libcxx/test/algorithms/alg.nonmodifying/alg.all_of/0000755000175000017500000000000012266757725023644 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp0000644000175000017500000000265312266757725026557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.nonmodifying/alg.adjacent.find/0000755000175000017500000000000012266757725025100 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp0000644000175000017500000000241512266757725031324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp0000644000175000017500000000275712266757725032347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.nonmodifying/mismatch/0000755000175000017500000000000012266757725023453 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp0000644000175000017500000000454412266757725027752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" #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}; assert(std::mismatch(input_iterator(ia), input_iterator(ia + sa), input_iterator(ib), std::equal_to()) == (std::pair, input_iterator >( input_iterator(ia+3), input_iterator(ib+3)))); #ifdef HAS_FOUR_ITERATOR_VERSION assert(std::mismatch(input_iterator(ia), input_iterator(ia + sa), input_iterator(ib), input_iterator(ib + sa), std::equal_to()) == (std::pair, input_iterator >( input_iterator(ia+3), input_iterator(ib+3)))); #endif assert(std::mismatch(ia, ia + sa, ib, std::equal_to()) == (std::pair(ia+3,ib+3))); #ifdef HAS_FOUR_ITERATOR_VERSION assert(std::mismatch(ia, ia + sa, ib, ib + sa, std::equal_to()) == (std::pair(ia+3,ib+3))); assert(std::mismatch(ia, ia + sa, ib, ib + 2, std::equal_to()) == (std::pair(ia+2,ib+2))); #endif } libcxx/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp0000644000175000017500000000443012266757725026732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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}; assert(std::mismatch(input_iterator(ia), input_iterator(ia + sa), input_iterator(ib)) == (std::pair, input_iterator >( input_iterator(ia+3), input_iterator(ib+3)))); #ifdef HAS_FOUR_ITERATOR_VERSION assert(std::mismatch(input_iterator(ia), input_iterator(ia + sa), input_iterator(ib), input_iterator(ib + sa)) == (std::pair, input_iterator >( input_iterator(ia+3), input_iterator(ib+3)))); assert(std::mismatch(input_iterator(ia), input_iterator(ia + sa), input_iterator(ib), input_iterator(ib + 2)) == (std::pair, input_iterator >( input_iterator(ia+2), input_iterator(ib+2)))); #endif } libcxx/test/algorithms/alg.nonmodifying/alg.find/0000755000175000017500000000000012266757725023330 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.nonmodifying/alg.find/find.pass.cpp0000644000175000017500000000176312266757725025730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp0000644000175000017500000000235512266757725027264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp0000644000175000017500000000231112266757725026374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/algorithms/alg.c.library/0000755000175000017500000000000012266757725021033 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.c.library/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757725026044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.sorting/0000755000175000017500000000000012266757725020633 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725025143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.sorting/alg.min.max/0000755000175000017500000000000012266757725022744 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp0000644000175000017500000000253512266757725026716 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } int main() { test >(); test >(); test >(); test(); } libcxx/test/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp0000644000175000017500000000205112266757725030272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } libcxx/test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp0000644000175000017500000000173112266757725025710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp0000644000175000017500000000234312266757725026726 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.sorting/alg.min.max/min.pass.cpp0000644000175000017500000000153112266757725025200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp0000644000175000017500000000344612266757725027426 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } } int main() { test >(); test >(); test >(); test(); } libcxx/test/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp0000644000175000017500000000376512266757725030450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } } int main() { test >(); test >(); test >(); test(); } libcxx/test/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp0000644000175000017500000000223512266757725031004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #include #include #include 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))); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } libcxx/test/algorithms/alg.sorting/alg.min.max/max.pass.cpp0000644000175000017500000000153112266757725025202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp0000644000175000017500000000271712266757725027740 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } int main() { test >(); test >(); test >(); test(); } libcxx/test/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp0000644000175000017500000000205112266757725030274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } libcxx/test/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp0000644000175000017500000000157012266757725027261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } libcxx/test/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp0000644000175000017500000000157112266757725027264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } libcxx/test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp0000644000175000017500000000214312266757725026220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp0000644000175000017500000000175412266757725027773 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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))); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } libcxx/test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp0000644000175000017500000000253512266757725026720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } int main() { test >(); test >(); test >(); test(); } libcxx/test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp0000644000175000017500000000214312266757725026216 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp0000644000175000017500000000271712266757725027736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } int main() { test >(); test >(); test >(); test(); } libcxx/test/algorithms/alg.sorting/alg.merge/0000755000175000017500000000000012266757725022474 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp0000644000175000017500000003312412266757725026265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 OutputIterator // && OutputIterator // && CopyConstructible // OutIter // merge(InIter1 first1, InIter1 last1, // InIter2 first2, InIter2 last2, OutIter result, Compare comp); #include #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; std::reverse(ia, ia+N); std::reverse(ib, ib+N); OutIter r = std::merge(InIter1(ia), InIter1(ia+N), InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater()); 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())); 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()); OutIter r = std::merge(InIter1(ia), InIter1(ia+N), InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater()); 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())); 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(); } libcxx/test/algorithms/alg.sorting/alg.merge/merge.pass.cpp0000644000175000017500000003246712266757725025260 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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(); } libcxx/test/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp0000644000175000017500000000530712266757725027762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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 #include "test_iterators.h" template void test_one(unsigned N, unsigned M) { assert(M <= N); int* ia = new int[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()); std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N), std::greater()); if(N > 0) { assert(ia[0] == N-1); assert(ia[N-1] == 0); assert(std::is_sorted(ia, ia+N, std::greater())); } 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(); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp0000644000175000017500000000334212266757725026741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" template void test_one(unsigned N, unsigned M) { assert(M <= N); int* ia = new int[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(); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/0000755000175000017500000000000012266757725024474 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/0000755000175000017500000000000012266757725026377 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp0000644000175000017500000000164412266757725032041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp0000644000175000017500000000332012266757725033050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725031004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.sorting/alg.heap.operations/is.heap/0000755000175000017500000000000012266757725026023 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp0000644000175000017500000005531312266757725032326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp0000644000175000017500000006755612266757725033360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp0000644000175000017500000012055612266757725032133 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp0000644000175000017500000007427512266757725031123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/push.heap/0000755000175000017500000000000012266757725026367 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp0000644000175000017500000000160212266757725032013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp0000644000175000017500000000315012266757725033031 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/0000755000175000017500000000000012266757725026325 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp0000644000175000017500000000315212266757725032727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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())); 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()); assert(std::is_heap(ia, ia+N, indirect_less())); delete [] ia; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp0000644000175000017500000000160412266757725031711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/0000755000175000017500000000000012266757725026206 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp0000644000175000017500000000344312266757725032474 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp0000644000175000017500000000165712266757725031463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.sorting/alg.lex.comparison/0000755000175000017500000000000012266757725024336 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp0000644000175000017500000000570612266757725032663 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(ia, ia+sa, ib, ib+2)); assert(std::lexicographical_compare(ib, ib+2, ia, ia+sa)); assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+3)); assert(std::lexicographical_compare(ib, ib+3, ia, ia+sa)); assert(std::lexicographical_compare(ia, ia+sa, ib+1, ib+3)); assert(!std::lexicographical_compare(ib+1, ib+3, ia, 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(); } libcxx/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp0000644000175000017500000000616412266757725033700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(ia, ia+sa, ib, ib+2, c)); assert(std::lexicographical_compare(ib, ib+2, ia, ia+sa, c)); assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+3, c)); assert(std::lexicographical_compare(ib, ib+3, ia, ia+sa, c)); assert(!std::lexicographical_compare(ia, ia+sa, ib+1, ib+3, c)); assert(std::lexicographical_compare(ib+1, ib+3, ia, 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(); } libcxx/test/algorithms/alg.sorting/alg.nth.element/0000755000175000017500000000000012266757725023616 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp0000644000175000017500000000374512266757725030620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); 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 } libcxx/test/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp0000644000175000017500000000247112266757725027575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); 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); } libcxx/test/algorithms/alg.sorting/alg.permutation.generators/0000755000175000017500000000000012266757725026114 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp0000644000175000017500000000317512266757725034216 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp0000644000175000017500000000317512266757725034214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp0000644000175000017500000000300212266757725033165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp0000644000175000017500000000300212266757725033163 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.sort/0000755000175000017500000000000012266757725022364 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.sorting/alg.sort/sort/0000755000175000017500000000000012266757725023353 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp0000644000175000017500000000703612266757725026021 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp0000644000175000017500000000303412266757725027031 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.sorting/alg.sort/stable.sort/0000755000175000017500000000000012266757725024624 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp0000644000175000017500000000713512266757725030624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp0000644000175000017500000000374612266757725031646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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
); // ... // }; #include #include int main() { { int i = 0; int* a = std::pointer_traits::pointer_to(i); assert(a = &i); } { (std::pointer_traits::element_type)0; } } libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp0000644000175000017500000000121412266757726027346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp0000644000175000017500000000141212266757726025673 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp0000644000175000017500000000144212266757726025461 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/0000755000175000017500000000000012266757726027540 5ustar sylvestresylvestrelibcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp0000644000175000017500000000205512266757726033375 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } } libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp0000644000175000017500000000120012266757726026700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/0000755000175000017500000000000012266757726026674 5ustar sylvestresylvestrelibcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp0000644000175000017500000000223112266757726033476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp0000644000175000017500000000414112266757726031610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp0000644000175000017500000000213112266757726033034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/util.dynamic.safety/0000755000175000017500000000000012266757726023451 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp0000644000175000017500000000116012266757726031136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp0000644000175000017500000000116112266757726030506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp0000644000175000017500000000122712266757726031016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/specialized.algorithms/0000755000175000017500000000000012266757726024223 5ustar sylvestresylvestrelibcxx/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726030533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill/0000755000175000017500000000000012266757726030020 5ustar sylvestresylvestrelibcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp0000644000175000017500000000222712266757726035352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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); } libcxx/test/utilities/memory/specialized.algorithms/specialized.addressof/0000755000175000017500000000000012266757726030470 5ustar sylvestresylvestrelibcxx/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp0000644000175000017500000000173212266757726034116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/0000755000175000017500000000000012266757726030044 5ustar sylvestresylvestrelibcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp0000644000175000017500000000227412266757726035424 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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); } libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp0000644000175000017500000000230012266757726035727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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); } libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/0000755000175000017500000000000012266757726030254 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpplibcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.c0000644000175000017500000000225012266757726035557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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); } libcxx/test/utilities/allocator.adaptor/0000755000175000017500000000000012266757725021657 5ustar sylvestresylvestrelibcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/0000755000175000017500000000000012266757725026721 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpplibcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construct0000644000175000017500000000353512266757725036025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp0000644000175000017500000000416212266757725034235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp0000644000175000017500000000232512266757725033572 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp0000644000175000017500000000217112266757725032212 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp0000644000175000017500000000251212266757725033210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp0000644000175000017500000000247412266757725032476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp0000644000175000017500000001013312266757725032414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp0000644000175000017500000000247712266757725033557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp0000644000175000017500000000316712266757725032072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/types.pass.cpp0000644000175000017500000000632212266757725024477 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/scoped.adaptor.operators/0000755000175000017500000000000012266757725026602 5ustar sylvestresylvestrelibcxx/test/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp0000644000175000017500000000360412266757725030663 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/0000755000175000017500000000000012266757725026420 5ustar sylvestresylvestrelibcxx/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp0000644000175000017500000000771112266757725031354 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp0000644000175000017500000000477012266757725033305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp0000644000175000017500000000431012266757725033277 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp0000644000175000017500000000352012266757725031515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp0000644000175000017500000000423412266757725031046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.types/0000755000175000017500000000000012266757725026433 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpplibcxx/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignme0000644000175000017500000000227012266757725036013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp0000644000175000017500000000230012266757725034313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpplibcxx/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignme0000644000175000017500000000227112266757725036020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp0000644000175000017500000000221512266757725035656 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/ratio/0000755000175000017500000000000012266757725017364 5ustar sylvestresylvestrelibcxx/test/utilities/ratio/ratio.ratio/0000755000175000017500000000000012266757725021617 5ustar sylvestresylvestrelibcxx/test/utilities/ratio/ratio.ratio/ratio3.fail.cpp0000644000175000017500000000114212266757725024434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/ratio/ratio.ratio/ratio1.fail.cpp0000644000175000017500000000101012266757725024424 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/ratio/ratio.ratio/ratio2.fail.cpp0000644000175000017500000000114212266757725024433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/ratio/ratio.ratio/ratio.pass.cpp0000644000175000017500000000255712266757725024417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 thcommon // 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>(); } libcxx/test/utilities/ratio/version.pass.cpp0000644000175000017500000000072512266757725022526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/ratio/typedefs.pass.cpp0000644000175000017500000000321312266757725022657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, ""); } libcxx/test/utilities/ratio/ratio.arithmetic/0000755000175000017500000000000012266757725022632 5ustar sylvestresylvestrelibcxx/test/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp0000644000175000017500000000325112266757725026746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, ""); } } libcxx/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp0000644000175000017500000000427712266757725027342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, ""); } } libcxx/test/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp0000644000175000017500000000327112266757725027363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, ""); } } libcxx/test/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp0000644000175000017500000000104412266757725027324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp0000644000175000017500000000103212266757725026172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp0000644000175000017500000000104512266757725027275 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp0000644000175000017500000000420512266757725026232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, ""); } } libcxx/test/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp0000644000175000017500000000104012266757725026705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/ratio/ratio.si/0000755000175000017500000000000012266757725021114 5ustar sylvestresylvestrelibcxx/test/utilities/ratio/ratio.si/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725025424 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/ratio/ratio.comparison/0000755000175000017500000000000012266757725022653 5ustar sylvestresylvestrelibcxx/test/utilities/ratio/ratio.comparison/ratio_less.pass.cpp0000644000175000017500000000552312266757725026475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp0000644000175000017500000000336512266757725027666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp0000644000175000017500000000331112266757725026627 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp0000644000175000017500000000333412266757725027156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp0000644000175000017500000000335512266757725027517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp0000644000175000017500000000341612266757725030346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/utilities/time/0000755000175000017500000000000012266757726017205 5ustar sylvestresylvestrelibcxx/test/utilities/time/hours.pass.cpp0000644000175000017500000000153012266757725022014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/minutes.pass.cpp0000644000175000017500000000153112266757725022341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/version.pass.cpp0000644000175000017500000000072712266757725022350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/time/time.clock.req/0000755000175000017500000000000012266757725022022 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.clock.req/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/time/clock.h0000644000175000017500000000141712266757725020453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/utilities/time/time.traits/0000755000175000017500000000000012266757726021450 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.traits/time.traits.specializations/0000755000175000017500000000000012266757726027113 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp0000644000175000017500000000332412266757726032735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 > >(); } libcxx/test/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp0000644000175000017500000000302512266757726032411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 > >(); } libcxx/test/utilities/time/time.traits/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726025760 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/time/time.traits/time.traits.is_fp/0000755000175000017500000000000012266757726025012 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp0000644000175000017500000000145412266757726033365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/time/time.traits/time.traits.duration_values/0000755000175000017500000000000012266757726027116 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp0000644000175000017500000000225112266757726031352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp0000644000175000017500000000140712266757726031550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp0000644000175000017500000000222712266757726031357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/rep.h0000644000175000017500000000146612266757725020152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/utilities/time/seconds.pass.cpp0000644000175000017500000000151512266757726022316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/time.clock/0000755000175000017500000000000012266757725021234 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.clock/time.clock.system/0000755000175000017500000000000012266757725024607 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.clock/time.clock.system/consistency.pass.cpp0000644000175000017500000000217412266757725030625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } libcxx/test/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp0000644000175000017500000000106712266757725030247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp0000644000175000017500000000110212266757725030371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp0000644000175000017500000000111312266757725030560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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())); } libcxx/test/utilities/time/time.clock/time.clock.system/now.pass.cpp0000644000175000017500000000101412266757725027057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 int main() { typedef std::chrono::system_clock C; C::time_point t1 = C::now(); } libcxx/test/utilities/time/time.clock/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725025544 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/time/time.clock/time.clock.steady/0000755000175000017500000000000012266757725024554 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp0000644000175000017500000000204212266757725030564 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 // // 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); } libcxx/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp0000644000175000017500000000112612266757725027030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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); } libcxx/test/utilities/time/time.clock/time.clock.hires/0000755000175000017500000000000012266757725024375 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp0000644000175000017500000000211612266757725030407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } libcxx/test/utilities/time/time.clock/time.clock.hires/now.pass.cpp0000644000175000017500000000103612266757725026651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 int main() { typedef std::chrono::high_resolution_clock C; C::time_point t1 = C::now(); } libcxx/test/utilities/time/microseconds.pass.cpp0000644000175000017500000000153112266757725023345 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/time.point/0000755000175000017500000000000012266757725021272 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.arithmetic/0000755000175000017500000000000012266757725025510 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp0000644000175000017500000000130612266757725030106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp0000644000175000017500000000130612266757725030110 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/time/time.point/time.point.cast/0000755000175000017500000000000012266757725024311 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp0000644000175000017500000000605412266757725031150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp0000644000175000017500000000164112266757725030121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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))); } libcxx/test/utilities/time/time.point/default_duration.pass.cpp0000644000175000017500000000133212266757725026273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/time.point/time.point.cons/0000755000175000017500000000000012266757725024321 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.cons/convert.fail.cpp0000644000175000017500000000150712266757725027422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } } libcxx/test/utilities/time/time.point/time.point.cons/convert.pass.cpp0000644000175000017500000000211512266757725027451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/time.point.cons/duration.fail.cpp0000644000175000017500000000120012266757725027555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.point/time.point.cons/default.pass.cpp0000644000175000017500000000154312266757725027421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/time.point.cons/duration.pass.cpp0000644000175000017500000000221712266757725027621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/time.point.nonmember/0000755000175000017500000000000012266757725025341 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp0000644000175000017500000000241712266757725031416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp0000644000175000017500000000335512266757725027650 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp0000644000175000017500000000230512266757725031734 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/duration.fail.cpp0000644000175000017500000000104212266757725024532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.point/time.point.observer/0000755000175000017500000000000012266757725025206 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757725032217 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/time/time.point/time.point.special/0000755000175000017500000000000012266757725024777 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.special/min.pass.cpp0000644000175000017500000000124112266757725027231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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())); } libcxx/test/utilities/time/time.point/time.point.special/max.pass.cpp0000644000175000017500000000124112266757725027233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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())); } libcxx/test/utilities/time/time.point/time.point.comparisons/0000755000175000017500000000000012266757725025714 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp0000644000175000017500000000230212266757725031134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp0000644000175000017500000000302512266757725030776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp0000644000175000017500000000414712266757725031200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp0000644000175000017500000000563712266757725031044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/0000755000175000017500000000000012266757726021767 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/ratio.fail.cpp0000644000175000017500000000122512266757725024522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/types.pass.cpp0000644000175000017500000000130312266757726024601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/0000755000175000017500000000000012266757725026700 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp0000644000175000017500000000110612266757725031256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp0000644000175000017500000000110612266757725031252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp0000644000175000017500000000123712266757725033474 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp0000644000175000017500000000105512266757725032266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp0000644000175000017500000000105512266757725032433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp0000644000175000017500000000111112266757725031761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp0000644000175000017500000000105512266757725032411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp0000644000175000017500000000117612266757725031303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp0000644000175000017500000000111112266757725031765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp0000644000175000017500000000117712266757725031306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp0000644000175000017500000000140512266757725031201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp0000644000175000017500000000140712266757725031205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.cast/0000755000175000017500000000000012266757726025502 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp0000644000175000017500000000122712266757726031312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp0000644000175000017500000000344512266757726032020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.cons/0000755000175000017500000000000012266757726025512 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp0000644000175000017500000000106612266757726030062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp0000644000175000017500000000167212266757726027757 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp0000644000175000017500000000170312266757726032357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp0000644000175000017500000000133212266757726030112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp0000644000175000017500000000110012266757726030051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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.); } libcxx/test/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp0000644000175000017500000000121412266757726033347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp0000644000175000017500000000164212266757726033407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp0000644000175000017500000000156512266757726032036 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp0000644000175000017500000000117412266757726032326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp0000644000175000017500000000141712266757726032571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp0000644000175000017500000000111712266757726030060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp0000644000175000017500000000143612266757726030613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 >(); } libcxx/test/utilities/time/time.duration/time.duration.special/0000755000175000017500000000000012266757726026170 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.special/min.pass.cpp0000644000175000017500000000173212266757726030427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 >(); } libcxx/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp0000644000175000017500000000172112266757726030621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 >(); } libcxx/test/utilities/time/time.duration/time.duration.special/max.pass.cpp0000644000175000017500000000173212266757726030431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 >(); } libcxx/test/utilities/time/time.duration/time.duration.literals/0000755000175000017500000000000012266757726026367 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp0000644000175000017500000000107312266757726031707 0ustar sylvestresylvestre// -*- 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 } libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp0000644000175000017500000000104712266757726031707 0ustar sylvestresylvestre// -*- 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 } libcxx/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp0000644000175000017500000000246412266757726031747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp0000644000175000017500000000220012266757726031732 0ustar sylvestresylvestre// -*- 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 } libcxx/test/utilities/time/time.duration/time.duration.literals/literals.pass.cpp0000644000175000017500000000360412266757726031662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/duration.fail.cpp0000644000175000017500000000114112266757726025227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.nonmember/0000755000175000017500000000000012266757726026532 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp0000644000175000017500000000162512266757726033017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp0000644000175000017500000000356512266757726034063 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp0000644000175000017500000000162412266757726032331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp0000644000175000017500000000234412266757726032673 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp0000644000175000017500000000151612266757726032722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp0000644000175000017500000000151612266757726032721 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp0000644000175000017500000000124412266757726032274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp0000644000175000017500000000361412266757726033371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp0000644000175000017500000000447612266757726031046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp0000644000175000017500000000124512266757726032762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp0000644000175000017500000000452312266757726031041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/positive_num.fail.cpp0000644000175000017500000000104012266757726026121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/time/time.duration/time.duration.observer/0000755000175000017500000000000012266757725026376 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757725033407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/time/time.duration/default_ratio.pass.cpp0000644000175000017500000000124612266757725026264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/time.duration/time.duration.comparisons/0000755000175000017500000000000012266757726027105 5ustar sylvestresylvestrelibcxx/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp0000644000175000017500000000622412266757726032367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp0000644000175000017500000001054412266757726032226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/time/milliseconds.pass.cpp0000644000175000017500000000153112266757725023342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/time/nanoseconds.pass.cpp0000644000175000017500000000152512266757725023172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/utility/0000755000175000017500000000000012266757726017752 5ustar sylvestresylvestrelibcxx/test/utilities/utility/declval/0000755000175000017500000000000012266757726021364 5ustar sylvestresylvestrelibcxx/test/utilities/utility/declval/declval.pass.cpp0000644000175000017500000000141612266757726024451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/version.pass.cpp0000644000175000017500000000073112266757726023111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/utility/utility.swap/0000755000175000017500000000000012266757726022426 5ustar sylvestresylvestrelibcxx/test/utilities/utility/utility.swap/swap.pass.cpp0000644000175000017500000000200712266757726025050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/utility.swap/swap_array.pass.cpp0000644000175000017500000000252212266757726026250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/operators/0000755000175000017500000000000012266757726021770 5ustar sylvestresylvestrelibcxx/test/utilities/utility/operators/rel_ops.pass.cpp0000644000175000017500000000161412266757726025106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/utility/pairs/0000755000175000017500000000000012266757726021070 5ustar sylvestresylvestrelibcxx/test/utilities/utility/pairs/pairs.pair/0000755000175000017500000000000012266757726023140 5ustar sylvestresylvestrelibcxx/test/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp0000644000175000017500000000211712266757726026567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/types.pass.cpp0000644000175000017500000000132212266757726025753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp0000644000175000017500000000150012266757726027613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/swap.pass.cpp0000644000175000017500000000134212266757726025563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp0000644000175000017500000000176212266757726030376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp0000644000175000017500000000176112266757726027530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp0000644000175000017500000000173412266757726027031 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/U_V.pass.cpp0000644000175000017500000000146412266757726025307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp0000644000175000017500000000272512266757726031715 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/default.pass.cpp0000644000175000017500000000145012266757726026235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp0000644000175000017500000000173412266757726026617 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp0000644000175000017500000000136212266757726031071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/utilities/utility/pairs/pair.astuple/0000755000175000017500000000000012266757726023477 5ustar sylvestresylvestrelibcxx/test/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp0000644000175000017500000000113212266757726027704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/utility/pairs/pair.astuple/get_const.fail.cpp0000644000175000017500000000143112266757726027101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } } libcxx/test/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp0000644000175000017500000000116712266757726027712 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp0000644000175000017500000000227312266757726030013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp0000644000175000017500000000114712266757726027711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp0000644000175000017500000000162312266757726026440 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp0000644000175000017500000000113512266757726027333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp0000644000175000017500000000167612266757726030024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 int main() { { typedef std::pair P1; static_assert((std::is_same::type, int>::value), ""); static_assert((std::is_same::type, short>::value), ""); } { typedef std::pair P1; static_assert((std::is_same::type, int*>::value), ""); static_assert((std::is_same::type, char>::value), ""); } } libcxx/test/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp0000644000175000017500000000220412266757726027655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp0000644000175000017500000000172412266757726027141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726025400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/utility/pairs/pairs.general/0000755000175000017500000000000012266757726023622 5ustar sylvestresylvestrelibcxx/test/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726030132 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/utility/pairs/pair.piecewise/0000755000175000017500000000000012266757726023777 5ustar sylvestresylvestrelibcxx/test/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp0000644000175000017500000000257012266757726031535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.spec/0000755000175000017500000000000012266757726023137 5ustar sylvestresylvestrelibcxx/test/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp0000644000175000017500000000252712266757726026546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.spec/comparison.pass.cpp0000644000175000017500000000525512266757726026771 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp0000644000175000017500000000143212266757726027763 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/utilities/utility/exchange/0000755000175000017500000000000012266757726021534 5ustar sylvestresylvestrelibcxx/test/utilities/utility/exchange/exchange.pass.cpp0000644000175000017500000000245012266757726024770 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/utility/forward/0000755000175000017500000000000012266757726021416 5ustar sylvestresylvestrelibcxx/test/utilities/utility/forward/forward6.fail.cpp0000644000175000017500000000072012266757726024565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/forward/move_only3.fail.cpp0000644000175000017500000000235012266757726025126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/utilities/utility/forward/move_if_noexcept.pass.cpp0000644000175000017500000000375012266757726026425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 class A { A(const A&); A& operator=(const A&); public: A() {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 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; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES static_assert((std::is_same::value), ""); #if _LIBCPP_STD_VER > 11 constexpr int i1 = 23; constexpr int i2 = std::move_if_noexcept(i1); static_assert(i2 == 23, "" ); #endif } libcxx/test/utilities/utility/forward/move_only2.fail.cpp0000644000175000017500000000240512266757726025126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/utility/forward/forward1.fail.cpp0000644000175000017500000000101412266757726024555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/forward/forward4.fail.cpp0000644000175000017500000000103312266757726024561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/forward/move_copy.pass.cpp0000644000175000017500000000260212266757726025067 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 int copy_ctor = 0; int move_ctor = 0; class A { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #else #endif public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES A(const A&) {++copy_ctor;} A& operator=(const A&); A(A&&) {++move_ctor;} A& operator=(A&&); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES A(const A&) {++copy_ctor;} A& operator=(A&); operator std::__rv () {return std::__rv(*this);} A(std::__rv) {++move_ctor;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 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); } libcxx/test/utilities/utility/forward/forward2.fail.cpp0000644000175000017500000000103412266757726024560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/forward/forward.pass.cpp0000644000175000017500000000514612266757726024541 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/forward/move_only1.fail.cpp0000644000175000017500000000240412266757726025124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/utility/forward/forward3.fail.cpp0000644000175000017500000000101512266757726024560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/forward/forward5.fail.cpp0000644000175000017500000000104212266757726024562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/utility/forward/move_only.pass.cpp0000644000175000017500000000234412266757726025101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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&&) {return *this;} #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 mo; test(std::move(mo)); test(source()); } libcxx/test/utilities/utility/forward/move_only4.fail.cpp0000644000175000017500000000241412266757726025130 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/utilities/template.bitset/0000755000175000017500000000000012266757726021353 5ustar sylvestresylvestrelibcxx/test/utilities/template.bitset/version.pass.cpp0000644000175000017500000000072712266757726024517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/template.bitset/includes.pass.cpp0000644000175000017500000000136112266757726024633 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/utilities/template.bitset/bitset.hash/0000755000175000017500000000000012266757726023567 5ustar sylvestresylvestrelibcxx/test/utilities/template.bitset/bitset.hash/bitset.pass.cpp0000644000175000017500000000171312266757726026534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_base_of, H>::value), ""); H h; T bs(static_cast(N)); assert(h(bs) == N); } int main() { test<0>(); test<10>(); test<100>(); test<1000>(); } libcxx/test/utilities/template.bitset/bitset.operators/0000755000175000017500000000000012266757726024662 5ustar sylvestresylvestrelibcxx/test/utilities/template.bitset/bitset.operators/op_or.pass.cpp0000644000175000017500000000217012266757726027451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.operators/op_not.pass.cpp0000644000175000017500000000220212266757726027625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.operators/stream_in.pass.cpp0000644000175000017500000000127412266757726030320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/template.bitset/bitset.operators/stream_out.pass.cpp0000644000175000017500000000126212266757726030516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } libcxx/test/utilities/template.bitset/bitset.operators/op_and.pass.cpp0000644000175000017500000000220212266757726027567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.cons/0000755000175000017500000000000012266757726023606 5ustar sylvestresylvestrelibcxx/test/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp0000644000175000017500000000206712266757726027107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp0000644000175000017500000000373612266757726027625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp0000644000175000017500000000274212266757726030115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.cons/default.pass.cpp0000644000175000017500000000170012266757726026701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/0000755000175000017500000000000012266757726024276 5ustar sylvestresylvestrelibcxx/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp0000644000175000017500000000232012266757726027534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/index_const.pass.cpp0000644000175000017500000000217612266757726030272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/none.pass.cpp0000644000175000017500000000166712266757726026720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/set_one.pass.cpp0000644000175000017500000000207012266757726027402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/set_all.pass.cpp0000644000175000017500000000153312266757726027374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/size.pass.cpp0000644000175000017500000000133412266757726026722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/to_string.pass.cpp0000644000175000017500000001053112266757726027757 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp0000644000175000017500000000227512266757726027560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp0000644000175000017500000000250012266757726030743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp0000644000175000017500000000216012266757726027530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/any.pass.cpp0000644000175000017500000000164712266757726026546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp0000644000175000017500000000160112266757726027717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp0000644000175000017500000000244312266757726027545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp0000644000175000017500000000226312266757726030264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp0000644000175000017500000000246012266757726030565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp0000644000175000017500000000230712266757726027676 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp0000644000175000017500000000320112266757726027571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/count.pass.cpp0000644000175000017500000000220012266757726027071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/index.pass.cpp0000644000175000017500000000325712266757726027065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp0000644000175000017500000000324012266757726027750 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/all.pass.cpp0000644000175000017500000000153412266757726026522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp0000644000175000017500000000225112266757726030076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/not_all.pass.cpp0000644000175000017500000000214212266757726027376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/test.pass.cpp0000644000175000017500000000224012266757726026724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp0000644000175000017500000000220112266757726027725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp0000644000175000017500000000230712266757726027744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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>(); } libcxx/test/utilities/utility.requirements/0000755000175000017500000000000012266757725022473 5ustar sylvestresylvestrelibcxx/test/utilities/utility.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027003 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/utility.requirements/allocator.requirements/0000755000175000017500000000000012266757725027175 5ustar sylvestresylvestrelibcxx/test/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725033505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/utility.requirements/nullablepointer.requirements/0000755000175000017500000000000012266757725030414 5ustar sylvestresylvestrelibcxx/test/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725034724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/utility.requirements/utility.arg.requirements/0000755000175000017500000000000012266757725027470 5ustar sylvestresylvestrelibcxx/test/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725034000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/utility.requirements/hash.requirements/0000755000175000017500000000000012266757725026140 5ustar sylvestresylvestrelibcxx/test/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725032450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/utility.requirements/swappable.requirements/0000755000175000017500000000000012266757725027173 5ustar sylvestresylvestrelibcxx/test/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725033503 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/optional/0000755000175000017500000000000012266757725020073 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.object/0000755000175000017500000000000012266757725023165 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.object/optional.object.observe/0000755000175000017500000000000012266757725027723 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp0000644000175000017500000000200512266757725033221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 { int test() const {return 2;} int test() {return 3;} }; #endif // _LIBCPP_STD_VER > 11 int main() { #if _LIBCPP_STD_VER > 11 { optional opt(X{}); assert(opt->test() == 3); } #ifdef _LIBCPP_DEBUG { optional opt; assert(opt->test() == 3); assert(false); } #endif // _LIBCPP_DEBUG #endif // _LIBCPP_STD_VER > 11 } libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp0000644000175000017500000000153712266757725033671 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp0000644000175000017500000000342412266757725034421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp0000644000175000017500000000301012266757725033202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp0000644000175000017500000000255112266757725034435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp0000644000175000017500000000212112266757725032504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp0000644000175000017500000000243212266757725033717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp0000644000175000017500000000202212266757725033637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp0000644000175000017500000000226012266757725035051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp0000644000175000017500000000143212266757725032327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/types.pass.cpp0000644000175000017500000000172112266757725026003 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/utilities/optional/optional.object/optional_void.fail.cpp0000644000175000017500000000117412266757725027454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.swap/0000755000175000017500000000000012266757725027230 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp0000644000175000017500000002160412266757725031656 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.assign/0000755000175000017500000000000012266757725027542 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp0000644000175000017500000000401212266757725033670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp0000644000175000017500000000524712266757725032171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp0000644000175000017500000000312412266757725033233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp0000644000175000017500000000620512266757725032624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpplibcxx/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.0000644000175000017500000000544112266757725035560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp0000644000175000017500000000427312266757725032173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp0000644000175000017500000000132412266757725032061 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional_const_void.fail.cpp0000644000175000017500000000117712266757725030665 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.dtor/0000755000175000017500000000000012266757725027226 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp0000644000175000017500000000267512266757725031661 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp0000644000175000017500000000133312266757725033766 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/0000755000175000017500000000000012266757725027225 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp0000644000175000017500000000642312266757725034261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp0000644000175000017500000000461112266757725031646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp0000644000175000017500000000257612266757725032730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp0000644000175000017500000000650012266757725032774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp0000644000175000017500000000446012266757725032463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp0000644000175000017500000000252412266757725032325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp0000644000175000017500000000436512266757725031660 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp0000644000175000017500000000457412266757725032321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.nullops/0000755000175000017500000000000012266757725023413 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp0000644000175000017500000000221212266757725026170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp0000644000175000017500000000217612266757725027052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/version.pass.cpp0000644000175000017500000000075012266757725023233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/optional/optional.bad_optional_access/0000755000175000017500000000000012266757725025673 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.bad_optional_access/string.pass.cpp0000644000175000017500000000142612266757725030655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // explicit bad_optional_access(const string& what_arg); #include #include #include #include int main() { #if _LIBCPP_STD_VER > 11 using std::experimental::bad_optional_access; const std::string s("message"); bad_optional_access e(s); assert(std::strcmp(e.what(), s.c_str()) == 0); #endif // _LIBCPP_STD_VER > 11 } libcxx/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp0000644000175000017500000000141612266757725030624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp0000644000175000017500000000140712266757725032023 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // explicit bad_optional_access(const char* what_arg); #include #include #include #include int main() { #if _LIBCPP_STD_VER > 11 using std::experimental::bad_optional_access; const char* s = "message"; bad_optional_access e(s); assert(std::strcmp(e.what(), s) == 0); #endif // _LIBCPP_STD_VER > 11 } libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp0000644000175000017500000000126612266757725030775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 not default constructible #include #include int main() { #if _LIBCPP_STD_VER > 11 using std::experimental::bad_optional_access; static_assert(!std::is_default_constructible::value, ""); #endif // _LIBCPP_STD_VER > 11 } libcxx/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp0000644000175000017500000000165212266757725031351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // bad_optional_access(const bad_optional_access&); #include #include #include #include #include int main() { #if _LIBCPP_STD_VER > 11 using std::experimental::bad_optional_access; static_assert(std::is_nothrow_copy_constructible::value, ""); const std::string s("another message"); bad_optional_access e1(s); bad_optional_access e2 = e1; assert(std::strcmp(e1.what(), e2.what()) == 0); #endif // _LIBCPP_STD_VER > 11 } libcxx/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp0000644000175000017500000000203512266757725031662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // bad_optional_access& operator=(const bad_optional_access&); #include #include #include #include #include int main() { #if _LIBCPP_STD_VER > 11 using std::experimental::bad_optional_access; static_assert(std::is_nothrow_copy_assignable::value, ""); const std::string s1("one message"); const std::string s2("another message"); bad_optional_access e1(s1); bad_optional_access e2(s2); assert(std::strcmp(e1.what(), e2.what()) != 0); e1 = e2; assert(std::strcmp(e1.what(), e2.what()) == 0); #endif // _LIBCPP_STD_VER > 11 } libcxx/test/utilities/optional/optional.syn/0000755000175000017500000000000012266757725022530 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp0000644000175000017500000000123712266757725031410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp0000644000175000017500000000140412266757725031300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp0000644000175000017500000000123112266757725030174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp0000644000175000017500000000123212266757725030203 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp0000644000175000017500000000137612266757725030102 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp0000644000175000017500000000140712266757725031360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp0000644000175000017500000000111312266757725033346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp0000644000175000017500000000140112266757725030144 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.nullopt/0000755000175000017500000000000012266757725023414 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp0000644000175000017500000000203612266757725027106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/optional/optional.general/0000755000175000017500000000000012266757725023334 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/optional/optional.specalg/0000755000175000017500000000000012266757725023335 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.specalg/swap.pass.cpp0000644000175000017500000002157012266757725025765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.specalg/make_optional.pass.cpp0000644000175000017500000000240212266757725027626 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.defs/0000755000175000017500000000000012266757725022640 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.defs/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757725027651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/optional/optional.relops/0000755000175000017500000000000012266757725023223 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.relops/equal.pass.cpp0000644000175000017500000000377112266757725026013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp0000644000175000017500000000364212266757725026661 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.hash/0000755000175000017500000000000012266757725022642 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.hash/hash.pass.cpp0000644000175000017500000000241512266757725025240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.comp_with_t/0000755000175000017500000000000012266757725024233 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp0000644000175000017500000000266312266757725027022 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp0000644000175000017500000000277212266757725027674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 ( o2 < T(2) , "" ); static_assert ( o2 < T(val), "" ); static_assert ( o3 < T(3) , "" ); static_assert ( !(T(1) < o1), "" ); static_assert ( !(T(1) < o2), "" ); static_assert ( T(1) < o3 , "" ); static_assert ( !(T(2) < o2), "" ); static_assert (!(T(val) < o2), "" ); static_assert ( !(T(3) < o3), "" ); } #endif } libcxx/test/utilities/optional/optional.inplace/0000755000175000017500000000000012266757725023332 5ustar sylvestresylvestrelibcxx/test/utilities/optional/optional.inplace/in_place_t.pass.cpp0000644000175000017500000000161012266757725027076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/intseq/0000755000175000017500000000000012266757726017552 5ustar sylvestresylvestrelibcxx/test/utilities/intseq/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726024062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/intseq/intseq.intseq/0000755000175000017500000000000012266757726022357 5ustar sylvestresylvestrelibcxx/test/utilities/intseq/intseq.intseq/integer_seq.fail.cpp0000644000175000017500000000155112266757726026304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/intseq/intseq.intseq/integer_seq.pass.cpp0000644000175000017500000000305312266757726026336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/intseq/intseq.general/0000755000175000017500000000000012266757726022471 5ustar sylvestresylvestrelibcxx/test/utilities/intseq/intseq.general/integer_seq.pass.cpp0000644000175000017500000000716412266757726026457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/intseq/intseq.make/0000755000175000017500000000000012266757726021771 5ustar sylvestresylvestrelibcxx/test/utilities/intseq/intseq.make/make_integer_seq.fail.cpp0000644000175000017500000000123712266757726026714 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/intseq/intseq.make/make_integer_seq.pass.cpp0000644000175000017500000000313312266757726026744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/tuple/0000755000175000017500000000000012266757725017377 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/version.pass.cpp0000644000175000017500000000072512266757725022541 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/tuple/tuple.general/0000755000175000017500000000000012266757725022144 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/tuple/tuple.tuple/0000755000175000017500000000000012266757725021660 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.traits/0000755000175000017500000000000012266757725024316 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp0000644000175000017500000000247312266757725031014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 { }; #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), ""); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/0000755000175000017500000000000012266757725024274 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp0000644000175000017500000000236512266757725026721 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp0000644000175000017500000000117412266757725026667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #include #include #include "../MoveOnly.h" int main() { { typedef std::tuple T; T t0(MoveOnly(2)); T t; t = t0; } } libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp0000644000175000017500000000177312266757725027736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp0000644000175000017500000000144412266757725030111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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')); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp0000644000175000017500000000330612266757725030461 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp0000644000175000017500000000417112266757725030456 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp0000644000175000017500000000223012266757725026714 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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"); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/0000755000175000017500000000000012266757725024141 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp0000644000175000017500000000412512266757725030126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&...); #include #include #include 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"); } // 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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp0000644000175000017500000000413212266757725031476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp0000644000175000017500000000227612266757725026567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #include #include #include "../MoveOnly.h" int main() { { typedef std::tuple<> T; T t0; T t = std::move(t0); } { 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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp0000644000175000017500000000331512266757725031127 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp0000644000175000017500000000116012266757725026527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; #include #include #include "../MoveOnly.h" int main() { { typedef std::tuple T; T t0(MoveOnly(2)); T t = t0; } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp0000644000175000017500000000105712266757725030074 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&...); #include #include #include int main() { { std::tuple t = 0; } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp0000644000175000017500000000173312266757725027577 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp0000644000175000017500000000226612266757725027761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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 } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp0000644000175000017500000000520212266757725030323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp0000644000175000017500000000455712266757725030230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&&...); #include #include #include "../MoveOnly.h" #include "allocators.h" #include "../alloc_first.h" #include "../alloc_last.h" 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()); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp0000644000175000017500000000403612266757725030323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp0000644000175000017500000000233112266757725027007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); /* 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; } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp0000644000175000017500000000435312266757725027743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp0000644000175000017500000000524512266757725031304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&...); #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)); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp0000644000175000017500000000456412266757725031503 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&&); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp0000644000175000017500000000525212266757725026710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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()); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp0000644000175000017500000000234612266757725030752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&&); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp0000644000175000017500000000435512266757725027741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&&); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp0000644000175000017500000000113312266757725030151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&...); #include #include #include int main() { { std::tuple t(2, nullptr, "text"); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp0000644000175000017500000000272512266757725027244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); #include #include #include #include "DefaultOnly.h" 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()); } #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); } #endif } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp0000644000175000017500000000361212266757725027045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #include #include #include "../MoveOnly.h" #if _LIBCPP_STD_VER > 11 struct Empty {}; struct A { int id_; explicit constexpr A(int i) : id_(i) {} }; #endif 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 } libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp0000644000175000017500000000263112266757725026566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; #include #include #include struct Empty {}; int main() { { typedef std::tuple<> T; T t0; T t = t0; } { 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; } #endif } libcxx/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp0000644000175000017500000000201712266757725026016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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)), ""); } } libcxx/test/utilities/tuple/tuple.tuple/MoveOnly.h0000644000175000017500000000232412266757725023602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/utilities/tuple/tuple.tuple/tuple.swap/0000755000175000017500000000000012266757725023762 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp0000644000175000017500000000302312266757725027732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/0000755000175000017500000000000012266757725024614 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp0000644000175000017500000000256112266757725030417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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 } libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp0000644000175000017500000001572212266757725030254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #include #include #include #include #include #include "../MoveOnly.h" int main() { { std::tuple<> t = std::tuple_cat(); } { std::tuple<> t1; std::tuple<> t2 = std::tuple_cat(t1); } { std::tuple<> t = std::tuple_cat(std::tuple<>()); } { std::tuple<> t = std::tuple_cat(std::array()); } { 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(); } { constexpr std::tuple<> t1; constexpr std::tuple<> t2 = std::tuple_cat(t1); } { constexpr std::tuple<> t = std::tuple_cat(std::tuple<>()); } { constexpr std::tuple<> t = std::tuple_cat(std::array()); } { 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); } { 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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp0000644000175000017500000000373412266757725031634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #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 } } libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp0000644000175000017500000000133212266757725027045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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++"); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.special/0000755000175000017500000000000012266757725024430 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp0000644000175000017500000000312212266757725031252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/0000755000175000017500000000000012266757725024267 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp0000644000175000017500000000257712266757725030136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 { }; #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>(); } libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp0000644000175000017500000000250612266757725030605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // }; #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), ""); } int main() { test, 0, int>(); test, 0, char>(); test, 1, int>(); test, 0, int*>(); test, 1, char>(); test, 2, int>(); } libcxx/test/utilities/tuple/tuple.tuple/alloc_first.h0000644000175000017500000000266212266757725024340 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/0000755000175000017500000000000012266757725023572 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp0000644000175000017500000001315012266757725025662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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 } libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp0000644000175000017500000001006712266757725025654 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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 } libcxx/test/utilities/tuple/tuple.tuple/alloc_last.h0000644000175000017500000000254012266757725024147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/0000755000175000017500000000000012266757725023732 5ustar sylvestresylvestrelibcxx/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp0000644000175000017500000000126612266757725030162 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_tuple ( 42, 21, "Hi", { 1,2 } ); assert ( std::get(t1) == 42 ); // two ints here (one at the end) #else #error #endif } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp0000644000175000017500000000206012266757725027333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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"; } } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp0000644000175000017500000000442012266757725030242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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 } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp0000644000175000017500000000144712266757725026677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp0000644000175000017500000000121612266757725030153 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_tuple ( 42, "Hi" ); assert ( std::get(t1) == cf {1,2} ); // no such type #else #error #endif } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp0000644000175000017500000000114112266757725030153 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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::unique_ptr upint; std::tuple t(upint(new int(4))); upint p = std::get(t); #else #error #endif } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp0000644000175000017500000000123512266757725030155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_tuple ( 42, 21, "Hi", { 1,2 } ); assert ( std::get(t1) == 42 ); // two ints here #else #error #endif } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp0000644000175000017500000000327512266757725030134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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::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 } libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp0000644000175000017500000000321512266757725027371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); #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); } #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); } } libcxx/test/utilities/utilities.general/0000755000175000017500000000000012266757725021675 5ustar sylvestresylvestrelibcxx/test/utilities/utilities.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/lit.cfg0000644000175000017500000002763412266757727015522 0ustar sylvestresylvestre# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: # Configuration file for the 'lit' test runner. import errno import os import platform import re import shlex import signal import subprocess import sys import tempfile import time import lit.Test import lit.formats import lit.util class LibcxxTestFormat(lit.formats.FileBasedTest): """ 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. """ def __init__(self, cxx_under_test, cpp_flags, ld_flags, exec_env): self.cxx_under_test = cxx_under_test self.cpp_flags = list(cpp_flags) self.ld_flags = list(ld_flags) self.exec_env = dict(exec_env) def execute_command(self, command, in_dir=None): kwargs = { 'stdin' :subprocess.PIPE, 'stdout':subprocess.PIPE, 'stderr':subprocess.PIPE, } if in_dir: kwargs['cwd'] = in_dir p = subprocess.Popen(command, **kwargs) out,err = p.communicate() exitCode = p.wait() # Detect Ctrl-C in subprocess. if exitCode == -signal.SIGINT: raise KeyboardInterrupt return out, err, exitCode def execute(self, test, lit_config): while True: try: return self._execute(test, lit_config) except OSError, oe: if oe.errno != errno.ETXTBSY: raise time.sleep(0.1) def _execute(self, test, lit_config): # Extract test metadata from the test file. requires = [] with open(test.getSourcePath()) as f: for ln in f: if 'XFAIL:' in ln: items = ln[ln.index('XFAIL:') + 6:].split(',') test.xfails.extend([s.strip() for s in items]) elif 'REQUIRES:' in ln: items = ln[ln.index('REQUIRES:') + 9:].split(',') requires.extend([s.strip() for s in items]) elif not ln.startswith("//") and ln.strip(): # Stop at the first non-empty line that is not a C++ # comment. break # Check that we have the required features. # # FIXME: For now, this is cribbed from lit.TestRunner, to avoid # introducing a dependency there. What we more ideally would like to do # is lift the "requires" handling to be a core lit framework feature. missing_required_features = [f for f in requires if f not in test.config.available_features] if missing_required_features: return (lit.Test.UNSUPPORTED, "Test requires the following features: %s" % ( ', '.join(missing_required_features),)) # Evaluate the test. return self._evaluate_test(test, lit_config) def _evaluate_test(self, test, lit_config): name = test.path_in_suite[-1] source_path = test.getSourcePath() source_dir = os.path.dirname(source_path) # Check what kind of test this is. assert name.endswith('.pass.cpp') or name.endswith('.fail.cpp') expected_compile_fail = name.endswith('.fail.cpp') # If this is a compile (failure) test, build it and check for failure. if expected_compile_fail: cmd = [self.cxx_under_test, '-c', '-o', '/dev/null', source_path] + self.cpp_flags out, err, exitCode = self.execute_command(cmd) if exitCode == 1: return lit.Test.PASS, "" else: 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\nExpected compilation to fail!" return lit.Test.FAIL, report else: exec_file = tempfile.NamedTemporaryFile(suffix="exe", delete=False) exec_path = exec_file.name exec_file.close() try: compile_cmd = [self.cxx_under_test, '-o', exec_path, source_path] + self.cpp_flags + self.ld_flags cmd = compile_cmd out, err, exitCode = self.execute_command(cmd) 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\nCompilation failed unexpectedly!" return lit.Test.FAIL, report cmd = [] if self.exec_env: cmd.append('env') cmd.extend('%s=%s' % (name, value) for name,value in self.exec_env.items()) cmd.append(exec_path) if lit_config.useValgrind: cmd = lit_config.valgrindArgs + cmd out, err, exitCode = self.execute_command(cmd, source_dir) if exitCode != 0: report = """Compiled With: %s\n""" % \ ' '.join(["'%s'" % a for a in compile_cmd]) 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\nCompiled test failed unexpectedly!" return lit.Test.FAIL, report finally: try: os.remove(exec_path) except: pass return lit.Test.PASS, "" # name: The name of this test suite. config.name = 'libc++' # suffixes: A list of file extensions to treat as test files. config.suffixes = ['.cpp'] # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) # Gather various compiler parameters. cxx_under_test = lit_config.params.get('cxx_under_test', None) if cxx_under_test is None: cxx_under_test = getattr(config, 'cxx_under_test', None) # If no specific cxx_under_test was given, attempt to infer it as clang++. clangxx = lit.util.which('clang++', config.environment['PATH']) if clangxx is not None: cxx_under_test = clangxx lit_config.note("inferred cxx_under_test as: %r" % (cxx_under_test,)) if cxx_under_test is None: lit_config.fatal('must specify user parameter cxx_under_test ' '(e.g., --param=cxx_under_test=clang++)') libcxx_src_root = lit_config.params.get('libcxx_src_root', None) if libcxx_src_root is None: libcxx_src_root = getattr(config, 'libcxx_src_root', None) if libcxx_src_root is None: libcxx_src_root = os.path.dirname(config.test_source_root) libcxx_obj_root = lit_config.params.get('libcxx_obj_root', None) if libcxx_obj_root is None: libcxx_obj_root = getattr(config, 'libcxx_obj_root', None) if libcxx_obj_root is None: libcxx_obj_root = libcxx_src_root cxx_has_stdcxx0x_flag_str = lit_config.params.get('cxx_has_stdcxx0x_flag', None) if cxx_has_stdcxx0x_flag_str is not None: if cxx_has_stdcxx0x_flag_str.lower() in ('1', 'true'): cxx_has_stdcxx0x_flag = True elif cxx_has_stdcxx0x_flag_str.lower() in ('', '0', 'false'): cxx_has_stdcxx0x_flag = False else: lit_config.fatal( 'user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1') else: cxx_has_stdcxx0x_flag = getattr(config, 'cxx_has_stdcxx0x_flag', True) # 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. use_system_lib_str = lit_config.params.get('use_system_lib', None) if use_system_lib_str is not None: if use_system_lib_str.lower() in ('1', 'true'): use_system_lib = True elif use_system_lib_str.lower() in ('', '0', 'false'): use_system_lib = False else: lit_config.fatal('user parameter use_system_lib should be 0 or 1') else: # Default to testing against the locally built libc++ library. use_system_lib = False lit_config.note("inferred use_system_lib as: %r" % (use_system_lib,)) link_flags = [] link_flags_str = lit_config.params.get('link_flags', None) if link_flags_str is None: link_flags_str = getattr(config, 'link_flags', None) if link_flags_str is None: cxx_abi = getattr(config, 'cxx_abi', 'libcxxabi') if cxx_abi == 'libstdc++': link_flags += ['-lstdc++'] elif cxx_abi == 'libsupc++': link_flags += ['-lsupc++'] elif cxx_abi == 'libcxxabi': link_flags += ['-lc++abi'] elif cxx_abi == 'none': pass else: lit_config.fatal('C++ ABI setting %s unsupported for tests' % cxx_abi) if sys.platform == 'darwin': link_flags += ['-lSystem'] elif sys.platform == 'linux2': link_flags += [ '-lgcc_eh', '-lc', '-lm', '-lpthread', '-lrt', '-lgcc_s'] else: lit_config.fatal("unrecognized system") lit_config.note("inferred link_flags as: %r" % (link_flags,)) if not link_flags_str is None: link_flags += shlex.split(link_flags_str) # Configure extra compiler flags. include_paths = ['-I' + libcxx_src_root + '/include', '-I' + libcxx_src_root + '/test/support'] library_paths = ['-L' + libcxx_obj_root + '/lib'] compile_flags = [] if cxx_has_stdcxx0x_flag: compile_flags += ['-std=c++0x'] # Configure extra linker parameters. exec_env = {} if sys.platform == 'darwin': if not use_system_lib: exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxx_obj_root, 'lib') elif sys.platform == 'linux2': if not use_system_lib: link_flags += ['-Wl,-R', libcxx_obj_root + '/lib'] compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS'] else: lit_config.fatal("unrecognized system") config.test_format = LibcxxTestFormat( cxx_under_test, cpp_flags = ['-nostdinc++'] + compile_flags + include_paths, ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + link_flags, exec_env = exec_env) # Get or infer the target triple. config.target_triple = lit_config.params.get('target_triple', None) # If no target triple was given, try to infer it from the compiler under test. if config.target_triple is None: config.target_triple = lit.util.capture( [cxx_under_test, '-dumpmachine']).strip() lit_config.note("inferred target_triple as: %r" % (config.target_triple,)) # Write an "available feature" that combines the triple when use_system_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 use_system_lib: # Drop sub-major version components from the triple, because the current # XFAIL handling expects exact matches for feature checks. sanitized_triple = re.sub(r"([^-]+)-([^-]+)-([^-.]+).*", r"\1-\2-\3", config.target_triple) config.available_features.add('with_system_lib=%s' % (sanitized_triple,)) libcxx/test/diagnostics/0000755000175000017500000000000012266757725016542 5ustar sylvestresylvestrelibcxx/test/diagnostics/assertions/0000755000175000017500000000000012266757725020734 5ustar sylvestresylvestrelibcxx/test/diagnostics/assertions/cassert.pass.cpp0000644000175000017500000000101712266757725024050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/diagnostics/errno/0000755000175000017500000000000012266757725017667 5ustar sylvestresylvestrelibcxx/test/diagnostics/errno/cerrno.pass.cpp0000644000175000017500000001142512266757725022633 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/diagnostics/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725023052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/0000755000175000017500000000000012266757725020071 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/version.pass.cpp0000644000175000017500000000074312266757725023233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/diagnostics/syserr/syserr.compare/0000755000175000017500000000000012266757725023045 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp0000644000175000017500000000754012266757725031537 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/diagnostics/syserr/errc.pass.cpp0000644000175000017500000001601212266757725022475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, ""); } libcxx/test/diagnostics/syserr/syserr.errcondition/0000755000175000017500000000000012266757725024116 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725030426 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/0000755000175000017500000000000012266757725032154 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp0000644000175000017500000000107712266757725034746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp0000644000175000017500000000115612266757725035445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp0000644000175000017500000000117212266757725035252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp0000644000175000017500000000136012266757725034560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/0000755000175000017500000000000012266757725032307 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp0000644000175000017500000000133212266757725034376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_conditi0000644000175000017500000000135512266757725036075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/0000755000175000017500000000000012266757725032712 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_catego0000644000175000017500000000151412266757725036163 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp0000644000175000017500000000112412266757725036005 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEn0000644000175000017500000000132612266757725036062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/0000755000175000017500000000000012266757725032010 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.c0000644000175000017500000000056412266757725035760 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/0000755000175000017500000000000012266757725032123 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp0000644000175000017500000000155612266757725035067 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp0000644000175000017500000000140312266757725034660 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.0000644000175000017500000000136212266757725035713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.hash/0000755000175000017500000000000012266757725022342 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.hash/error_code.pass.cpp0000644000175000017500000000163312266757725026141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_base_of, H>::value), ""); H h; T ec(i, std::system_category()); assert(h(ec) == i); } int main() { test(0); test(2); test(10); } libcxx/test/diagnostics/syserr/syserr.syserr/0000755000175000017500000000000012266757725022746 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/0000755000175000017500000000000012266757725027254 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp0000644000175000017500000000155112266757725035656 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpplibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pa0000644000175000017500000000176312266757725036122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp0000644000175000017500000000154112266757725034100 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpplibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointe0000644000175000017500000000166112266757725036136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpplibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_cha0000644000175000017500000000177112266757725036155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp0000644000175000017500000000165312266757725035472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/0000755000175000017500000000000012266757725027470 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725034000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/syserr.errcat/0000755000175000017500000000000012266757725022677 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/0000755000175000017500000000000012266757725027352 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp0000644000175000017500000000073112266757725034052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/0000755000175000017500000000000012266757725030070 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp0000644000175000017500000000210312266757725034210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp0000644000175000017500000000145512266757725032165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp0000644000175000017500000000140312266757725032322 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp0000644000175000017500000000140312266757725032144 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/0000755000175000017500000000000012266757725027135 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp0000644000175000017500000000157112266757725034033 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(500); assert(e_cond.value() == 500); assert(e_cond.category() == std::system_category()); } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp0000644000175000017500000000121612266757725034117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/0000755000175000017500000000000012266757725027355 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.p0000644000175000017500000000136212266757725036046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp0000644000175000017500000000146212266757725035734 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.c0000644000175000017500000000131712266757725035722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/0000755000175000017500000000000012266757725027126 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp0000644000175000017500000000162012266757725032222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/diagnostics/syserr/syserr.errcode/0000755000175000017500000000000012266757725023042 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/0000755000175000017500000000000012266757725027660 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725034170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/0000755000175000017500000000000012266757725030157 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp0000644000175000017500000000132212266757725034746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp0000644000175000017500000000130112266757725032242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp0000644000175000017500000000134312266757725035037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/0000755000175000017500000000000012266757725030562 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp0000644000175000017500000000160012266757725034741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cp0000644000175000017500000000147012266757725035755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp0000644000175000017500000000110412266757725033653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/0000755000175000017500000000000012266757725030024 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpplibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.0000644000175000017500000000152412266757725035677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp0000644000175000017500000000106512266757725032613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp0000644000175000017500000000114412266757725033312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp0000644000175000017500000000116012266757725033117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp0000644000175000017500000000134112266757725032427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/0000755000175000017500000000000012266757725027773 5ustar sylvestresylvestrelibcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp0000644000175000017500000000163012266757725034155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp0000644000175000017500000000153712266757725032736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp0000644000175000017500000000137212266757725032535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/diagnostics/std.exceptions/0000755000175000017500000000000012266757725021514 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/version.pass.cpp0000644000175000017500000000073512266757725024657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/diagnostics/std.exceptions/overflow.error/0000755000175000017500000000000012266757725024507 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp0000644000175000017500000000243212266757725031235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/logic.error/0000755000175000017500000000000012266757725023741 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp0000644000175000017500000000236112266757725027722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/domain.error/0000755000175000017500000000000012266757725024113 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp0000644000175000017500000000240012266757725030240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/runtime.error/0000755000175000017500000000000012266757725024327 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp0000644000175000017500000000240712266757725030677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/length.error/0000755000175000017500000000000012266757725024125 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/length.error/length_error.pass.cpp0000644000175000017500000000240012266757725030264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/range.error/0000755000175000017500000000000012266757725023740 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/range.error/range_error.pass.cpp0000644000175000017500000000237112266757725027721 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/invalid.argument/0000755000175000017500000000000012266757725024763 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp0000644000175000017500000000245412266757725031771 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/underflow.error/0000755000175000017500000000000012266757725024651 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp0000644000175000017500000000244512266757725031545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/std.exceptions/out.of.range/0000755000175000017500000000000012266757725024021 5ustar sylvestresylvestrelibcxx/test/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp0000644000175000017500000000240012266757725030135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/diagnostics/diagnostics.general/0000755000175000017500000000000012266757725022465 5ustar sylvestresylvestrelibcxx/test/diagnostics/diagnostics.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/0000755000175000017500000000000012266757727016725 5ustar sylvestresylvestrelibcxx/test/localization/locale.stdcvt/0000755000175000017500000000000012266757727021472 5ustar sylvestresylvestrelibcxx/test/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp0000644000175000017500000000206012266757727030431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_mode.pass.cpp0000644000175000017500000000131712266757727025600 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp0000644000175000017500000005423512266757727026316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/version.pass.cpp0000644000175000017500000000073112266757727024631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp0000644000175000017500000000210012266757727030552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp0000644000175000017500000002514112266757727026231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp0000644000175000017500000000303112266757727030322 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp0000644000175000017500000000212412266757727031526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp0000644000175000017500000002755312266757727027174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp0000644000175000017500000000305412266757727030775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp0000644000175000017500000003111512266757727027455 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp0000644000175000017500000000203012266757727027401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf16.pass.cpp0000644000175000017500000000237012266757727025621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 int outstanding_news = 0; void* operator new(std::size_t s) throw(std::bad_alloc) { ++outstanding_news; return std::malloc(s); } void operator delete(void* p) throw() { if (p) { --outstanding_news; std::free(p); } } int main() { assert(outstanding_news == 0); { typedef std::codecvt_utf16 C; C c; assert(outstanding_news == 0); } { typedef std::codecvt_utf16 C; std::locale loc(std::locale::classic(), new C); assert(outstanding_news != 0); } assert(outstanding_news == 0); } libcxx/test/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp0000644000175000017500000001441212266757727027103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp0000644000175000017500000000300212266757727027741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp0000644000175000017500000001411512266757727030130 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp0000644000175000017500000000207412266757727030505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp0000644000175000017500000000203412266757727027464 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp0000644000175000017500000000300512266757727027355 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp0000644000175000017500000002632612266757727027264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp0000644000175000017500000000301112266757727030020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8.pass.cpp0000644000175000017500000000236512266757727025546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 int outstanding_news = 0; void* operator new(std::size_t s) throw(std::bad_alloc) { ++outstanding_news; return std::malloc(s); } void operator delete(void* p) throw() { if (p) { --outstanding_news; std::free(p); } } int main() { assert(outstanding_news == 0); { typedef std::codecvt_utf8 C; C c; assert(outstanding_news == 0); } { typedef std::codecvt_utf8 C; std::locale loc(std::locale::classic(), new C); assert(outstanding_news != 0); } assert(outstanding_news == 0); } libcxx/test/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp0000644000175000017500000002424212266757727026512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp0000644000175000017500000000300112266757727027272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp0000644000175000017500000003371112266757727026434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/localization/version.pass.cpp0000644000175000017500000000072712266757727022071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/localization/localization.general/0000755000175000017500000000000012266757727023031 5ustar sylvestresylvestrelibcxx/test/localization/localization.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727027341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.syn/0000755000175000017500000000000012266757727020774 5ustar sylvestresylvestrelibcxx/test/localization/locale.syn/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727025304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/0000755000175000017500000000000012266757727022310 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/facets.examples/0000755000175000017500000000000012266757727025372 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727031702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.messages/0000755000175000017500000000000012266757727025733 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.messages/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727032243 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.messages/locale.messages/0000755000175000017500000000000012266757727031000 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.messages/locale.messages/types.pass.cpp0000644000175000017500000000254412266757727033622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp0000644000175000017500000000214212266757727033417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/libcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members0000755000175000017500000000000012266757727035417 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpplibcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members0000644000175000017500000000151012266757727035416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp0000644000175000017500000000103012266757727035244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/libcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtual0000755000175000017500000000000012266757727035453 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtual0000644000175000017500000000056412266757727035462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.messages/locale.messages.byname/0000755000175000017500000000000012266757727032252 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpplibcxx/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pa0000644000175000017500000000056412266757727035433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.time/0000755000175000017500000000000012266757727025062 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.time/locale.time.get/0000755000175000017500000000000012266757727030034 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.time/locale.time.get/types.pass.cpp0000644000175000017500000000302612266757727032652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp0000644000175000017500000000217612266757727032462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp0000644000175000017500000000140612266757727033436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/0000755000175000017500000000000012266757727034656 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/te0000644000175000017500000000056412266757727035216 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/0000755000175000017500000000000012266757727034437 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000002277612266757727035157 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000000701212266757727035141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000001512712266757727035147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000000362512266757727035147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/dat0000644000175000017500000000140512266757727035132 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000001011112266757727035133 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000000241112266757727035137 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000001775312266757727035156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000000234312266757727035143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000001570512266757727035151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000002066312266757727035150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get0000644000175000017500000000655212266757727035151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/localization/locale.categories/category.time/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727031372 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/0000755000175000017500000000000012266757727031306 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp0000644000175000017500000001263012266757727034401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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; #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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.c0000644000175000017500000000527712266757727035237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp0000644000175000017500000000513012266757727035246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_byname // 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" #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); } } libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp0000644000175000017500000000234712266757727035075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp0000644000175000017500000000464412266757727034566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.c0000644000175000017500000000531312266757727035205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.c0000644000175000017500000000467212266757727035237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass0000644000175000017500000000235512266757727035323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.c0000644000175000017500000000473712266757727035257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp0000644000175000017500000000526512266757727034543 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pas0000644000175000017500000000500112266757727035307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_byname // 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" #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); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cp0000644000175000017500000001252512266757727035234 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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; #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); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.p0000644000175000017500000000523512266757727035331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } libcxx/test/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp0000644000175000017500000000507112266757727034557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } libcxx/test/localization/locale.categories/category.time/locale.time.put.byname/0000755000175000017500000000000012266757727031337 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp0000644000175000017500000000406112266757727033702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_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(); // }; #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 abreviated %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 abreviated Sat."); } { const my_facet f(LOCALE_fr_FR_UTF_8, 1); std::string pat("Today is %A which is abreviated %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 abreviated Sam.")|| (ex == "Today is samedi which is abreviated sam." )); } } libcxx/test/localization/locale.categories/category.time/locale.time.put/0000755000175000017500000000000012266757727030065 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/0000755000175000017500000000000012266757727034740 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/te0000644000175000017500000000056412266757727035300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.time/locale.time.put/types.pass.cpp0000644000175000017500000000235312266757727032705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp0000644000175000017500000000217112266757727032506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/0000755000175000017500000000000012266757727034521 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put0000644000175000017500000000322512266757727035256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 abreviated %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 abreviated 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."); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpplibcxx/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put0000644000175000017500000002563512266757727035267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 = {0}; 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); { 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 == "00"); } { iter = f.put(output_iterator(str), ios, '*', &t, 'V', 'O'); std::string ex(str, iter.base()); assert(ex == "52"); } { 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 == "00"); } { 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, 'B', 'O'); std::string ex(str, iter.base()); assert(ex == "May"); } { 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 == "2008"); } { iter = f.put(output_iterator(str), ios, '*', &t, 'g'); std::string ex(str, iter.base()); assert(ex == "08"); } { 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 == "000"); } { iter = f.put(output_iterator(str), ios, '*', &t, 'k'); std::string ex(str, iter.base()); assert(ex == "13"); } { iter = f.put(output_iterator(str), ios, '*', &t, 'l'); std::string ex(str, iter.base()); assert(ex == " 1"); } { 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, 's'); std::string ex(str, iter.base()); // assert(ex == "1241283786"); depends on time zone } { 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 == "00"); } { 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 == "52"); } { iter = f.put(output_iterator(str), ios, '*', &t, 'v'); std::string ex(str, iter.base()); assert(ex == " 2-May-2009"); } { iter = f.put(output_iterator(str), ios, '*', &t, 'W'); std::string ex(str, iter.base()); assert(ex == "00"); } { 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 == "%"); } { iter = f.put(output_iterator(str), ios, '*', &t, '%', 'J'); std::string ex(str, iter.base()); assert(ex == "J%"); } { iter = f.put(output_iterator(str), ios, '*', &t, 'J'); std::string ex(str, iter.base()); assert(ex == "J"); } } libcxx/test/localization/locale.categories/category.ctype/0000755000175000017500000000000012266757727025250 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/0000755000175000017500000000000012266757727031407 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.c0000644000175000017500000000351212266757727035155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp0000644000175000017500000000350212266757727035024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.c0000644000175000017500000000351212266757727035157 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cp0000644000175000017500000000365112266757727035363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/category.ctype/ctype_base.pass.cpp0000644000175000017500000000464712266757727031052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/0000755000175000017500000000000012266757727030135 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp0000644000175000017500000000237312266757727034247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/0000755000175000017500000000000012266757727034453 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000233612266757727035317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000126112266757727035313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000125512266757727035316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000125512266757727035316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wcha0000644000175000017500000000125312266757727035321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_0000644000175000017500000001112112266757727035327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wcha0000644000175000017500000000507312266757727035325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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")); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wcha0000644000175000017500000000125712266757727035325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000170412266757727035315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000232312266757727035313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wcha0000644000175000017500000000201312266757727035314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000167412266757727035323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000125112266757727035312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000125312266757727035314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000124512266757727035315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000170412266757727035315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000126412266757727035316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wcha0000644000175000017500000000274712266757727035332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000254712266757727035323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000232312266757727035313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wcha0000644000175000017500000000126212266757727035321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000254712266757727035323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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]); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000200012266757727035303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000126412266757727035316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000126112266757727035313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000233112266757727035312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000201512266757727035311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char0000644000175000017500000000201512266757727035311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wcha0000644000175000017500000000201412266757727035315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp0000644000175000017500000000222112266757727033547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp0000644000175000017500000000126112266757727034227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp0000644000175000017500000000244212266757727034441 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp0000644000175000017500000000244212266757727034443 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp0000644000175000017500000000237312266757727034251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp0000644000175000017500000000234612266757727033754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp0000644000175000017500000000222712266757727034267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/0000755000175000017500000000000012266757727034672 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tes0000644000175000017500000000056412266757727035415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp0000644000175000017500000000235712266757727034470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/0000755000175000017500000000000012266757727031104 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp0000644000175000017500000000416112266757727033723 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp0000644000175000017500000000345412266757727035117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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* 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] == '*'); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp0000644000175000017500000000544312266757727035302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 #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'); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp0000644000175000017500000000301612266757727034103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 #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)); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp0000644000175000017500000000567512266757727033425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 #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')); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp0000644000175000017500000000544312266757727035305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 #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'); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp0000644000175000017500000000350012266757727034705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 #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)); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp0000644000175000017500000000647112266757727034204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; #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); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp0000644000175000017500000000652212266757727034366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; #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); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp0000644000175000017500000000531012266757727034472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 #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'); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp0000644000175000017500000002043612266757727034221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; #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)); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp0000644000175000017500000000531012266757727034467 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 #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'); } } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp0000644000175000017500000000311212266757727034302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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', '*') == '*'); } } } libcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/0000755000175000017500000000000012266757727031074 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp0000644000175000017500000000212012266757727033704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/libcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000755000175000017500000000000012266757727035222 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000205012266757727035221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000171712266757727035232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000231512266757727035225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000152412266757727035226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000270412266757727035227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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')); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000171712266757727035232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000203112266757727035220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000351212266757727035225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000352712266757727035233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000154012266757727035224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000704612266757727035233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000161612266757727035230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000154012266757727035224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.membe0000644000175000017500000000160612266757727035227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/libcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.stati0000755000175000017500000000000012266757727035261 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.stati0000644000175000017500000000107612266757727035267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/libcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtu0000755000175000017500000000000012266757727035306 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtu0000644000175000017500000000056412266757727035315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/0000755000175000017500000000000012266757727035164 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpplibcxx/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/0000644000175000017500000000242412266757727035170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 unsigned delete_called = 0; void* operator new[](size_t sz) { return operator new(sz); } void operator delete[](void* p) throw() { operator delete(p); ++delete_called; } int main() { { delete_called = 0; std::locale l(std::locale::classic(), new std::ctype); assert(delete_called == 0); } assert(delete_called == 0); { std::ctype::mask table[256]; delete_called = 0; std::locale l(std::locale::classic(), new std::ctype(table)); assert(delete_called == 0); } assert(delete_called == 0); { delete_called = 0; std::locale l(std::locale::classic(), new std::ctype(new std::ctype::mask[256], true)); assert(delete_called == 0); } assert(delete_called == 1); } libcxx/test/localization/locale.categories/category.ctype/locale.ctype/0000755000175000017500000000000012266757727027632 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp0000644000175000017500000000215612266757727032453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp0000644000175000017500000000232612266757727032255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/0000755000175000017500000000000012266757727033645 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_m0000644000175000017500000000206512266757727035417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_0000644000175000017500000000174212266757727035426 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.0000644000175000017500000000154312266757727035177 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pas0000644000175000017500000000274312266757727035213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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')); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_0000644000175000017500000000174212266757727035431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_ma0000644000175000017500000000205312266757727035353 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.0000644000175000017500000000352712266757727035274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not0000644000175000017500000000354412266757727035402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_0000644000175000017500000000156612266757727035435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.0000644000175000017500000000707712266757727035320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_0000644000175000017500000000156612266757727035432 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_10000644000175000017500000000162512266757727035324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } libcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/0000755000175000017500000000000012266757727034064 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_0000644000175000017500000000056412266757727035443 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/__scan_keyword.pass.cpp0000644000175000017500000001165012266757727026752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_senstive 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); } } libcxx/test/localization/locale.categories/category.numeric/0000755000175000017500000000000012266757727025566 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727032076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.numeric/locale.nm.put/0000755000175000017500000000000012266757727030245 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/0000755000175000017500000000000012266757727034604 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tes0000644000175000017500000000056412266757727035327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp0000644000175000017500000000234412266757727033065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp0000644000175000017500000000216612266757727032672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/0000755000175000017500000000000012266757727034365 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000002443312266757727035265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000002523512266757727035266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000527075112266757727035300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; #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(""); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000002672512266757727035273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000000203312266757727035255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)"); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000003025112266757727035260 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000000525012266757727035261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_0000644000175000017500000352015312266757727035270 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/localization/locale.categories/category.numeric/locale.num.get/0000755000175000017500000000000012266757727030401 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/0000755000175000017500000000000012266757727034470 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000001562712266757727035205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000004354712266757727035207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000000453612266757727035202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/tes0000644000175000017500000000271512266757727035213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000001277412266757727035205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000000621012266757727035171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000002211512266757727035173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000000324212266757727035173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000000447312266757727035202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000000447712266757727035206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000000450112266757727035172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get0000644000175000017500000001735112266757727035201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp0000644000175000017500000000233112266757727033215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp0000644000175000017500000000216512266757727033025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/0000755000175000017500000000000012266757727034707 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/te0000644000175000017500000000056412266757727035247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/facet.numpunct/0000755000175000017500000000000012266757727025242 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727031552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/0000755000175000017500000000000012266757727030351 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp0000644000175000017500000000324312266757727033170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp0000644000175000017500000000325112266757727032772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/0000755000175000017500000000000012266757727034734 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/fal0000644000175000017500000000156412266757727035427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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")); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/tru0000644000175000017500000000155712266757727035501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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")); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/gro0000644000175000017500000000153412266757727035451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/dec0000644000175000017500000000153312266757727035414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'.'); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/tho0000644000175000017500000000153312266757727035453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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','); } } libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/0000755000175000017500000000000012266757727035153 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/te0000644000175000017500000000056412266757727035513 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/0000755000175000017500000000000012266757727031623 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp0000644000175000017500000000331212266757727035125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_byname; // string grouping() 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.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"); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.0000644000175000017500000000335112266757727035402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_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','); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpplibcxx/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.0000644000175000017500000000335112266757727035452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_byname; // char_type thousands_sep() 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.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','); } } } libcxx/test/localization/locale.categories/category.collate/0000755000175000017500000000000012266757727025547 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.collate/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727032057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.collate/locale.collate/0000755000175000017500000000000012266757727030430 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.collate/locale.collate/types.pass.cpp0000644000175000017500000000323112266757727033244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp0000644000175000017500000000327412266757727033056 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/0000755000175000017500000000000012266757727035161 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/t0000644000175000017500000000056412266757727035354 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/0000755000175000017500000000000012266757727034742 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpplibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/ha0000644000175000017500000000221512266757727035255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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())); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpplibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/co0000644000175000017500000000342712266757727035274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpplibcxx/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/tr0000644000175000017500000000172112266757727035313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/localization/locale.categories/category.collate/locale.collate.byname/0000755000175000017500000000000012266757727031702 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp0000644000175000017500000000236412266757727034524 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp0000644000175000017500000000230312266757727034274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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())); } } libcxx/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp0000644000175000017500000000553312266757727035007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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. #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); } } } libcxx/test/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp0000644000175000017500000000417412266757727035374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; #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); } } } libcxx/test/localization/locale.categories/category.monetary/0000755000175000017500000000000012266757727025762 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.monetary/locale.money.put/0000755000175000017500000000000012266757727031156 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp0000644000175000017500000000274412266757727034002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp0000644000175000017500000000217412266757727033602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/libcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.membe0000755000175000017500000000000012266757727035357 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.membe0000644000175000017500000004166512266757727035375 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; #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); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.membe0000644000175000017500000004240312266757727035364 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.membe0000644000175000017500000004207212266757727035366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; #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); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.membe0000644000175000017500000004210012266757727035356 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; #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); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.membe0000644000175000017500000004202612266757727035365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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); } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/libcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtu0000755000175000017500000000000012266757727035443 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtu0000644000175000017500000000056412266757727035452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/0000755000175000017500000000000012266757727031421 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp0000644000175000017500000000356612266757727034250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp0000644000175000017500000000216712266757727034047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp0000644000175000017500000000151012266757727035210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000755000175000017500000000000012266757727035556 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000307112266757727035561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000304312266757727035560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000447212266757727035567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000321512266757727035561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000447212266757727035567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000321512266757727035561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000277712266757727035575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000313612266757727035563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"-"); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.mem0000644000175000017500000000310312266757727035555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.vir0000755000175000017500000000000012266757727035600 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.vir0000644000175000017500000000056412266757727035607 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727032272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locale.categories/category.monetary/locale.money.get/0000755000175000017500000000000012266757727031125 5ustar sylvestresylvestrelibcxx/test/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp0000644000175000017500000000274312266757727033750 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp0000644000175000017500000000220112266757727033540 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/libcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtu0000755000175000017500000000000012266757727035361 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtu0000644000175000017500000000056412266757727035370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/libcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.membe0000755000175000017500000000000012266757727035275 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.membe0000644000175000017500000007451412266757727035312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.membe0000644000175000017500000007447112266757727035314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; #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); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.membe0000644000175000017500000007526312266757727035314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.membe0000644000175000017500000007420512266757727035307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; #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); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.membe0000644000175000017500000007501512266757727035307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; #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""); } } } libcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/0000755000175000017500000000000012266757727032673 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pa0000644000175000017500000000631412266757727035561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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 "); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.0000644000175000017500000000641612266757727035502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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"); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pas0000644000175000017500000001701212266757727035522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.0000644000175000017500000000631312266757727035506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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'.'); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pas0000644000175000017500000001701212266757727035552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // // 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); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.0000644000175000017500000000631312266757727035556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_byname // charT thousands_sep() 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.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','); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pa0000644000175000017500000000576512266757727035510 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.0000644000175000017500000000620112266757727035515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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"-"); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpplibcxx/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.0000644000175000017500000000616112266757727035562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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""); } } libcxx/test/localization/locales/0000755000175000017500000000000012266757727020347 5ustar sylvestresylvestrelibcxx/test/localization/locales/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727024657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locales/locale.global.templates/0000755000175000017500000000000012266757727025042 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale.global.templates/has_facet.pass.cpp0000644000175000017500000000145312266757727030433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.global.templates/use_facet.pass.cpp0000644000175000017500000000225312266757727030453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locales/locale.convenience/0000755000175000017500000000000012266757727024101 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale.convenience/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727030411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locales/locale.convenience/conversions/0000755000175000017500000000000012266757727026451 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/0000755000175000017500000000000012266757727032271 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp0000644000175000017500000000137712266757727035054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp0000644000175000017500000000340712266757727034715 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 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(new_called != 0); } assert(new_called == 0); { std::stringstream s; B b(s.rdbuf()); assert(b.rdbuf() == s.rdbuf()); assert(new_called != 0); } assert(new_called == 0); { std::stringstream s; B b(s.rdbuf(), new std::codecvt_utf8); assert(b.rdbuf() == s.rdbuf()); assert(new_called != 0); } assert(new_called == 0); { std::stringstream s; B b(s.rdbuf(), new std::codecvt_utf8, std::mbstate_t()); assert(b.rdbuf() == s.rdbuf()); assert(new_called != 0); } assert(new_called == 0); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cp0000644000175000017500000000331212266757727035475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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'); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.datlibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.da0000644000175000017500000000001112266757727035542 0ustar sylvestresylvestre乑乒乓libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat0000644000175000017500000000001112266757727034760 0ustar sylvestresylvestre123456789libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp0000644000175000017500000000351312266757727035366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cp0000644000175000017500000000470012266757727035570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp0000644000175000017500000000122212266757727035057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } } libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp0000644000175000017500000000176512266757727034732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } libcxx/test/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp0000644000175000017500000000546112266757727035613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } libcxx/test/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727032761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locales/locale.convenience/conversions/conversions.character/0000755000175000017500000000000012266757727032754 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.c0000644000175000017500000000170712266757727035565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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) == '+'); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.c0000644000175000017500000000170712266757727035570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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) == '+'); } libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/0000755000175000017500000000000012266757727032326 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp0000644000175000017500000000252412266757727035146 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp0000644000175000017500000000232412266757727035630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cp0000644000175000017500000000166512266757727035620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.c0000644000175000017500000000227712266757727035620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.p0000644000175000017500000000337012266757727035717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_stat0000644000175000017500000000140012266757727035755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpplibcxx/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass0000644000175000017500000000212612266757727035675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } } libcxx/test/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp0000644000175000017500000000123412266757727035117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/localization/locales/locale.convenience/classification/0000755000175000017500000000000012266757727027074 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale.convenience/classification/isgraph.pass.cpp0000644000175000017500000000160312266757727032202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/isupper.pass.cpp0000644000175000017500000000160312266757727032234 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/isspace.pass.cpp0000644000175000017500000000160312266757727032174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/isalpha.pass.cpp0000644000175000017500000000160312266757727032166 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/isxdigit.pass.cpp0000644000175000017500000000161712266757727032376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/islower.pass.cpp0000644000175000017500000000160312266757727032231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/iscntrl.pass.cpp0000644000175000017500000000160312266757727032223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/isdigit.pass.cpp0000644000175000017500000000160312266757727032201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/isalnum.pass.cpp0000644000175000017500000000160312266757727032215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/isprint.pass.cpp0000644000175000017500000000160312266757727032235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale.convenience/classification/ispunct.pass.cpp0000644000175000017500000000160312266757727032232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/localization/locales/locale/0000755000175000017500000000000012266757727021606 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.operators/0000755000175000017500000000000012266757727025062 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.operators/compare.pass.cpp0000644000175000017500000000163312266757727030164 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } } libcxx/test/localization/locales/locale/locale.operators/eq.pass.cpp0000644000175000017500000000415312266757727027143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/localization/locales/locale/locale.statics/0000755000175000017500000000000012266757727024516 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.statics/classic.pass.cpp0000644000175000017500000000432512266757727027614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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")); } libcxx/test/localization/locales/locale/locale.statics/global.pass.cpp0000644000175000017500000000452412266757727027434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/localization/locales/locale/locale.types/0000755000175000017500000000000012266757727024210 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.types/locale.category/0000755000175000017500000000000012266757727027263 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.types/locale.category/category.pass.cpp0000644000175000017500000000325712266757727032560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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); } libcxx/test/localization/locales/locale/locale.types/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727030520 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locales/locale/locale.types/locale.facet/0000755000175000017500000000000012266757727026530 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp0000644000175000017500000000230312266757727031261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locales/locale/locale.types/locale.id/0000755000175000017500000000000012266757727026042 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.types/locale.id/id.pass.cpp0000644000175000017500000000236312266757727030113 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/localization/locales/locale/nothing_to_do.pass.cpp0000644000175000017500000000056412266757727026116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/localization/locales/locale/locale.cons/0000755000175000017500000000000012266757727024006 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp0000644000175000017500000000577312266757727030622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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); } } libcxx/test/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp0000644000175000017500000000510212266757727031131 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(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); } libcxx/test/localization/locales/locale/locale.cons/assign.pass.cpp0000644000175000017500000000505112266757727026744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/localization/locales/locale/locale.cons/string.pass.cpp0000644000175000017500000000530312266757727026766 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp0000644000175000017500000000507612266757727031074 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(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); } libcxx/test/localization/locales/locale/locale.cons/char_pointer.pass.cpp0000644000175000017500000000575112266757727030144 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/localization/locales/locale/locale.cons/default.pass.cpp0000644000175000017500000000553012266757727027106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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() { int ok; { std::locale loc; assert(new_called == 0); assert(loc.name() == "C"); assert(new_called == 0); check(loc); assert(new_called == 0); assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc); ok = new_called; std::locale loc2; assert(new_called == ok); check(loc2); assert(new_called == ok); assert(loc2 == std::locale(LOCALE_en_US_UTF_8)); assert(new_called == ok); } assert(new_called == ok); } libcxx/test/localization/locales/locale/locale.cons/copy.pass.cpp0000644000175000017500000000501212266757727026427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(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); } libcxx/test/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp0000644000175000017500000000505712266757727032311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(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); } libcxx/test/localization/locales/locale/locale.members/0000755000175000017500000000000012266757727024476 5ustar sylvestresylvestrelibcxx/test/localization/locales/locale/locale.members/combine.pass.cpp0000644000175000017500000000611412266757727027565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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; 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(new_called == 0); } { { std::locale loc; std::locale loc2; try { std::locale loc3 = loc.combine(loc2); assert(false); } catch (std::runtime_error&) { } } assert(new_called == 0); } } libcxx/test/localization/locales/locale/locale.members/name.pass.cpp0000644000175000017500000000126412266757727027072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/localization/c.locales/0000755000175000017500000000000012266757727020570 5ustar sylvestresylvestrelibcxx/test/localization/c.locales/version.pass.cpp0000644000175000017500000000073112266757727023727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/localization/c.locales/clocale.pass.cpp0000644000175000017500000000174512266757727023652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { std::lconv lc; static_assert((std::is_same<__typeof__(std::setlocale(0, "")), char*>::value), ""); static_assert((std::is_same<__typeof__(std::localeconv()), std::lconv*>::value), ""); } libcxx/test/input.output/0000755000175000017500000000000012266757723016727 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/0000755000175000017500000000000012266757723021712 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/version.pass.cpp0000644000175000017500000000073112266757723025051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/string.streams/istringstream/0000755000175000017500000000000012266757723024605 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/istringstream/istringstream.members/0000755000175000017500000000000012266757723031131 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp0000644000175000017500000000263712266757723033422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/string.streams/istringstream/types.pass.cpp0000644000175000017500000000334612266757723027430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/string.streams/istringstream/istringstream.cons/0000755000175000017500000000000012266757723030441 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp0000644000175000017500000000243612266757723033065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp0000644000175000017500000000340312266757723033420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp0000644000175000017500000000227212266757723033541 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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""); } } libcxx/test/input.output/string.streams/istringstream/istringstream.assign/0000755000175000017500000000000012266757723030763 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp0000644000175000017500000000250312266757723033402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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::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); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp0000644000175000017500000000262312266757723034740 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp0000644000175000017500000000305112266757723035447 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/string.streams/stringstream.cons/0000755000175000017500000000000012266757723025375 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/0000755000175000017500000000000012266757723031402 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp0000644000175000017500000000272112266757723034023 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp0000644000175000017500000000275212266757723035362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpplibcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cp0000644000175000017500000000317712266757723035717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringstream.cons/move.pass.cpp0000644000175000017500000000265412266757723030023 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/string.streams/stringstream.cons/move2.pass.cpp0000644000175000017500000000220612266757723030076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/string.streams/stringstream.cons/string.pass.cpp0000644000175000017500000000255612266757723030364 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 "); } } libcxx/test/input.output/string.streams/stringstream.cons/default.pass.cpp0000644000175000017500000000230212266757723030467 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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""); } } libcxx/test/input.output/string.streams/stringstream.members/0000755000175000017500000000000012266757723026065 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringstream.members/str.pass.cpp0000644000175000017500000000317112266757723030350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 "); } } libcxx/test/input.output/string.streams/stringstream/0000755000175000017500000000000012266757723024434 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringstream/types.pass.cpp0000644000175000017500000000334012266757723027251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/string.streams/stringbuf/0000755000175000017500000000000012266757723023715 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/0000755000175000017500000000000012266757723027570 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp0000644000175000017500000000157712266757723032543 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp0000644000175000017500000000673612266757723033171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp0000644000175000017500000001667312266757723032700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp0000644000175000017500000000431212266757723033246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp0000644000175000017500000000560512266757723032720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp0000644000175000017500000000614612266757723033113 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/0000755000175000017500000000000012266757723026661 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp0000644000175000017500000000270312266757723031302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp0000644000175000017500000000250012266757723031635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp0000644000175000017500000000142012266757723031753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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""); } } libcxx/test/input.output/string.streams/stringbuf/types.pass.cpp0000644000175000017500000000331212266757723026531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/string.streams/stringbuf/stringbuf.members/0000755000175000017500000000000012266757723027351 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp0000644000175000017500000000167112266757723031637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/0000755000175000017500000000000012266757723027203 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp0000644000175000017500000000304212266757723031621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp0000644000175000017500000000332312266757723033156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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""); } } libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp0000644000175000017500000000355112266757723033674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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""); } } libcxx/test/input.output/string.streams/ostringstream/0000755000175000017500000000000012266757723024613 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/ostringstream/types.pass.cpp0000644000175000017500000000334612266757723027436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/string.streams/ostringstream/ostringstream.members/0000755000175000017500000000000012266757723031145 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp0000644000175000017500000000263512266757723033434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/0000755000175000017500000000000012266757723030455 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp0000644000175000017500000000240712266757723033077 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp0000644000175000017500000000332312266757723033435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp0000644000175000017500000000227412266757723033557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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""); } } libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/0000755000175000017500000000000012266757723030777 5ustar sylvestresylvestrelibcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp0000644000175000017500000000245412266757723033423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp0000644000175000017500000000250612266757723034754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp0000644000175000017500000000251012266757723035462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/iostream.forward/0000755000175000017500000000000012266757723022215 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.forward/version.pass.cpp0000644000175000017500000000072712266757723025361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/iostream.forward/iosfwd.pass.cpp0000644000175000017500000001030512266757723025160 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } } libcxx/test/input.output/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723023237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/file.streams/0000755000175000017500000000000012266757722021322 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/nothing_to_do.pass.cpp0000644000175000017500000000056412266757722025632 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/file.streams/c.files/0000755000175000017500000000000012266757722022645 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp0000644000175000017500000000072712266757722027521 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/file.streams/c.files/gets.fail.cpp0000644000175000017500000000076512266757722025235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp0000644000175000017500000000073512266757722030112 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp0000644000175000017500000001224112266757722025603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); #if _LIBCPP_STD_VER <= 11 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), ""); } libcxx/test/input.output/file.streams/c.files/cinttypes.pass.cpp0000644000175000017500000003320412266757722026342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/input.output/file.streams/fstreams/0000755000175000017500000000000012266757723023147 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ofstream.assign/0000755000175000017500000000000012266757722026251 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp0000644000175000017500000000353012266757722032224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp0000644000175000017500000000366312266757722032746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp0000644000175000017500000000237012266757722032236 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/file.streams/fstreams/ifstream/0000755000175000017500000000000012266757722024760 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp0000644000175000017500000000275312266757722027604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/file.streams/fstreams/filebuf.assign/0000755000175000017500000000000012266757722026045 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp0000644000175000017500000000315212266757722032020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp0000644000175000017500000000330512266757722032533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp0000644000175000017500000000332312266757722032031 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/file.streams/fstreams/version.pass.cpp0000644000175000017500000000073112266757722026305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/file.streams/fstreams/ofstream.cons/0000755000175000017500000000000012266757722025727 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp0000644000175000017500000000232512266757722030350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp0000644000175000017500000000213412266757722031060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp0000644000175000017500000000207612266757722030713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp0000644000175000017500000000114712266757722031027 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } } libcxx/test/input.output/file.streams/fstreams/fstream.members/0000755000175000017500000000000012266757723026241 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp0000644000175000017500000000205312266757723031017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp0000644000175000017500000000126212266757723031015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp0000644000175000017500000000261712266757723032247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp0000644000175000017500000000260312266757723032414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.members/0000755000175000017500000000000012266757722026417 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp0000644000175000017500000000200612266757722031173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp0000644000175000017500000000170112266757722031171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp0000644000175000017500000000253412266757722032423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp0000644000175000017500000000255212266757722032575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/ifstream.cons/0000755000175000017500000000000012266757722025721 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp0000644000175000017500000000166712266757722030352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp0000644000175000017500000000211612266757722031052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp0000644000175000017500000000220412266757722030676 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/file.streams/fstreams/ifstream.cons/test.dat0000644000175000017500000000000412266757722027364 0ustar sylvestresylvestre3.25libcxx/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp0000644000175000017500000000114712266757722031021 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } } libcxx/test/input.output/file.streams/fstreams/fstream.cons/0000755000175000017500000000000012266757722025550 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp0000644000175000017500000000254012266757722030170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp0000644000175000017500000000240712266757722030704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp0000644000175000017500000000243412266757722030532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp0000644000175000017500000000114312266757722030644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } } libcxx/test/input.output/file.streams/fstreams/filebuf.members/0000755000175000017500000000000012266757722026213 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp0000644000175000017500000000264212266757722032371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/input.output/file.streams/fstreams/fstream/0000755000175000017500000000000012266757722024607 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/fstream/types.pass.cpp0000644000175000017500000000274612266757722027435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/file.streams/fstreams/ofstream/0000755000175000017500000000000012266757722024766 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp0000644000175000017500000000275312266757722027612 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/file.streams/fstreams/filebuf/0000755000175000017500000000000012266757722024562 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp0000644000175000017500000000275112266757722027404 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/file.streams/fstreams/filebuf.cons/0000755000175000017500000000000012266757722025523 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp0000644000175000017500000000325612266757722030150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp0000644000175000017500000000123112266757722030615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/file.streams/fstreams/ifstream.members/0000755000175000017500000000000012266757722026411 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp0000644000175000017500000000157112266757722031173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp0000644000175000017500000000145512266757722031171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp0000644000175000017500000000216712266757722032417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp0000644000175000017500000000213312266757722032562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } libcxx/test/input.output/file.streams/fstreams/ifstream.members/test.dat0000644000175000017500000000000112266757722030051 0ustar sylvestresylvestrerlibcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/0000755000175000017500000000000012266757722026432 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp0000644000175000017500000000317612266757722032026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat0000644000175000017500000000001112266757722032067 0ustar sylvestresylvestre乑乒乓libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat0000644000175000017500000000001112266757722031121 0ustar sylvestresylvestre123456789libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp0000644000175000017500000000547012266757722031533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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::pos_type pos_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() { { 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"); } libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp0000644000175000017500000000725412266757722032120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp0000644000175000017500000001032312266757722031745 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } libcxx/test/input.output/file.streams/fstreams/ifstream.assign/0000755000175000017500000000000012266757723026244 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat0000644000175000017500000000000312266757723027770 0ustar sylvestresylvestre4.5libcxx/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp0000644000175000017500000000175012266757723032221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp0000644000175000017500000000210312266757723032725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/file.streams/fstreams/ifstream.assign/test.dat0000644000175000017500000000000412266757723027707 0ustar sylvestresylvestre3.25libcxx/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp0000644000175000017500000000173212266757723032232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/file.streams/fstreams/fstream.assign/0000755000175000017500000000000012266757722026072 5ustar sylvestresylvestrelibcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp0000644000175000017500000000405212266757722032045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp0000644000175000017500000000420412266757722032557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp0000644000175000017500000000262312266757722032060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/0000755000175000017500000000000012266757723022041 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/ext.manip/0000755000175000017500000000000012266757723023744 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/ext.manip/get_money.pass.cpp0000644000175000017500000000371712266757723027413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #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); } } libcxx/test/input.output/iostream.format/ext.manip/put_time.pass.cpp0000644000175000017500000000425212266757723027246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; os << std::put_time(&t, "%c"); 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"%c"); assert(sb.str() == L"Sat Dec 31 23:55:59 2061"); } } libcxx/test/input.output/iostream.format/ext.manip/put_money.pass.cpp0000644000175000017500000000466212266757723027444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #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"); } } libcxx/test/input.output/iostream.format/ext.manip/get_time.pass.cpp0000644000175000017500000000375112266757723027220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, "%c"); 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"%c"); 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()); } } libcxx/test/input.output/iostream.format/quoted.manip/0000755000175000017500000000000012266757723024445 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp0000644000175000017500000001214512266757723027422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 } #else int main() {} #endif libcxx/test/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp0000644000175000017500000000126612266757723030366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp0000644000175000017500000000144512266757723030756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/input.output/iostream.format/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723026351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostream.format/input.streams/0000755000175000017500000000000012266757723024655 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/version.pass.cpp0000644000175000017500000000073112266757723030014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/iostream.format/input.streams/istream/0000755000175000017500000000000012266757723026321 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream/types.pass.cpp0000644000175000017500000000303112266757723031133 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/0000755000175000017500000000000012266757723030726 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp0000644000175000017500000000302612266757723034370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp0000644000175000017500000000420712266757723033350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/0000755000175000017500000000000012266757723031250 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp0000644000175000017500000000500712266757723035224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp0000644000175000017500000000541212266757723035235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/input.streams/istream/istream_sentry/0000755000175000017500000000000012266757723031371 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp0000644000175000017500000000647612266757723034026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostream.format/input.streams/iostreamclass/0000755000175000017500000000000012266757723027526 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp0000644000175000017500000000321612266757723032345 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/0000755000175000017500000000000012266757723032634 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpplibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pas0000644000175000017500000000502212266757723035641 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpplibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pas0000644000175000017500000000542712266757723035663 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/0000755000175000017500000000000012266757723032307 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpplibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pas0000644000175000017500000000056412266757723035653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/0000755000175000017500000000000012266757723032312 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpplibcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cp0000644000175000017500000000303212266757723035571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp0000644000175000017500000000422412266757723034733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/input.streams/istream.rvalue/0000755000175000017500000000000012266757723027616 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp0000644000175000017500000000312212266757723032563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/0000755000175000017500000000000012266757723030650 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp0000644000175000017500000000371212266757723033607 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pa0000644000175000017500000000532312266757723035727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp0000644000175000017500000000316712266757723033437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp0000644000175000017500000000467012266757723034127 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 // // 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); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass0000644000175000017500000000433412266757723035765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp0000644000175000017500000000523612266757723035700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp0000644000175000017500000000400212266757723034245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp0000644000175000017500000000322212266757723033416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp0000644000175000017500000000435112266757723033755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp0000644000175000017500000000335212266757723033250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp0000644000175000017500000000435412266757723033242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 // // 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp0000644000175000017500000000373512266757723033453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_char0000644000175000017500000000441212266757723036012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp0000644000175000017500000000267112266757723033303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp0000644000175000017500000000175012266757723034532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 // // 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); } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp0000644000175000017500000000514512266757723033105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 // // 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); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.0000644000175000017500000000472712266757723035640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp0000644000175000017500000000521312266757723034262 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 // // 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp0000644000175000017500000000462012266757723035152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.formatted/0000755000175000017500000000000012266757723030305 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723034615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/0000755000175000017500000000000012266757723035247 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/te0000644000175000017500000000056412266757723035607 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000755000175000017500000000000012266757723035643 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000357012266757723035652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000352212266757723035647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000356512266757723035656 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000357512266757723035657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000353312266757723035651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000355312266757723035653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000357312266757723035655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000353712266757723035655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000354012266757723035647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000357112266757723035653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000360212266757723035646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000362612266757723035654 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmeti0000644000175000017500000000352212266757723035647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/0000755000175000017500000000000012266757723034227 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambu0000644000175000017500000000355212266757723036001 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.0000644000175000017500000000161712266757723035701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_io0000644000175000017500000000157712266757723035734 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_0000644000175000017500000000427412266757723035747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_c0000644000175000017500000000337112266757723035731 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_c0000644000175000017500000000432712266757723035733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pa0000644000175000017500000000420312266757723035651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned0000644000175000017500000000337712266757723036000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned0000644000175000017500000000434112266757723035770 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpplibcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base0000644000175000017500000000141712266757723035741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/input.streams/istream.manip/0000755000175000017500000000000012266757723027424 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp0000644000175000017500000000271112266757723031527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/input.output/iostream.format/std.manip/0000755000175000017500000000000012266757723023736 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/std.manip/version.pass.cpp0000644000175000017500000000073112266757723027075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/iostream.format/std.manip/setfill.pass.cpp0000644000175000017500000000151412266757723027052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'*'); } } libcxx/test/input.output/iostream.format/std.manip/setw.pass.cpp0000644000175000017500000000206712266757723026376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp0000644000175000017500000000274612266757723030272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } libcxx/test/input.output/iostream.format/std.manip/setprecision.pass.cpp0000644000175000017500000000215712266757723030123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/std.manip/setbase.pass.cpp0000644000175000017500000000475112266757723027044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp0000644000175000017500000000267112266757723027740 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/input.output/iostream.format/output.streams/0000755000175000017500000000000012266757723025056 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.seeks/0000755000175000017500000000000012266757723027641 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp0000644000175000017500000000251612266757723032425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() { { std::ostream os((std::streambuf*)0); assert(&os.seekp(5) == &os); assert(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()); } } libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp0000644000175000017500000000234312266757723032434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp0000644000175000017500000000302312266757723032501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() { { std::ostream os((std::streambuf*)0); assert(&os.seekp(5, std::ios_base::beg) == &os); assert(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()); } } libcxx/test/input.output/iostream.format/output.streams/version.pass.cpp0000644000175000017500000000073112266757723030215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/iostream.format/output.streams/ostream.assign/0000755000175000017500000000000012266757723030013 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp0000644000175000017500000000500712266757723033767 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp0000644000175000017500000000541212266757723034000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/0000755000175000017500000000000012266757723030514 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/0000755000175000017500000000000012266757723034203 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambu0000644000175000017500000000354612266757723035760 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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..."); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_io0000644000175000017500000000344112266757723035700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.0000644000175000017500000000331112266757723035654 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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..."); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base0000644000175000017500000000315612266757723035717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000755000175000017500000000000012266757723035740 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000373512266757723035752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000367712266757723035757 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000366312266757723035752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000375212266757723035751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000367412266757723035754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000373112266757723035746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000367112266757723035751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000427512266757723035752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 sb; std::ostream os(&sb); const void* n = 0; os << n; assert(os.good()); // %p is implementation defined. // On some platforms (Windows), it's a hex number without // any leading 0x like prefix. // In that format, we assume a null pointer will yield 2 '0' hex digits // for each 8 bits of address space. assert(sb.str() == "0x0" || sb.str() == "(nil)" || sb.str() == std::string(sizeof(void*)*2,'0')); } { testbuf sb; std::ostream os(&sb); const void* n = &sb; os << n; assert(os.good()); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000370112266757723035743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000373212266757723035747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000374712266757723035755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000400412266757723035740 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmet0000644000175000017500000000415312266757723035745 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723035024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/0000755000175000017500000000000012266757723035464 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/t0000644000175000017500000000056412266757723035657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000755000175000017500000000000012266757723035675 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000421312266757723035677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000433512266757723035704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000426012266757723035701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000425612266757723035706 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000443712266757723035707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000431412266757723035701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000427012266757723035702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000446112266757723035704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000425412266757723035704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpplibcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.characte0000644000175000017500000000423712266757723035705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/output.streams/ostream.rvalue/0000755000175000017500000000000012266757723030025 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp0000644000175000017500000000357612266757723034252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/0000755000175000017500000000000012266757723031057 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp0000644000175000017500000000353712266757723033350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp0000644000175000017500000000374712266757723033675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp0000644000175000017500000000204412266757723033651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/output.streams/ostream_sentry/0000755000175000017500000000000012266757723030134 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp0000644000175000017500000000244612266757723033637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp0000644000175000017500000000277212266757723033452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostream.format/output.streams/ostream.manip/0000755000175000017500000000000012266757723027633 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp0000644000175000017500000000365312266757723032235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp0000644000175000017500000000347712266757723032250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp0000644000175000017500000000223612266757723032430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostream.format/output.streams/ostream.cons/0000755000175000017500000000000012266757723027471 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp0000644000175000017500000000272212266757723033135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } } libcxx/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp0000644000175000017500000000377512266757723032124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/input.output/iostream.format/output.streams/ostream/0000755000175000017500000000000012266757723026530 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp0000644000175000017500000000303112266757723031342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/input.output.general/0000755000175000017500000000000012266757723023041 5ustar sylvestresylvestrelibcxx/test/input.output/input.output.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723027351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.requirements/0000755000175000017500000000000012266757723023457 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.requirements/iostreams.limits.pos/0000755000175000017500000000000012266757723027565 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723034075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723027767 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.requirements/iostreams.threadsafety/0000755000175000017500000000000012266757723030147 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723034457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.requirements/iostream.limits.imbue/0000755000175000017500000000000012266757723027702 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757723034713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.base/0000755000175000017500000000000012266757723021646 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/version.pass.cpp0000644000175000017500000000072112266757723025004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/iostreams.base/fpos/0000755000175000017500000000000012266757723022615 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723027125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.base/fpos/fpos.operations/0000755000175000017500000000000012266757723025746 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp0000644000175000017500000000104212266757723031235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } libcxx/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp0000644000175000017500000000112512266757723031510 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp0000644000175000017500000000114712266757723030710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp0000644000175000017500000000117212266757723031755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp0000644000175000017500000000107712266757723030703 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp0000644000175000017500000000115412266757723031213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp0000644000175000017500000000110412266757723031601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/input.output/iostreams.base/fpos/fpos.members/0000755000175000017500000000000012266757723025215 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp0000644000175000017500000000104412266757723030005 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/0000755000175000017500000000000012266757723024334 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/0000755000175000017500000000000012266757723027475 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp0000644000175000017500000000123512266757723034267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp0000644000175000017500000000114612266757723034670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp0000644000175000017500000000127712266757723035351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723030644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/0000755000175000017500000000000012266757723027550 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp0000644000175000017500000000135712266757723033701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp0000644000175000017500000000125312266757723032321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp0000644000175000017500000000134112266757723033032 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp0000644000175000017500000000127212266757723033343 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/0000755000175000017500000000000012266757723027242 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp0000644000175000017500000000126112266757723032415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp0000644000175000017500000000126712266757723032753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp0000644000175000017500000000126712266757723032710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp0000644000175000017500000000131712266757723032754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp0000644000175000017500000000131312266757723032566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp0000644000175000017500000000126412266757723032531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp0000644000175000017500000000132312266757723033062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp0000644000175000017500000000131712266757723032726 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp0000644000175000017500000000132712266757723033242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp0000644000175000017500000000132712266757723033305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp0000644000175000017500000000126712266757723032662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp0000644000175000017500000000132712266757723033214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp0000644000175000017500000000125612266757723032237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp0000644000175000017500000000126112266757723032367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/0000755000175000017500000000000012266757723027735 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp0000644000175000017500000000126412266757723033225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp0000644000175000017500000000125312266757723032524 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp0000644000175000017500000000125012266757723032336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/0000755000175000017500000000000012266757723027355 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp0000644000175000017500000000124512266757723031614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp0000644000175000017500000000124512266757723031615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp0000644000175000017500000000124512266757723031563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/0000755000175000017500000000000012266757723023351 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/0000755000175000017500000000000012266757723026517 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp0000644000175000017500000000155612266757723031332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp0000644000175000017500000000123712266757723031455 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp0000644000175000017500000000146112266757723031316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/input.output/iostreams.base/ios.base/ios.members.static/0000755000175000017500000000000012266757723027062 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp0000644000175000017500000000153412266757723033747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/input.output/iostreams.base/ios.base/ios.base.callback/0000755000175000017500000000000012266757723026607 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp0000644000175000017500000000217712266757723033727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/ios.types/0000755000175000017500000000000012266757723025306 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_openmode/0000755000175000017500000000000012266757723027766 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp0000644000175000017500000000200212266757723033237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 ); } libcxx/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723031616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_iostate/0000755000175000017500000000000012266757723027630 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp0000644000175000017500000000151712266757723032755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_Init/0000755000175000017500000000000012266757723027063 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757723034074 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/0000755000175000017500000000000012266757723027607 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpplibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.c0000644000175000017500000000255612266757723035470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpplibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.0000644000175000017500000000257412266757723035527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/0000755000175000017500000000000012266757723027606 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp0000644000175000017500000000125612266757723032711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/0000755000175000017500000000000012266757723027763 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp0000644000175000017500000000516012266757723033241 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp0000644000175000017500000000061612266757723027657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/iostreams.base/ios.base/ios.base.cons/0000755000175000017500000000000012266757723026015 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp0000644000175000017500000000343012266757723030436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/0000755000175000017500000000000012266757723026475 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp0000644000175000017500000000403112266757723031245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp0000644000175000017500000000117512266757723031427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/0000755000175000017500000000000012266757723026273 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp0000644000175000017500000000141212266757723032721 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp0000644000175000017500000000112712266757723031064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp0000644000175000017500000000113712266757723031741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp0000644000175000017500000000115612266757723031043 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp0000644000175000017500000000130012266757723034177 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp0000644000175000017500000000144212266757723032571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp0000644000175000017500000000146312266757723033607 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp0000644000175000017500000000125612266757723033335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp0000644000175000017500000000127212266757723032265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/input.output/iostreams.base/ios/0000755000175000017500000000000012266757723022440 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios/types.pass.cpp0000644000175000017500000000253312266757723025260 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/iostreams.base/ios/iostate.flags/0000755000175000017500000000000012266757723025203 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp0000644000175000017500000000142512266757723031037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp0000644000175000017500000000142012266757723027601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp0000644000175000017500000000151712266757723027431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp0000644000175000017500000000172712266757723027411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp0000644000175000017500000000124512266757723030324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } libcxx/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp0000644000175000017500000000116012266757723027452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp0000644000175000017500000000173512266757723027575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp0000644000175000017500000000313112266757723030506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp0000644000175000017500000000237712266757723032576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp0000644000175000017500000000303712266757723027745 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp0000644000175000017500000000124612266757723027612 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/0000755000175000017500000000000012266757723025743 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp0000644000175000017500000000517312266757723030523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp0000644000175000017500000000135612266757723030523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp0000644000175000017500000000107312266757723030523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp0000644000175000017500000000117312266757723030544 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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', '*') == '*'); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp0000644000175000017500000000635212266757723030370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp0000644000175000017500000001036112266757723030367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp0000644000175000017500000000126712266757723031735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp0000644000175000017500000000223612266757723031374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp0000644000175000017500000000106012266757723030337 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() == ' '); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp0000644000175000017500000000120512266757723032376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() == '*'); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp0000644000175000017500000001134012266757723031074 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_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'); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp0000644000175000017500000000111312266757723030171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp0000644000175000017500000000163712266757723032575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } libcxx/test/input.output/iostreams.base/ios/basic.ios.cons/0000755000175000017500000000000012266757723025253 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp0000644000175000017500000000276412266757723031754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/input.output/iostreams.base/stream.types/0000755000175000017500000000000012266757723024304 5ustar sylvestresylvestrelibcxx/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp0000644000175000017500000000110012266757723027733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, ""); } libcxx/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp0000644000175000017500000000110212266757723030135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, ""); } libcxx/test/input.output/iostream.objects/0000755000175000017500000000000012266757722022201 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.objects/version.pass.cpp0000644000175000017500000000073312266757722025342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/iostream.objects/wide.stream.objects/0000755000175000017500000000000012266757722026053 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp0000644000175000017500000000114212266757722030644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 assert(std::wcerr.tie() == &std::wcout); assert(std::wcerr.flags() & std::ios_base::unitbuf); #endif // 0 } libcxx/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp0000644000175000017500000000077112266757722030644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp0000644000175000017500000000077112266757722030672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 wcout; #include int main() { #if 0 std::wcout << L"Hello World!\n"; #else (void)std::wcout; #endif } libcxx/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp0000644000175000017500000000124212266757722030463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 assert(std::wcin.tie() == &std::wcout); #endif } libcxx/test/input.output/iostream.objects/narrow.stream.objects/0000755000175000017500000000000012266757722026433 5ustar sylvestresylvestrelibcxx/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp0000644000175000017500000000113412266757722031036 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 assert(std::cerr.tie() == &std::cout); assert(std::cerr.flags() & std::ios_base::unitbuf); #endif // 0 } libcxx/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp0000644000175000017500000000122712266757722030657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 assert(std::cin.tie() == &std::cout); #endif } libcxx/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp0000644000175000017500000000116012266757722031054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 } libcxx/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp0000644000175000017500000000076512266757722031040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/input.output/stream.buffers/0000755000175000017500000000000012266757723021655 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/version.pass.cpp0000644000175000017500000000073512266757723025020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/input.output/stream.buffers/streambuf.reqts/0000755000175000017500000000000012266757723025002 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757723032013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/stream.buffers/streambuf/0000755000175000017500000000000012266757723023645 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf/types.pass.cpp0000644000175000017500000000341412266757723026464 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/0000755000175000017500000000000012266757723026576 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp0000644000175000017500000000117312266757723031170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp0000644000175000017500000000107612266757723031644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp0000644000175000017500000000243712266757723031701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp0000644000175000017500000000365312266757723031230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/0000755000175000017500000000000012266757723027505 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/0000755000175000017500000000000012266757723033236 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.c0000644000175000017500000000125112266757723035502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pa0000644000175000017500000000122112266757723035561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pa0000644000175000017500000000131612266757723035571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.0000644000175000017500000000172712266757723035523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/0000755000175000017500000000000012266757723033730 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_el0000644000175000017500000000056412266757723035630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723034015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/0000755000175000017500000000000012266757723034101 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_0000644000175000017500000000056412266757723035636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/0000755000175000017500000000000012266757723033267 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.0000644000175000017500000000202712266757723035577 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pas0000644000175000017500000000125512266757723035642 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/0000755000175000017500000000000012266757723033537 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.0000644000175000017500000000131512266757723035454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/0000755000175000017500000000000012266757723027625 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723034135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/0000755000175000017500000000000012266757723033100 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp0000644000175000017500000000467312266757723035535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.c0000644000175000017500000000402212266757723035473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/0000755000175000017500000000000012266757723033302 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.0000644000175000017500000000252212266757723035363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.c0000644000175000017500000000224612266757723035361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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])); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/0000755000175000017500000000000012266757723033333 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.c0000644000175000017500000000216212266757723035420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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])); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.0000644000175000017500000000253112266757723035425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/0000755000175000017500000000000012266757723027266 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp0000644000175000017500000000056412266757723033576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/0000755000175000017500000000000012266757723032677 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.c0000644000175000017500000000227112266757723035434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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() == "en_US.UTF-8"); assert(t.getloc().name() == LOCALE_fr_FR_UTF_8); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/0000755000175000017500000000000012266757723032652 5ustar sylvestresylvestrelibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp0000644000175000017500000000265712266757723035473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp0000644000175000017500000000161712266757723035501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/0000755000175000017500000000000012266757723032621 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cp0000644000175000017500000000227412266757723035423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp0000644000175000017500000000160512266757723035414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.0000644000175000017500000000213512266757723035352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cp0000644000175000017500000000227512266757723035411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp0000644000175000017500000000232512266757723035401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/0000755000175000017500000000000012266757723033122 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass0000644000175000017500000000237612266757723035472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pa0000644000175000017500000000243212266757723035424 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/0000755000175000017500000000000012266757723032526 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass0000644000175000017500000000164012266757723035550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.0000644000175000017500000000135512266757723035477 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cp0000644000175000017500000000127512266757723035507 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpplibcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass0000644000175000017500000000147012266757723035600 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/depr/0000755000175000017500000000000012266757730015161 5ustar sylvestresylvestrelibcxx/test/depr/depr.auto.ptr/0000755000175000017500000000000012266757730017666 5ustar sylvestresylvestrelibcxx/test/depr/depr.auto.ptr/nothing_to_do.pass.cpp0000644000175000017500000000056412266757730024176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/depr/depr.auto.ptr/auto.ptr/0000755000175000017500000000000012266757730021442 5ustar sylvestresylvestrelibcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/0000755000175000017500000000000012266757730024157 5ustar sylvestresylvestrelibcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp0000644000175000017500000000145112266757730027256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp0000644000175000017500000000202212266757730031501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp0000644000175000017500000000201412266757730031535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp0000644000175000017500000000136512266757730027423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp0000644000175000017500000000136212266757730026551 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp0000644000175000017500000000165312266757730027752 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp0000644000175000017500000000136412266757730027314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp0000644000175000017500000000144312266757730027312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp0000644000175000017500000000164512266757730030006 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp0000644000175000017500000000135412266757730026605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/AB.h0000644000175000017500000000147012266757730022077 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/0000755000175000017500000000000012266757730024162 5ustar sylvestresylvestrelibcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp0000644000175000017500000000146712266757730032723 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp0000644000175000017500000000124012266757730032563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp0000644000175000017500000000143212266757730033107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp0000644000175000017500000000123712266757730031735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/0000755000175000017500000000000012266757730024647 5ustar sylvestresylvestrelibcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp0000644000175000017500000000131012266757730027733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp0000644000175000017500000000127612266757730027460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp0000644000175000017500000000202212266757730027436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp0000644000175000017500000000131012266757730027400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.auto.ptr/auto.ptr/A.h0000644000175000017500000000122612266757730021774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp0000644000175000017500000000134012266757730025603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/depr/depr.str.strstreams/0000755000175000017500000000000012266757730021130 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/version.pass.cpp0000644000175000017500000000073512266757730024273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/depr/depr.str.strstreams/depr.strstream/0000755000175000017500000000000012266757730024105 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstream/types.pass.cpp0000644000175000017500000000227412266757730026727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/0000755000175000017500000000000012266757730030020 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp0000644000175000017500000000130312266757730032570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/0000755000175000017500000000000012266757730030026 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp0000644000175000017500000000116212266757730032307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp0000644000175000017500000000117212266757730033010 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp0000644000175000017500000000137612266757730032766 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/0000755000175000017500000000000012266757730030023 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp0000644000175000017500000000311712266757730034136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp0000644000175000017500000000145212266757730033122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.str.strstreams/depr.ostrstream/0000755000175000017500000000000012266757730024264 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp0000644000175000017500000000111212266757730027074 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/0000755000175000017500000000000012266757730030361 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp0000644000175000017500000000227212266757730034475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp0000644000175000017500000000122412266757730033455 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/0000755000175000017500000000000012266757730031051 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp0000644000175000017500000000130512266757730033623 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp0000644000175000017500000000116412266757730033334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp0000644000175000017500000000117412266757730034035 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp0000644000175000017500000000140012266757730033775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/0000755000175000017500000000000012266757730024602 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/0000755000175000017500000000000012266757730031705 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp0000644000175000017500000000116512266757730034171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp0000644000175000017500000000140412266757730034665 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp0000644000175000017500000000122412266757730034635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp0000644000175000017500000000110212266757730027411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/0000755000175000017500000000000012266757730032124 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp0000644000175000017500000000125112266757730035064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp0000644000175000017500000000342612266757730035516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp0000644000175000017500000000521012266757730035215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp0000644000175000017500000000260212266757730035602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp0000644000175000017500000000235512266757730035253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp0000644000175000017500000000304212266757730035437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/0000755000175000017500000000000012266757730031215 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp0000644000175000017500000000207012266757730035351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp0000644000175000017500000000574312266757730035367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp0000644000175000017500000000206712266757730034472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp0000644000175000017500000000211412266757730034646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp0000644000175000017500000000210612266757730034651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp0000644000175000017500000000563512266757730035015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp0000644000175000017500000000572512266757730035363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp0000644000175000017500000000133412266757730034313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/depr/depr.str.strstreams/depr.istrstream/0000755000175000017500000000000012266757730024256 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/0000755000175000017500000000000012266757730031035 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp0000644000175000017500000000122012266757730033603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp0000644000175000017500000000114212266757730033314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp0000644000175000017500000000111212266757730027066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/0000755000175000017500000000000012266757730030345 5ustar sylvestresylvestrelibcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp0000644000175000017500000000175712266757730033464 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp0000644000175000017500000000177212266757730033624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp0000644000175000017500000000174312266757730032425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp0000644000175000017500000000175612266757730032574 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } libcxx/test/depr/depr.ios.members/0000755000175000017500000000000012266757730020335 5ustar sylvestresylvestrelibcxx/test/depr/depr.ios.members/streamoff.pass.cpp0000644000175000017500000000120612266757730023773 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.ios.members/streampos.pass.cpp0000644000175000017500000000111012266757730024014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.ios.members/open_mode.pass.cpp0000644000175000017500000000110612266757730023751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.ios.members/seek_dir.pass.cpp0000644000175000017500000000110412266757730023567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.ios.members/io_state.pass.cpp0000644000175000017500000000111212266757730023610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.c.headers/0000755000175000017500000000000012266757730017746 5ustar sylvestresylvestrelibcxx/test/depr/depr.c.headers/assert_h.pass.cpp0000644000175000017500000000071612266757730023233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/depr/depr.c.headers/float_h.pass.cpp0000644000175000017500000000426712266757730023044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/depr/depr.c.headers/fenv_h.pass.cpp0000644000175000017500000000372612266757730022674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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), ""); } libcxx/test/depr/depr.c.headers/iso646_h.pass.cpp0000644000175000017500000000065712266757730022770 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/depr/depr.c.headers/stdio_h.pass.cpp0000644000175000017500000001152312266757730023052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } libcxx/test/depr/depr.c.headers/stdint_h.pass.cpp0000644000175000017500000002573512266757730023247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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 } libcxx/test/depr/depr.c.headers/uchar_h.pass.cpp0000644000175000017500000000066012266757730023032 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // #include int main() { } libcxx/test/depr/depr.c.headers/locale_h.pass.cpp0000644000175000017500000000172312266757730023170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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<__typeof__(setlocale(0, "")), char*>::value), ""); static_assert((std::is_same<__typeof__(localeconv()), lconv*>::value), ""); } libcxx/test/depr/depr.c.headers/stdlib_h.pass.cpp0000644000175000017500000000725512266757730023220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); static_assert((std::is_same::value), ""); wchar_t* pw = 0; const wchar_t* pwc = 0; char* pc = 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), ""); } libcxx/test/depr/depr.c.headers/wchar_h.pass.cpp0000644000175000017500000001340112266757730023031 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/depr/depr.c.headers/tgmath_h.pass.cpp0000644000175000017500000000102112266757730023204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/depr/depr.c.headers/signal_h.pass.cpp0000644000175000017500000000210712266757730023203 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.c.headers/stddef_h.pass.cpp0000644000175000017500000000222512266757730023200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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"); } libcxx/test/depr/depr.c.headers/ciso646.pass.cpp0000644000175000017500000000073112266757730022615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/depr/depr.c.headers/ctype_h.pass.cpp0000644000175000017500000000470612266757730023061 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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'); } libcxx/test/depr/depr.c.headers/setjmp_h.pass.cpp0000644000175000017500000000113312266757730023226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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<__typeof__(longjmp(jb, 0)), void>::value), "std::is_same<__typeof__(longjmp(jb, 0)), void>::value"); } libcxx/test/depr/depr.c.headers/math_h.pass.cpp0000644000175000017500000006325312266757730022670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "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) == 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(); } libcxx/test/depr/depr.c.headers/errno_h.pass.cpp0000644000175000017500000000115012266757730023050 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/depr/depr.c.headers/time_h.pass.cpp0000644000175000017500000000250712266757730022670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.c.headers/inttypes_h.pass.cpp0000644000175000017500000002222312266757730023606 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.c.headers/limits_h.pass.cpp0000644000175000017500000000263512266757730023235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/depr/depr.c.headers/complex.h.pass.cpp0000644000175000017500000000077112266757730023321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/depr/depr.c.headers/stdbool_h.pass.cpp0000644000175000017500000000124212266757730023373 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/depr/depr.c.headers/string_h.pass.cpp0000644000175000017500000000447212266757730023243 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } libcxx/test/depr/depr.c.headers/wctype_h.pass.cpp0000644000175000017500000000531612266757730023246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/depr/depr.c.headers/stdarg_h.pass.cpp0000644000175000017500000000116712266757730023217 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #ifndef va_copy #error va_copy not defined #endif #ifndef va_end #error va_end not defined #endif #ifndef va_start #error va_start not defined #endif int main() { va_list va; } libcxx/test/depr/nothing_to_do.pass.cpp0000644000175000017500000000056412266757730021471 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/depr/depr.lib.binders/0000755000175000017500000000000012266757730020305 5ustar sylvestresylvestrelibcxx/test/depr/depr.lib.binders/nothing_to_do.pass.cpp0000644000175000017500000000056412266757730024615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/depr/depr.lib.binders/depr.lib.binder.1st/0000755000175000017500000000000012266757730023754 5ustar sylvestresylvestrelibcxx/test/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp0000644000175000017500000000304312266757730027320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.lib.binders/depr.lib.binder.2nd/0000755000175000017500000000000012266757730023730 5ustar sylvestresylvestrelibcxx/test/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp0000644000175000017500000000304412266757730027251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/depr/depr.lib.binders/test_func.h0000644000175000017500000000174612266757730022460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/depr/depr.lib.binders/depr.lib.bind.2nd/0000755000175000017500000000000012266757730023401 5ustar sylvestresylvestrelibcxx/test/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp0000644000175000017500000000113312266757730026370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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.); } libcxx/test/depr/depr.lib.binders/depr.lib.bind.1st/0000755000175000017500000000000012266757730023425 5ustar sylvestresylvestrelibcxx/test/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp0000644000175000017500000000113512266757730026442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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.); } libcxx/test/depr/exception.unexpected/0000755000175000017500000000000012266757730021322 5ustar sylvestresylvestrelibcxx/test/depr/exception.unexpected/unexpected/0000755000175000017500000000000012266757730023466 5ustar sylvestresylvestrelibcxx/test/depr/exception.unexpected/unexpected/unexpected.pass.cpp0000644000175000017500000000105412266757730027303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/exception.unexpected/unexpected.handler/0000755000175000017500000000000012266757730025102 5ustar sylvestresylvestrelibcxx/test/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp0000644000175000017500000000072612266757730032421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/depr/exception.unexpected/nothing_to_do.pass.cpp0000644000175000017500000000056412266757730025632 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/depr/exception.unexpected/set.unexpected/0000755000175000017500000000000012266757730024260 5ustar sylvestresylvestrelibcxx/test/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp0000644000175000017500000000166412266757730030743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp0000644000175000017500000000152012266757730030746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.function.objects/0000755000175000017500000000000012266757730021367 5ustar sylvestresylvestrelibcxx/test/depr/depr.function.objects/depr.base/0000755000175000017500000000000012266757730023232 5ustar sylvestresylvestrelibcxx/test/depr/depr.function.objects/depr.base/unary_function.pass.cpp0000644000175000017500000000143012266757730027744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.function.objects/depr.base/binary_function.pass.cpp0000644000175000017500000000173612266757730030103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/depr/depr.function.objects/nothing_to_do.pass.cpp0000644000175000017500000000056412266757730025677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/depr/depr.function.objects/depr.adaptors/0000755000175000017500000000000012266757730024135 5ustar sylvestresylvestrelibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/0000755000175000017500000000000012266757730031630 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pas0000644000175000017500000000141512266757730035253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pa0000644000175000017500000000150112266757730035326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass0000644000175000017500000000145312266757730035330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass0000644000175000017500000000136212266757730035356 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp0000644000175000017500000000136512266757730035015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.0000644000175000017500000000137412266757730035326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.0000644000175000017500000000140012266757730035134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pas0000644000175000017500000000147512266757730035232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp0000644000175000017500000000133112266757730034725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp0000644000175000017500000000144512266757730035256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cp0000644000175000017500000000146712266757730035163 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref0000644000175000017500000000154112266757730035325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_0000644000175000017500000000150112266757730035377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref10000644000175000017500000000143012266757730035322 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.c0000644000175000017500000000134412266757730035225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.p0000644000175000017500000000154112266757730035252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp0000644000175000017500000000056412266757730030445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/0000755000175000017500000000000012266757730032206 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary0000644000175000017500000000132212266757730035527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cp0000644000175000017500000000123712266757730035240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binar0000644000175000017500000000136512266757730035473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpplibcxx/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cp0000644000175000017500000000132712266757730035241 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/thread/0000755000175000017500000000000012266757725015502 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/0000755000175000017500000000000012266757725020402 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/version.pass.cpp0000644000175000017500000000072712266757725023546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/thread/thread.threads/thread.thread.this/0000755000175000017500000000000012266757725024065 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp0000644000175000017500000000200412266757725030055 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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()); } libcxx/test/thread/thread.threads/thread.thread.this/yield.pass.cpp0000644000175000017500000000074512266757725026652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 this_thread::yield(); #include #include int main() { std::this_thread::yield(); } libcxx/test/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp0000644000175000017500000000176112266757725027521 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 sleep_for(const chrono::duration& rel_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_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()); } libcxx/test/thread/thread.threads/thread.thread.this/get_id.pass.cpp0000644000175000017500000000104712266757725026773 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // thread::id this_thread::get_id(); #include #include int main() { std::thread::id id = std::this_thread::get_id(); assert(id != std::thread::id()); } libcxx/test/thread/thread.threads/thread.thread.class/0000755000175000017500000000000012266757725024223 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.assign/0000755000175000017500000000000012266757725030223 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp0000644000175000017500000000331112266757725032640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } 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() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES std::set_terminate(f1); { 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; 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); } { std::thread t0(G(), 5, 5.5); std::thread::id id = t0.get_id(); std::thread t1; t0 = std::move(t1); assert(false); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp0000644000175000017500000000167612266757725032625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } } libcxx/test/thread/thread.threads/thread.thread.class/types.pass.cpp0000644000175000017500000000114412266757725027040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // { // public: // typedef pthread_t native_handle_type; // ... // }; #include #include int main() { static_assert((std::is_same::value), ""); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.destr/0000755000175000017500000000000012266757725030060 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp0000644000175000017500000000212312266757725032477 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #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); std::thread t((G())); std::this_thread::sleep_for(std::chrono::milliseconds(250)); } assert(false); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/0000755000175000017500000000000012266757725030206 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp0000644000175000017500000000176412266757725034470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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() { { std::thread t0((G())); pthread_t pid = t0.native_handle(); assert(pid != 0); t0.join(); } } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp0000644000175000017500000000213312266757725033106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // void detach(); #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())); assert(t0.joinable()); t0.detach(); assert(!t0.joinable()); std::this_thread::sleep_for(std::chrono::milliseconds(250)); assert(G::op_run); assert(G::n_alive == 0); } } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp0000644000175000017500000000215312266757725032632 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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() { { 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(); } } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp0000644000175000017500000000174012266757725033444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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() { { std::thread t0((G())); assert(t0.joinable()); t0.join(); assert(!t0.joinable()); } } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp0000644000175000017500000000214112266757725033110 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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() { { 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(); } } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp0000644000175000017500000000172612266757725032624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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() { { std::thread t0((G())); assert(t0.joinable()); t0.join(); assert(!t0.joinable()); } } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.static/0000755000175000017500000000000012266757725030226 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpplibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass0000644000175000017500000000102212266757725035320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // unsigned hardware_concurrency(); #include #include int main() { assert(std::thread::hardware_concurrency() > 0); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/0000755000175000017500000000000012266757725027333 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp0000644000175000017500000000167512266757725031434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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::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)); assert( (id0 <= id2)); assert(!(id0 > id2)); assert(!(id0 >= id2)); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp0000644000175000017500000000134312266757725032730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 int main() { std::thread::id id1; std::thread::id id2 = std::this_thread::get_id(); typedef std::hash H; H h; assert(h(id1) != h(id2)); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp0000644000175000017500000000117312266757725032272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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::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); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp0000644000175000017500000000127112266757725032300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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::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; } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp0000644000175000017500000000136012266757725031411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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::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)); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp0000644000175000017500000000100312266757725032422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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::id // id(); #include #include int main() { std::thread::id id; assert(id == std::thread::id()); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp0000644000175000017500000000105112266757725031753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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::id // id(const id&) = default; #include #include int main() { std::thread::id id0; std::thread::id id1 = id0; assert(id1 == id0); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/0000755000175000017500000000000012266757725030247 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp0000644000175000017500000000271712266757725032675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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 { 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 = 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 } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp0000644000175000017500000000257312266757725032646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp0000644000175000017500000000133612266757725033200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 ); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp0000644000175000017500000000540112266757725032105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 thread(F&& f, Args&&... args); #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 } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp0000644000175000017500000000100612266757725033341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include #include int main() { std::thread t; assert(t.get_id() == std::thread::id()); } libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/0000755000175000017500000000000012266757725030725 5ustar sylvestresylvestrelibcxx/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp0000644000175000017500000000216712266757725033356 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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() { { 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(); } } libcxx/test/thread/macro.pass.cpp0000644000175000017500000000101212266757725020246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 __STDCPP_THREADS__ __cplusplus #include int main() { #ifndef __STDCPP_THREADS__ #error __STDCPP_THREADS__ is not defined #endif } libcxx/test/thread/thread.condition/0000755000175000017500000000000012266757725020736 5ustar sylvestresylvestrelibcxx/test/thread/thread.condition/notify_all_at_thread_exit.pass.cpp0000644000175000017500000000207212266757725027614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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)); } libcxx/test/thread/thread.condition/version.pass.cpp0000644000175000017500000000075712266757725024105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/thread/thread.condition/thread.condition.condvar/0000755000175000017500000000000012266757725025625 5ustar sylvestresylvestrelibcxx/test/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp0000644000175000017500000000150212266757725032075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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); } libcxx/test/thread/thread.condition/thread.condition.condvar/wait.pass.cpp0000644000175000017500000000201312266757725030236 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } libcxx/test/thread/thread.condition/thread.condition.condvar/assign.fail.cpp0000644000175000017500000000116512266757725030532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/thread/thread.condition/thread.condition.condvar/copy.fail.cpp0000644000175000017500000000114012266757725030211 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp0000644000175000017500000000401712266757725032124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp0000644000175000017500000000477612266757725032505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp0000644000175000017500000000342212266757725031450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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); } libcxx/test/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp0000644000175000017500000000226712266757725031263 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } libcxx/test/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp0000644000175000017500000000452612266757725031464 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp0000644000175000017500000000255312266757725031443 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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); } libcxx/test/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp0000644000175000017500000000205312266757725031474 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #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(); } libcxx/test/thread/thread.condition/thread.condition.condvar/default.pass.cpp0000644000175000017500000000102712266757725030722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include #include int main() { std::condition_variable cv; } libcxx/test/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp0000644000175000017500000000364112266757725031114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.condition/cv_status.pass.cpp0000644000175000017500000000115712266757725024426 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/thread/thread.condition/thread.condition.condvarany/0000755000175000017500000000000012266757725026335 5ustar sylvestresylvestrelibcxx/test/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp0000644000175000017500000000204212266757725030750 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } libcxx/test/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp0000644000175000017500000000121112266757725031232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp0000644000175000017500000000116412266757725030727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp0000644000175000017500000000374712266757725032645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp0000644000175000017500000000473712266757725033212 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp0000644000175000017500000000331512266757725032161 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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); } libcxx/test/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp0000644000175000017500000000227712266757725031774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } libcxx/test/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp0000644000175000017500000000446412266757725032175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp0000644000175000017500000000250012266757725032143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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); } libcxx/test/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp0000644000175000017500000000204712266757725032207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #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(); } libcxx/test/thread/thread.condition/thread.condition.condvarany/default.pass.cpp0000644000175000017500000000104312266757725031430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include #include int main() { std::condition_variable_any cv; } libcxx/test/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp0000644000175000017500000000357312266757725031630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.general/0000755000175000017500000000000012266757725020365 5ustar sylvestresylvestrelibcxx/test/thread/thread.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725024675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.mutex/0000755000175000017500000000000012266757725020112 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/version.pass.cpp0000644000175000017500000000072512266757725023254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/thread/thread.mutex/thread.lock/0000755000175000017500000000000012266757725022310 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.lock/thread.lock.guard/0000755000175000017500000000000012266757725025607 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp0000644000175000017500000000122012266757725030417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 // { // public: // typedef Mutex mutex_type; // ... // }; #include #include int main() { static_assert((std::is_same::mutex_type, std::mutex>::value), ""); } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp0000644000175000017500000000117312266757725030513 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp0000644000175000017500000000111612266757725030176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp0000644000175000017500000000205412266757725030423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 < ms(200)); // within 200ms } int main() { m.lock(); std::thread t(f); std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp0000644000175000017500000000206112266757725030366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp0000644000175000017500000000211612266757725031377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(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(); } libcxx/test/thread/thread.mutex/thread.lock/types.pass.cpp0000644000175000017500000000147312266757725025132 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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; } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/0000755000175000017500000000000012266757725026013 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp0000644000175000017500000000122212266757725030625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 // { // public: // typedef Mutex mutex_type; // ... // }; #include #include int main() { static_assert((std::is_same::mutex_type, std::mutex>::value), ""); } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/0000755000175000017500000000000012266757725033143 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.p0000644000175000017500000000241512266757725035154 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pas0000644000175000017500000000203312266757725035141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_f0000644000175000017500000000311512266757725035221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.0000644000175000017500000000262612266757725035047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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(); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_u0000644000175000017500000000332712266757725035245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/0000755000175000017500000000000012266757725032457 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_l0000644000175000017500000000121712266757725035225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.f0000644000175000017500000000143512266757725035147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duratio0000644000175000017500000000305512266757725035276 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cp0000644000175000017500000000205512266757725035114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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(); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pas0000644000175000017500000000150412266757725035161 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&& 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 } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_0000644000175000017500000000273412266757725035311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(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(); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fai0000644000175000017500000000136012266757725035141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.0000644000175000017500000000111312266757725035045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); #include #include int main() { std::unique_lock ul; assert(!ul.owns_lock()); assert(ul.mutex() == nullptr); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.p0000644000175000017500000000156112266757725035155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&& 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 } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_l0000644000175000017500000000123412266757725035246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(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); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_po0000644000175000017500000000313312266757725035260 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/0000755000175000017500000000000012266757725032274 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.c0000644000175000017500000000205212266757725035024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pa0000644000175000017500000000143512266757725035122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap0000644000175000017500000000153012266757725035232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/0000755000175000017500000000000012266757725032300 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp0000644000175000017500000000130412266757725035111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass0000644000175000017500000000132012266757725035162 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.c0000644000175000017500000000135512266757725035046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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); } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/0000755000175000017500000000000012266757725025753 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/0000755000175000017500000000000012266757725033043 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.p0000644000175000017500000000263512266757725035060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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 } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pas0000644000175000017500000000225312266757725035045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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 } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_f0000644000175000017500000000333512266757725035125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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 } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.0000644000175000017500000000324112266757725034741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // void lock(); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 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() { 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 } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_u0000644000175000017500000000354712266757725035151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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 } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp0000644000175000017500000000133112266757725030566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 // { // 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 } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/0000755000175000017500000000000012266757725032357 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_l0000644000175000017500000000134412266757725035126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(mutex_type& m, defer_lock_t); #include #include int main() { #if _LIBCPP_STD_VER > 11 std::shared_mutex m; std::shared_lock lk(m, std::defer_lock); assert(lk.mutex() == &m); assert(lk.owns_lock() == false); #endif // _LIBCPP_STD_VER > 11 } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.f0000644000175000017500000000145112266757725035045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_mutex m0; std::shared_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 } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duratio0000644000175000017500000000365612266757725035205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // template // shared_lock(mutex_type& m, const chrono::duration& rel_time); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cp0000644000175000017500000000333512266757725035016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // explicit shared_lock(mutex_type& m); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 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(); 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 } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pas0000644000175000017500000000160412266757725035062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&& u); #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_0000644000175000017500000000337412266757725035212 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(mutex_type& m, try_to_lock_t); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 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(); { 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 } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fai0000644000175000017500000000136612266757725035047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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_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 } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.0000644000175000017500000000123112266757725034746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); #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 } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.p0000644000175000017500000000167212266757725035060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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&& u); #include #include #if _LIBCPP_STD_VER > 11 std::shared_mutex m0; std::shared_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 } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_l0000644000175000017500000000136112266757725035147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(mutex_type& m, adopt_lock_t); #include #include int main() { #if _LIBCPP_STD_VER > 11 std::shared_mutex m; m.lock(); std::shared_lock lk(m, std::adopt_lock); assert(lk.mutex() == &m); assert(lk.owns_lock() == true); #endif // _LIBCPP_STD_VER > 11 } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_po0000644000175000017500000000373512266757725035170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // template // shared_lock(mutex_type& m, const chrono::time_point& abs_time); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/0000755000175000017500000000000012266757725032200 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp0000644000175000017500000000165212266757725035017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // mutex_type *mutex() const noexcept; #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass0000644000175000017500000000167412266757725035076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // bool owns_lock() const noexcept; #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.c0000644000175000017500000000175712266757725034754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // explicit operator bool() const noexcept; #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } libcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/0000755000175000017500000000000012266757725032174 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.c0000644000175000017500000000240112266757725034722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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 } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pa0000644000175000017500000000200212266757725035011 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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 } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpplibcxx/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap0000644000175000017500000000210212266757725035126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // 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 } libcxx/test/thread/thread.mutex/thread.lock.algorithm/0000755000175000017500000000000012266757725024275 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp0000644000175000017500000002341612266757725027602 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 } libcxx/test/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp0000644000175000017500000002164612266757725026707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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 } libcxx/test/thread/thread.mutex/thread.mutex.requirements/0000755000175000017500000000000012266757725025244 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/0000755000175000017500000000000012266757725033421 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_0000644000175000017500000000056412266757725035660 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000755000175000017500000000000012266757725035546 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000222012266757725035544 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000112312266757725035545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000107712266757725035555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000304412266757725035551 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000205512266757725035552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000310612266757725035550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000076212266757725035555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include int main() { std::recursive_timed_mutex m; } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000755000175000017500000000000012266757725035546 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000212212266757725035545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000104112266757725035544 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000101512266757725035545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000273212266757725035554 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000177312266757725035560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000301012266757725035542 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.time0000644000175000017500000000072412266757725035553 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include int main() { std::timed_mutex m; } libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/0000755000175000017500000000000012266757725034012 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_0000644000175000017500000000056412266757725035547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725031554 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/0000755000175000017500000000000012266757725033537 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000755000175000017500000000000012266757725035533 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000113312266757725035533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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); } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000210612266757725035534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000100312266757725035527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000075712266757725035546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000175712266757725035547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000070212266757725035534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include int main() { std::mutex m; } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to0000644000175000017500000000056412266757725035637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000755000175000017500000000000012266757725035533 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000115712266757725035541 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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); } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000220412266757725035533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000106512266757725035537 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000104112266757725035531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000204312266757725035534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // 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(); } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mut0000644000175000017500000000074012266757725035536 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include int main() { std::recursive_mutex m; } libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/0000755000175000017500000000000012266757725033565 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/nothing_to_do.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/nothing_to0000644000175000017500000000056412266757725035665 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/libcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000755000175000017500000000000012266757725035527 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000232612266757725035534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // bool try_lock(); #include #include #include #include #if _LIBCPP_STD_VER > 11 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 } #endif // _LIBCPP_STD_VER > 11 int main() { #if _LIBCPP_STD_VER > 11 m.lock(); std::thread t(f); std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); #endif // _LIBCPP_STD_VER > 11 } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_for.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000356612266757725035543 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // template // bool try_lock_shared_for(const chrono::duration& rel_time); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } #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 } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared_until.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000364412266757725035540 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // template // bool try_lock_shared_until(const chrono::time_point& abs_time); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } #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 } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/assign.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000114412266757725035531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 int main() { #if _LIBCPP_STD_VER > 11 std::shared_mutex m0; std::shared_mutex m1; m1 = m0; #else # error #endif } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/copy.fail.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000112012266757725035523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 int main() { #if _LIBCPP_STD_VER > 11 std::shared_mutex m0; std::shared_mutex m1(m0); #else # error #endif } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_for.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000313612266757725035534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // template // bool try_lock_for(const chrono::duration& rel_time); #include #include #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } #endif // _LIBCPP_STD_VER > 11 int main() { #if _LIBCPP_STD_VER > 11 { 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(); } #endif // _LIBCPP_STD_VER > 11 } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_shared.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000257312266757725035540 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // bool try_lock_shared(); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 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 } #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 } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000215212266757725035531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // void lock(); #include #include #include #include #if _LIBCPP_STD_VER > 11 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 } #endif // _LIBCPP_STD_VER > 11 int main() { #if _LIBCPP_STD_VER > 11 m.lock(); std::thread t(f); std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); #endif // _LIBCPP_STD_VER > 11 } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/try_lock_until.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000321412266757725035531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // template // bool try_lock_until(const chrono::time_point& abs_time); #include #include #include #include #if _LIBCPP_STD_VER > 11 std::shared_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 } #endif // _LIBCPP_STD_VER > 11 int main() { #if _LIBCPP_STD_VER > 11 { 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(); } #endif // _LIBCPP_STD_VER > 11 } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/lock_shared.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000321012266757725035525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; // void lock_shared(); #include #include #include #include #include #if _LIBCPP_STD_VER > 11 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 } #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 } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sharedmutex.class/default.pass.cpplibcxx/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedmutex.requirements/thread.sha0000644000175000017500000000100512266757725035525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include int main() { #if _LIBCPP_STD_VER > 11 std::shared_mutex m; #endif } libcxx/test/thread/thread.mutex/thread.once/0000755000175000017500000000000012266757725022304 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.mutex/thread.once/thread.once.callonce/0000755000175000017500000000000012266757725026255 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp0000644000175000017500000000642612266757725031655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; // 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 { MoveOnly(const MoveOnly&); public: MoveOnly() {} MoveOnly(MoveOnly&&) {} void operator()(MoveOnly&&) { } }; #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()); } #endif // _LIBCPP_HAS_NO_VARIADICS } libcxx/test/thread/thread.mutex/thread.once/thread.once.onceflag/0000755000175000017500000000000012266757725026253 5ustar sylvestresylvestrelibcxx/test/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp0000644000175000017500000000102612266757725031154 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp0000644000175000017500000000100212266757725030634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp0000644000175000017500000000110212266757725031342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/thread/futures/0000755000175000017500000000000012266757725017177 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.state/0000755000175000017500000000000012266757725022013 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.state/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725026315 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/thread/futures/version.pass.cpp0000644000175000017500000000072712266757725022343 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/thread/futures/futures.shared_future/0000755000175000017500000000000012266757725023533 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.shared_future/wait.pass.cpp0000644000175000017500000000420412266757725026150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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)); } } libcxx/test/thread/futures/futures.shared_future/ctor_future.pass.cpp0000644000175000017500000000313312266757725027545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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()); } } libcxx/test/thread/futures/futures.shared_future/dtor.pass.cpp0000644000175000017500000000347312266757725026163 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } libcxx/test/thread/futures/futures.shared_future/move_ctor.pass.cpp0000644000175000017500000000321112266757725027176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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()); } } libcxx/test/thread/futures/futures.shared_future/wait_until.pass.cpp0000644000175000017500000000526212266757725027370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_future // template // future_status // wait_until(const chrono::time_point& abs_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_until(Clock::now() + ms(300)) == std::future_status::timeout); assert(f.valid()); assert(f.wait_until(Clock::now() + 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_until(Clock::now() + ms(300)) == std::future_status::timeout); assert(f.valid()); assert(f.wait_until(Clock::now() + 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_until(Clock::now() + ms(300)) == std::future_status::timeout); assert(f.valid()); assert(f.wait_until(Clock::now() + 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)); } } libcxx/test/thread/futures/futures.shared_future/default.pass.cpp0000644000175000017500000000127212266757725026632 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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()); } } libcxx/test/thread/futures/futures.shared_future/get.pass.cpp0000644000175000017500000000671612266757725025775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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()); } } } libcxx/test/thread/futures/futures.shared_future/wait_for.pass.cpp0000644000175000017500000000510012266757725027012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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)); } } libcxx/test/thread/futures/futures.shared_future/copy_ctor.pass.cpp0000644000175000017500000000312412266757725027205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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()); } } libcxx/test/thread/futures/futures.shared_future/move_assign.pass.cpp0000644000175000017500000000345312266757725027523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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 } libcxx/test/thread/futures/futures.shared_future/copy_assign.pass.cpp0000644000175000017500000000335312266757725027526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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 } libcxx/test/thread/futures/test_allocator.h0000644000175000017500000001223012266757725022365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 libcxx/test/thread/futures/futures.overview/0000755000175000017500000000000012266757725022541 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.overview/launch.pass.cpp0000644000175000017500000000267712266757725025500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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, ""); } libcxx/test/thread/futures/futures.overview/future_status.pass.cpp0000644000175000017500000000131212266757725027124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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, ""); } libcxx/test/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp0000644000175000017500000000105312266757725032460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_error_code_enum : public true_type {}; #include int main() { static_assert(std::is_error_code_enum::value, ""); } libcxx/test/thread/futures/futures.overview/future_errc.pass.cpp0000644000175000017500000000156712266757725026550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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, ""); } libcxx/test/thread/futures/futures.tas/0000755000175000017500000000000012266757725021462 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.tas/types.pass.cpp0000644000175000017500000000123312266757725024276 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // class packaged_task // { // public: // typedef R result_type; #include #include struct A {}; int main() { static_assert((std::is_same::result_type, A>::value), ""); } libcxx/test/thread/futures/futures.tas/futures.task.nonmembers/0000755000175000017500000000000012266757725026264 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp0000644000175000017500000000131712266757725032756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // struct uses_allocator, Alloc> // : true_type { }; #include #include "../../test_allocator.h" int main() { static_assert((std::uses_allocator, test_allocator >::value), ""); } libcxx/test/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp0000644000175000017500000000230512266757725030707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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()); } } libcxx/test/thread/futures/futures.tas/futures.task.members/0000755000175000017500000000000012266757725025551 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp0000644000175000017500000000462612266757725034377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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(); } } libcxx/test/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp0000644000175000017500000000220312266757725031531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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&& 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()); } } libcxx/test/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp0000644000175000017500000000270612266757725031400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } } libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp0000644000175000017500000000264112266757725031207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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 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); } } libcxx/test/thread/futures/futures.tas/futures.task.members/swap.pass.cpp0000644000175000017500000000214512266757725030176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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()); } } libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp0000644000175000017500000000165112266757725030223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // explicit 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 {}}; } libcxx/test/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp0000644000175000017500000000215712266757725031512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp0000644000175000017500000000251612266757725030176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #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); } } libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp0000644000175000017500000000143312266757725030220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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{} }; } libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp0000644000175000017500000000214212266757725031216 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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&& 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()); } } libcxx/test/thread/futures/futures.tas/futures.task.members/reset.pass.cpp0000644000175000017500000000232712266757725030350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } } libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp0000644000175000017500000000352612266757725032364 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f); #include #include #include "../../test_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 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_copies = 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); } libcxx/test/thread/futures/futures.tas/futures.task.members/operator.pass.cpp0000644000175000017500000000442012266757725031055 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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(); } } libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp0000644000175000017500000000211412266757725031166 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp0000644000175000017500000000106212266757725031674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include #include struct A {}; int main() { std::packaged_task p; assert(!p.valid()); } libcxx/test/thread/futures/futures.promise/0000755000175000017500000000000012266757725022351 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.promise/get_future.pass.cpp0000644000175000017500000000243612266757725026200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } } libcxx/test/thread/futures/futures.promise/set_rvalue.pass.cpp0000644000175000017500000000273012266757725026175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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 } libcxx/test/thread/futures/futures.promise/alloc_ctor.pass.cpp0000644000175000017500000000267112266757725026151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // template // promise(allocator_arg_t, const Allocator& a); #include #include #include "../test_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); } libcxx/test/thread/futures/futures.promise/copy_assign.fail.cpp0000644000175000017500000000516012266757725026307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/thread/futures/futures.promise/uses_allocator.pass.cpp0000644000175000017500000000152012266757725027037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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), ""); } libcxx/test/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp0000644000175000017500000000136612266757725032271 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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); } } libcxx/test/thread/futures/futures.promise/swap.pass.cpp0000644000175000017500000000511012266757725024771 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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); } libcxx/test/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp0000644000175000017500000000141312266757725031230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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); } } libcxx/test/thread/futures/futures.promise/set_value_void.pass.cpp0000644000175000017500000000154612266757725027040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } } libcxx/test/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp0000644000175000017500000000164712266757725031747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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); } } } libcxx/test/thread/futures/futures.promise/set_exception.pass.cpp0000644000175000017500000000205212266757725026672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } } libcxx/test/thread/futures/futures.promise/dtor.pass.cpp0000644000175000017500000000425712266757725025002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #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) { assert(e.code() == make_error_code(std::future_errc::broken_promise)); } } } libcxx/test/thread/futures/futures.promise/move_ctor.pass.cpp0000644000175000017500000000464012266757725026023 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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 } libcxx/test/thread/futures/futures.promise/set_value_const.pass.cpp0000644000175000017500000000235312266757725027222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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); } } } libcxx/test/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp0000644000175000017500000000142312266757725032076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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); } } libcxx/test/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp0000644000175000017500000000175512266757725031247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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 } libcxx/test/thread/futures/futures.promise/copy_ctor.fail.cpp0000644000175000017500000000446412266757725026000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/thread/futures/futures.promise/default.pass.cpp0000644000175000017500000000144212266757725025447 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #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()); } } libcxx/test/thread/futures/futures.promise/set_lvalue.pass.cpp0000644000175000017500000000170312266757725026166 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } } libcxx/test/thread/futures/futures.promise/move_assign.pass.cpp0000644000175000017500000000533012266757725026335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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=(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 } libcxx/test/thread/futures/futures.async/0000755000175000017500000000000012266757725022010 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.async/async.pass.cpp0000644000175000017500000001174512266757725024606 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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); } 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)); } } libcxx/test/thread/futures/futures.unique_future/0000755000175000017500000000000012266757725023573 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.unique_future/wait.pass.cpp0000644000175000017500000000415012266757725026210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } libcxx/test/thread/futures/futures.unique_future/copy_assign.fail.cpp0000644000175000017500000000321212266757725027525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/thread/futures/futures.unique_future/share.pass.cpp0000644000175000017500000000320112266757725026342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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()); } } libcxx/test/thread/futures/futures.unique_future/dtor.pass.cpp0000644000175000017500000000343012266757725026214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #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); } libcxx/test/thread/futures/futures.unique_future/move_ctor.pass.cpp0000644000175000017500000000316512266757725027246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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 } libcxx/test/thread/futures/futures.unique_future/wait_until.pass.cpp0000644000175000017500000000522612266757725027430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // template // future_status // wait_until(const chrono::time_point& abs_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_until(Clock::now() + ms(300)) == std::future_status::timeout); assert(f.valid()); assert(f.wait_until(Clock::now() + 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::future f = p.get_future(); std::thread(func3, std::move(p)).detach(); assert(f.valid()); assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout); assert(f.valid()); assert(f.wait_until(Clock::now() + 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::future f = p.get_future(); std::thread(func5, std::move(p)).detach(); assert(f.valid()); assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout); assert(f.valid()); assert(f.wait_until(Clock::now() + 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)); } } libcxx/test/thread/futures/futures.unique_future/copy_ctor.fail.cpp0000644000175000017500000000276312266757725027222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/thread/futures/futures.unique_future/default.pass.cpp0000644000175000017500000000122712266757725026672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include #include int main() { { std::future f; assert(!f.valid()); } { std::future f; assert(!f.valid()); } { std::future f; assert(!f.valid()); } } libcxx/test/thread/futures/futures.unique_future/get.pass.cpp0000644000175000017500000000660712266757725026034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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()); } } } libcxx/test/thread/futures/futures.unique_future/wait_for.pass.cpp0000644000175000017500000000504712266757725027064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // 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)); } } libcxx/test/thread/futures/futures.unique_future/move_assign.pass.cpp0000644000175000017500000000330212266757725027554 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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=(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 } libcxx/test/thread/futures/futures.errors/0000755000175000017500000000000012266757725022207 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.errors/make_error_code.pass.cpp0000644000175000017500000000132212266757725026776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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()); } } libcxx/test/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp0000644000175000017500000000137112266757725032170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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& 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)); } libcxx/test/thread/futures/futures.errors/default_error_condition.pass.cpp0000644000175000017500000000147112266757725030566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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& 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)); } libcxx/test/thread/futures/futures.errors/make_error_condition.pass.cpp0000644000175000017500000000145112266757725030055 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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()); } } libcxx/test/thread/futures/futures.errors/future_category.pass.cpp0000644000175000017500000000112612266757725027067 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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& future_category(); #include #include #include int main() { const std::error_category& ec = std::future_category(); assert(std::strcmp(ec.name(), "future") == 0); } libcxx/test/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp0000644000175000017500000000132612266757725031114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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& 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)); } libcxx/test/thread/futures/futures.future_error/0000755000175000017500000000000012266757725023416 5ustar sylvestresylvestrelibcxx/test/thread/futures/futures.future_error/types.pass.cpp0000644000175000017500000000114112266757725026230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_error : public logic_error {...}; #include #include int main() { static_assert((std::is_convertible::value), ""); } libcxx/test/thread/futures/futures.future_error/what.pass.cpp0000644000175000017500000000264412266757725026040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } libcxx/test/thread/futures/futures.future_error/code.pass.cpp0000644000175000017500000000220112266757725025774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } } libcxx/test/thread/thread.req/0000755000175000017500000000000012266757725017537 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.lockable/0000755000175000017500000000000012266757725023347 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/0000755000175000017500000000000012266757725030237 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725034547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.general/0000755000175000017500000000000012266757725030573 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725035103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.req/0000755000175000017500000000000012266757725027745 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725034255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/0000755000175000017500000000000012266757725030260 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725034570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.paramname/0000755000175000017500000000000012266757725023534 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725030044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.exception/0000755000175000017500000000000012266757725023571 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725030101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.timing/0000755000175000017500000000000012266757725023062 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027372 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725024047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/thread/thread.req/thread.req.native/0000755000175000017500000000000012266757725023061 5ustar sylvestresylvestrelibcxx/test/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/0000755000175000017500000000000012266757725014641 5ustar sylvestresylvestrelibcxx/test/re/re.general/0000755000175000017500000000000012266757725016663 5ustar sylvestresylvestrelibcxx/test/re/re.general/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725023165 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.const/0000755000175000017500000000000012266757725016374 5ustar sylvestresylvestrelibcxx/test/re/re.const/re.err/0000755000175000017500000000000012266757724017570 5ustar sylvestresylvestrelibcxx/test/re/re.const/re.err/error_type.pass.cpp0000644000175000017500000002043712266757724023441 0ustar sylvestresylvestre// -*- 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); } libcxx/test/re/re.const/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725022676 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.const/re.matchflag/0000755000175000017500000000000012266757724020726 5ustar sylvestresylvestrelibcxx/test/re/re.const/re.matchflag/match_flag_type.pass.cpp0000644000175000017500000001612212266757724025527 0ustar sylvestresylvestre// -*- 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; } libcxx/test/re/re.const/re.synopt/0000755000175000017500000000000012266757725020335 5ustar sylvestresylvestrelibcxx/test/re/re.const/re.synopt/syntax_option_type.pass.cpp0000644000175000017500000001241012266757725025763 0ustar sylvestresylvestre// -*- 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; } libcxx/test/re/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725021151 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/re.results/0000755000175000017500000000000012266757724016746 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.state/0000755000175000017500000000000012266757724022173 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.state/ready.pass.cpp0000644000175000017500000000165712266757724024761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.const/0000755000175000017500000000000012266757724022201 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.const/default.pass.cpp0000644000175000017500000000145312266757724025301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.const/allocator.pass.cpp0000644000175000017500000000165412266757724025640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/re/re.results/re.results.swap/0000755000175000017500000000000012266757724022025 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.swap/member_swap.pass.cpp0000644000175000017500000000160312266757724025777 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.swap/non_member_swap.pass.cpp0000644000175000017500000000204712266757724026654 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/types.pass.cpp0000644000175000017500000000450212266757724021564 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/re/re.results/re.results.nonmember/0000755000175000017500000000000012266757724023035 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.nonmember/equal.pass.cpp0000644000175000017500000000230312266757724025613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.size/0000755000175000017500000000000012266757724022025 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.size/max_size.pass.cpp0000644000175000017500000000122412266757724025314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.size/empty.pass.cpp0000644000175000017500000000147512266757724024643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.form/0000755000175000017500000000000012266757724022016 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.form/form4.pass.cpp0000644000175000017500000000564112266757724024524 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.results/re.results.form/form1.pass.cpp0000644000175000017500000001010612266757724024511 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.results/re.results.form/form2.pass.cpp0000644000175000017500000000757112266757724024526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.results/re.results.form/form3.pass.cpp0000644000175000017500000000613212266757724024517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.results/re.results.acc/0000755000175000017500000000000012266757724021601 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.acc/begin_end.pass.cpp0000644000175000017500000000165712266757724025175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.acc/position.pass.cpp0000644000175000017500000000203712266757724025120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.acc/length.pass.cpp0000644000175000017500000000166712266757724024545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.acc/suffix.pass.cpp0000644000175000017500000000144012266757724024555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.acc/str.pass.cpp0000644000175000017500000000166612266757724024073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.acc/index.pass.cpp0000644000175000017500000000225212266757724024362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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::match_results m; const char s[] = "abcdefghijk"; assert(std::regex_search(s, m, std::regex("cd((e)fg)hi"))); 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(); } libcxx/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp0000644000175000017500000000166312266757724025500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.acc/prefix.pass.cpp0000644000175000017500000000143512266757724024552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.results/re.results.all/0000755000175000017500000000000012266757724021623 5ustar sylvestresylvestrelibcxx/test/re/re.results/re.results.all/get_allocator.pass.cpp0000644000175000017500000000164112266757724026115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/re/re.req/0000755000175000017500000000000012266757725016035 5ustar sylvestresylvestrelibcxx/test/re/re.req/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725022337 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.alg/0000755000175000017500000000000012266757724016010 5ustar sylvestresylvestrelibcxx/test/re/re.alg/re.except/0000755000175000017500000000000012266757724017705 5ustar sylvestresylvestrelibcxx/test/re/re.alg/re.except/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724024215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/re.alg/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724022320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/re.alg/re.alg.search/0000755000175000017500000000000012266757724020424 5ustar sylvestresylvestrelibcxx/test/re/re.alg/re.alg.search/extended.pass.cpp0000644000175000017500000016213012266757724023700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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[] = "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("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("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); } } libcxx/test/re/re.alg/re.alg.search/awk.pass.cpp0000644000175000017500000016352212266757724022670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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[] = "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("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("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); } } libcxx/test/re/re.alg/re.alg.search/backup.pass.cpp0000644000175000017500000000362512266757724023350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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{}; 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{}; 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); } } libcxx/test/re/re.alg/re.alg.search/ecma.pass.cpp0000644000175000017500000015553112266757724023014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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[] = "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("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("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); } } libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp0000644000175000017500000016122412266757724023164 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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("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("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); } } libcxx/test/re/re.alg/re.alg.search/grep.pass.cpp0000644000175000017500000000404112266757724023031 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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) == ""); } } libcxx/test/re/re.alg/re.alg.search/egrep.pass.cpp0000644000175000017500000000642212266757724023203 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.alg/re.alg.search/no_update_pos.pass.cpp0000644000175000017500000000223412266757724024735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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{}; assert(it->str() == "a"); assert(it->position(0) == 0); assert(it->length(0) == 1); ++it; assert(it == end); } libcxx/test/re/re.alg/re.alg.search/lookahead.pass.cpp0000644000175000017500000000173512266757724024032 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"))); } libcxx/test/re/re.alg/re.alg.match/0000755000175000017500000000000012266757724020253 5ustar sylvestresylvestrelibcxx/test/re/re.alg/re.alg.match/extended.pass.cpp0000644000175000017500000014362112266757724023533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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[] = "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("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("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); } } libcxx/test/re/re.alg/re.alg.match/awk.pass.cpp0000644000175000017500000014533012266757724022514 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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[] = "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("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("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); } */} libcxx/test/re/re.alg/re.alg.match/lookahead_capture.pass.cpp0000644000175000017500000000527712266757724025411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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] == ""); } } libcxx/test/re/re.alg/re.alg.match/ecma.pass.cpp0000644000175000017500000013110612266757724022633 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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[] = "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("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::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("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); } } libcxx/test/re/re.alg/re.alg.match/basic.pass.cpp0000644000175000017500000014271312266757724023015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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("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("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); } } libcxx/test/re/re.alg/re.alg.match/grep.pass.cpp0000644000175000017500000000323312266757724022662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/re/re.alg/re.alg.match/egrep.pass.cpp0000644000175000017500000000561212266757724023032 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp0000644000175000017500000000330612266757724026134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.alg/re.alg.replace/0000755000175000017500000000000012266757724020572 5ustar sylvestresylvestrelibcxx/test/re/re.alg/re.alg.replace/test1.pass.cpp0000644000175000017500000001144312266757724023306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/re/re.alg/re.alg.replace/test4.pass.cpp0000644000175000017500000000610212266757724023305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.alg/re.alg.replace/test6.pass.cpp0000644000175000017500000000606112266757724023313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.alg/re.alg.replace/test2.pass.cpp0000644000175000017500000001127712266757724023314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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")); } } libcxx/test/re/re.alg/re.alg.replace/test3.pass.cpp0000644000175000017500000000632412266757724023312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.alg/re.alg.replace/test5.pass.cpp0000644000175000017500000000625112266757724023313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.grammar/0000755000175000017500000000000012266757725016674 5ustar sylvestresylvestrelibcxx/test/re/re.grammar/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725023204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/re.submatch/0000755000175000017500000000000012266757725017054 5ustar sylvestresylvestrelibcxx/test/re/re.submatch/re.submatch.members/0000755000175000017500000000000012266757725022720 5ustar sylvestresylvestrelibcxx/test/re/re.submatch/re.submatch.members/operator_string.pass.cpp0000644000175000017500000000232212266757725027611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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")); } } libcxx/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp0000644000175000017500000000255412266757725030454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp0000644000175000017500000000236512266757725031147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/re/re.submatch/re.submatch.members/length.pass.cpp0000644000175000017500000000214212266757725025651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/re/re.submatch/re.submatch.members/str.pass.cpp0000644000175000017500000000234512266757725025205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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")); } } libcxx/test/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp0000644000175000017500000000261712266757725030052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/re/re.submatch/re.submatch.members/default.pass.cpp0000644000175000017500000000143112266757725026014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/re/re.submatch/types.pass.cpp0000644000175000017500000000471612266757725021701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } } libcxx/test/re/re.submatch/re.submatch.op/0000755000175000017500000000000012266757725021704 5ustar sylvestresylvestrelibcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp0000644000175000017500000002353512266757725025013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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) { 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)); 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")); } libcxx/test/re/re.submatch/re.submatch.op/stream.pass.cpp0000644000175000017500000000213012266757725024644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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")); } libcxx/test/re/re.syn/0000755000175000017500000000000012266757725016057 5ustar sylvestresylvestrelibcxx/test/re/re.syn/cmatch.pass.cpp0000644000175000017500000000106612266757725020772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/regex.pass.cpp0000644000175000017500000000104312266757725020640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/smatch.pass.cpp0000644000175000017500000000112112266757725021002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wsregex_iterator.pass.cpp0000644000175000017500000000115112266757725023123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/sregex_iterator.pass.cpp0000644000175000017500000000114512266757725022737 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/cregex_iterator.pass.cpp0000644000175000017500000000111212266757725022711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/csub_match.pass.cpp0000644000175000017500000000106612266757725021643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/sregex_token_iterator.pass.cpp0000644000175000017500000000117512266757725024142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wregex.pass.cpp0000644000175000017500000000105012266757725021025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wssub_match.pass.cpp0000644000175000017500000000112512266757725022046 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wsmatch.pass.cpp0000644000175000017500000000112512266757725021175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wcregex_token_iterator.pass.cpp0000644000175000017500000000115212266757725024304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wcregex_iterator.pass.cpp0000644000175000017500000000112212266757725023101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/ssub_match.pass.cpp0000644000175000017500000000112112266757725021653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wsregex_token_iterator.pass.cpp0000644000175000017500000000120112266757725024317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wcsub_match.pass.cpp0000644000175000017500000000107612266757725022033 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/cregex_token_iterator.pass.cpp0000644000175000017500000000114212266757725024114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.syn/wcmatch.pass.cpp0000644000175000017500000000107612266757725021162 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/re/re.def/0000755000175000017500000000000012266757725016004 5ustar sylvestresylvestrelibcxx/test/re/re.def/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725022306 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.def/defns.regex.finite.state.machine/0000755000175000017500000000000012266757725024213 5ustar sylvestresylvestrelibcxx/test/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725030515 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.def/defns.regex.collating.element/0000755000175000017500000000000012266757725023617 5ustar sylvestresylvestrelibcxx/test/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725030121 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.def/defns.regex.format.specifier/0000755000175000017500000000000012266757725023453 5ustar sylvestresylvestrelibcxx/test/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725027755 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.def/defns.regex.regular.expression/0000755000175000017500000000000012266757725024052 5ustar sylvestresylvestrelibcxx/test/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725030354 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.def/defns.regex.primary.equivalence.class/0000755000175000017500000000000012266757725025302 5ustar sylvestresylvestrelibcxx/test/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725031604 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.def/defns.regex.subexpression/0000755000175000017500000000000012266757725023124 5ustar sylvestresylvestrelibcxx/test/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725027426 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.def/defns.regex.matched/0000755000175000017500000000000012266757725021620 5ustar sylvestresylvestrelibcxx/test/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp0000644000175000017500000000060312266757725026122 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/re/re.iter/0000755000175000017500000000000012266757724016210 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.regiter/0000755000175000017500000000000012266757724020256 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.regiter/types.pass.cpp0000644000175000017500000000336412266757724023101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/0000755000175000017500000000000012266757724023454 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp0000644000175000017500000000265012266757724026261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp0000644000175000017500000000123312266757724026550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.iter/re.regiter/re.regiter.incr/0000755000175000017500000000000012266757724023256 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp0000644000175000017500000000660412266757724025722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/re/re.iter/re.regiter/re.regiter.deref/0000755000175000017500000000000012266757724023410 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp0000644000175000017500000000243612266757724026153 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/re/re.iter/re.regiter/re.regiter.comp/0000755000175000017500000000000012266757724023261 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp0000644000175000017500000000105612266757724030267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/re/re.iter/re.tokiter/0000755000175000017500000000000012266757724020276 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.tokiter/types.pass.cpp0000644000175000017500000000333412266757724023116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.iter/re.tokiter/re.tokiter.cnstr/0000755000175000017500000000000012266757724023514 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp0000644000175000017500000000425312266757724026307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp0000644000175000017500000000532612266757724025765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp0000644000175000017500000001060412266757724026470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp0000644000175000017500000000432612266757724026135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp0000644000175000017500000000125512266757724026614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/re/re.iter/re.tokiter/re.tokiter.comp/0000755000175000017500000000000012266757724023321 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp0000644000175000017500000000221112266757724026075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/re/re.iter/re.tokiter/re.tokiter.incr/0000755000175000017500000000000012266757724023316 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp0000644000175000017500000001202612266757724025755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/re/re.iter/re.tokiter/re.tokiter.deref/0000755000175000017500000000000012266757724023450 5ustar sylvestresylvestrelibcxx/test/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp0000644000175000017500000000477212266757724026220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/re/re.iter/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724022520 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/re.traits/0000755000175000017500000000000012266757725016554 5ustar sylvestresylvestrelibcxx/test/re/re.traits/imbue.pass.cpp0000644000175000017500000000142112266757725021324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/re/re.traits/translate_nocase.pass.cpp0000644000175000017500000000467412266757725023565 0ustar sylvestresylvestre// -*- 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; // XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_lib=x86_64-apple-darwin12 #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'); } } libcxx/test/re/re.traits/isctype.pass.cpp0000644000175000017500000003710212266757725021710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()))); } } libcxx/test/re/re.traits/types.pass.cpp0000644000175000017500000000232512266757725021373 0ustar sylvestresylvestre// -*- 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), ""); } libcxx/test/re/re.traits/translate.pass.cpp0000644000175000017500000000154512266757725022227 0ustar sylvestresylvestre// -*- 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'); } } libcxx/test/re/re.traits/value.pass.cpp0000644000175000017500000000717412266757725021352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } } libcxx/test/re/re.traits/length.pass.cpp0000644000175000017500000000174412266757725021514 0ustar sylvestresylvestre// -*- 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); } libcxx/test/re/re.traits/lookup_classname.pass.cpp0000644000175000017500000001762412266757725023576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, std::ctype_base::mask 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", 0); test("", 0); test("digits", 0); 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", 0); test(L"", 0); test(L"digits", 0); } libcxx/test/re/re.traits/transform.pass.cpp0000644000175000017500000000247012266757725022243 0ustar sylvestresylvestre// -*- 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; // template // string_type transform(ForwardIterator first, ForwardIterator last) const; #include #include #include "test_iterators.h" 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("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("cs_CZ.ISO8859-2")); assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1))); } } libcxx/test/re/re.traits/getloc.pass.cpp0000644000175000017500000000173712266757725021512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/re/re.traits/transform_primary.pass.cpp0000644000175000017500000000277512266757725024016 0ustar sylvestresylvestre// -*- 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; // template // string_type // transform_primary(ForwardIterator first, ForwardIterator last) const; #include #include #include "test_iterators.h" 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("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("cs_CZ.ISO8859-2")); assert(t.transform_primary(F(A), F(A+1)) == t.transform_primary(F(Aacute), F(Aacute+1))); } } libcxx/test/re/re.traits/default.pass.cpp0000644000175000017500000000174312266757725021656 0ustar sylvestresylvestre// -*- 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); } } libcxx/test/re/re.traits/lookup_collatename.pass.cpp0000644000175000017500000001545612266757725024115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 // string_type // lookup_collatename(ForwardIterator first, ForwardIterator last) const; #include #include #include #include "test_iterators.h" 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("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("cs_CZ.ISO8859-2")); test(L"ch", std::wstring(L"ch")); std::locale::global(std::locale("C")); } libcxx/test/re/re.regex/0000755000175000017500000000000012266757725016360 5ustar sylvestresylvestrelibcxx/test/re/re.regex/types.pass.cpp0000644000175000017500000000261612266757725021202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/re/re.regex/re.regex.nonmemb/0000755000175000017500000000000012266757725021531 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/re.regex/re.regex.nonmemb/re.regex.nmswap/0000755000175000017500000000000012266757725024554 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp0000644000175000017500000000153712266757725027205 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/0000755000175000017500000000000012266757725022122 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.construct/il_flg.pass.cpp0000644000175000017500000000643712266757725025041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/re/re.regex/re.regex.construct/ptr.pass.cpp0000644000175000017500000000151212266757725024377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp0000644000175000017500000000234312266757725025563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/awk_oct.pass.cpp0000644000175000017500000000156512266757725025231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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})); } libcxx/test/re/re.regex/re.regex.construct/string_flg.pass.cpp0000644000175000017500000000504212266757725025732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/string.pass.cpp0000644000175000017500000000172012266757725025101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/bad_escape.pass.cpp0000644000175000017500000000230412266757725025640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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")); } libcxx/test/re/re.regex/re.regex.construct/default.pass.cpp0000644000175000017500000000126512266757725025223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/re/re.regex/re.regex.construct/copy.pass.cpp0000644000175000017500000000125212266757725024545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp0000644000175000017500000000546512266757725026423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp0000644000175000017500000000420612266757725025232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp0000644000175000017500000000433512266757725026267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.operations/0000755000175000017500000000000012266757725022261 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757725027272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/re/re.regex/re.regex.assign/0000755000175000017500000000000012266757725021362 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp0000644000175000017500000000132512266757725027230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.assign/ptr.pass.cpp0000644000175000017500000000124212266757725023637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp0000644000175000017500000000172312266757725026701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp0000644000175000017500000000152512266757725026200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.assign/assign.pass.cpp0000644000175000017500000000130312266757725024314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.assign/assign.il.pass.cpp0000644000175000017500000000203112266757725024716 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/re/re.regex/re.regex.assign/string.pass.cpp0000644000175000017500000000134712266757725024346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.assign/copy.pass.cpp0000644000175000017500000000127512266757725024012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.assign/il.pass.cpp0000644000175000017500000000146112266757725023441 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp0000644000175000017500000000261512266757725027362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.swap/0000755000175000017500000000000012266757725021050 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.swap/swap.pass.cpp0000644000175000017500000000140212266757725023470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } libcxx/test/re/re.regex/re.regex.locale/0000755000175000017500000000000012266757725021335 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.locale/imbue.pass.cpp0000644000175000017500000000160512266757725024111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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"); } libcxx/test/re/re.regex/re.regex.const/0000755000175000017500000000000012266757725021224 5ustar sylvestresylvestrelibcxx/test/re/re.regex/re.regex.const/constants.pass.cpp0000644000175000017500000000502312266757725024711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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(); } libcxx/test/re/re.badexp/0000755000175000017500000000000012266757724016510 5ustar sylvestresylvestrelibcxx/test/re/re.badexp/regex_error.pass.cpp0000644000175000017500000000764012266757724022513 0ustar sylvestresylvestre// -*- 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.")); } } libcxx/test/lit.site.cfg.in0000644000175000017500000000076312266757723017060 0ustar sylvestresylvestre@AUTO_GEN_COMMENT@ config.cxx_under_test = "@LIBCXX_COMPILER@" config.cxx_has_stdcxx0x_flag = @LIBCXX_HAS_STDCXX0X_FLAG@ config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@" config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@" config.python_executable = "@PYTHON_EXECUTABLE@" config.enable_shared = @LIBCXX_ENABLE_SHARED@ config.cxx_abi = "@LIBCXX_CXX_ABI@" # Let the main config do the real work. lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg") libcxx/test/containers/0000755000175000017500000000000012266757724016377 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/0000755000175000017500000000000012266757724022175 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724026505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.adaptors/stack/0000755000175000017500000000000012266757724023302 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/stack/stack.cons/0000755000175000017500000000000012266757724025350 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp0000644000175000017500000000135412266757724031677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp0000644000175000017500000000155712266757724032224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000136012266757724033240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp0000644000175000017500000000144312266757724032034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } } libcxx/test/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp0000644000175000017500000000164112266757724031020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp0000644000175000017500000000135312266757724032354 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp0000644000175000017500000000120512266757724031674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp0000644000175000017500000000124012266757724031017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp0000644000175000017500000000123612266757724031476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/version.pass.cpp0000644000175000017500000000072512266757724026444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/container.adaptors/stack/stack.special/0000755000175000017500000000000012266757724026026 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/stack/stack.special/swap.pass.cpp0000644000175000017500000000156212266757724030455 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp0000644000175000017500000000134312266757724032357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.cons.alloc/0000755000175000017500000000000012266757724026441 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp0000644000175000017500000000231212266757724032231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp0000644000175000017500000000251412266757724033267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp0000644000175000017500000000315312266757724034461 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp0000644000175000017500000000324112266757724033621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp0000644000175000017500000000273612266757724034305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } } libcxx/test/containers/container.adaptors/stack/stack.defn/0000755000175000017500000000000012266757724025322 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp0000644000175000017500000000166412266757724031314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.defn/types.pass.cpp0000644000175000017500000000371512266757724030145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp0000644000175000017500000000125312266757724031312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp0000644000175000017500000000153512266757724030465 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/stack/stack.defn/size.pass.cpp0000644000175000017500000000103512266757724027744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.defn/swap.pass.cpp0000644000175000017500000000144212266757724027746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.defn/top.pass.cpp0000644000175000017500000000110512266757724027572 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp0000644000175000017500000000140312266757724030377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp0000644000175000017500000000117712266757724031011 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.defn/pop.pass.cpp0000644000175000017500000000136512266757724027576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.defn/push.pass.cpp0000644000175000017500000000125412266757724027754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/stack/stack.defn/empty.pass.cpp0000644000175000017500000000106612266757724030134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/containers/container.adaptors/stack/stack.ops/0000755000175000017500000000000012266757724025207 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/stack/stack.ops/lt.pass.cpp0000644000175000017500000000227612266757724027306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/stack/stack.ops/eq.pass.cpp0000644000175000017500000000200212266757724027257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/queue/0000755000175000017500000000000012266757724023321 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/queue/queue.special/0000755000175000017500000000000012266757724026064 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/queue/queue.special/swap.pass.cpp0000644000175000017500000000156212266757724030513 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp0000644000175000017500000000134312266757724032415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/version.pass.cpp0000644000175000017500000000072512266757724026463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/0000755000175000017500000000000012266757724026477 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp0000644000175000017500000000231212266757724032267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp0000644000175000017500000000315312266757724034517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp0000644000175000017500000000250712266757724033501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp0000644000175000017500000000324112266757724033657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp0000644000175000017500000000272112266757724034335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } } libcxx/test/containers/container.adaptors/queue/queue.ops/0000755000175000017500000000000012266757724025245 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/queue/queue.ops/lt.pass.cpp0000644000175000017500000000227612266757724027344 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/queue/queue.ops/eq.pass.cpp0000644000175000017500000000200212266757724027315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/queue/queue.cons/0000755000175000017500000000000012266757724025406 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp0000644000175000017500000000135412266757724031735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp0000644000175000017500000000155712266757724032262 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000136012266757724033276 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp0000644000175000017500000000142612266757724032073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } } libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp0000644000175000017500000000164112266757724031056 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp0000644000175000017500000000135312266757724032412 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp0000644000175000017500000000120512266757724031732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp0000644000175000017500000000124012266757724031055 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp0000644000175000017500000000125112266757724031531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/0000755000175000017500000000000012266757724025360 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp0000644000175000017500000000166412266757724031352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.defn/types.pass.cpp0000644000175000017500000000367312266757724030206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp0000644000175000017500000000125312266757724031350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp0000644000175000017500000000120112266757724031131 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp0000644000175000017500000000172212266757724030521 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/queue/queue.defn/size.pass.cpp0000644000175000017500000000103512266757724030002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/swap.pass.cpp0000644000175000017500000000144212266757724030004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/back.pass.cpp0000644000175000017500000000110712266757724027730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp0000644000175000017500000000146212266757724030442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp0000644000175000017500000000120312266757724031363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/pop.pass.cpp0000644000175000017500000000151412266757724027630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/front.pass.cpp0000644000175000017500000000111112266757724030153 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/push.pass.cpp0000644000175000017500000000140312266757724030006 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/queue/queue.defn/empty.pass.cpp0000644000175000017500000000106612266757724030172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/containers/container.adaptors/priority.queue/0000755000175000017500000000000012266757724025201 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/0000755000175000017500000000000012266757724030001 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpplibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass0000644000175000017500000000145712266757724035756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp0000644000175000017500000000177412266757724033775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp0000644000175000017500000000156512266757724033777 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp0000644000175000017500000000151312266757724034325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000151112266757724035667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp0000644000175000017500000000126612266757724034474 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp0000644000175000017500000000172212266757724035665 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpplibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pas0000644000175000017500000000176712266757724035761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp0000644000175000017500000000141612266757724035507 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp0000644000175000017500000000175212266757724033454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp0000644000175000017500000000150412266757724035003 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp0000644000175000017500000000145512266757724035506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp0000644000175000017500000000122712266757724034331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp0000644000175000017500000000131612266757724033440 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp0000644000175000017500000000154312266757724033456 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp0000644000175000017500000000123612266757724034127 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.special/0000755000175000017500000000000012266757724030457 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp0000644000175000017500000000147012266757724033104 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp0000644000175000017500000000145712266757724035016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/types.pass.cpp0000644000175000017500000000422112266757724030015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/0000755000175000017500000000000012266757724031072 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpplibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cp0000644000175000017500000000410012266757724035525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp0000644000175000017500000000311612266757724034665 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpplibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cp0000644000175000017500000000314712266757724035527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpplibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.p0000644000175000017500000000354012266757724035621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpplibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cp0000644000175000017500000000326212266757724035541 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpplibcxx/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pa0000644000175000017500000000356212266757724035604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/0000755000175000017500000000000012266757724030471 5ustar sylvestresylvestrelibcxx/test/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp0000644000175000017500000000114412266757724033114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp0000644000175000017500000000125712266757724033121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp0000644000175000017500000000116712266757724032751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp0000644000175000017500000000153712266757724033556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp0000644000175000017500000000133012266757724032735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp0000644000175000017500000000117212266757724033122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp0000644000175000017500000000135712266757724034505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp0000644000175000017500000000112512266757724033277 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/containers/container.requirements/0000755000175000017500000000000012266757724023103 5ustar sylvestresylvestrelibcxx/test/containers/container.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724027413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.requirements/associative.reqmts/0000755000175000017500000000000012266757724026727 5ustar sylvestresylvestrelibcxx/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/0000755000175000017500000000000012266757724034042 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpplibcxx/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_t0000644000175000017500000000056412266757724035763 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724033237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.requirements/container.requirements.dataraces/0000755000175000017500000000000012266757724031535 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpplibcxx/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cp0000644000175000017500000000056412266757724035665 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.requirements/unord.req/0000755000175000017500000000000012266757724025020 5ustar sylvestresylvestrelibcxx/test/containers/container.requirements/unord.req/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724031330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.requirements/unord.req/unord.req.except/0000755000175000017500000000000012266757724030224 5ustar sylvestresylvestrelibcxx/test/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724034534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.requirements/sequence.reqmts/0000755000175000017500000000000012266757724026225 5ustar sylvestresylvestrelibcxx/test/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724032535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/container.requirements/container.requirements.general/0000755000175000017500000000000012266757724031223 5ustar sylvestresylvestrelibcxx/test/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724035533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/test_hash.h0000644000175000017500000000147612266757724020542 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/MoveOnly.h0000644000175000017500000000232412266757724020321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/Copyable.h0000644000175000017500000000067712266757724020320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724022707 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/NotConstructible.h0000644000175000017500000000160212266757724022050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/Emplaceable.h0000644000175000017500000000272412266757724020747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/test_compare.h0000644000175000017500000000177512266757724021247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/stack_allocator.h0000644000175000017500000000331612266757724021720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/0000755000175000017500000000000012266757724017526 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.set/0000755000175000017500000000000012266757724021447 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.set/unord.set.cnstr/0000755000175000017500000000000012266757724024520 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp0000644000175000017500000001307512266757724027273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp0000644000175000017500000000705712266757724032522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp0000644000175000017500000001610212266757724030503 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp0000644000175000017500000001170012266757724030310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp0000644000175000017500000000505212266757724030150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp0000644000175000017500000000305512266757724027113 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp0000644000175000017500000001226612266757724030516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp0000644000175000017500000001422212266757724027140 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp0000644000175000017500000000364712266757724031056 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp0000644000175000017500000000462712266757724027154 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp0000644000175000017500000000404712266757724032415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp0000644000175000017500000000530012266757724031333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp0000644000175000017500000000676512266757724030333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp0000644000175000017500000000547412266757724033407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp0000644000175000017500000000650212266757724031174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp0000644000175000017500000000604012266757724030500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp0000644000175000017500000000667612266757724032377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp0000644000175000017500000001247312266757724027143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp0000644000175000017500000000403412266757724031523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp0000644000175000017500000000344412266757724031053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp0000644000175000017500000000666312266757724031335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp0000644000175000017500000000724612266757724034562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp0000644000175000017500000000457512266757724027630 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } #endif } libcxx/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp0000644000175000017500000001151612266757724027147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp0000644000175000017500000000646412266757724030331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp0000644000175000017500000000704012266757724034421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp0000644000175000017500000000630712266757724030174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp0000644000175000017500000000761312266757724030160 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/erase_range.pass.cpp0000644000175000017500000000460612266757724025401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/version.pass.cpp0000644000175000017500000000074512266757724024613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/unord/unord.set/equal_range_const.pass.cpp0000644000175000017500000000427312266757724026617 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/bucket_count.pass.cpp0000644000175000017500000000360412266757724025610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/erase_iter_db1.pass.cpp0000644000175000017500000000141212266757724025766 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp0000644000175000017500000000163112266757724027015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/types.pass.cpp0000644000175000017500000000721012266757724024264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } #endif } libcxx/test/containers/unord/unord.set/max_bucket_count.pass.cpp0000644000175000017500000000177012266757724026457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/local_iterators.pass.cpp0000644000175000017500000002265512266757724026320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/iterators.pass.cpp0000644000175000017500000000671112266757724025141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp0000644000175000017500000000700312266757724027024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/erase_const_iter.pass.cpp0000644000175000017500000000323112266757724026447 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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 } libcxx/test/containers/unord/unord.set/reserve.pass.cpp0000644000175000017500000000413412266757724024575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/db_iterators_7.pass.cpp0000644000175000017500000000206212266757724026027 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/swap_member.pass.cpp0000644000175000017500000004647312266757724025437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp0000644000175000017500000000201512266757724027200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp0000644000175000017500000000434212266757724030227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/rehash.pass.cpp0000644000175000017500000000412512266757724024374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/insert_range.pass.cpp0000644000175000017500000000346212266757724025605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/emplace.pass.cpp0000644000175000017500000000374012266757724024532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/erase_key.pass.cpp0000644000175000017500000000670012266757724025072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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); } #endif } libcxx/test/containers/unord/unord.set/count.pass.cpp0000644000175000017500000000317012266757724024251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/find_const.pass.cpp0000644000175000017500000000313212266757724025245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/bucket_size.pass.cpp0000644000175000017500000000374012266757724025433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/max_size.pass.cpp0000644000175000017500000000165212266757724024743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/insert_init.pass.cpp0000644000175000017500000000363512266757724025456 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/erase_iter_db2.pass.cpp0000644000175000017500000000157012266757724025774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/bucket.pass.cpp0000644000175000017500000000345712266757724024406 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/db_iterators_8.pass.cpp0000644000175000017500000000177712266757724026044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/local_iterators.fail.cpp0000644000175000017500000001421512266757724026256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp0000644000175000017500000000163012266757724027013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/eq.pass.cpp0000644000175000017500000000731512266757724023533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp0000644000175000017500000000202312266757724027176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/unord.set.swap/0000755000175000017500000000000012266757724024341 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp0000644000175000017500000004653712266757724031204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp0000644000175000017500000000236512266757724027657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp0000644000175000017500000000364112266757724030675 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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_hash { typedef T value_type; some_hash() {} some_hash(const some_hash&); }; 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)), ""); } #endif } libcxx/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp0000644000175000017500000000403512266757724027204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/insert_rvalue.pass.cpp0000644000175000017500000000701112266757724026001 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/iterators.fail.cpp0000644000175000017500000000364112266757724025105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/containers/unord/unord.set/find_non_const.pass.cpp0000644000175000017500000000306612266757724026125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/clear.pass.cpp0000644000175000017500000000251312266757724024207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp0000644000175000017500000000152412266757724027020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.set/max_load_factor.pass.cpp0000644000175000017500000000347712266757724026255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/load_factor.pass.cpp0000644000175000017500000000364612266757724025406 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/emplace_hint.pass.cpp0000644000175000017500000000427412266757724025557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/equal_range_non_const.pass.cpp0000644000175000017500000000422112266757724027462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp0000644000175000017500000000163012266757724027015 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/next_prime.pass.cpp0000644000175000017500000000205412266757724023352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // <__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)); } } libcxx/test/containers/unord/unord.multimap/0000755000175000017500000000000012266757724022504 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.multimap/equal_range_const.pass.cpp0000644000175000017500000000604612266757724027654 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.multimap/bucket_count.pass.cpp0000644000175000017500000000255312266757724026647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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); } } libcxx/test/containers/unord/unord.multimap/unord.multimap.swap/0000755000175000017500000000000012266757724026433 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp0000644000175000017500000005466712266757724033301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp0000644000175000017500000000267312266757724031753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp0000644000175000017500000000404712266757724032770 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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_hash { typedef T value_type; some_hash() {} some_hash(const some_hash&); }; int main() { #if __has_feature(cxx_noexcept) { 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)), ""); } #endif } libcxx/test/containers/unord/unord.multimap/types.pass.cpp0000644000175000017500000000777112266757724025335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } #endif } libcxx/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp0000644000175000017500000000237712266757724027520 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/local_iterators.pass.cpp0000644000175000017500000003521412266757724027350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/iterators.pass.cpp0000644000175000017500000001007012266757724026167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/unord/unord.multimap/reserve.pass.cpp0000644000175000017500000000472712266757724025642 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp0000644000175000017500000000235412266757724027070 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/swap_member.pass.cpp0000644000175000017500000005464612266757724026475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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, "fourty"), 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 == "fourty"); 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 } libcxx/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp0000644000175000017500000000222512266757724030240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/0000755000175000017500000000000012266757724027442 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp0000644000175000017500000001335112266757724033371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp0000644000175000017500000000152112266757724033762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp0000644000175000017500000000175212266757724035014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp0000644000175000017500000001077312266757724035027 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp0000644000175000017500000000731612266757724034452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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 } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpplibcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.c0000644000175000017500000000522612266757724035664 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp0000644000175000017500000000757112266757724033605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp0000644000175000017500000000511012266757724032516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp0000644000175000017500000002770312266757724033073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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()); } #endif } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp0000644000175000017500000000774412266757724033456 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp0000644000175000017500000000171112266757724033764 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp0000644000175000017500000000175112266757724035012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp0000644000175000017500000000416012266757724035176 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp0000644000175000017500000000756012266757724034005 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp0000644000175000017500000000314012266757724032177 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp0000644000175000017500000000163312266757724035014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp0000644000175000017500000000745212266757724033553 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp0000644000175000017500000000175112266757724035014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/scary.pass.cpp0000644000175000017500000000127612266757724025304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/0000755000175000017500000000000012266757724026612 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp0000644000175000017500000002252312266757724031363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp0000644000175000017500000001277412266757724034616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp0000644000175000017500000002413112266757724032576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp0000644000175000017500000001755712266757724032422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp0000644000175000017500000000564312266757724032250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp0000644000175000017500000000541112266757724031203 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp0000644000175000017500000001531412266757724032605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp0000644000175000017500000002111612266757724031232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp0000644000175000017500000000406212266757724033140 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp0000644000175000017500000000540712266757724031243 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp0000644000175000017500000000426212266757724034506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp0000644000175000017500000000607112266757724033433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp0000644000175000017500000001136012266757724032410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp0000644000175000017500000000637512266757724035502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp0000644000175000017500000001232712266757724033270 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp0000644000175000017500000001175612266757724032604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp0000644000175000017500000001254412266757724034460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp0000644000175000017500000002206112266757724031227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp0000644000175000017500000000424212266757724033616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp0000644000175000017500000000365212266757724033146 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp0000644000175000017500000001260012266757724033413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpplibcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pas0000644000175000017500000001326112266757724035702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp0000644000175000017500000000536612266757724031721 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } #endif } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp0000644000175000017500000001512112266757724031235 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp0000644000175000017500000001240512266757724032413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpplibcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass0000644000175000017500000001300412266757724035727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp0000644000175000017500000001215512266757724032264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp0000644000175000017500000001046512266757724032251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/rehash.pass.cpp0000644000175000017500000000644012266757724025433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/count.pass.cpp0000644000175000017500000000375712266757724025321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.multimap/find_const.pass.cpp0000644000175000017500000000400312266757724026300 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.multimap/bucket_size.pass.cpp0000644000175000017500000000464312266757724026473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/max_size.pass.cpp0000644000175000017500000000173712266757724026004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/bucket.pass.cpp0000644000175000017500000000412612266757724025435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp0000644000175000017500000000232112266757724027063 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/local_iterators.fail.cpp0000644000175000017500000001704612266757724027320 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/containers/unord/unord.multimap/eq.pass.cpp0000644000175000017500000001232312266757724024563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, "fourty"), 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, "fourty"), 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, "fourty"), 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, "fourty"), 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp0000644000175000017500000000220312266757724030233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multimap/iterators.fail.cpp0000644000175000017500000000425012266757724026137 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/containers/unord/unord.multimap/find_non_const.pass.cpp0000644000175000017500000000373512266757724027165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.multimap/max_load_factor.pass.cpp0000644000175000017500000000410412266757724027276 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multimap/load_factor.pass.cpp0000644000175000017500000000446712266757724026445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp0000644000175000017500000000577412266757724030535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.multiset/0000755000175000017500000000000012266757724022522 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.multiset/erase_range.pass.cpp0000644000175000017500000000470112266757724026450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/0000755000175000017500000000000012266757724026646 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp0000644000175000017500000001313212266757724031413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp0000644000175000017500000000710312266757724034640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp0000644000175000017500000002152212266757724032633 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp0000644000175000017500000001507612266757724032450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp0000644000175000017500000000507612266757724032304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp0000644000175000017500000000465512266757724031250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp0000644000175000017500000001311312266757724032634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp0000644000175000017500000001430412266757724031267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp0000644000175000017500000000371212266757724033175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp0000644000175000017500000000465312266757724031301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp0000644000175000017500000000411212266757724034534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp0000644000175000017500000000532412266757724033467 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp0000644000175000017500000000741012266757724032445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp0000644000175000017500000000563012266757724035527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp0000644000175000017500000000652612266757724033330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp0000644000175000017500000000606412266757724032634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp0000644000175000017500000000672212266757724034515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp0000644000175000017500000001253112266757724031264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp0000644000175000017500000000407212266757724033653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp0000644000175000017500000000350212266757724033174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp0000644000175000017500000000670712266757724033462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpplibcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pas0000644000175000017500000000727212266757724035743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp0000644000175000017500000000462112266757724031746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } #endif } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp0000644000175000017500000001234312266757724031274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp0000644000175000017500000000651012266757724032447 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpplibcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass0000644000175000017500000000706412266757724035774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp0000644000175000017500000000633312266757724032321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp0000644000175000017500000000765112266757724032310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/equal_range_const.pass.cpp0000644000175000017500000000467412266757724027677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/bucket_count.pass.cpp0000644000175000017500000000375112266757724026666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp0000644000175000017500000000142412266757724027044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp0000644000175000017500000000165012266757724030071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/types.pass.cpp0000644000175000017500000000722712266757724025347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } #endif } libcxx/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp0000644000175000017500000000200712266757724027524 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/local_iterators.pass.cpp0000644000175000017500000002755212266757724027374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/iterators.pass.cpp0000644000175000017500000000650112266757724026211 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp0000644000175000017500000000712112266757724030100 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp0000644000175000017500000000342012266757724027522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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 } libcxx/test/containers/unord/unord.multiset/reserve.pass.cpp0000644000175000017500000000415312266757724025651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp0000644000175000017500000000207412266757724027105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/swap_member.pass.cpp0000644000175000017500000004660312266757724026505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp0000644000175000017500000000202712266757724030256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp0000644000175000017500000000443212266757724031302 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/scary.pass.cpp0000644000175000017500000000126412266757724025317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/containers/unord/unord.multiset/rehash.pass.cpp0000644000175000017500000000414412266757724025450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/insert_range.pass.cpp0000644000175000017500000000350112266757724026652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/emplace.pass.cpp0000644000175000017500000000337712266757724025613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/erase_key.pass.cpp0000644000175000017500000000676512266757724026160 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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); } #endif } libcxx/test/containers/unord/unord.multiset/count.pass.cpp0000644000175000017500000000325512266757724025330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/find_const.pass.cpp0000644000175000017500000000321712266757724026324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/bucket_size.pass.cpp0000644000175000017500000000426612266757724026512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/max_size.pass.cpp0000644000175000017500000000167112266757724026017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/insert_init.pass.cpp0000644000175000017500000000365412266757724026532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp0000644000175000017500000000160712266757724027050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/bucket.pass.cpp0000644000175000017500000000355112266757724025454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp0000644000175000017500000000201112266757724027075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/local_iterators.fail.cpp0000644000175000017500000001424612266757724027335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } } libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp0000644000175000017500000000164712266757724030076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/eq.pass.cpp0000644000175000017500000001030712266757724024601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp0000644000175000017500000000203512266757724030254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp0000644000175000017500000000337412266757724030264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp0000644000175000017500000000571612266757724027066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/iterators.fail.cpp0000644000175000017500000000366012266757724026161 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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()); } } libcxx/test/containers/unord/unord.multiset/find_non_const.pass.cpp0000644000175000017500000000315312266757724027175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/clear.pass.cpp0000644000175000017500000000260012266757724025257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp0000644000175000017500000000153612266757724030076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.multiset/max_load_factor.pass.cpp0000644000175000017500000000353112266757724027317 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.swap/0000755000175000017500000000000012266757724026467 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp0000644000175000017500000004665212266757724033330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp0000644000175000017500000000243512266757724032003 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp0000644000175000017500000000367712266757724033034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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_hash { typedef T value_type; some_hash() {} some_hash(const some_hash&); }; 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)), ""); } #endif } libcxx/test/containers/unord/unord.multiset/load_factor.pass.cpp0000644000175000017500000000367712266757724026465 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/emplace_hint.pass.cpp0000644000175000017500000000433412266757724026627 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp0000644000175000017500000000462212266757724030542 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp0000644000175000017500000000164712266757724030100 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/0000755000175000017500000000000012266757724021431 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.map/version.pass.cpp0000644000175000017500000000074512266757724024575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/unord/unord.map/equal_range_const.pass.cpp0000644000175000017500000000445112266757724026577 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/bucket_count.pass.cpp0000644000175000017500000000451012266757724025567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/types.pass.cpp0000644000175000017500000000775212266757724024261 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } #endif } libcxx/test/containers/unord/unord.map/max_bucket_count.pass.cpp0000644000175000017500000000236012266757724026435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/local_iterators.pass.cpp0000644000175000017500000002703712266757724026301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/iterators.pass.cpp0000644000175000017500000000756612266757724025134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/unord/unord.map/reserve.pass.cpp0000644000175000017500000000450312266757724024557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/db_iterators_7.pass.cpp0000644000175000017500000000234212266757724026012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/swap_member.pass.cpp0000644000175000017500000005203712266757724025412 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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 } libcxx/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp0000644000175000017500000000221312266757724027162 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/unord.map.elem/0000755000175000017500000000000012266757724024255 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp0000644000175000017500000000170612266757724030252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp0000644000175000017500000000636612266757724027050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp0000644000175000017500000000660012266757724026334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/rehash.pass.cpp0000644000175000017500000000447412266757724024365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/compare.pass.cpp0000644000175000017500000000221012266757724024523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } libcxx/test/containers/unord/unord.map/count.pass.cpp0000644000175000017500000000345012266757724024234 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/find_const.pass.cpp0000644000175000017500000000376412266757724025242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/bucket_size.pass.cpp0000644000175000017500000000436312266757724025417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/max_size.pass.cpp0000644000175000017500000000173012266757724024722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/0000755000175000017500000000000012266757724025643 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp0000644000175000017500000000543212266757724031573 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp0000644000175000017500000000150712266757724032167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp0000644000175000017500000000173312266757724033214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp0000644000175000017500000001076512266757724033231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp0000644000175000017500000000365312266757724032653 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp0000644000175000017500000000520212266757724034417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp0000644000175000017500000000404012266757724031772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp0000644000175000017500000000551112266757724030724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp0000644000175000017500000000736612266757724031277 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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); } #endif } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp0000644000175000017500000000421312266757724031643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp0000644000175000017500000000167212266757724032173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp0000644000175000017500000000173212266757724033212 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp0000644000175000017500000000470112266757724033400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp0000644000175000017500000001101312266757724032172 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp0000644000175000017500000000312112266757724030377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp0000644000175000017500000000162112266757724033212 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp0000644000175000017500000000636612266757724031757 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp0000644000175000017500000000173212266757724033214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/bucket.pass.cpp0000644000175000017500000000410212266757724024354 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/db_iterators_8.pass.cpp0000644000175000017500000000230712266757724026014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/unord.map.swap/0000755000175000017500000000000012266757724024305 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp0000644000175000017500000005206112266757724031135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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, "fourty"), 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) == "fourty"); 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 } libcxx/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp0000644000175000017500000000262312266757724027620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp0000644000175000017500000000401112266757724030631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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_hash { typedef T value_type; some_hash() {} some_hash(const some_hash&); }; int main() { #if __has_feature(cxx_noexcept) { 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)), ""); } #endif } libcxx/test/containers/unord/unord.map/eq.pass.cpp0000644000175000017500000001117712266757724023516 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, "fourty"), 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, "fourty"), 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, "fourty"), 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, "fourty"), 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp0000644000175000017500000000217112266757724027164 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/unord/unord.map/find_non_const.pass.cpp0000644000175000017500000000371612266757724026111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/max_load_factor.pass.cpp0000644000175000017500000000404612266757724026230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/load_factor.pass.cpp0000644000175000017500000000443612266757724025366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/equal_range_non_const.pass.cpp0000644000175000017500000000437712266757724027460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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, "fourty"), 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, "fourty"), 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/0000755000175000017500000000000012266757724024464 5ustar sylvestresylvestrelibcxx/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp0000644000175000017500000001416512266757724027240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp0000644000175000017500000000771612266757724032470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp0000644000175000017500000001734412266757724030460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp0000644000175000017500000001252012266757724030255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp0000644000175000017500000000561712266757724030123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp0000644000175000017500000000536512266757724027065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp0000644000175000017500000001311112266757724030450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp0000644000175000017500000001600212266757724027102 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp0000644000175000017500000000401712266757724031012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp0000644000175000017500000000536312266757724027116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp0000644000175000017500000000421712266757724032360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp0000644000175000017500000000604512266757724031306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp0000644000175000017500000000775112266757724030273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp0000644000175000017500000000635112266757724033346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp0000644000175000017500000000725112266757724031142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp0000644000175000017500000000651612266757724030454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp0000644000175000017500000000746612266757724032341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp0000644000175000017500000001372112266757724027104 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp0000644000175000017500000000420412266757724031466 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp0000644000175000017500000000361412266757724031016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp0000644000175000017500000000752212266757724031274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp0000644000175000017500000001020312266757724034511 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp0000644000175000017500000000534312266757724027566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } #endif } libcxx/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp0000644000175000017500000001271612266757724027116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp0000644000175000017500000000732712266757724030274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp0000644000175000017500000000772612266757724034400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp0000644000175000017500000000707712266757724030145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp0000644000175000017500000001042612266757724030120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 } libcxx/test/containers/associative/0000755000175000017500000000000012266757724020711 5ustar sylvestresylvestrelibcxx/test/containers/associative/multimap/0000755000175000017500000000000012266757724022541 5ustar sylvestresylvestrelibcxx/test/containers/associative/multimap/types.pass.cpp0000644000175000017500000001101012266757724025347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() { { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::mapped_type, double>::value), ""); static_assert((std::is_same::value_type, std::pair >::value), ""); static_assert((std::is_same::key_compare, std::less >::value), ""); static_assert((std::is_same::allocator_type, std::allocator > >::value), ""); static_assert((std::is_same::reference, std::pair&>::value), ""); static_assert((std::is_same::const_reference, const std::pair&>::value), ""); static_assert((std::is_same::pointer, std::pair*>::value), ""); static_assert((std::is_same::const_pointer, const std::pair*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); } #if __cplusplus >= 201103L { static_assert((std::is_same, min_allocator>>::key_type, int>::value), ""); static_assert((std::is_same, min_allocator>>::mapped_type, double>::value), ""); static_assert((std::is_same, min_allocator>>::value_type, std::pair >::value), ""); static_assert((std::is_same, min_allocator>>::key_compare, std::less >::value), ""); static_assert((std::is_same, min_allocator>>::allocator_type, min_allocator > >::value), ""); static_assert((std::is_same, min_allocator>>::reference, std::pair&>::value), ""); static_assert((std::is_same, min_allocator>>::const_reference, const std::pair&>::value), ""); static_assert((std::is_same, min_allocator>>::pointer, min_pointer>>::value), ""); static_assert((std::is_same, min_allocator>>::const_pointer, min_pointer>>::value), ""); static_assert((std::is_same, min_allocator>>::size_type, std::size_t>::value), ""); static_assert((std::is_same, min_allocator>>::difference_type, std::ptrdiff_t>::value), ""); } #endif } libcxx/test/containers/associative/multimap/size.pass.cpp0000644000175000017500000000266112266757724025171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/0000755000175000017500000000000012266757724025332 5ustar sylvestresylvestrelibcxx/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp0000644000175000017500000001156612266757724031134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } #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 } libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp0000644000175000017500000000504712266757724033167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp0000644000175000017500000000417412266757724033733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp0000644000175000017500000000416412266757724032366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp0000644000175000017500000000230612266757724031604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/move.pass.cpp0000644000175000017500000001027212266757724027753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp0000644000175000017500000000272712266757724031666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000305612266757724033226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp0000644000175000017500000000351012266757724031126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp0000644000175000017500000000603312266757724030773 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/compare.pass.cpp0000644000175000017500000000176012266757724030435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp0000644000175000017500000000657212266757724035253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp0000644000175000017500000000454512266757724032017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp0000644000175000017500000000204512266757724030076 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp0000644000175000017500000000301512266757724032333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp0000644000175000017500000000247512266757724031670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp0000644000175000017500000000455612266757724034101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/default.pass.cpp0000644000175000017500000000141512266757724030430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } #endif } libcxx/test/containers/associative/multimap/multimap.cons/copy.pass.cpp0000644000175000017500000000535512266757724027765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp0000644000175000017500000001166412266757724031325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp0000644000175000017500000000552312266757724031326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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 } libcxx/test/containers/associative/multimap/iterator.pass.cpp0000644000175000017500000001443012266757724026045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/associative/multimap/scary.pass.cpp0000644000175000017500000000115612266757724025336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/containers/associative/multimap/max_size.pass.cpp0000644000175000017500000000141312266757724026030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/0000755000175000017500000000000012266757724026351 5ustar sylvestresylvestrelibcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp0000644000175000017500000000640312266757724033377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp0000644000175000017500000000455612266757724033072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp0000644000175000017500000000441312266757724032037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp0000644000175000017500000001330512266757724031432 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp0000644000175000017500000001162312266757724031774 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(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(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 } libcxx/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp0000644000175000017500000000443212266757724033044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp0000644000175000017500000000424712266757724032025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp0000644000175000017500000000434412266757724034771 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp0000644000175000017500000000270712266757724031116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp0000644000175000017500000001275012266757724033174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp0000644000175000017500000001432512266757724032457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp0000644000175000017500000002444212266757724032152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/associative/multimap/multimap.ops/0000755000175000017500000000000012266757724025171 5ustar sylvestresylvestrelibcxx/test/containers/associative/multimap/multimap.ops/find.pass.cpp0000644000175000017500000001225712266757724027571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } { 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 } libcxx/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp0000644000175000017500000002011412266757724031123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } { 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 } libcxx/test/containers/associative/multimap/multimap.ops/count.pass.cpp0000644000175000017500000000403712266757724027776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp0000644000175000017500000001356312266757724031174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } { 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 } libcxx/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp0000644000175000017500000001347512266757724031173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } { 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 } libcxx/test/containers/associative/multimap/multimap.special/0000755000175000017500000000000012266757724026010 5ustar sylvestresylvestrelibcxx/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp0000644000175000017500000001037312266757724031766 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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 } libcxx/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp0000644000175000017500000000307112266757724032341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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)), ""); } #endif } libcxx/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp0000644000175000017500000001615612266757724032645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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 } libcxx/test/containers/associative/multimap/empty.pass.cpp0000644000175000017500000000167112266757724025355 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/tree_remove.pass.cpp0000644000175000017500000011504712266757724024706 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/containers/associative/map/0000755000175000017500000000000012266757724021466 5ustar sylvestresylvestrelibcxx/test/containers/associative/map/version.pass.cpp0000644000175000017500000000072112266757724024624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/associative/map/types.pass.cpp0000644000175000017500000001062512266757724024307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() { { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::mapped_type, double>::value), ""); static_assert((std::is_same::value_type, std::pair >::value), ""); static_assert((std::is_same::key_compare, std::less >::value), ""); static_assert((std::is_same::allocator_type, std::allocator > >::value), ""); static_assert((std::is_same::reference, std::pair&>::value), ""); static_assert((std::is_same::const_reference, const std::pair&>::value), ""); static_assert((std::is_same::pointer, std::pair*>::value), ""); static_assert((std::is_same::const_pointer, const std::pair*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); } #if __cplusplus >= 201103L { static_assert((std::is_same, min_allocator>>::key_type, int>::value), ""); static_assert((std::is_same, min_allocator>>::mapped_type, double>::value), ""); static_assert((std::is_same, min_allocator>>::value_type, std::pair >::value), ""); static_assert((std::is_same, min_allocator>>::key_compare, std::less >::value), ""); static_assert((std::is_same, min_allocator>>::allocator_type, min_allocator > >::value), ""); static_assert((std::is_same, min_allocator>>::reference, std::pair&>::value), ""); static_assert((std::is_same, min_allocator>>::const_reference, const std::pair&>::value), ""); static_assert((std::is_same, min_allocator>>::pointer, min_pointer>>::value), ""); static_assert((std::is_same, min_allocator>>::const_pointer, min_pointer>>::value), ""); static_assert((std::is_same, min_allocator>>::size_type, std::size_t>::value), ""); static_assert((std::is_same, min_allocator>>::difference_type, std::ptrdiff_t>::value), ""); } #endif } libcxx/test/containers/associative/map/map.modifiers/0000755000175000017500000000000012266757724024223 5ustar sylvestresylvestrelibcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp0000644000175000017500000000413412266757724031250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp0000644000175000017500000000452712266757724030742 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp0000644000175000017500000000521412266757724027711 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp0000644000175000017500000001435312266757724027310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp0000644000175000017500000002266012266757724027651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp0000644000175000017500000000437112266757724030720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp0000644000175000017500000000505012266757724027670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp0000644000175000017500000000401612266757724032637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp0000644000175000017500000000267012266757724026767 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp0000644000175000017500000001273112266757724031045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp0000644000175000017500000001422412266757724030327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp0000644000175000017500000002045512266757724030024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/associative/map/compare.pass.cpp0000644000175000017500000000166712266757724024577 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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)); } libcxx/test/containers/associative/map/map.cons/0000755000175000017500000000000012266757724023204 5ustar sylvestresylvestrelibcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp0000644000175000017500000001152312266757724026777 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } #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 } libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp0000644000175000017500000000526412266757724031042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp0000644000175000017500000000440712266757724031604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp0000644000175000017500000000404012266757724030231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp0000644000175000017500000000226212266757724027457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/move.pass.cpp0000644000175000017500000000706712266757724025635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/move_noexcept.pass.cpp0000644000175000017500000000267112266757724027536 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000302012266757724031067 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp0000644000175000017500000000501712266757724027004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp0000644000175000017500000000077012266757724030374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #if !__has_feature(cxx_noexcept) struct X { std::map m; }; #endif int main() { } libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp0000644000175000017500000000314412266757724026645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/compare.pass.cpp0000644000175000017500000000173412266757724026310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp0000644000175000017500000000617612266757724033125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp0000644000175000017500000000350012266757724027657 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp0000644000175000017500000000202112266757724025742 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/default_noexcept.pass.cpp0000644000175000017500000000276412266757724030217 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp0000644000175000017500000000244412266757724027536 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp0000644000175000017500000000434212266757724031744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/default.pass.cpp0000644000175000017500000000137112266757724026303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } #endif } libcxx/test/containers/associative/map/map.cons/copy.pass.cpp0000644000175000017500000000761312266757724025636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp0000644000175000017500000001162112266757724027170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp0000644000175000017500000001216512266757724027200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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 } libcxx/test/containers/associative/map/map.special/0000755000175000017500000000000012266757724023662 5ustar sylvestresylvestrelibcxx/test/containers/associative/map/map.special/member_swap.pass.cpp0000644000175000017500000001037012266757724027635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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::pair V; typedef std::map, min_allocator> M; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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 } libcxx/test/containers/associative/map/map.special/swap_noexcept.pass.cpp0000644000175000017500000000304012266757724030207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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)), ""); } #endif } libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp0000644000175000017500000001612712266757724030515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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::pair V; typedef std::map, min_allocator> M; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { V(1, 1), V(2, 2), V(3, 3), V(4, 4) }; V ar2[] = { }; 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); } { 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 } libcxx/test/containers/associative/map/map.ops/0000755000175000017500000000000012266757724023043 5ustar sylvestresylvestrelibcxx/test/containers/associative/map/map.ops/find.pass.cpp0000644000175000017500000001367012266757724025443 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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)); } { 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 } libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp0000644000175000017500000003612312266757724027004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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)); } { 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 } libcxx/test/containers/associative/map/map.ops/count.pass.cpp0000644000175000017500000000430712266757724025650 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp0000644000175000017500000002322512266757724027042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp0000644000175000017500000002311712266757724027037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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)); } { 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 } libcxx/test/containers/associative/map/map.access/0000755000175000017500000000000012266757724023503 5ustar sylvestresylvestrelibcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp0000644000175000017500000000257312266757724027651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.access/index_tuple.pass.cpp0000644000175000017500000000126512266757724027500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.access/size.pass.cpp0000644000175000017500000000264212266757724026132 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.access/iterator.pass.cpp0000644000175000017500000001375012266757724027013 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/associative/map/map.access/max_size.pass.cpp0000644000175000017500000000137412266757724027000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.access/at.pass.cpp0000644000175000017500000000727012266757724025566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.access/index_key.pass.cpp0000644000175000017500000000440512266757724027136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/map/map.access/empty.pass.cpp0000644000175000017500000000165212266757724026316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/tree_left_rotate.pass.cpp0000644000175000017500000000410012266757724025704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/containers/associative/set/0000755000175000017500000000000012266757724021504 5ustar sylvestresylvestrelibcxx/test/containers/associative/set/version.pass.cpp0000644000175000017500000000072112266757724024642 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/associative/set/insert_iter_iter.pass.cpp0000644000175000017500000000323312266757724026530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/find.pass.cpp0000644000175000017500000001314412266757724024100 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/equal_range.pass.cpp0000644000175000017500000003060512266757724025444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/0000755000175000017500000000000012266757724023240 5ustar sylvestresylvestrelibcxx/test/containers/associative/set/set.cons/move_alloc.pass.cpp0000644000175000017500000000651612266757724027041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp0000644000175000017500000000264712266757724031644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/initializer_list.pass.cpp0000644000175000017500000000264312266757724030274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/compare_alloc.pass.cpp0000644000175000017500000000144512266757724027515 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/associative/set/set.cons/move.pass.cpp0000644000175000017500000000555512266757724025671 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/move_noexcept.pass.cpp0000644000175000017500000000262112266757724027565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000275012266757724031134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/set/set.cons/copy_alloc.pass.cpp0000644000175000017500000000254512266757724027043 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/associative/set/set.cons/iter_iter.pass.cpp0000644000175000017500000000302712266757724026701 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/compare.pass.cpp0000644000175000017500000000124612266757724026342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp0000644000175000017500000000344512266757724033155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/iter_iter_comp.pass.cpp0000644000175000017500000000216612266757724027722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/associative/set/set.cons/alloc.pass.cpp0000644000175000017500000000126012266757724026002 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/associative/set/set.cons/default_noexcept.pass.cpp0000644000175000017500000000271412266757724030246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/set/set.cons/dtor_noexcept.pass.cpp0000644000175000017500000000237412266757724027574 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/set/set.cons/initializer_list_compare.pass.cpp0000644000175000017500000000211312266757724031772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/default.pass.cpp0000644000175000017500000000132012266757724026331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } #endif } libcxx/test/containers/associative/set/set.cons/copy.pass.cpp0000644000175000017500000000475312266757724025674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/move_assign.pass.cpp0000644000175000017500000001053112266757724027223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.cons/copy_assign.pass.cpp0000644000175000017500000000503012266757724027225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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); } } libcxx/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp0000644000175000017500000000370712266757724030060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/types.pass.cpp0000644000175000017500000000724212266757724024326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() { { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::value_type, int>::value), ""); static_assert((std::is_same::key_compare, std::less >::value), ""); static_assert((std::is_same::value_compare, std::less >::value), ""); static_assert((std::is_same::allocator_type, std::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, int*>::value), ""); static_assert((std::is_same::const_pointer, const int*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); } #if __cplusplus >= 201103L { static_assert((std::is_same, min_allocator>::key_type, int>::value), ""); static_assert((std::is_same, min_allocator>::value_type, int>::value), ""); static_assert((std::is_same, min_allocator>::key_compare, std::less >::value), ""); static_assert((std::is_same, min_allocator>::value_compare, std::less >::value), ""); static_assert((std::is_same, min_allocator>::allocator_type, min_allocator >::value), ""); static_assert((std::is_same, min_allocator>::reference, int&>::value), ""); static_assert((std::is_same, min_allocator>::const_reference, const int&>::value), ""); static_assert((std::is_same, min_allocator>::pointer, min_pointer>::value), ""); static_assert((std::is_same, min_allocator>::const_pointer, min_pointer>::value), ""); static_assert((std::is_same, min_allocator>::size_type, std::size_t>::value), ""); static_assert((std::is_same, min_allocator>::difference_type, std::ptrdiff_t>::value), ""); } #endif } libcxx/test/containers/associative/set/insert_iter_rv.pass.cpp0000644000175000017500000000376012266757724026221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/size.pass.cpp0000644000175000017500000000253312266757724024132 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/set.special/0000755000175000017500000000000012266757724023716 5ustar sylvestresylvestrelibcxx/test/containers/associative/set/set.special/member_swap.pass.cpp0000644000175000017500000000761412266757724027700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { 1, 2, 3, 4 }; V ar2[] = { }; 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); } { 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { 1, 2, 3, 4 }; V ar2[] = { }; 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); } { 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 } libcxx/test/containers/associative/set/set.special/swap_noexcept.pass.cpp0000644000175000017500000000277012266757724030254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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)), ""); } #endif } libcxx/test/containers/associative/set/set.special/non_member_swap.pass.cpp0000644000175000017500000000743012266757724030546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { 1, 2, 3, 4 }; V ar2[] = { }; 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); } { 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)); } } libcxx/test/containers/associative/set/iterator.pass.cpp0000644000175000017500000001147012266757724025011 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/associative/set/insert_rv.pass.cpp0000644000175000017500000000434712266757724025200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/emplace.pass.cpp0000644000175000017500000000477012266757724024573 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/erase_key.pass.cpp0000644000175000017500000001311312266757724025123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/count.pass.cpp0000644000175000017500000000403112266757724024303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/associative/set/max_size.pass.cpp0000644000175000017500000000132312266757724024773 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/insert_iter_cv.pass.cpp0000644000175000017500000000356012266757724026200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/insert_cv.pass.cpp0000644000175000017500000000414712266757724025157 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/insert_initializer_list.pass.cpp0000644000175000017500000000305012266757724030115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/upper_bound.pass.cpp0000644000175000017500000002250412266757724025502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/clear.pass.cpp0000644000175000017500000000234712266757724024251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/lower_bound.pass.cpp0000644000175000017500000002237512266757724025505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/erase_iter_iter.pass.cpp0000644000175000017500000001034612266757724026326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/emplace_hint.pass.cpp0000644000175000017500000000446312266757724025614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/empty.pass.cpp0000644000175000017500000000156712266757724024324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/set/erase_iter.pass.cpp0000644000175000017500000001245012266757724025301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/associative/tree_balance_after_insert.pass.cpp0000644000175000017500000011000712266757724027532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/containers/associative/tree_right_rotate.pass.cpp0000644000175000017500000000410212266757724026071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/containers/associative/multiset/0000755000175000017500000000000012266757724022557 5ustar sylvestresylvestrelibcxx/test/containers/associative/multiset/insert_iter_iter.pass.cpp0000644000175000017500000000427212266757724027607 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/find.pass.cpp0000644000175000017500000001423512266757724025155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/equal_range.pass.cpp0000644000175000017500000001735012266757724026521 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/types.pass.cpp0000644000175000017500000000742412266757724025403 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() { { static_assert((std::is_same::key_type, int>::value), ""); static_assert((std::is_same::value_type, int>::value), ""); static_assert((std::is_same::key_compare, std::less >::value), ""); static_assert((std::is_same::value_compare, std::less >::value), ""); static_assert((std::is_same::allocator_type, std::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, int*>::value), ""); static_assert((std::is_same::const_pointer, const int*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); } #if __cplusplus >= 201103L { static_assert((std::is_same, min_allocator>::key_type, int>::value), ""); static_assert((std::is_same, min_allocator>::value_type, int>::value), ""); static_assert((std::is_same, min_allocator>::key_compare, std::less >::value), ""); static_assert((std::is_same, min_allocator>::value_compare, std::less >::value), ""); static_assert((std::is_same, min_allocator>::allocator_type, min_allocator>::value), ""); static_assert((std::is_same, min_allocator>::reference, int&>::value), ""); static_assert((std::is_same, min_allocator>::const_reference, const int&>::value), ""); static_assert((std::is_same, min_allocator>::pointer, min_pointer>::value), ""); static_assert((std::is_same, min_allocator>::const_pointer, min_pointer>::value), ""); static_assert((std::is_same, min_allocator>::size_type, std::size_t>::value), ""); static_assert((std::is_same, min_allocator>::difference_type, std::ptrdiff_t>::value), ""); } #endif } libcxx/test/containers/associative/multiset/insert_iter_rv.pass.cpp0000644000175000017500000000377712266757724027304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/size.pass.cpp0000644000175000017500000000255212266757724025206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/iterator.pass.cpp0000644000175000017500000001201012266757724026053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/associative/multiset/insert_rv.pass.cpp0000644000175000017500000000362612266757724026252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/0000755000175000017500000000000012266757724025366 5ustar sylvestresylvestrelibcxx/test/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp0000644000175000017500000000655412266757724031171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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()); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp0000644000175000017500000000267312266757724033771 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp0000644000175000017500000000365712266757724032430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp0000644000175000017500000000146412266757724031644 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/associative/multiset/multiset.cons/move.pass.cpp0000644000175000017500000000665212266757724030016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp0000644000175000017500000000265712266757724031724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000300612266757724033255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp0000644000175000017500000000354412266757724031171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp0000644000175000017500000000400712266757724031026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/compare.pass.cpp0000644000175000017500000000126512266757724030471 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp0000644000175000017500000000232212266757724035274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp0000644000175000017500000000256512266757724032053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/containers/associative/multiset/multiset.cons/alloc.pass.cpp0000644000175000017500000000127712266757724030140 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp0000644000175000017500000000274512266757724032400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp0000644000175000017500000000242512266757724031717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp0000644000175000017500000000213212266757724034121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/default.pass.cpp0000644000175000017500000000134412266757724030465 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } #endif } libcxx/test/containers/associative/multiset/multiset.cons/copy.pass.cpp0000644000175000017500000000707212266757724030017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp0000644000175000017500000001057412266757724031360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp0000644000175000017500000000714712266757724031366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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); } } libcxx/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp0000644000175000017500000000447212266757724032206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/scary.pass.cpp0000644000175000017500000000114412266757724025351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/containers/associative/multiset/multiset.special/0000755000175000017500000000000012266757724026044 5ustar sylvestresylvestrelibcxx/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp0000644000175000017500000000764012266757724032025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { 1, 2, 3, 4 }; V ar2[] = { }; 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); } { 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { 1, 2, 3, 4 }; V ar2[] = { }; 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); } { 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 } libcxx/test/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp0000644000175000017500000000302112266757724032370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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)), ""); } #endif } libcxx/test/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp0000644000175000017500000000744712266757724032704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; { V ar1[] = { }; V ar2[] = { }; 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); } { V ar1[] = { }; 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); } { V ar1[] = { 1, 2, 3, 4 }; V ar2[] = { }; 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); } { 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)); } } libcxx/test/containers/associative/multiset/emplace.pass.cpp0000644000175000017500000000432012266757724025635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/erase_key.pass.cpp0000644000175000017500000000656012266757724026206 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/count.pass.cpp0000644000175000017500000000360412266757724025363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/associative/multiset/max_size.pass.cpp0000644000175000017500000000134212266757724026047 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/insert_iter_cv.pass.cpp0000644000175000017500000000357712266757724027263 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/insert_cv.pass.cpp0000644000175000017500000000342612266757724026231 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/insert_initializer_list.pass.cpp0000644000175000017500000000306712266757724031200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/upper_bound.pass.cpp0000644000175000017500000001254112266757724026555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/clear.pass.cpp0000644000175000017500000000236612266757724025325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/lower_bound.pass.cpp0000644000175000017500000001352212266757724026552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/erase_iter_iter.pass.cpp0000644000175000017500000001036512266757724027402 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/emplace_hint.pass.cpp0000644000175000017500000000451412266757724026664 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/empty.pass.cpp0000644000175000017500000000160612266757724025371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/associative/multiset/erase_iter.pass.cpp0000644000175000017500000001246712266757724026364 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/containers.general/0000755000175000017500000000000012266757724022160 5ustar sylvestresylvestrelibcxx/test/containers/containers.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724026470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/sequences/0000755000175000017500000000000012266757724020372 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector/0000755000175000017500000000000012266757724021674 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector/version.pass.cpp0000644000175000017500000000072712266757724025040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/sequences/vector/types.pass.cpp0000644000175000017500000001001212266757724024503 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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 } libcxx/test/containers/sequences/vector/db_iterators_2.pass.cpp0000644000175000017500000000176312266757724026256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/const_value_type.pass.cpp0000644000175000017500000000106612266757724026733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector/db_cback.pass.cpp0000644000175000017500000000170512266757724025060 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/iterators.pass.cpp0000644000175000017500000000733312266757724025367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/sequences/vector/db_iterators_7.pass.cpp0000644000175000017500000000202612266757724026254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.cons/0000755000175000017500000000000012266757724024137 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp0000644000175000017500000000536212266757724030130 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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 } libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp0000644000175000017500000000515412266757724033061 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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)); 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 } libcxx/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp0000644000175000017500000000361612266757724030674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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()); #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 } libcxx/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp0000644000175000017500000000534712266757724027741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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 } libcxx/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp0000644000175000017500000000177412266757724032543 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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({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::vector> 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 } libcxx/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp0000644000175000017500000000173412266757724031173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 = {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::vector> 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 } libcxx/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp0000644000175000017500000000253012266757724030126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp0000644000175000017500000000176612266757724033065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 = {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::vector> 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 } libcxx/test/containers/sequences/vector/vector.cons/move.pass.cpp0000644000175000017500000000534212266757724026562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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()); } { int a1[] = {1, 3, 7, 9, 10}; std::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector::const_iterator i = c1.begin(); std::vector c2 = std::move(c1); std::vector::iterator j = c2.erase(i); assert(*j == 3); } #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()); } { int a1[] = {1, 3, 7, 9, 10}; std::vector> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector>::const_iterator i = c1.begin(); std::vector> c2 = std::move(c1); std::vector>::iterator j = c2.erase(i); assert(*j == 3); } #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp0000644000175000017500000000247312266757724030471 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; static_assert(!std::is_nothrow_move_constructible::value, ""); } #endif } libcxx/test/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000262112266757724032030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp0000644000175000017500000000362712266757724027744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp0000644000175000017500000000174012266757724032064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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); test > >(50, 5); #if __cplusplus >= 201103L test> >(50, 3); #endif } libcxx/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp0000644000175000017500000000232112266757724032336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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({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::vector> 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 } libcxx/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp0000644000175000017500000000335012266757724031341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 Alloc& = Alloc()); #include #include #include "test_allocator.h" #include "../../../NotConstructible.h" #include "../../../stack_allocator.h" #include "min_allocator.h" template void test0() { C c; assert(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == typename C::allocator_type()); } template void test1(const typename C::allocator_type& a) { C c(a); assert(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == a); } int main() { { test0 >(); test0 >(); test1 > >(test_allocator(3)); test1 > > (test_allocator(5)); } { std::vector > v; assert(v.empty()); } #if __cplusplus >= 201103L { test0> >(); test0> >(); test1 > >(min_allocator{}); test1 > > (min_allocator{}); } { std::vector > v; assert(v.empty()); } #endif } libcxx/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp0000644000175000017500000000202112266757724033227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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 } libcxx/test/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp0000644000175000017500000000250312266757724031141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../../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 } libcxx/test/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp0000644000175000017500000000241512266757724030467 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp0000644000175000017500000000501612266757724031704 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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() { 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 } libcxx/test/containers/sequences/vector/vector.cons/copy.pass.cpp0000644000175000017500000000345712266757724026573 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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() { { 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(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 { 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(v2 == v); assert(v2.get_allocator() == v.get_allocator()); } #endif } libcxx/test/containers/sequences/vector/db_front.pass.cpp0000644000175000017500000000202212266757724025136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/db_cindex.pass.cpp0000644000175000017500000000175512266757724025274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/db_cfront.pass.cpp0000644000175000017500000000171012266757724025304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/db_iterators_5.pass.cpp0000644000175000017500000000211212266757724026246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/db_iterators_3.pass.cpp0000644000175000017500000000175312266757724026256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.modifiers/0000755000175000017500000000000012266757724025156 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp0000644000175000017500000000245312266757724031444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" int main() { #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector v; v.reserve(3); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); } { std::vector v; v.reserve(4); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); } #if __cplusplus >= 201103L { std::vector> v; v.reserve(3); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); } { std::vector> v; v.reserve(4); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); } #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp0000644000175000017500000000203412266757724031476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp0000644000175000017500000000225412266757724030410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp0000644000175000017500000000226412266757724032527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp0000644000175000017500000000515112266757724030570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" int main() { { std::vector c; c.push_back(0); assert(c.size() == 1); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(1); assert(c.size() == 2); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(2); assert(c.size() == 3); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(3); assert(c.size() == 4); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(4); assert(c.size() == 5); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); } { std::vector > c; c.push_back(0); assert(c.size() == 1); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(1); assert(c.size() == 2); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(2); assert(c.size() == 3); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(3); assert(c.size() == 4); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(4); assert(c.size() == 5); 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); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(1); assert(c.size() == 2); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(2); assert(c.size() == 3); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(3); assert(c.size() == 4); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(4); assert(c.size() == 5); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); } #endif } libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp0000644000175000017500000000427712266757724032364 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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 < 101; ++j) assert(v[j] == 0); } { 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 < 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(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 } libcxx/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp0000644000175000017500000001043512266757724030240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" #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); 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); } { 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 #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 } libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp0000644000175000017500000000222412266757724031500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp0000644000175000017500000000463012266757724031220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" #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); 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); } { std::vector > 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::vector> 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 } libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp0000644000175000017500000001214112266757724033223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" 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(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(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, 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 < 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(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(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(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 } libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp0000644000175000017500000000226312266757724032525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp0000644000175000017500000000465412266757724032545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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(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(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(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 } libcxx/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp0000644000175000017500000000603512266757724032150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector c; c.push_back(MoveOnly(0)); assert(c.size() == 1); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(1)); assert(c.size() == 2); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(2)); assert(c.size() == 3); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(3)); assert(c.size() == 4); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(4)); assert(c.size() == 5); 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); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(1)); assert(c.size() == 2); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(2)); assert(c.size() == 3); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(3)); assert(c.size() == 4); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(4)); assert(c.size() == 5); 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); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(1)); assert(c.size() == 2); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(2)); assert(c.size() == 3); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(3)); assert(c.size() == 4); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(4)); assert(c.size() == 5); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); } #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp0000644000175000017500000000543512266757724033413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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 < 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(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(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(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 } libcxx/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp0000644000175000017500000000325012266757724034614 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, 1); std::vector::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); } #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(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 } libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp0000644000175000017500000000207712266757724032533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp0000644000175000017500000000677612266757724032014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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::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()); } { std::vector > outer(2, std::vector(1)); outer.erase(outer.begin(), outer.begin()); assert(outer.size() == 2); assert(outer[0].size() == 1); assert(outer[1].size() == 1); } #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()); } { std::vector>, min_allocator>>> outer(2, std::vector>(1)); outer.erase(outer.begin(), outer.begin()); assert(outer.size() == 2); assert(outer[0].size() == 1); assert(outer[1].size() == 1); } #endif } libcxx/test/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp0000644000175000017500000000400612266757724034217 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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::vector vec; vec.push_back(instance); gCopyConstructorShouldThow = true; try { vec.push_back(instance); } catch (...) { } } libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp0000644000175000017500000000226312266757724032527 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp0000644000175000017500000000350612266757724030755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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::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 == 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::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 == 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 } libcxx/test/containers/sequences/vector/vector.capacity/0000755000175000017500000000000012266757724024772 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp0000644000175000017500000000364612266757724031007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { 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); } { 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); } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES { 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); } { 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); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #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); } #endif } libcxx/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp0000644000175000017500000000313212266757724030115 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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); } { 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 } libcxx/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp0000644000175000017500000000173712266757724030250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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 } libcxx/test/containers/sequences/vector/vector.capacity/swap.pass.cpp0000644000175000017500000000202112266757724027410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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); } #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); } #endif } libcxx/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp0000644000175000017500000000245512266757724031313 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" int main() { { std::vector v(100); v.push_back(1); v.shrink_to_fit(); assert(v.capacity() == 101); assert(v.size() == 101); } { std::vector > v(100); v.push_back(1); v.shrink_to_fit(); assert(v.capacity() == 101); assert(v.size() == 101); } #ifndef _LIBCPP_NO_EXCEPTIONS { std::vector > v(100); v.push_back(1); v.shrink_to_fit(); assert(v.capacity() == 200); assert(v.size() == 101); } #endif #if __cplusplus >= 201103L { std::vector> v(100); v.push_back(1); v.shrink_to_fit(); assert(v.capacity() == 101); assert(v.size() == 101); } #endif } libcxx/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp0000644000175000017500000000370212266757724032174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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); } { 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); } #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); } { 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); } #endif } libcxx/test/containers/sequences/vector/db_index.pass.cpp0000644000175000017500000000177112266757724025127 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/db_iterators_4.pass.cpp0000644000175000017500000000203312266757724026247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/db_iterators_8.pass.cpp0000644000175000017500000000174312266757724026262 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.special/0000755000175000017500000000000012266757724024615 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp0000644000175000017500000001301712266757724027242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "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::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector c2(a2, a2+sizeof(a2)/sizeof(a2[0])); 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]))); } { 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])); swap(c1, c2); assert(c1 == std::vector(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::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector c2(a2, a2); swap(c1, c2); assert(c1.empty()); assert(distance(c1.begin(), c1.end()) == 0); assert(c2 == std::vector(a1, a1+sizeof(a1)/sizeof(a1[0]))); } { 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); 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::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)); 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)); } #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])); 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])))); } { 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])); swap(c1, c2); assert((c1 == std::vector>(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::vector> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector> c2(a2, a2); swap(c1, c2); assert(c1.empty()); assert(distance(c1.begin(), c1.end()) == 0); assert((c2 == std::vector>(a1, a1+sizeof(a1)/sizeof(a1[0])))); } { 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); 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::vector c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A()); std::vector c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A()); 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()); } #endif #endif } libcxx/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp0000644000175000017500000000315012266757724030124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp0000644000175000017500000000274612266757724031156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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; static_assert(!noexcept(swap(c1, c2)), ""); } #endif } libcxx/test/containers/sequences/vector/db_back.pass.cpp0000644000175000017500000000201512266757724024710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector/vector.data/0000755000175000017500000000000012266757724024106 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector/vector.data/data_const.pass.cpp0000644000175000017500000000157512266757724027706 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" int main() { { const std::vector v; assert(v.data() == 0); } { const std::vector v(100); assert(v.data() == &v.front()); } #if __cplusplus >= 201103L { const std::vector> v; assert(v.data() == 0); } { const std::vector> v(100); assert(v.data() == &v.front()); } #endif } libcxx/test/containers/sequences/vector/vector.data/data.pass.cpp0000644000175000017500000000153112266757724026470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" int main() { { std::vector v; assert(v.data() == 0); } { std::vector v(100); assert(v.data() == &v.front()); } #if __cplusplus >= 201103L { std::vector> v; assert(v.data() == 0); } { std::vector> v(100); assert(v.data() == &v.front()); } #endif } libcxx/test/containers/sequences/vector/db_iterators_6.pass.cpp0000644000175000017500000000203412266757724026252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724024702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/sequences/forwardlist/0000755000175000017500000000000012266757724022732 5ustar sylvestresylvestrelibcxx/test/containers/sequences/forwardlist/version.pass.cpp0000644000175000017500000000074312266757724026074 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/0000755000175000017500000000000012266757724026072 5ustar sylvestresylvestrelibcxx/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp0000644000175000017500000000221012266757724030525 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp0000644000175000017500000000360612266757724033411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp0000644000175000017500000000615312266757724031523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" bool g(int i) { return i < 3; } 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_if(g); 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_if(g); 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_if(g); assert(c1 == c2); } { typedef int T; typedef std::forward_list C; C c1; C c2; c1.remove_if(g); 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_if(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[] = {5, 5, 5}; C c1(std::begin(t1), std::end(t1)); C c2(std::begin(t2), std::end(t2)); c1.remove_if(g); 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_if(g); 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_if(g); assert(c1 == c2); } { typedef int T; typedef std::forward_list> C; C c1; C c2; c1.remove_if(g); 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_if(g); assert(c1 == c2); } #endif } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp0000644000175000017500000000631512266757724032070 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp0000644000175000017500000000175712266757724031230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp0000644000175000017500000000601712266757724031044 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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); } #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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp0000644000175000017500000001155012266757724033361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp0000644000175000017500000000264512266757724030651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp0000644000175000017500000000613212266757724031053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp0000644000175000017500000000722012266757724033045 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp0000644000175000017500000000233012266757724031542 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp0000644000175000017500000000301012266757724031646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/types.pass.cpp0000644000175000017500000000557112266757724025557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" int main() { static_assert((std::is_same::value_type, char>::value), ""); static_assert((std::is_same::allocator_type, std::allocator >::value), ""); static_assert((std::is_same::reference, char&>::value), ""); static_assert((std::is_same::const_reference, const char&>::value), ""); static_assert((std::is_same::pointer, char*>::value), ""); static_assert((std::is_same::const_pointer, const char*>::value), ""); static_assert((std::is_same::size_type, std::size_t>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); #if __cplusplus >= 201103L static_assert((std::is_same>::value_type, char>::value), ""); static_assert((std::is_same>::allocator_type, min_allocator >::value), ""); static_assert((std::is_same>::reference, char&>::value), ""); static_assert((std::is_same>::const_reference, const char&>::value), ""); static_assert((std::is_same>::pointer, min_pointer>::value), ""); static_assert((std::is_same>::const_pointer, min_pointer>::value), ""); static_assert((std::is_same>::size_type, std::size_t>::value), ""); static_assert((std::is_same>::difference_type, std::ptrdiff_t>::value), ""); #endif } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/0000755000175000017500000000000012266757724026233 5ustar sylvestresylvestrelibcxx/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp0000644000175000017500000000254512266757724033232 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp0000644000175000017500000000266412266757724031010 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp0000644000175000017500000000407612266757724032720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp0000644000175000017500000001520712266757724032223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp0000644000175000017500000000451012266757724032024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp0000644000175000017500000000152212266757724030623 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp0000644000175000017500000001101212266757724032215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp0000644000175000017500000000444112266757724030655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp0000644000175000017500000000323412266757724032154 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp0000644000175000017500000000255312266757724032564 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp0000644000175000017500000000331112266757724030654 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000270112266757724034123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp0000644000175000017500000000217112266757724032053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp0000644000175000017500000000404012266757724032026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp0000644000175000017500000000142312266757724030743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp0000644000175000017500000000363412266757724033424 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp0000644000175000017500000000411212266757724032211 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp0000644000175000017500000000262312266757724032024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp0000644000175000017500000000230112266757724030643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp0000644000175000017500000000206112266757724030775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp0000644000175000017500000000255512266757724033244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp0000644000175000017500000000246712266757724032572 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp0000644000175000017500000000471512266757724032353 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, ++n) assert(*i == 10+n); assert(n == 4); } #endif } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp0000644000175000017500000000137512266757724031336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } #endif } libcxx/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp0000644000175000017500000000411412266757724030656 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/0000755000175000017500000000000012266757724027252 5ustar sylvestresylvestrelibcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp0000644000175000017500000000274112266757724033545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp0000644000175000017500000001360412266757724034233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp0000644000175000017500000000667412266757724033273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp0000644000175000017500000000613012266757724033512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp0000644000175000017500000000520412266757724034565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp0000644000175000017500000000451012266757724035636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp0000644000175000017500000000466412266757724034445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp0000644000175000017500000000252412266757724033624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp0000644000175000017500000000413012266757724032727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpplibcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.0000644000175000017500000000403312266757724036040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (...) { } } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp0000644000175000017500000000616312266757724034052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp0000644000175000017500000000523512266757724034623 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp0000644000175000017500000000542612266757724034126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp0000644000175000017500000000233312266757724034321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp0000644000175000017500000000276612266757724032024 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp0000644000175000017500000000511312266757724034452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.access/0000755000175000017500000000000012266757724026532 5ustar sylvestresylvestrelibcxx/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp0000644000175000017500000000322412266757724031334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/max_size.pass.cpp0000644000175000017500000000142712266757724026226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.iter/0000755000175000017500000000000012266757724026234 5ustar sylvestresylvestrelibcxx/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp0000644000175000017500000000607712266757724032325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp0000644000175000017500000000735212266757724031730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); // std::forward_list c; // assert ( ii1 != c.cbegin()); // assert ( cii != c.begin()); // assert ( cii != c.cend()); // assert ( ii1 != c.end()); } #endif } libcxx/test/containers/sequences/forwardlist/forwardlist.spec/0000755000175000017500000000000012266757724026223 5ustar sylvestresylvestrelibcxx/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp0000644000175000017500000000345012266757724032030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp0000644000175000017500000000277512266757724031016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp0000644000175000017500000001777212266757724032213 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp0000644000175000017500000000302012266757724032546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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; static_assert(!noexcept(swap(c1, c2)), ""); } #endif } libcxx/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp0000644000175000017500000002013612266757724033051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/0000755000175000017500000000000012266757724021345 5ustar sylvestresylvestrelibcxx/test/containers/sequences/list/version.pass.cpp0000644000175000017500000000072312266757724024505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/sequences/list/list.special/0000755000175000017500000000000012266757724023737 5ustar sylvestresylvestrelibcxx/test/containers/sequences/list/list.special/swap.pass.cpp0000644000175000017500000001267712266757724026377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.special/db_swap_1.pass.cpp0000644000175000017500000000331112266757724027245 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.special/swap_noexcept.pass.cpp0000644000175000017500000000273012266757724030271 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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; static_assert(!noexcept(swap(c1, c2)), ""); } #endif } libcxx/test/containers/sequences/list/types.pass.cpp0000644000175000017500000000421212266757724024161 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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" 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 } libcxx/test/containers/sequences/list/db_cback.pass.cpp0000644000175000017500000000167512266757724024537 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/iterators.pass.cpp0000644000175000017500000000743112266757724025037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); assert ( ii1 != c.cbegin()); assert ( cii != c.begin()); } #endif } libcxx/test/containers/sequences/list/db_iterators_7.pass.cpp0000644000175000017500000000201612266757724025724 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/db_front.pass.cpp0000644000175000017500000000201212266757724024606 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/db_cfront.pass.cpp0000644000175000017500000000170012266757724024754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.capacity/0000755000175000017500000000000012266757724024114 5ustar sylvestresylvestrelibcxx/test/containers/sequences/list/list.capacity/resize_size.pass.cpp0000644000175000017500000000424212266757724030122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.capacity/resize_size_value.pass.cpp0000644000175000017500000000273012266757724031316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.ops/0000755000175000017500000000000012266757724023120 5ustar sylvestresylvestrelibcxx/test/containers/sequences/list/list.ops/sort.pass.cpp0000644000175000017500000000204412266757724025560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp0000644000175000017500000006040712266757724027773 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.ops/remove_if.pass.cpp0000644000175000017500000000167112266757724026551 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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" bool g(int i) { return i < 3; } int main() { { int a1[] = {1, 2, 3, 4}; int a2[] = {3, 4}; std::list c(a1, a1+4); c.remove_if(g); assert(c == std::list(a2, a2+2)); } #if __cplusplus >= 201103L { int a1[] = {1, 2, 3, 4}; int a2[] = {3, 4}; std::list> c(a1, a1+4); c.remove_if(g); assert((c == std::list>(a2, a2+2))); } #endif } libcxx/test/containers/sequences/list/list.ops/unique_pred.pass.cpp0000644000175000017500000000200612266757724027107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.ops/reverse.pass.cpp0000644000175000017500000000205512266757724026246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.ops/merge_comp.pass.cpp0000644000175000017500000000247712266757724026720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.ops/remove.pass.cpp0000644000175000017500000000156312266757724026073 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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)); } #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 } libcxx/test/containers/sequences/list/list.ops/merge.pass.cpp0000644000175000017500000000233012266757724025666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.ops/unique.pass.cpp0000644000175000017500000000165412266757724026105 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.ops/sort_comp.pass.cpp0000644000175000017500000000220012266757724026570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp0000644000175000017500000001533612266757724032042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp0000644000175000017500000002656212266757724031022 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/db_iterators_8.pass.cpp0000644000175000017500000000173312266757724025732 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.modifiers/0000755000175000017500000000000012266757724024300 5ustar sylvestresylvestrelibcxx/test/containers/sequences/list/list.modifiers/emplace_front.pass.cpp0000644000175000017500000000305512266757724030572 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp0000644000175000017500000000202012266757724030613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp0000644000175000017500000000237312266757724027534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp0000644000175000017500000000225412266757724031650 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.modifiers/push_back.pass.cpp0000644000175000017500000000157012266757724027713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp0000644000175000017500000000501612266757724031476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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 } libcxx/test/containers/sequences/list/list.modifiers/emplace.pass.cpp0000644000175000017500000000424112266757724027360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp0000644000175000017500000000220412266757724030620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.modifiers/emplace_back.pass.cpp0000644000175000017500000000305012266757724030335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp0000644000175000017500000001015612266757724032351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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 } libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp0000644000175000017500000000225312266757724031646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.modifiers/pop_front.pass.cpp0000644000175000017500000000201112266757724027751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp0000644000175000017500000000400312266757724033566 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (...) { } } libcxx/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp0000644000175000017500000000341212266757724031656 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp0000644000175000017500000000226612266757724031274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp0000644000175000017500000000474712266757724032542 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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 } libcxx/test/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp0000644000175000017500000000331612266757724033741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/clear.pass.cpp0000644000175000017500000000133112266757724027035 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp0000644000175000017500000000207312266757724031651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp0000644000175000017500000000227312266757724031522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp0000644000175000017500000000561612266757724031126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp0000644000175000017500000000400012266757724033333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (...) { } } libcxx/test/containers/sequences/list/list.modifiers/push_front.pass.cpp0000644000175000017500000000157312266757724030146 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp0000644000175000017500000000225312266757724031650 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.modifiers/erase_iter.pass.cpp0000644000175000017500000000346612266757724030104 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/db_iterators_9.pass.cpp0000644000175000017500000000311112266757724025723 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/list.cons/0000755000175000017500000000000012266757724023261 5ustar sylvestresylvestrelibcxx/test/containers/sequences/list/list.cons/size_value_alloc.pass.cpp0000644000175000017500000000422312266757724030253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/assign_move.pass.cpp0000644000175000017500000000532212266757724027246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/move_alloc.pass.cpp0000644000175000017500000000530712266757724027057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/size_type.pass.cpp0000644000175000017500000000527612266757724026757 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp0000644000175000017500000000214012266757724031651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/initializer_list.pass.cpp0000644000175000017500000000207712266757724030316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/assign_copy.pass.cpp0000644000175000017500000000250412266757724027251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp0000644000175000017500000000212712266757724032177 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/move.pass.cpp0000644000175000017500000000444412266757724025706 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp0000644000175000017500000000242512266757724030720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/move_noexcept.pass.cpp0000644000175000017500000000245312266757724027611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000260112266757724031150 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/copy_alloc.pass.cpp0000644000175000017500000000247312266757724027064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp0000644000175000017500000000246312266757724031467 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/default_noexcept.pass.cpp0000644000175000017500000000246512266757724030272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp0000644000175000017500000000237712266757724027620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/default.pass.cpp0000644000175000017500000000262712266757724026365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } #endif } libcxx/test/containers/sequences/list/list.cons/copy.pass.cpp0000644000175000017500000000303012266757724025700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/list/list.cons/input_iterator.pass.cpp0000644000175000017500000000607412266757724030011 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/list/db_back.pass.cpp0000644000175000017500000000200512266757724024360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/list/db_iterators_6.pass.cpp0000644000175000017500000000202412266757724025722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/vector.bool/0000755000175000017500000000000012266757724022626 5ustar sylvestresylvestrelibcxx/test/containers/sequences/vector.bool/assign_move.pass.cpp0000644000175000017500000000507712266757724026622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/find.pass.cpp0000644000175000017500000000175412266757724025226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } { 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); } } } libcxx/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp0000644000175000017500000000436012266757724031546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/construct_size.pass.cpp0000644000175000017500000000314412266757724027357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/move_alloc.pass.cpp0000644000175000017500000000505012266757724026417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp0000644000175000017500000000206712266757724031226 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/resize_size.pass.cpp0000644000175000017500000000176512266757724026643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } #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); } #endif } libcxx/test/containers/sequences/vector.bool/types.pass.cpp0000644000175000017500000000551112266757724025445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/vector.bool/initializer_list.pass.cpp0000644000175000017500000000203012266757724027650 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/assign_copy.pass.cpp0000644000175000017500000000255512266757724026624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/push_back.pass.cpp0000644000175000017500000000235312266757724026241 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp0000644000175000017500000000536412266757724026323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); } #endif } libcxx/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp0000644000175000017500000000206112266757724031541 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/move.pass.cpp0000644000175000017500000000371712266757724025255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/move_noexcept.pass.cpp0000644000175000017500000000240012266757724027146 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; static_assert(!std::is_nothrow_move_constructible::value, ""); } #endif } libcxx/test/containers/sequences/vector.bool/reserve.pass.cpp0000644000175000017500000000244212266757724025754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/capacity.pass.cpp0000644000175000017500000000176712266757724026107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp0000644000175000017500000000252612266757724030523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/copy_alloc.pass.cpp0000644000175000017500000000366112266757724026431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/swap.pass.cpp0000644000175000017500000000553012266757724025254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp0000644000175000017500000000245012266757724030023 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 < 101; ++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 < 101; ++j) assert(v[j] == 0); } #endif } libcxx/test/containers/sequences/vector.bool/construct_size_value.pass.cpp0000644000175000017500000000161612266757724030555 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp0000644000175000017500000000242112266757724031026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/emplace.pass.cpp0000644000175000017500000000344412266757724025712 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/construct_default.pass.cpp0000644000175000017500000000221612266757724030030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_allocator.h" #include "min_allocator.h" template void test0() { C c; assert(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == typename C::allocator_type()); } template void test1(const typename C::allocator_type& a) { C c(a); assert(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == a); } int main() { { test0 >(); test1 > >(test_allocator(3)); } #if __cplusplus >= 201103L { test0> >(); test1 > >(min_allocator()); } #endif } libcxx/test/containers/sequences/vector.bool/vector_bool.pass.cpp0000644000175000017500000000245512266757724026622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_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); } #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 } libcxx/test/containers/sequences/vector.bool/emplace_back.pass.cpp0000644000175000017500000000272312266757724026671 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp0000644000175000017500000000602412266757724030676 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 < 105; ++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); } #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 < 105; ++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); } #endif } libcxx/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp0000644000175000017500000000204712266757724031726 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp0000644000175000017500000000156212266757724027145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/default_noexcept.pass.cpp0000644000175000017500000000241612266757724027633 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/dtor_noexcept.pass.cpp0000644000175000017500000000233012266757724027152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp0000644000175000017500000000375512266757724030403 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp0000644000175000017500000000257312266757724031063 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 < 105; ++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 < 105; ++j) assert(v[j] == 0); } #endif } libcxx/test/containers/sequences/vector.bool/copy.pass.cpp0000644000175000017500000000352612266757724025257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp0000644000175000017500000000345012266757724032266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp0000644000175000017500000000575112266757724027454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/swap_noexcept.pass.cpp0000644000175000017500000000265312266757724027164 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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; static_assert(!noexcept(swap(c1, c2)), ""); } #endif } libcxx/test/containers/sequences/vector.bool/resize_size_value.pass.cpp0000644000175000017500000000265512266757724030036 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/vector.bool/erase_iter.pass.cpp0000644000175000017500000000353012266757724026422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/array/0000755000175000017500000000000012266757724021510 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.fill/0000755000175000017500000000000012266757724023553 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.fill/fill.pass.cpp0000644000175000017500000000150012266757724026146 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/containers/sequences/array/version.pass.cpp0000644000175000017500000000072512266757724024652 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/sequences/array/array.swap/0000755000175000017500000000000012266757724023577 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.swap/swap.pass.cpp0000644000175000017500000000200612266757724026220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/containers/sequences/array/array.special/0000755000175000017500000000000012266757724024245 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.special/swap.pass.cpp0000644000175000017500000000207112266757724026670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/containers/sequences/array/array.zero/0000755000175000017500000000000012266757724023604 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp0000644000175000017500000000066312266757724030615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/sequences/array/types.pass.cpp0000644000175000017500000000535412266757724024334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } } libcxx/test/containers/sequences/array/iterators.pass.cpp0000644000175000017500000000521212266757724025175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 == 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)); } } #endif } libcxx/test/containers/sequences/array/array.tuple/0000755000175000017500000000000012266757724023756 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.tuple/get_rv.pass.cpp0000644000175000017500000000145212266757724026717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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 } libcxx/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp0000644000175000017500000000130412266757724027610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 int main() { { typedef double T; typedef std::array C; static_assert((std::tuple_size::value == 3), ""); } { typedef double T; typedef std::array C; static_assert((std::tuple_size::value == 0), ""); } } libcxx/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp0000644000175000017500000000214112266757724030267 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 int main() { { typedef double T; typedef std::array C; static_assert((std::is_same::type, T>::value), ""); static_assert((std::is_same::type, T>::value), ""); static_assert((std::is_same::type, T>::value), ""); } { typedef int T; typedef std::array C; static_assert((std::is_same::type, T>::value), ""); static_assert((std::is_same::type, T>::value), ""); static_assert((std::is_same::type, T>::value), ""); } } libcxx/test/containers/sequences/array/array.tuple/get.fail.cpp0000644000175000017500000000120612266757724026152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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! } } libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp0000644000175000017500000000242012266757724026204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp0000644000175000017500000000176712266757724027427 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/array/array.data/0000755000175000017500000000000012266757724023536 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.data/data_const.pass.cpp0000644000175000017500000000143612266757724027332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } } libcxx/test/containers/sequences/array/array.data/data.pass.cpp0000644000175000017500000000137212266757724026123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } } libcxx/test/containers/sequences/array/front_back.pass.cpp0000644000175000017500000000264212266757724025275 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/array/array.cons/0000755000175000017500000000000012266757724023567 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.cons/initializer_list.pass.cpp0000644000175000017500000000143512266757724030621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/containers/sequences/array/array.cons/default.pass.cpp0000644000175000017500000000123612266757724026666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/containers/sequences/array/at.pass.cpp0000644000175000017500000000315512266757724023571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/array/array.size/0000755000175000017500000000000012266757724023577 5ustar sylvestresylvestrelibcxx/test/containers/sequences/array/array.size/size.pass.cpp0000644000175000017500000000254412266757724026227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/array/begin.pass.cpp0000644000175000017500000000130312266757724024242 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } { } } libcxx/test/containers/sequences/array/indexing.pass.cpp0000644000175000017500000000267612266757724025001 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/dynarray/0000755000175000017500000000000012266757724022223 5ustar sylvestresylvestrelibcxx/test/containers/sequences/dynarray/dynarray.cons/0000755000175000017500000000000012266757724025015 5ustar sylvestresylvestrelibcxx/test/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp0000644000175000017500000000507712266757724027571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.cons/default.pass.cpp0000644000175000017500000000516312266757724030117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.traits/0000755000175000017500000000000012266757724025361 5ustar sylvestresylvestrelibcxx/test/containers/sequences/dynarray/dynarray.traits/default.pass.cpp0000644000175000017500000000137112266757724030460 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // dynarray.data // template // struct uses_allocator, Alloc> : true_type { }; #include <__config> #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 libcxx/test/containers/sequences/dynarray/nothing_to_do.pass.cpp0000644000175000017500000000056412266757724026533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/containers/sequences/dynarray/dynarray.overview/0000755000175000017500000000000012266757724025721 5ustar sylvestresylvestrelibcxx/test/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp0000644000175000017500000000641512266757724031312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp0000644000175000017500000000260212266757724031167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp0000644000175000017500000000275312266757724031511 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.overview/at.pass.cpp0000644000175000017500000000456312266757724030006 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp0000644000175000017500000000341012266757724031175 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.data/0000755000175000017500000000000012266757724024764 5ustar sylvestresylvestrelibcxx/test/containers/sequences/dynarray/dynarray.data/default.pass.cpp0000644000175000017500000000264112266757724030064 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.mutate/0000755000175000017500000000000012266757724025352 5ustar sylvestresylvestrelibcxx/test/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp0000644000175000017500000000207512266757724030453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/dynarray/dynarray.zero/0000755000175000017500000000000012266757724025032 5ustar sylvestresylvestrelibcxx/test/containers/sequences/dynarray/dynarray.zero/default.pass.cpp0000644000175000017500000000223212266757724030126 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/containers/sequences/deque/0000755000175000017500000000000012266757724021475 5ustar sylvestresylvestrelibcxx/test/containers/sequences/deque/version.pass.cpp0000644000175000017500000000072512266757724024637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/containers/sequences/deque/types.pass.cpp0000644000175000017500000001015112266757724024310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } #endif } libcxx/test/containers/sequences/deque/deque.special/0000755000175000017500000000000012266757724024217 5ustar sylvestresylvestrelibcxx/test/containers/sequences/deque/deque.special/move.pass.cpp0000644000175000017500000000474412266757724026647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.special/swap.pass.cpp0000644000175000017500000000670412266757724026651 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp0000644000175000017500000000504312266757724030502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.special/move_backward.pass.cpp0000644000175000017500000000504412266757724030477 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.special/copy.pass.cpp0000644000175000017500000000500612266757724026643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp0000644000175000017500000000273712266757724030560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); // 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; }; 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; static_assert(!noexcept(swap(c1, c2)), ""); } #endif } libcxx/test/containers/sequences/deque/iterators.pass.cpp0000644000175000017500000000277312266757724025173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 == cii ); assert ( !(ii1 != ii2 )); assert ( !(ii1 != cii )); // std::deque c; // assert ( ii1 != c.cbegin()); // assert ( cii != c.begin()); // assert ( cii != c.cend()); // assert ( ii1 != c.end()); } #endif } libcxx/test/containers/sequences/deque/deque.modifiers/0000755000175000017500000000000012266757724024560 5ustar sylvestresylvestrelibcxx/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp0000644000175000017500000000415312266757724031052 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp0000644000175000017500000001462512266757724031613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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, C& c1, const C& c2) { typedef typename C::iterator I; typedef typename C::const_iterator CI; typedef bidirectional_iterator BCI; 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 } libcxx/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp0000644000175000017500000000357212266757724030016 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp0000644000175000017500000000346012266757724030173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp0000644000175000017500000000764612266757724032000 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, 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 } libcxx/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp0000644000175000017500000000532212266757724027641 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp0000644000175000017500000000415112266757724030620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp0000644000175000017500000000357412266757724030250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp0000644000175000017500000000655012266757724030737 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp0000644000175000017500000000400612266757724034051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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::deque vec; vec.push_front(instance); gCopyConstructorShouldThow = true; try { vec.push_front(instance); } catch (...) { } } libcxx/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp0000644000175000017500000000554412266757724031123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp0000644000175000017500000000402612266757724031550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp0000644000175000017500000000320012266757724034211 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp0000644000175000017500000000422212266757724031776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp0000644000175000017500000000453012266757724031400 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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) #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 } libcxx/test/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp0000644000175000017500000000400312266757724033616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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::deque vec; vec.push_back(instance); gCopyConstructorShouldThow = true; try { vec.push_back(instance); } catch (...) { } } libcxx/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp0000644000175000017500000000362712266757724030430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp0000644000175000017500000000416412266757724030360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.capacity/0000755000175000017500000000000012266757724024374 5ustar sylvestresylvestrelibcxx/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp0000644000175000017500000000415112266757724030401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; std::size_t 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 } libcxx/test/containers/sequences/deque/deque.capacity/access.pass.cpp0000644000175000017500000000462512266757724027315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp0000644000175000017500000000325112266757724030710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp0000644000175000017500000000421512266757724031576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; std::size_t 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 } libcxx/test/containers/sequences/deque/deque.cons/0000755000175000017500000000000012266757724023541 5ustar sylvestresylvestrelibcxx/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp0000644000175000017500000000307112266757724030533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp0000644000175000017500000000565612266757724027346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp0000644000175000017500000000177012266757724032141 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp0000644000175000017500000000173012266757724030571 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp0000644000175000017500000000176112266757724032462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/move.pass.cpp0000644000175000017500000000455412266757724026170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp0000644000175000017500000000246312266757724030072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/size.pass.cpp0000644000175000017500000000615512266757724026173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp0000644000175000017500000000261112266757724031431 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/size_value.pass.cpp0000644000175000017500000000306012266757724027357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp0000644000175000017500000000313012266757724027333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp0000644000175000017500000000342412266757724027022 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp0000644000175000017500000000412212266757724027177 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp0000644000175000017500000000231412266757724031742 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp0000644000175000017500000000413112266757724030723 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp0000644000175000017500000000521612266757724030550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/containers/sequences/deque/deque.cons/alloc.pass.cpp0000644000175000017500000000170712266757724026311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp0000644000175000017500000000247412266757724030552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp0000644000175000017500000000240612266757724030071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/default.pass.cpp0000644000175000017500000000157612266757724026647 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } int main() { test >(); test >(); #if __cplusplus >= 201103L test >(); test >(); #endif } libcxx/test/containers/sequences/deque/deque.cons/copy.pass.cpp0000644000175000017500000000332512266757724026167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp0000644000175000017500000000572412266757724027534 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp0000644000175000017500000000413512266757724030355 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/CMakeLists.txt0000644000175000017500000000260612266757726017000 0ustar sylvestresylvestremacro(pythonize_bool var) if (${var}) set(${var} True) else() set(${var} False) endif() endmacro() include(FindPythonInterp) if(PYTHONINTERP_FOUND) if(LIBCXX_BUILT_STANDALONE) set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's lit.py.") else() set(LIT_EXECUTABLE "${CMAKE_SOURCE_DIR}/utils/lit/lit.py") endif() set(LIT_ARGS_DEFAULT "-sv") 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_COMPILER ${CMAKE_CXX_COMPILER}) set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR}) set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) pythonize_bool(LIBCXX_ENABLE_SHARED) pythonize_bool(LIBCXX_HAS_STDCXX0X_FLAG) 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 ${PYTHON_EXECUTABLE} ${LIT_EXECUTABLE} ${LIT_ARGS} ${CMAKE_CURRENT_BINARY_DIR} DEPENDS cxx COMMENT "Running libcxx tests") else() message(WARNING "Could not find Python, no check target will be available!") endif() libcxx/test/support/0000755000175000017500000000000012266757726015750 5ustar sylvestresylvestrelibcxx/test/support/test_allocator.h0000644000175000017500000001273012266757726021143 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 { 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)std::malloc(n * sizeof(T)); } void deallocate(pointer p, size_type n) {assert(data_ >= 0); --alloc_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 libcxx/test/support/test_iterators.h0000644000175000017500000002203712266757726021200 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 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 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 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 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 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; } #endif // ITERATORS_H libcxx/test/support/DefaultOnly.h0000644000175000017500000000164212266757726020352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/support/nothing_to_do.pass.cpp0000644000175000017500000000060312266757726022252 0ustar sylvestresylvestre// -*- 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() { } libcxx/test/support/private_constructor.hpp0000644000175000017500000000206012266757726022576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/support/hexfloat.h0000644000175000017500000000203512266757726017733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/support/min_allocator.h0000644000175000017500000001650612266757726020754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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() noexcept = default; min_pointer(std::nullptr_t) : ptr_(nullptr) {} template min_pointer(min_pointer p) : 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() noexcept = default; min_pointer(std::nullptr_t) : ptr_(nullptr) {} template ::value >::type > min_pointer(min_pointer p) : 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) : ptr_(p) {} public: min_pointer() noexcept = default; min_pointer(std::nullptr_t) : ptr_(nullptr) {} 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 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() 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 libcxx/test/support/allocators.h0000644000175000017500000001010712266757726020263 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template class A1 { int id_; public: explicit A1(int id = 0) : 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) : id_(a.id()) {copy_called = true;} A1(A1&& a) : id_(a.id()) {move_called = true;} template A1(const A1& a) : id_(a.id()) {copy_called = true;} template A1(A1&& a) : 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) : 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) : id_(a.id()) {copy_called = true;} A2(A2&& a) : 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) : 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) : id_(a.id()) {copy_called = true;} A3(A3&& a) : 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 libcxx/test/support/platform_support.h0000644000175000017500000000350512266757726021544 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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" #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 #endif inline std::string get_temp_file_name() { std::string s("temp.XXXXXX"); #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) _mktemp(&s[0]); #else mktemp(&s[0]); #endif return s; } #endif // PLATFORM_SUPPORT_H libcxx/include/0000755000175000017500000000000012266757731014674 5ustar sylvestresylvestrelibcxx/include/type_traits0000644000175000017500000031773612266757731017207 0ustar sylvestresylvestre// -*- C++ -*- //===------------------------ type_traits ---------------------------------===// // // The 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_TYPE_TRAITS #define _LIBCPP_TYPE_TRAITS /* type_traits synopsis namespace std { // helper class: template struct integral_constant; typedef integral_constant true_type; typedef integral_constant false_type; // helper traits template struct enable_if; template struct conditional; // Primary classification traits: template struct is_void; template struct is_null_pointer; // C++14 template struct is_integral; template struct is_floating_point; template struct is_array; template struct is_pointer; template struct is_lvalue_reference; template struct is_rvalue_reference; template struct is_member_object_pointer; template struct is_member_function_pointer; template struct is_enum; template struct is_union; template struct is_class; template struct is_function; // Secondary classification traits: template struct is_reference; template struct is_arithmetic; template struct is_fundamental; template struct is_member_pointer; template struct is_scalar; template struct is_object; template struct is_compound; // Const-volatile properties and transformations: template struct is_const; template struct is_volatile; template struct remove_const; template struct remove_volatile; template struct remove_cv; template struct add_const; template struct add_volatile; template struct add_cv; // Reference transformations: template struct remove_reference; template struct add_lvalue_reference; template struct add_rvalue_reference; // Pointer transformations: template struct remove_pointer; template struct add_pointer; // Integral properties: template struct is_signed; template struct is_unsigned; template struct make_signed; template struct make_unsigned; // Array properties and transformations: template struct rank; template struct extent; template struct remove_extent; template struct remove_all_extents; // Member introspection: template struct is_pod; template struct is_trivial; template struct is_trivially_copyable; template struct is_standard_layout; template struct is_literal_type; template struct is_empty; template struct is_polymorphic; template struct is_abstract; template struct is_constructible; template struct is_default_constructible; template struct is_copy_constructible; template struct is_move_constructible; template struct is_assignable; template struct is_copy_assignable; template struct is_move_assignable; template struct is_destructible; template struct is_trivially_constructible; template struct is_trivially_default_constructible; template struct is_trivially_copy_constructible; template struct is_trivially_move_constructible; template struct is_trivially_assignable; template struct is_trivially_copy_assignable; template struct is_trivially_move_assignable; template struct is_trivially_destructible; template struct is_nothrow_constructible; template struct is_nothrow_default_constructible; template struct is_nothrow_copy_constructible; template struct is_nothrow_move_constructible; template struct is_nothrow_assignable; template struct is_nothrow_copy_assignable; template struct is_nothrow_move_assignable; template struct is_nothrow_destructible; template struct has_virtual_destructor; // Relationships between types: template struct is_same; template struct is_base_of; template struct is_convertible; // Alignment properties and transformations: template struct alignment_of; template struct aligned_storage; template struct aligned_union; template struct decay; template struct common_type; template struct underlying_type; template class result_of; // undefined template class result_of; // const-volatile modifications: template using remove_const_t = typename remove_const::type; // C++14 template using remove_volatile_t = typename remove_volatile::type; // C++14 template using remove_cv_t = typename remove_cv::type; // C++14 template using add_const_t = typename add_const::type; // C++14 template using add_volatile_t = typename add_volatile::type; // C++14 template using add_cv_t = typename add_cv::type; // C++14 // reference modifications: template using remove_reference_t = typename remove_reference::type; // C++14 template using add_lvalue_reference_t = typename add_lvalue_reference::type; // C++14 template using add_rvalue_reference_t = typename add_rvalue_reference::type; // C++14 // sign modifications: template using make_signed_t = typename make_signed::type; // C++14 template using make_unsigned_t = typename make_unsigned::type; // C++14 // array modifications: template using remove_extent_t = typename remove_extent::type; // C++14 template using remove_all_extents_t = typename remove_all_extents::type; // C++14 // pointer modifications: template using remove_pointer_t = typename remove_pointer::type; // C++14 template using add_pointer_t = typename add_pointer::type; // C++14 // other transformations: template using aligned_storage_t = typename aligned_storage::type; // C++14 template using aligned_union_t = typename aligned_union::type; // C++14 template using decay_t = typename decay::type; // C++14 template using enable_if_t = typename enable_if::type; // C++14 template using conditional_t = typename conditional::type; // C++14 template using common_type_t = typename common_type::type; // C++14 template using underlying_type_t = typename underlying_type::type; // C++14 template using result_of_t = typename result_of::type; // C++14 } // std */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; template struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _Then type;}; #if _LIBCPP_STD_VER > 11 template using conditional_t = typename conditional<_Bp, _If, _Then>::type; #endif template struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; template struct _LIBCPP_TYPE_VIS_ONLY enable_if {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using enable_if_t = typename enable_if<_Bp, _Tp>::type; #endif struct __two {char __lx[2];}; // helper class: template struct _LIBCPP_TYPE_VIS_ONLY integral_constant { static _LIBCPP_CONSTEXPR const _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator value_type() const {return value;} #if _LIBCPP_STD_VER > 11 _LIBCPP_INLINE_VISIBILITY constexpr value_type operator ()() const {return value;} #endif }; template _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; typedef integral_constant true_type; typedef integral_constant false_type; // is_const template struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; // is_volatile template struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; // remove_const template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_const_t = typename remove_const<_Tp>::type; #endif // remove_volatile template struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_volatile_t = typename remove_volatile<_Tp>::type; #endif // remove_cv template struct _LIBCPP_TYPE_VIS_ONLY remove_cv {typedef typename remove_volatile::type>::type type;}; #if _LIBCPP_STD_VER > 11 template using remove_cv_t = typename remove_cv<_Tp>::type; #endif // is_void template struct __libcpp_is_void : public false_type {}; template <> struct __libcpp_is_void : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_void : public __libcpp_is_void::type> {}; // __is_nullptr_t template struct __is_nullptr_t_impl : public false_type {}; template <> struct __is_nullptr_t_impl : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t : public __is_nullptr_t_impl::type> {}; #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer : public __is_nullptr_t_impl::type> {}; #endif // is_integral template struct __libcpp_is_integral : public false_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __libcpp_is_integral::type> {}; // is_floating_point template struct __libcpp_is_floating_point : public false_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_floating_point : public __libcpp_is_floating_point::type> {}; // is_array template struct _LIBCPP_TYPE_VIS_ONLY is_array : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> : public true_type {}; // is_pointer template struct __libcpp_is_pointer : public false_type {}; template struct __libcpp_is_pointer<_Tp*> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_pointer : public __libcpp_is_pointer::type> {}; // is_reference template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {}; #endif template struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) #define _LIBCPP_HAS_TYPE_TRAITS #endif // is_union #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_union : public integral_constant {}; #else template struct __libcpp_union : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_union : public __libcpp_union::type> {}; #endif // is_class #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant {}; #else namespace __is_class_imp { template char __test(int _Tp::*); template __two __test(...); } template struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant(0)) == 1 && !is_union<_Tp>::value> {}; #endif // is_same template struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; // is_function namespace __libcpp_is_function_imp { template char __test(_Tp*); template __two __test(...); template _Tp& __source(); } template ::value || is_union<_Tp>::value || is_void<_Tp>::value || is_reference<_Tp>::value || __is_nullptr_t<_Tp>::value > struct __libcpp_is_function : public integral_constant(__libcpp_is_function_imp::__source<_Tp>())) == 1> {}; template struct __libcpp_is_function<_Tp, true> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_function : public __libcpp_is_function<_Tp> {}; // is_member_function_pointer template struct __libcpp_is_member_function_pointer : public false_type {}; template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __libcpp_is_member_function_pointer::type> {}; // is_member_pointer template struct __libcpp_is_member_pointer : public false_type {}; template struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer : public __libcpp_is_member_pointer::type> {}; // is_member_object_pointer template struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer : public integral_constant::value && !is_member_function_pointer<_Tp>::value> {}; // is_enum #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant {}; #else template struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant::value && !is_integral<_Tp>::value && !is_floating_point<_Tp>::value && !is_array<_Tp>::value && !is_pointer<_Tp>::value && !is_reference<_Tp>::value && !is_member_pointer<_Tp>::value && !is_union<_Tp>::value && !is_class<_Tp>::value && !is_function<_Tp>::value > {}; #endif // is_arithmetic template struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic : public integral_constant::value || is_floating_point<_Tp>::value> {}; // is_fundamental template struct _LIBCPP_TYPE_VIS_ONLY is_fundamental : public integral_constant::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; // is_scalar template struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public integral_constant::value || is_member_pointer<_Tp>::value || is_pointer<_Tp>::value || __is_nullptr_t<_Tp>::value || is_enum<_Tp>::value > {}; template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public true_type {}; // is_object template struct _LIBCPP_TYPE_VIS_ONLY is_object : public integral_constant::value || is_array<_Tp>::value || is_union<_Tp>::value || is_class<_Tp>::value > {}; // is_compound template struct _LIBCPP_TYPE_VIS_ONLY is_compound : public integral_constant::value> {}; // add_const template ::value || is_function<_Tp>::value || is_const<_Tp>::value > struct __add_const {typedef _Tp type;}; template struct __add_const<_Tp, false> {typedef const _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY add_const {typedef typename __add_const<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template using add_const_t = typename add_const<_Tp>::type; #endif // add_volatile template ::value || is_function<_Tp>::value || is_volatile<_Tp>::value > struct __add_volatile {typedef _Tp type;}; template struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY add_volatile {typedef typename __add_volatile<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template using add_volatile_t = typename add_volatile<_Tp>::type; #endif // add_cv template struct _LIBCPP_TYPE_VIS_ONLY add_cv {typedef typename add_const::type>::type type;}; #if _LIBCPP_STD_VER > 11 template using add_cv_t = typename add_cv<_Tp>::type; #endif // remove_reference template struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;}; #endif #if _LIBCPP_STD_VER > 11 template using remove_reference_t = typename remove_reference<_Tp>::type; #endif // add_lvalue_reference template struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;}; template struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef const void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef volatile void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; #endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef const void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef volatile void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename add_rvalue_reference<_Tp>::type declval() _NOEXCEPT; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename add_lvalue_reference<_Tp>::type declval(); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES struct __any { __any(...); }; // remove_pointer template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_pointer_t = typename remove_pointer<_Tp>::type; #endif // add_pointer template struct _LIBCPP_TYPE_VIS_ONLY add_pointer {typedef typename remove_reference<_Tp>::type* type;}; #if _LIBCPP_STD_VER > 11 template using add_pointer_t = typename add_pointer<_Tp>::type; #endif // is_signed template ::value> struct __libcpp_is_signed_impl : public integral_constant {}; template struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point template ::value> struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; template struct __libcpp_is_signed<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; // is_unsigned template ::value> struct __libcpp_is_unsigned_impl : public integral_constant {}; template struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point template ::value> struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; template struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; // rank template struct _LIBCPP_TYPE_VIS_ONLY rank : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> : public integral_constant::value + 1> {}; template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> : public integral_constant::value + 1> {}; // extent template struct _LIBCPP_TYPE_VIS_ONLY extent : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0> : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip> : public integral_constant::value> {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0> : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> : public integral_constant::value> {}; // remove_extent template struct _LIBCPP_TYPE_VIS_ONLY remove_extent {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_extent_t = typename remove_extent<_Tp>::type; #endif // remove_all_extents template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]> {typedef typename remove_all_extents<_Tp>::type type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]> {typedef typename remove_all_extents<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template using remove_all_extents_t = typename remove_all_extents<_Tp>::type; #endif // decay template struct _LIBCPP_TYPE_VIS_ONLY decay { private: typedef typename remove_reference<_Tp>::type _Up; public: typedef typename conditional < is_array<_Up>::value, typename remove_extent<_Up>::type*, typename conditional < is_function<_Up>::value, typename add_pointer<_Up>::type, typename remove_cv<_Up>::type >::type >::type type; }; #if _LIBCPP_STD_VER > 11 template using decay_t = typename decay<_Tp>::type; #endif // is_abstract namespace __is_abstract_imp { template char __test(_Tp (*)[1]); template __two __test(...); } template ::value> struct __libcpp_abstract : public integral_constant(0)) != 1> {}; template struct __libcpp_abstract<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF template struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant {}; #else // __has_feature(is_base_of) namespace __is_base_of_imp { template struct _Dst { _Dst(const volatile _Tp &); }; template struct _Src { operator const volatile _Tp &(); template operator const _Dst<_Up> &(); }; template struct __one { typedef char type; }; template typename __one(declval<_Src<_Dp> >()))>::type __test(int); template __two __test(...); } template struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant::value && sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; #endif // __has_feature(is_base_of) // is_convertible #if __has_feature(is_convertible_to) template struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public integral_constant::value> {}; #else // __has_feature(is_convertible_to) namespace __is_convertible_imp { template char __test(_Tp); template __two __test(...); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template _Tp&& __source(); #else template typename remove_reference<_Tp>::type& __source(); #endif template ::value, bool _IsFunction = is_function<_Tp>::value, bool _IsVoid = is_void<_Tp>::value> struct __is_array_function_or_void {enum {value = 0};}; template struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; template struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; template struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; } template ::type>::value> struct __is_convertible_check { static const size_t __v = 0; }; template struct __is_convertible_check<_Tp, 0> { static const size_t __v = sizeof(_Tp); }; template ::value, unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::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_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value && (!is_const::type>::value || is_volatile::type>::value) && (is_same::type, typename remove_cv::type>::type>::value || is_base_of::type, _T1>::value)) #endif > {}; template struct __is_convertible<_T1, _T2, 1, 0> : false_type {}; template struct __is_convertible<_T1, const _T1&, 1, 0> : 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 {}; template struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {}; template struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {}; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct __is_convertible<_T1, _T2*, 1, 0> : public integral_constant::type*, _T2*>::value> {}; template struct __is_convertible<_T1, _T2* const, 1, 0> : public integral_constant::type*, _T2*const>::value> {}; template struct __is_convertible<_T1, _T2* volatile, 1, 0> : public integral_constant::type*, _T2*volatile>::value> {}; template struct __is_convertible<_T1, _T2* const volatile, 1, 0> : public integral_constant::type*, _T2*const volatile>::value> {}; template struct __is_convertible<_T1, _T2, 2, 0> : public false_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {}; #endif template struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T2, 3, 0> : public false_type {}; template struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; template struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; template struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; template struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public __is_convertible<_T1, _T2> { static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; }; #endif // __has_feature(is_convertible_to) // is_empty #if __has_feature(is_empty) template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public integral_constant {}; #else // __has_feature(is_empty) template struct __is_empty1 : public _Tp { double __lx; }; struct __is_empty2 { double __lx; }; template ::value> struct __libcpp_empty : public integral_constant) == sizeof(__is_empty2)> {}; template struct __libcpp_empty<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {}; #endif // __has_feature(is_empty) // is_polymorphic #if __has_feature(is_polymorphic) template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant {}; #else template char &__is_polymorphic_impl( typename enable_if(declval<_Tp*>())) != 0, int>::type); template __two &__is_polymorphic_impl(...); template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant(0)) == 1> {}; #endif // __has_feature(is_polymorphic) // has_virtual_destructor #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public false_type {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // alignment_of template struct _LIBCPP_TYPE_VIS_ONLY alignment_of : public integral_constant {}; // aligned_storage template struct __type_list { typedef _Hp _Head; typedef _Tp _Tail; }; struct __nat { #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __nat() = delete; __nat(const __nat&) = delete; __nat& operator=(const __nat&) = delete; ~__nat() = delete; #endif }; template struct __align_type { static const size_t value = alignment_of<_Tp>::value; typedef _Tp type; }; struct __struct_double {long double __lx;}; struct __struct_double4 {double __lx[4];}; typedef __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type<__struct_double>, __type_list<__align_type<__struct_double4>, __type_list<__align_type, __nat > > > > > > > > > > __all_types; template struct __find_pod; template struct __find_pod<__type_list<_Hp, __nat>, _Align> { typedef typename conditional< _Align == _Hp::value, typename _Hp::type, void >::type type; }; template struct __find_pod<__type_list<_Hp, _Tp>, _Align> { typedef typename conditional< _Align == _Hp::value, typename _Hp::type, typename __find_pod<_Tp, _Align>::type >::type type; }; template struct __find_max_align; template struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant {}; template struct __select_align { private: static const size_t __min = _A2 < _A1 ? _A2 : _A1; static const size_t __max = _A1 < _A2 ? _A2 : _A1; public: static const size_t value = _Len < __max ? __min : __max; }; template struct __find_max_align<__type_list<_Hp, _Tp>, _Len> : public integral_constant::value>::value> {}; template ::value> struct _LIBCPP_TYPE_VIS_ONLY aligned_storage { typedef typename __find_pod<__all_types, _Align>::type _Aligner; static_assert(!is_void<_Aligner>::value, ""); union type { _Aligner __align; unsigned char __data[_Len]; }; }; #if _LIBCPP_STD_VER > 11 template ::value> using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; #endif #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ template \ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ unsigned char __lx[_Len];\ };\ } _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000) #if !defined(_LIBCPP_MSVC) _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); #endif // !_LIBCPP_MSVC #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION #ifndef _LIBCPP_HAS_NO_VARIADICS // aligned_union template struct __static_max; template struct __static_max<_I0> { static const size_t value = _I0; }; template struct __static_max<_I0, _I1, _In...> { static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : __static_max<_I1, _In...>::value; }; template struct aligned_union { static const size_t alignment_value = __static_max<__alignof__(_Type0), __alignof__(_Types)...>::value; static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value; typedef typename aligned_storage<__len, alignment_value>::type type; }; #if _LIBCPP_STD_VER > 11 template using aligned_union_t = typename aligned_union<_Len, _Types...>::type; #endif #endif // _LIBCPP_HAS_NO_VARIADICS template struct __numeric_type { static void __test(...); static float __test(float); static double __test(char); static double __test(int); static double __test(unsigned); static double __test(long); static double __test(unsigned long); static double __test(long long); static double __test(unsigned long long); static double __test(double); static long double __test(long double); typedef decltype(__test(declval<_Tp>())) type; static const bool value = !is_same::value; }; template <> struct __numeric_type { static const bool value = true; }; // __promote template ::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value> class __promote { static const bool value = false; }; template class __promote<_A1, _A2, _A3, true> { private: typedef typename __promote<_A1>::type __type1; typedef typename __promote<_A2>::type __type2; typedef typename __promote<_A3>::type __type3; public: typedef decltype(__type1() + __type2() + __type3()) type; static const bool value = true; }; template class __promote<_A1, _A2, void, true> { private: typedef typename __promote<_A1>::type __type1; typedef typename __promote<_A2>::type __type2; public: typedef decltype(__type1() + __type2()) type; static const bool value = true; }; template class __promote<_A1, void, void, true> { public: typedef typename __numeric_type<_A1>::type type; static const bool value = true; static const bool __does_not_throw = _NOEXCEPT_OR_FALSE(static_cast(declval<_A1>())); }; #ifdef _LIBCPP_STORE_AS_OPTIMIZATION // __transform template ::value> struct __transform {typedef _Tp type;}; template struct __transform<_Tp, 1, true> {typedef unsigned char type;}; template struct __transform<_Tp, 2, true> {typedef unsigned short type;}; template struct __transform<_Tp, 4, true> {typedef unsigned int type;}; template struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; #endif // _LIBCPP_STORE_AS_OPTIMIZATION // make_signed / make_unsigned typedef __type_list > > > > __signed_types; typedef __type_list > > > > __unsigned_types; template struct __find_first; template struct __find_first<__type_list<_Hp, _Tp>, _Size, true> { typedef _Hp type; }; template struct __find_first<__type_list<_Hp, _Tp>, _Size, false> { typedef typename __find_first<_Tp, _Size>::type type; }; template ::type>::value, bool = is_volatile::type>::value> struct __apply_cv { typedef _Up type; }; template struct __apply_cv<_Tp, _Up, true, false> { typedef const _Up type; }; template struct __apply_cv<_Tp, _Up, false, true> { typedef volatile _Up type; }; template struct __apply_cv<_Tp, _Up, true, true> { typedef const volatile _Up type; }; template struct __apply_cv<_Tp&, _Up, false, false> { typedef _Up& type; }; template struct __apply_cv<_Tp&, _Up, true, false> { typedef const _Up& type; }; template struct __apply_cv<_Tp&, _Up, false, true> { typedef volatile _Up& type; }; template struct __apply_cv<_Tp&, _Up, true, true> { typedef const volatile _Up& type; }; template ::value || is_enum<_Tp>::value> struct __make_signed {}; template struct __make_signed<_Tp, true> { typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; }; template <> struct __make_signed {}; template <> struct __make_signed< signed short, true> {typedef short type;}; template <> struct __make_signed {typedef short type;}; template <> struct __make_signed< signed int, true> {typedef int type;}; template <> struct __make_signed {typedef int type;}; template <> struct __make_signed< signed long, true> {typedef long type;}; template <> struct __make_signed {typedef long type;}; template <> struct __make_signed< signed long long, true> {typedef long long type;}; template <> struct __make_signed {typedef long long type;}; template struct _LIBCPP_TYPE_VIS_ONLY make_signed { typedef typename __apply_cv<_Tp, typename __make_signed::type>::type>::type type; }; #if _LIBCPP_STD_VER > 11 template using make_signed_t = typename make_signed<_Tp>::type; #endif template ::value || is_enum<_Tp>::value> struct __make_unsigned {}; template struct __make_unsigned<_Tp, true> { typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; }; template <> struct __make_unsigned {}; template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; template <> struct __make_unsigned {typedef unsigned short type;}; template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; template <> struct __make_unsigned {typedef unsigned int type;}; template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; template <> struct __make_unsigned {typedef unsigned long type;}; template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; template <> struct __make_unsigned {typedef unsigned long long type;}; template struct _LIBCPP_TYPE_VIS_ONLY make_unsigned { typedef typename __apply_cv<_Tp, typename __make_unsigned::type>::type>::type type; }; #if _LIBCPP_STD_VER > 11 template using make_unsigned_t = typename make_unsigned<_Tp>::type; #endif #ifdef _LIBCPP_HAS_NO_VARIADICS template struct _LIBCPP_TYPE_VIS_ONLY common_type { public: typedef typename common_type::type, V>::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> { public: typedef _Tp type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> { private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES static _Tp&& __t(); static _Up&& __u(); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES static _Tp __t(); static _Up __u(); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES public: typedef typename remove_reference::type type; }; #else // _LIBCPP_HAS_NO_VARIADICS template struct common_type; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> { typedef typename decay<_Tp>::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> { private: static _Tp&& __t(); static _Up&& __u(); static bool __f(); public: typedef typename decay::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> { typedef typename common_type::type, _Vp...>::type type; }; #if _LIBCPP_STD_VER > 11 template using common_type_t = typename common_type<_Tp...>::type; #endif #endif // _LIBCPP_HAS_NO_VARIADICS // is_assignable template struct __select_2nd { typedef _Tp type; }; template typename __select_2nd() = _VSTD::declval<_Arg>())), true_type>::type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(_Tp&&, _Arg&&); #else __is_assignable_test(_Tp, _Arg&); #endif template false_type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(__any, _Arg&&); #else __is_assignable_test(__any, _Arg&); #endif template ::value || is_void<_Arg>::value> struct __is_assignable_imp : public common_type < decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>())) >::type {}; template struct __is_assignable_imp<_Tp, _Arg, true> : public false_type { }; template struct is_assignable : public __is_assignable_imp<_Tp, _Arg> {}; // is_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_assignable::type, const typename add_rvalue_reference<_Tp>::type> {}; #else : public is_copy_assignable<_Tp> {}; #endif // is_destructible template struct __destructible_test { _Tp __t; }; template decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type())) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_destructible_test(_Tp&&); #else __is_destructible_test(_Tp&); #endif false_type __is_destructible_test(__any); template ::value || is_abstract<_Tp>::value || is_function<_Tp>::value> struct __destructible_imp : public common_type < decltype(__is_destructible_test(declval<_Tp>())) >::type {}; template struct __destructible_imp<_Tp, true> : public false_type {}; template struct is_destructible : public __destructible_imp<_Tp> {}; template struct is_destructible<_Tp[]> : public false_type {}; // move #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename remove_reference<_Tp>::type&& move(_Tp&& __t) _NOEXCEPT { typedef typename remove_reference<_Tp>::type _Up; return static_cast<_Up&&>(__t); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT { return static_cast<_Tp&&>(__t); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT { static_assert(!std::is_lvalue_reference<_Tp>::value, "Can not forward an rvalue as an lvalue."); return static_cast<_Tp&&>(__t); } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY _Tp& move(_Tp& __t) { return __t; } template inline _LIBCPP_INLINE_VISIBILITY const _Tp& move(const _Tp& __t) { return __t; } template inline _LIBCPP_INLINE_VISIBILITY _Tp& forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT { return __t; } template class __rv { typedef typename remove_reference<_Tp>::type _Trr; _Trr& t_; public: _LIBCPP_INLINE_VISIBILITY _Trr* operator->() {return &t_;} _LIBCPP_INLINE_VISIBILITY explicit __rv(_Trr& __t) : t_(__t) {} }; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(_Tp&& __t) { return _VSTD::forward<_Tp>(__t); } #else template inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(const _Tp& __t) { return _VSTD::forward<_Tp>(__t); } #endif template struct __member_pointer_traits_imp { }; #ifndef _LIBCPP_HAS_NO_VARIADICS template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; }; #if __has_feature(cxx_reference_qualified_functions) template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> { typedef _Class& _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> { typedef _Class const& _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> { typedef _Class volatile& _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> { typedef _Class const volatile& _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> { typedef _Class&& _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> { typedef _Class const&& _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> { typedef _Class volatile&& _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> { typedef _Class const volatile&& _ClassType; typedef _Rp _ReturnType; }; #endif // __has_feature(cxx_reference_qualified_functions) #else // _LIBCPP_HAS_NO_VARIADICS template struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; }; #endif // _LIBCPP_HAS_NO_VARIADICS template struct __member_pointer_traits_imp<_Rp _Class::*, false, true> { typedef _Class _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits : public __member_pointer_traits_imp::type, is_member_function_pointer<_MP>::value, is_member_object_pointer<_MP>::value> { // typedef ... _ClassType; // typedef ... _ReturnType; }; // result_of template class result_of; #ifdef _LIBCPP_HAS_NO_VARIADICS template class __result_of { }; template class __result_of<_Fn(), true, false> { public: typedef decltype(declval<_Fn>()()) type; }; template class __result_of<_Fn(_A0), true, false> { public: typedef decltype(declval<_Fn>()(declval<_A0>())) type; }; template class __result_of<_Fn(_A0, _A1), true, false> { public: typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; }; template class __result_of<_Fn(_A0, _A1, _A2), true, false> { public: typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; }; template struct __result_of_mp; // member function pointer template struct __result_of_mp<_MP, _Tp, true> : public common_type::_ReturnType> { }; // member data pointer template struct __result_of_mdp; template struct __result_of_mdp<_Rp _Class::*, _Tp, false> { typedef typename __apply_cv()), _Rp>::type& type; }; template struct __result_of_mdp<_Rp _Class::*, _Tp, true> { typedef typename __apply_cv<_Tp, _Rp>::type& type; }; template struct __result_of_mp<_Rp _Class::*, _Tp, false> : public __result_of_mdp<_Rp _Class::*, _Tp, is_base_of<_Class, typename remove_reference<_Tp>::type>::value> { }; template class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; template class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; template class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; template class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; // result_of template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()> : public __result_of<_Fn(), is_class::type>::value || is_function::type>::value, is_member_pointer::type>::value > { }; template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)> : public __result_of<_Fn(_A0), is_class::type>::value || is_function::type>::value, is_member_pointer::type>::value > { }; 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_member_pointer::type>::value > { }; 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_member_pointer::type>::value > { }; #endif // _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS // template struct is_constructible; // main is_constructible test template typename __select_2nd()...))), true_type>::type __is_constructible_test(_Tp&&, _Args&& ...); template false_type __is_constructible_test(__any, _Args&& ...); template struct __is_constructible // false, _Tp is not a scalar : public common_type < decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...)) >::type {}; // function types are not constructible template struct __is_constructible : public false_type {}; // handle scalars and reference types // Scalars are default constructible, references are not template struct __is_constructible : public is_scalar<_Tp> {}; // Scalars and references are constructible from one arg if that arg is // implicitly convertible to the scalar or reference. template struct __is_constructible_ref { true_type static __lxx(_Tp); false_type static __lxx(...); }; template struct __is_constructible : public common_type < decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>())) >::type {}; // Scalars and references are not constructible from multiple args. template struct __is_constructible : public false_type {}; // Treat scalars and reference types separately template struct __is_constructible_void_check : public __is_constructible::value || is_reference<_Tp>::value, _Tp, _Args...> {}; // If any of T or Args is void, is_constructible should be false template struct __is_constructible_void_check : public false_type {}; template struct __contains_void; template <> struct __contains_void<> : false_type {}; template struct __contains_void<_A0, _Args...> { static const bool value = is_void<_A0>::value || __contains_void<_Args...>::value; }; // is_constructible entry point template struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value || is_abstract<_Tp>::value, _Tp, _Args...> {}; // Array types are default constructible if their element type // is default constructible template struct __is_constructible : public is_constructible::type> {}; // Otherwise array types are not constructible by this syntax template struct __is_constructible : public false_type {}; // Incomplete array types are not constructible template struct __is_constructible : public false_type {}; #else // _LIBCPP_HAS_NO_VARIADICS // template struct is_constructible0; // main is_constructible0 test template decltype((_Tp(), true_type())) __is_constructible0_test(_Tp&); false_type __is_constructible0_test(__any); template decltype((_Tp(_VSTD::declval<_A0>()), true_type())) __is_constructible1_test(_Tp&, _A0&); template false_type __is_constructible1_test(__any, _A0&); template decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) __is_constructible2_test(_Tp&, _A0&, _A1&); template false_type __is_constructible2_test(__any, _A0&, _A1&); template struct __is_constructible0_imp // false, _Tp is not a scalar : public common_type < decltype(__is_constructible0_test(declval<_Tp&>())) >::type {}; template struct __is_constructible1_imp // false, _Tp is not a scalar : public common_type < decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) >::type {}; template struct __is_constructible2_imp // false, _Tp is not a scalar : public common_type < decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) >::type {}; // handle scalars and reference types // Scalars are default constructible, references are not template struct __is_constructible0_imp : public is_scalar<_Tp> {}; template struct __is_constructible1_imp : public is_convertible<_A0, _Tp> {}; template struct __is_constructible2_imp : public false_type {}; // Treat scalars and reference types separately template struct __is_constructible0_void_check : public __is_constructible0_imp::value || is_reference<_Tp>::value, _Tp> {}; template struct __is_constructible1_void_check : public __is_constructible1_imp::value || is_reference<_Tp>::value, _Tp, _A0> {}; template struct __is_constructible2_void_check : public __is_constructible2_imp::value || is_reference<_Tp>::value, _Tp, _A0, _A1> {}; // If any of T or Args is void, is_constructible should be false template struct __is_constructible0_void_check : public false_type {}; template struct __is_constructible1_void_check : public false_type {}; template struct __is_constructible2_void_check : public false_type {}; // is_constructible entry point namespace __is_construct { struct __nat {}; } template struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible2_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value || is_void<_A0>::value || is_void<_A1>::value, _Tp, _A0, _A1> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : public __is_constructible0_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value, _Tp> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> : public __is_constructible1_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value || is_void<_A0>::value, _Tp, _A0> {}; // Array types are default constructible if their element type // is default constructible template struct __is_constructible0_imp : public is_constructible::type> {}; template struct __is_constructible1_imp : public false_type {}; template struct __is_constructible2_imp : public false_type {}; // Incomplete array types are not constructible template struct __is_constructible0_imp : public false_type {}; template struct __is_constructible1_imp : public false_type {}; template struct __is_constructible2_imp : public false_type {}; #endif // _LIBCPP_HAS_NO_VARIADICS // is_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible : public is_constructible<_Tp> {}; // is_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else : public is_copy_constructible<_Tp> #endif {}; // is_trivially_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS #if __has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : integral_constant { }; #else // !__has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> #else struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> #endif : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> : integral_constant::value> { }; #endif // !__has_feature(is_trivially_constructible) #else // _LIBCPP_HAS_NO_VARIADICS template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; #if __has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant { }; #else // !__has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant::value> { }; #endif // !__has_feature(is_trivially_constructible) #endif // _LIBCPP_HAS_NO_VARIADICS // is_trivially_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible : public is_trivially_constructible<_Tp> {}; // is_trivially_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible : public is_trivially_constructible<_Tp, typename add_lvalue_reference::type> {}; // is_trivially_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else : public is_trivially_copy_constructible<_Tp> #endif {}; // is_trivially_assignable #if __has_feature(is_trivially_constructible) template struct is_trivially_assignable : integral_constant { }; #else // !__has_feature(is_trivially_constructible) template struct is_trivially_assignable : public false_type {}; template struct is_trivially_assignable<_Tp&, _Tp> : integral_constant::value> {}; template struct is_trivially_assignable<_Tp&, _Tp&> : integral_constant::value> {}; template struct is_trivially_assignable<_Tp&, const _Tp&> : integral_constant::value> {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct is_trivially_assignable<_Tp&, _Tp&&> : integral_constant::value> {}; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // !__has_feature(is_trivially_constructible) // is_trivially_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_trivially_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable : public is_trivially_assignable::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> #else typename add_lvalue_reference<_Tp>::type> #endif {}; // is_trivially_destructible #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS template struct __libcpp_trivial_destructor : public integral_constant::value || is_reference<_Tp>::value> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor::type> {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // is_nothrow_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS #if __has_feature(cxx_noexcept) template struct __is_nothrow_constructible; template struct __is_nothrow_constructible : public integral_constant()...))> { }; template struct __is_nothrow_constructible : public false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : __is_nothrow_constructible::value, _Tp, _Args...> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> : __is_nothrow_constructible::value, _Tp> { }; #else // __has_feature(cxx_noexcept) template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> #else struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> #endif #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; #endif // __has_feature(cxx_noexcept) #else // _LIBCPP_HAS_NO_VARIADICS template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; #endif // _LIBCPP_HAS_NO_VARIADICS // is_nothrow_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible : public is_nothrow_constructible<_Tp> {}; // is_nothrow_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_nothrow_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else : public is_nothrow_copy_constructible<_Tp> #endif {}; // is_nothrow_assignable #if __has_feature(cxx_noexcept) template struct __is_nothrow_assignable; template struct __is_nothrow_assignable : public false_type { }; template struct __is_nothrow_assignable : public integral_constant() = _VSTD::declval<_Arg>()) > { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public __is_nothrow_assignable::value, _Tp, _Arg> { }; #else // __has_feature(cxx_noexcept) template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct is_nothrow_assignable<_Tp&, _Tp&&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // __has_feature(cxx_noexcept) // is_nothrow_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_nothrow_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable : public is_nothrow_assignable::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> #else typename add_lvalue_reference<_Tp>::type> #endif {}; // is_nothrow_destructible #if __has_feature(cxx_noexcept) template struct __is_nothrow_destructible; template struct __is_nothrow_destructible : public false_type { }; template struct __is_nothrow_destructible : public integral_constant().~_Tp()) > { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __is_nothrow_destructible::value, _Tp> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> : public is_nothrow_destructible<_Tp> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> : public true_type { }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> : public true_type { }; #endif #else template struct __libcpp_nothrow_destructor : public integral_constant::value || is_reference<_Tp>::value> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor::type> {}; #endif // is_pod #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant::value && is_trivially_copy_constructible<_Tp>::value && is_trivially_copy_assignable<_Tp>::value && is_trivially_destructible<_Tp>::value> {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // is_literal_type; template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type #if __has_feature(is_literal) : public integral_constant #else : integral_constant::type>::value || is_reference::type>::value> #endif {}; // is_standard_layout; template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout #if __has_feature(is_standard_layout) : public integral_constant #else : integral_constant::type>::value> #endif {}; // is_trivially_copyable; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #if __has_feature(is_trivially_copyable) : public integral_constant #else : integral_constant::type>::value> #endif {}; // is_trivial; template struct _LIBCPP_TYPE_VIS_ONLY is_trivial #if __has_feature(is_trivial) : public integral_constant #else : integral_constant::value && is_trivially_default_constructible<_Tp>::value> #endif {}; #ifndef _LIBCPP_HAS_NO_VARIADICS // Check for complete types template struct __check_complete; template <> struct __check_complete<> { }; template struct __check_complete<_Hp, _T0, _Tp...> : private __check_complete<_Hp>, private __check_complete<_T0, _Tp...> { }; template struct __check_complete<_Hp, _Hp> : private __check_complete<_Hp> { }; template struct __check_complete<_Tp> { static_assert(sizeof(_Tp) > 0, "Type must be complete."); }; template struct __check_complete<_Tp&> : private __check_complete<_Tp> { }; template struct __check_complete<_Tp&&> : private __check_complete<_Tp> { }; template struct __check_complete<_Rp (*)(_Param...)> : private __check_complete<_Rp> { }; template struct __check_complete { }; template struct __check_complete<_Rp (_Param...)> : private __check_complete<_Rp> { }; template struct __check_complete { }; template struct __check_complete<_Rp (_Class::*)(_Param...)> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) volatile> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const volatile> : private __check_complete<_Class> { }; #if __has_feature(cxx_reference_qualified_functions) template struct __check_complete<_Rp (_Class::*)(_Param...) &> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) volatile&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) &&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const&&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&> : private __check_complete<_Class> { }; #endif template struct __check_complete<_Rp _Class::*> : private __check_complete<_Class> { }; // __invoke forward declarations // fall back - none of the bullets template auto __invoke(__any, _Args&& ...__args) -> __nat; // bullets 1 and 2 template ::type>::value && is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)); template ::type>::value && !is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)); // bullets 3 and 4 template ::type>::value && is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0) -> decltype(_VSTD::forward<_A0>(__a0).*__f); template ::type>::value && !is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0) -> decltype((*_VSTD::forward<_A0>(__a0)).*__f); // bullet 5 template _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _Args&& ...__args) -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)); // __invokable template struct __invokable_imp : private __check_complete<_Fp> { typedef decltype( __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...) ) type; static const bool value = !is_same::value; }; template struct __invokable : public integral_constant::value> { }; // __invoke_of template struct __invoke_of_imp // false { }; template struct __invoke_of_imp { typedef typename __invokable_imp<_Fp, _Args...>::type type; }; template struct __invoke_of : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...> { }; template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> { }; #if _LIBCPP_STD_VER > 11 template using result_of_t = typename result_of<_Tp>::type; #endif #endif // _LIBCPP_HAS_NO_VARIADICS template inline _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE typename enable_if < is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value >::type #else void #endif swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && is_nothrow_move_assignable<_Tp>::value) { _Tp __t(_VSTD::move(__x)); __x = _VSTD::move(__y); __y = _VSTD::move(__t); } template inline _LIBCPP_INLINE_VISIBILITY void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), *_VSTD::declval<_ForwardIterator2>()))) { swap(*__a, *__b); } // __swappable namespace __detail { using _VSTD::swap; __nat swap(__any, __any); template struct __swappable { typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type; static const bool value = !is_same::value; }; } // __detail template struct __is_swappable : public integral_constant::value> { }; #if __has_feature(cxx_noexcept) template struct __is_nothrow_swappable_imp : public integral_constant(), _VSTD::declval<_Tp&>()))> { }; template struct __is_nothrow_swappable_imp : public false_type { }; template struct __is_nothrow_swappable : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp> { }; #else // __has_feature(cxx_noexcept) template struct __is_nothrow_swappable : public false_type { }; #endif // __has_feature(cxx_noexcept) #ifdef _LIBCXX_UNDERLYING_TYPE template struct underlying_type { typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; }; #if _LIBCPP_STD_VER > 11 template using underlying_type_t = typename underlying_type<_Tp>::type; #endif #else // _LIBCXX_UNDERLYING_TYPE template struct underlying_type { static_assert(_Support, "The underyling_type trait requires compiler " "support. Either no such support exists or " "libc++ does not know how to use it."); }; #endif // _LIBCXX_UNDERLYING_TYPE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE template struct __has_operator_addressof_imp { template static auto __test(__any) -> false_type; template static auto __test(_Up* __u) -> typename __select_2ndoperator&()), true_type>::type; static const bool value = decltype(__test<_Tp>(nullptr))::value; }; template struct __has_operator_addressof : public integral_constant::value> {}; #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_TYPE_TRAITS libcxx/include/cfenv0000644000175000017500000000306412266757731015723 0ustar sylvestresylvestre// -*- C++ -*- //===---------------------------- cctype ----------------------------------===// // // The 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_CFENV #define _LIBCPP_CFENV /* cfenv synopsis This entire header is C99 / C++0X Macros: FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW FE_ALL_EXCEPT FE_DOWNWARD FE_TONEAREST FE_TOWARDZERO FE_UPWARD FE_DFL_ENV namespace std { Types: fenv_t fexcept_t int feclearexcept(int excepts); int fegetexceptflag(fexcept_t* flagp, int excepts); int feraiseexcept(int excepts); int fesetexceptflag(const fexcept_t* flagp, int excepts); int fetestexcept(int excepts); int fegetround(); int fesetround(int round); int fegetenv(fenv_t* envp); int feholdexcept(fenv_t* envp); int fesetenv(const fenv_t* envp); int feupdateenv(const fenv_t* envp); } // std */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD using ::fenv_t; using ::fexcept_t; using ::feclearexcept; using ::fegetexceptflag; using ::feraiseexcept; using ::fesetexceptflag; using ::fetestexcept; using ::fegetround; using ::fesetround; using ::fegetenv; using ::feholdexcept; using ::fesetenv; using ::feupdateenv; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CFENV libcxx/include/cassert0000644000175000017500000000104212266757731016260 0ustar sylvestresylvestre// -*- C++ -*- //===-------------------------- cassert -----------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// /* cassert synopsis Macros: assert */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif libcxx/include/forward_list0000644000175000017500000015667512266757730017341 0ustar sylvestresylvestre// -*- C++ -*- //===----------------------- forward_list ---------------------------------===// // // The 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_FORWARD_LIST #define _LIBCPP_FORWARD_LIST /* forward_list synopsis namespace std { 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; typedef
iterator; typedef
const_iterator; forward_list() noexcept(is_nothrow_default_constructible::value); explicit forward_list(const allocator_type& a); explicit forward_list(size_type n); explicit forward_list(size_type n, const allocator_type& a); // C++14 forward_list(size_type n, const value_type& v); forward_list(size_type n, const value_type& v, const allocator_type& a); template forward_list(InputIterator first, InputIterator last); template forward_list(InputIterator first, InputIterator last, const allocator_type& a); forward_list(const forward_list& x); forward_list(const forward_list& x, const allocator_type& a); forward_list(forward_list&& x) noexcept(is_nothrow_move_constructible::value); forward_list(forward_list&& x, const allocator_type& a); forward_list(initializer_list il); forward_list(initializer_list il, const allocator_type& a); ~forward_list(); forward_list& operator=(const forward_list& x); forward_list& operator=(forward_list&& x) noexcept( allocator_type::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); forward_list& operator=(initializer_list il); template void assign(InputIterator first, InputIterator last); void assign(size_type n, const value_type& v); void assign(initializer_list il); allocator_type get_allocator() const noexcept; iterator begin() noexcept; const_iterator begin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; iterator before_begin() noexcept; const_iterator before_begin() const noexcept; const_iterator cbefore_begin() const noexcept; bool empty() const noexcept; size_type max_size() const noexcept; reference front(); const_reference front() const; template void emplace_front(Args&&... args); void push_front(const value_type& v); void push_front(value_type&& v); void pop_front(); template iterator emplace_after(const_iterator p, Args&&... args); iterator insert_after(const_iterator p, const value_type& v); iterator insert_after(const_iterator p, value_type&& v); iterator insert_after(const_iterator p, size_type n, const value_type& v); template iterator insert_after(const_iterator p, InputIterator first, InputIterator last); iterator insert_after(const_iterator p, initializer_list il); iterator erase_after(const_iterator p); 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); void resize(size_type n); void resize(size_type n, const value_type& v); void clear() noexcept; void splice_after(const_iterator p, forward_list& x); void splice_after(const_iterator p, forward_list&& x); void splice_after(const_iterator p, forward_list& x, const_iterator i); void splice_after(const_iterator p, forward_list&& x, const_iterator i); void splice_after(const_iterator p, forward_list& x, const_iterator first, const_iterator last); void splice_after(const_iterator p, forward_list&& x, const_iterator first, const_iterator last); void remove(const value_type& v); template void remove_if(Predicate pred); void unique(); template void unique(BinaryPredicate binary_pred); void merge(forward_list& x); void merge(forward_list&& x); template void merge(forward_list& x, Compare comp); template void merge(forward_list&& x, Compare comp); void sort(); template void sort(Compare comp); void reverse() noexcept; }; 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); template bool operator>=(const forward_list& x, const forward_list& y); template bool operator<=(const forward_list& x, const forward_list& y); template void swap(forward_list& x, forward_list& y) noexcept(noexcept(x.swap(y))); } // std */ #include <__config> #include #include #include #include #include #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template struct __forward_list_node; template struct __forward_begin_node { typedef __forward_begin_node __self; typedef _NodePtr pointer; pointer __next_; _LIBCPP_INLINE_VISIBILITY __forward_begin_node() : __next_(nullptr) {} }; template struct __forward_list_node : public __forward_begin_node < typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__forward_list_node<_Tp, _VoidPtr> > #else rebind<__forward_list_node<_Tp, _VoidPtr> >::other #endif > { typedef _Tp value_type; value_type __value_; }; template class _LIBCPP_TYPE_VIS_ONLY forward_list; template class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; template class _LIBCPP_TYPE_VIS_ONLY __forward_list_iterator { typedef _NodePtr __node_pointer; __node_pointer __ptr_; _LIBCPP_INLINE_VISIBILITY explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template friend class _LIBCPP_TYPE_VIS_ONLY forward_list; template friend class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; public: typedef forward_iterator_tag iterator_category; typedef typename pointer_traits<__node_pointer>::element_type::value_type value_type; typedef value_type& reference; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; _LIBCPP_INLINE_VISIBILITY __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY __forward_list_iterator& operator++() { __ptr_ = __ptr_->__next_; return *this; } _LIBCPP_INLINE_VISIBILITY __forward_list_iterator operator++(int) { __forward_list_iterator __t(*this); ++(*this); return __t; } friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __forward_list_iterator& __x, const __forward_list_iterator& __y) {return __x.__ptr_ == __y.__ptr_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __forward_list_iterator& __x, const __forward_list_iterator& __y) {return !(__x == __y);} }; template class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator { typedef _NodeConstPtr __node_const_pointer; __node_const_pointer __ptr_; _LIBCPP_INLINE_VISIBILITY explicit __forward_list_const_iterator(__node_const_pointer __p) _NOEXCEPT : __ptr_(__p) {} typedef typename remove_const < typename pointer_traits<__node_const_pointer>::element_type >::type __node; typedef typename pointer_traits<__node_const_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__node> #else rebind<__node>::other #endif __node_pointer; template friend class forward_list; public: typedef forward_iterator_tag iterator_category; typedef typename __node::value_type value_type; typedef const value_type& reference; typedef typename pointer_traits<__node_const_pointer>::difference_type difference_type; typedef typename pointer_traits<__node_const_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator(__forward_list_iterator<__node_pointer> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return pointer_traits::pointer_to(__ptr_->__value_);} _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator& operator++() { __ptr_ = __ptr_->__next_; return *this; } _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator operator++(int) { __forward_list_const_iterator __t(*this); ++(*this); return __t; } friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) {return __x.__ptr_ == __y.__ptr_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) {return !(__x == __y);} }; template class __forward_list_base { protected: typedef _Tp value_type; typedef _Alloc allocator_type; typedef typename allocator_traits::void_pointer void_pointer; typedef __forward_list_node __node; typedef typename __node::__self __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 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 allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer; __compressed_pair<__begin_node, __node_allocator> __before_begin_; _LIBCPP_INLINE_VISIBILITY __node_pointer __before_begin() _NOEXCEPT {return static_cast<__node_pointer>(pointer_traits<__begin_node_pointer>:: pointer_to(__before_begin_.first()));} _LIBCPP_INLINE_VISIBILITY __node_const_pointer __before_begin() const _NOEXCEPT {return static_cast<__node_const_pointer>(pointer_traits<__begin_node_pointer>:: pointer_to(const_cast<__begin_node&>(__before_begin_.first())));} _LIBCPP_INLINE_VISIBILITY __node_allocator& __alloc() _NOEXCEPT {return __before_begin_.second();} _LIBCPP_INLINE_VISIBILITY const __node_allocator& __alloc() const _NOEXCEPT {return __before_begin_.second();} typedef __forward_list_iterator<__node_pointer> iterator; typedef __forward_list_const_iterator<__node_pointer> const_iterator; _LIBCPP_INLINE_VISIBILITY __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) : __before_begin_(__begin_node()) {} _LIBCPP_INLINE_VISIBILITY __forward_list_base(const allocator_type& __a) : __before_begin_(__begin_node(), __node_allocator(__a)) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES public: __forward_list_base(__forward_list_base&& __x) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value); __forward_list_base(__forward_list_base&& __x, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: __forward_list_base(const __forward_list_base&); __forward_list_base& operator=(const __forward_list_base&); public: ~__forward_list_base(); protected: _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __forward_list_base& __x) {__copy_assign_alloc(__x, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__forward_list_base& __x) _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || is_nothrow_move_assignable<__node_allocator>::value) {__move_assign_alloc(__x, integral_constant());} public: void swap(__forward_list_base& __x) _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value); protected: void clear() _NOEXCEPT; private: _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __forward_list_base&, false_type) {} _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __forward_list_base& __x, true_type) { if (__alloc() != __x.__alloc()) clear(); __alloc() = __x.__alloc(); } _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__forward_list_base& __x, false_type) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY 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 template inline _LIBCPP_INLINE_VISIBILITY __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value) : __before_begin_(_VSTD::move(__x.__before_begin_)) { __x.__before_begin()->__next_ = nullptr; } template inline _LIBCPP_INLINE_VISIBILITY __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a) : __before_begin_(__begin_node(), __node_allocator(__a)) { if (__alloc() == __x.__alloc()) { __before_begin()->__next_ = __x.__before_begin()->__next_; __x.__before_begin()->__next_ = nullptr; } } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template __forward_list_base<_Tp, _Alloc>::~__forward_list_base() { clear(); } 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) { __swap_alloc(__alloc(), __x.__alloc()); using _VSTD::swap; swap(__before_begin()->__next_, __x.__before_begin()->__next_); } template void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT { __node_allocator& __a = __alloc(); for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;) { __node_pointer __next = __p->__next_; __node_traits::destroy(__a, _VSTD::addressof(__p->__value_)); __node_traits::deallocate(__a, __p, 1); __p = __next; } __before_begin()->__next_ = nullptr; } template > class _LIBCPP_TYPE_VIS_ONLY forward_list : private __forward_list_base<_Tp, _Alloc> { typedef __forward_list_base<_Tp, _Alloc> base; typedef typename base::__node_allocator __node_allocator; typedef typename base::__node __node; typedef typename base::__node_traits __node_traits; typedef typename base::__node_pointer __node_pointer; public: typedef _Tp value_type; 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; typedef typename base::iterator iterator; typedef typename base::const_iterator const_iterator; _LIBCPP_INLINE_VISIBILITY forward_list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} // = default; explicit forward_list(const allocator_type& __a); explicit forward_list(size_type __n); #if _LIBCPP_STD_VER > 11 explicit forward_list(size_type __n, const allocator_type& __a); #endif forward_list(size_type __n, const value_type& __v); forward_list(size_type __n, const value_type& __v, const allocator_type& __a); template forward_list(_InputIterator __f, _InputIterator __l, typename enable_if< __is_input_iterator<_InputIterator>::value >::type* = nullptr); template forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a, typename enable_if< __is_input_iterator<_InputIterator>::value >::type* = nullptr); forward_list(const forward_list& __x); forward_list(const forward_list& __x, const allocator_type& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY forward_list(forward_list&& __x) _NOEXCEPT_(is_nothrow_move_constructible::value) : base(_VSTD::move(__x)) {} forward_list(forward_list&& __x, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS forward_list(initializer_list __il); forward_list(initializer_list __il, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // ~forward_list() = default; forward_list& operator=(const forward_list& __x); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES forward_list& operator=(forward_list&& __x) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); #endif #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS forward_list& operator=(initializer_list __il); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template typename enable_if < __is_input_iterator<_InputIterator>::value, void >::type assign(_InputIterator __f, _InputIterator __l); void assign(size_type __n, const value_type& __v); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS void assign(initializer_list __il); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT {return allocator_type(base::__alloc());} _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(base::__before_begin()->__next_);} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return const_iterator(base::__before_begin()->__next_);} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return iterator(nullptr);} _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(nullptr);} _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT {return const_iterator(base::__before_begin()->__next_);} _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return const_iterator(nullptr);} _LIBCPP_INLINE_VISIBILITY iterator before_begin() _NOEXCEPT {return iterator(base::__before_begin());} _LIBCPP_INLINE_VISIBILITY const_iterator before_begin() const _NOEXCEPT {return const_iterator(base::__before_begin());} _LIBCPP_INLINE_VISIBILITY const_iterator cbefore_begin() const _NOEXCEPT {return const_iterator(base::__before_begin());} _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return base::__before_begin()->__next_ == nullptr;} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {return numeric_limits::max();} _LIBCPP_INLINE_VISIBILITY reference front() {return base::__before_begin()->__next_->__value_;} _LIBCPP_INLINE_VISIBILITY const_reference front() const {return base::__before_begin()->__next_->__value_;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template void emplace_front(_Args&&... __args); #endif void push_front(value_type&& __v); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void push_front(const value_type& __v); void pop_front(); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template iterator emplace_after(const_iterator __p, _Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS iterator insert_after(const_iterator __p, value_type&& __v); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES iterator insert_after(const_iterator __p, const value_type& __v); iterator insert_after(const_iterator __p, size_type __n, const value_type& __v); template _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_input_iterator<_InputIterator>::value, iterator >::type insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS iterator insert_after(const_iterator __p, initializer_list __il) {return insert_after(__p, __il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS iterator erase_after(const_iterator __p); iterator erase_after(const_iterator __f, const_iterator __l); _LIBCPP_INLINE_VISIBILITY void swap(forward_list& __x) _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) {base::swap(__x);} void resize(size_type __n); void resize(size_type __n, const value_type& __v); _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT {base::clear();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void splice_after(const_iterator __p, forward_list&& __x); _LIBCPP_INLINE_VISIBILITY void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i); _LIBCPP_INLINE_VISIBILITY void splice_after(const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void splice_after(const_iterator __p, forward_list& __x); void splice_after(const_iterator __p, forward_list& __x, const_iterator __i); void splice_after(const_iterator __p, forward_list& __x, const_iterator __f, const_iterator __l); void remove(const value_type& __v); template void remove_if(_Predicate __pred); _LIBCPP_INLINE_VISIBILITY void unique() {unique(__equal_to());} template void unique(_BinaryPredicate __binary_pred); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void merge(forward_list&& __x) {merge(__x, __less());} template _LIBCPP_INLINE_VISIBILITY void merge(forward_list&& __x, _Compare __comp) {merge(__x, _VSTD::move(__comp));} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void merge(forward_list& __x) {merge(__x, __less());} template void merge(forward_list& __x, _Compare __comp); _LIBCPP_INLINE_VISIBILITY void sort() {sort(__less());} template void sort(_Compare __comp); void reverse() _NOEXCEPT; private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void __move_assign(forward_list& __x, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); void __move_assign(forward_list& __x, false_type); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template static __node_pointer __merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp); template static __node_pointer __sort(__node_pointer __f, difference_type __sz, _Compare& __comp); }; template inline _LIBCPP_INLINE_VISIBILITY forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : base(__a) { } template forward_list<_Tp, _Alloc>::forward_list(size_type __n) { if (__n > 0) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_) { __h.reset(__node_traits::allocate(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); __h->__next_ = nullptr; __p->__next_ = __h.release(); } } } #if _LIBCPP_STD_VER > 11 template forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a) : base ( __a ) { if (__n > 0) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_) { __h.reset(__node_traits::allocate(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); __h->__next_ = nullptr; __p->__next_ = __h.release(); } } } #endif template forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { insert_after(cbefore_begin(), __n, __v); } template forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a) { insert_after(cbefore_begin(), __n, __v); } template template forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, typename enable_if< __is_input_iterator<_InputIterator>::value >::type*) { insert_after(cbefore_begin(), __f, __l); } template template forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a, typename enable_if< __is_input_iterator<_InputIterator>::value >::type*) : base(__a) { insert_after(cbefore_begin(), __f, __l); } template forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x) : base(allocator_type( __node_traits::select_on_container_copy_construction(__x.__alloc()) ) ) { insert_after(cbefore_begin(), __x.begin(), __x.end()); } template forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const allocator_type& __a) : base(__a) { insert_after(cbefore_begin(), __x.begin(), __x.end()); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const allocator_type& __a) : base(_VSTD::move(__x), __a) { if (base::__alloc() != __x.__alloc()) { typedef move_iterator _Ip; insert_after(cbefore_begin(), _Ip(__x.begin()), _Ip(__x.end())); } } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template forward_list<_Tp, _Alloc>::forward_list(initializer_list __il) { insert_after(cbefore_begin(), __il.begin(), __il.end()); } template forward_list<_Tp, _Alloc>::forward_list(initializer_list __il, const allocator_type& __a) : base(__a) { insert_after(cbefore_begin(), __il.begin(), __il.end()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) { if (this != &__x) { base::__copy_assign_alloc(__x); assign(__x.begin(), __x.end()); } return *this; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { clear(); base::__move_assign_alloc(__x); base::__before_begin()->__next_ = __x.__before_begin()->__next_; __x.__before_begin()->__next_ = nullptr; } template void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) { if (base::__alloc() == __x.__alloc()) __move_assign(__x, true_type()); else { typedef move_iterator _Ip; assign(_Ip(__x.begin()), _Ip(__x.end())); } } template inline _LIBCPP_INLINE_VISIBILITY forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(forward_list&& __x) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value) { __move_assign(__x, integral_constant()); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializer_list __il) { assign(__il.begin(), __il.end()); return *this; } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template template typename enable_if < __is_input_iterator<_InputIterator>::value, void >::type forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) { iterator __i = before_begin(); iterator __j = _VSTD::next(__i); iterator __e = end(); for (; __j != __e && __f != __l; ++__i, ++__j, ++__f) *__j = *__f; if (__j == __e) insert_after(__i, __f, __l); else erase_after(__i, __e); } template void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) { iterator __i = before_begin(); iterator __j = _VSTD::next(__i); iterator __e = end(); for (; __j != __e && __n > 0; --__n, ++__i, ++__j) *__j = __v; if (__j == __e) insert_after(__i, __n, __v); else erase_after(__i, __e); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY void forward_list<_Tp, _Alloc>::assign(initializer_list __il) { assign(__il.begin(), __il.end()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template template void forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::forward<_Args>(__args)...); __h->__next_ = base::__before_begin()->__next_; base::__before_begin()->__next_ = __h.release(); } #endif // _LIBCPP_HAS_NO_VARIADICS template void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v)); __h->__next_ = base::__before_begin()->__next_; base::__before_begin()->__next_ = __h.release(); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); __h->__next_ = base::__before_begin()->__next_; base::__before_begin()->__next_ = __h.release(); } template void forward_list<_Tp, _Alloc>::pop_front() { __node_allocator& __a = base::__alloc(); __node_pointer __p = base::__before_begin()->__next_; base::__before_begin()->__next_ = __p->__next_; __node_traits::destroy(__a, _VSTD::addressof(__p->__value_)); __node_traits::deallocate(__a, __p, 1); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args) { __node_pointer const __r = __p.__ptr_; __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::forward<_Args>(__args)...); __h->__next_ = __r->__next_; __r->__next_ = __h.release(); return iterator(__r->__next_); } #endif // _LIBCPP_HAS_NO_VARIADICS template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { __node_pointer const __r = __p.__ptr_; __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v)); __h->__next_ = __r->__next_; __r->__next_ = __h.release(); return iterator(__r->__next_); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v) { __node_pointer const __r = __p.__ptr_; __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); __h->__next_ = __r->__next_; __r->__next_ = __h.release(); return iterator(__r->__next_); } template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const value_type& __v) { __node_pointer __r = __p.__ptr_; if (__n > 0) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); __node_pointer __first = __h.release(); __node_pointer __last = __first; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (--__n; __n != 0; --__n, __last = __last->__next_) { __h.reset(__node_traits::allocate(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); __last->__next_ = __h.release(); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { while (__first != nullptr) { __node_pointer __next = __first->__next_; __node_traits::destroy(__a, _VSTD::addressof(__first->__value_)); __node_traits::deallocate(__a, __first, 1); __first = __next; } throw; } #endif // _LIBCPP_NO_EXCEPTIONS __last->__next_ = __r->__next_; __r->__next_ = __first; __r = __last; } return iterator(__r); } template template typename enable_if < __is_input_iterator<_InputIterator>::value, typename forward_list<_Tp, _Alloc>::iterator >::type forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l) { __node_pointer __r = __p.__ptr_; if (__f != __l) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f); __node_pointer __first = __h.release(); __node_pointer __last = __first; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (++__f; __f != __l; ++__f, __last = __last->__next_) { __h.reset(__node_traits::allocate(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f); __last->__next_ = __h.release(); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { while (__first != nullptr) { __node_pointer __next = __first->__next_; __node_traits::destroy(__a, _VSTD::addressof(__first->__value_)); __node_traits::deallocate(__a, __first, 1); __first = __next; } throw; } #endif // _LIBCPP_NO_EXCEPTIONS __last->__next_ = __r->__next_; __r->__next_ = __first; __r = __last; } return iterator(__r); } template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_after(const_iterator __f) { __node_pointer __p = __f.__ptr_; __node_pointer __n = __p->__next_; __p->__next_ = __n->__next_; __node_allocator& __a = base::__alloc(); __node_traits::destroy(__a, _VSTD::addressof(__n->__value_)); __node_traits::deallocate(__a, __n, 1); return iterator(__p->__next_); } template typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) { __node_pointer __e = __l.__ptr_; if (__f != __l) { __node_pointer __p = __f.__ptr_; __node_pointer __n = __p->__next_; if (__n != __e) { __p->__next_ = __e; __node_allocator& __a = base::__alloc(); do { __p = __n->__next_; __node_traits::destroy(__a, _VSTD::addressof(__n->__value_)); __node_traits::deallocate(__a, __n, 1); __n = __p; } while (__n != __e); } } return iterator(__e); } template void forward_list<_Tp, _Alloc>::resize(size_type __n) { size_type __sz = 0; iterator __p = before_begin(); iterator __i = begin(); iterator __e = end(); for (; __i != __e && __sz < __n; ++__p, ++__i, ++__sz) ; if (__i != __e) erase_after(__p, __e); else { __n -= __sz; if (__n > 0) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__node_pointer __ptr = __p.__ptr_; __n > 0; --__n, __ptr = __ptr->__next_) { __h.reset(__node_traits::allocate(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); __h->__next_ = nullptr; __ptr->__next_ = __h.release(); } } } } template void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) { size_type __sz = 0; iterator __p = before_begin(); iterator __i = begin(); iterator __e = end(); for (; __i != __e && __sz < __n; ++__p, ++__i, ++__sz) ; if (__i != __e) erase_after(__p, __e); else { __n -= __sz; if (__n > 0) { __node_allocator& __a = base::__alloc(); typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__node_pointer __ptr = __p.__ptr_; __n > 0; --__n, __ptr = __ptr->__next_) { __h.reset(__node_traits::allocate(__a, 1)); __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); __h->__next_ = nullptr; __ptr->__next_ = __h.release(); } } } } template void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& __x) { if (!__x.empty()) { if (__p.__ptr_->__next_ != nullptr) { const_iterator __lm1 = __x.before_begin(); while (__lm1.__ptr_->__next_ != nullptr) ++__lm1; __lm1.__ptr_->__next_ = __p.__ptr_->__next_; } __p.__ptr_->__next_ = __x.__before_begin()->__next_; __x.__before_begin()->__next_ = nullptr; } } template void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& __x, const_iterator __i) { const_iterator __lm1 = _VSTD::next(__i); if (__p != __i && __p != __lm1) { __i.__ptr_->__next_ = __lm1.__ptr_->__next_; __lm1.__ptr_->__next_ = __p.__ptr_->__next_; __p.__ptr_->__next_ = __lm1.__ptr_; } } template void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& __x, const_iterator __f, const_iterator __l) { if (__f != __l && __p != __f) { const_iterator __lm1 = __f; while (__lm1.__ptr_->__next_ != __l.__ptr_) ++__lm1; if (__f != __lm1) { __lm1.__ptr_->__next_ = __p.__ptr_->__next_; __p.__ptr_->__next_ = __f.__ptr_->__next_; __f.__ptr_->__next_ = __l.__ptr_; } } } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x) { splice_after(__p, __x); } template inline _LIBCPP_INLINE_VISIBILITY void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x, const_iterator __i) { splice_after(__p, __x, __i); } template inline _LIBCPP_INLINE_VISIBILITY void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l) { splice_after(__p, __x, __f, __l); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void forward_list<_Tp, _Alloc>::remove(const value_type& __v) { iterator __e = end(); for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;) { if (__i.__ptr_->__next_->__value_ == __v) { iterator __j = _VSTD::next(__i, 2); for (; __j != __e && *__j == __v; ++__j) ; erase_after(__i, __j); if (__j == __e) break; __i = __j; } else ++__i; } } template template void forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred) { iterator __e = end(); for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;) { if (__pred(__i.__ptr_->__next_->__value_)) { iterator __j = _VSTD::next(__i, 2); for (; __j != __e && __pred(*__j); ++__j) ; erase_after(__i, __j); if (__j == __e) break; __i = __j; } else ++__i; } } template template void forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) { for (iterator __i = begin(), __e = end(); __i != __e;) { iterator __j = _VSTD::next(__i); for (; __j != __e && __binary_pred(*__i, *__j); ++__j) ; if (__i.__ptr_->__next_ != __j.__ptr_) erase_after(__i, __j); __i = __j; } } template template void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) { if (this != &__x) { base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp); __x.__before_begin()->__next_ = nullptr; } } template template typename forward_list<_Tp, _Alloc>::__node_pointer forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp) { if (__f1 == nullptr) return __f2; if (__f2 == nullptr) return __f1; __node_pointer __r; if (__comp(__f2->__value_, __f1->__value_)) { __node_pointer __t = __f2; while (__t->__next_ != nullptr && __comp(__t->__next_->__value_, __f1->__value_)) __t = __t->__next_; __r = __f2; __f2 = __t->__next_; __t->__next_ = __f1; } else __r = __f1; __node_pointer __p = __f1; __f1 = __f1->__next_; while (__f1 != nullptr && __f2 != nullptr) { if (__comp(__f2->__value_, __f1->__value_)) { __node_pointer __t = __f2; while (__t->__next_ != nullptr && __comp(__t->__next_->__value_, __f1->__value_)) __t = __t->__next_; __p->__next_ = __f2; __f2 = __t->__next_; __t->__next_ = __f1; } __p = __f1; __f1 = __f1->__next_; } if (__f2 != nullptr) __p->__next_ = __f2; return __r; } template template inline _LIBCPP_INLINE_VISIBILITY void forward_list<_Tp, _Alloc>::sort(_Compare __comp) { base::__before_begin()->__next_ = __sort(base::__before_begin()->__next_, _VSTD::distance(begin(), end()), __comp); } template template typename forward_list<_Tp, _Alloc>::__node_pointer forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Compare& __comp) { switch (__sz) { case 0: case 1: return __f1; case 2: if (__comp(__f1->__next_->__value_, __f1->__value_)) { __node_pointer __t = __f1->__next_; __t->__next_ = __f1; __f1->__next_ = nullptr; __f1 = __t; } return __f1; } difference_type __sz1 = __sz / 2; difference_type __sz2 = __sz - __sz1; __node_pointer __t = _VSTD::next(iterator(__f1), __sz1 - 1).__ptr_; __node_pointer __f2 = __t->__next_; __t->__next_ = nullptr; return __merge(__sort(__f1, __sz1, __comp), __sort(__f2, __sz2, __comp), __comp); } template void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT { __node_pointer __p = base::__before_begin()->__next_; if (__p != nullptr) { __node_pointer __f = __p->__next_; __p->__next_ = nullptr; while (__f != nullptr) { __node_pointer __t = __f->__next_; __f->__next_ = __p; __p = __f; __f = __t; } base::__before_begin()->__next_ = __p; } } template bool operator==(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { typedef forward_list<_Tp, _Alloc> _Cp; typedef typename _Cp::const_iterator _Ip; _Ip __ix = __x.begin(); _Ip __ex = __x.end(); _Ip __iy = __y.begin(); _Ip __ey = __y.end(); for (; __ix != __ex && __iy != __ey; ++__ix, ++__iy) if (!(*__ix == *__iy)) return false; return (__ix == __ex) == (__iy == __ey); } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { return !(__x == __y); } template inline _LIBCPP_INLINE_VISIBILITY bool operator< (const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } template inline _LIBCPP_INLINE_VISIBILITY bool operator> (const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { return __y < __x; } template inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { return !(__x < __y); } template inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { return !(__y < __x); } template inline _LIBCPP_INLINE_VISIBILITY void swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_FORWARD_LIST libcxx/include/__hash_table0000644000175000017500000024532112266757731017216 0ustar sylvestresylvestre// -*- 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. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP__HASH_TABLE #define _LIBCPP__HASH_TABLE #include <__config> #include #include #include #include #include #include <__undef_min_max> #ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_FUNC_VIS size_t __next_prime(size_t __n); template struct __hash_node_base { typedef __hash_node_base __first_node; _NodePtr __next_; _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {} }; template struct __hash_node : public __hash_node_base < typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__hash_node<_Tp, _VoidPtr> > #else rebind<__hash_node<_Tp, _VoidPtr> >::other #endif > { typedef _Tp value_type; size_t __hash_; value_type __value_; }; inline _LIBCPP_INLINE_VISIBILITY bool __is_power2(size_t __bc) { return __bc > 2 && !(__bc & (__bc - 1)); } inline _LIBCPP_INLINE_VISIBILITY size_t __constrain_hash(size_t __h, size_t __bc) { return !(__bc & (__bc - 1)) ? __h & (__bc - 1) : __h % __bc; } inline _LIBCPP_INLINE_VISIBILITY size_t __next_pow2(size_t __n) { return size_t(1) << (std::numeric_limits::digits - __clz(__n-1)); } 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 { typedef _NodePtr __node_pointer; __node_pointer __node_; public: typedef forward_iterator_tag iterator_category; typedef typename pointer_traits<__node_pointer>::element_type::value_type value_type; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef value_type& reference; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 : __node_(nullptr) #endif { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_i(this); #endif } #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_iterator(const __hash_iterator& __i) : __node_(__i.__node_) { __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY ~__hash_iterator() { __get_db()->__erase_i(this); } _LIBCPP_INLINE_VISIBILITY __hash_iterator& operator=(const __hash_iterator& __i) { if (this != &__i) { __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; } return *this; } #endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container iterator"); #endif return __node_->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container iterator"); #endif return pointer_traits::pointer_to(__node_->__value_); } _LIBCPP_INLINE_VISIBILITY __hash_iterator& operator++() { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to increment non-incrementable unordered container iterator"); #endif __node_ = __node_->__next_; return *this; } _LIBCPP_INLINE_VISIBILITY __hash_iterator operator++(int) { __hash_iterator __t(*this); ++(*this); return __t; } friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_iterator& __x, const __hash_iterator& __y) { return __x.__node_ == __y.__node_; } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_iterator& __x, const __hash_iterator& __y) {return !(__x == __y);} private: #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_iterator(__node_pointer __node, const void* __c) _NOEXCEPT : __node_(__node) { __get_db()->__insert_ic(this, __c); } #else _LIBCPP_INLINE_VISIBILITY __hash_iterator(__node_pointer __node) _NOEXCEPT : __node_(__node) {} #endif template friend class __hash_table; template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; template class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator { typedef _ConstNodePtr __node_pointer; __node_pointer __node_; typedef typename remove_const< typename pointer_traits<__node_pointer>::element_type >::type __node; public: typedef forward_iterator_tag iterator_category; typedef typename __node::value_type value_type; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef const value_type& reference; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__node> #else rebind<__node>::other #endif __non_const_node_pointer; typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator; _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 : __node_(nullptr) #endif { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_i(this); #endif } _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__iterator_copy(this, &__x); #endif } #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(const __hash_const_iterator& __i) : __node_(__i.__node_) { __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY ~__hash_const_iterator() { __get_db()->__erase_i(this); } _LIBCPP_INLINE_VISIBILITY __hash_const_iterator& operator=(const __hash_const_iterator& __i) { if (this != &__i) { __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; } return *this; } #endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container const_iterator"); #endif return __node_->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container const_iterator"); #endif return pointer_traits::pointer_to(__node_->__value_); } _LIBCPP_INLINE_VISIBILITY __hash_const_iterator& operator++() { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to increment non-incrementable unordered container const_iterator"); #endif __node_ = __node_->__next_; return *this; } _LIBCPP_INLINE_VISIBILITY __hash_const_iterator operator++(int) { __hash_const_iterator __t(*this); ++(*this); return __t; } friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_const_iterator& __x, const __hash_const_iterator& __y) { return __x.__node_ == __y.__node_; } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_const_iterator& __x, const __hash_const_iterator& __y) {return !(__x == __y);} private: #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(__node_pointer __node, const void* __c) _NOEXCEPT : __node_(__node) { __get_db()->__insert_ic(this, __c); } #else _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(__node_pointer __node) _NOEXCEPT : __node_(__node) {} #endif template friend class __hash_table; template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; template class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; template class _LIBCPP_TYPE_VIS_ONLY __hash_local_iterator { typedef _NodePtr __node_pointer; __node_pointer __node_; size_t __bucket_; size_t __bucket_count_; typedef pointer_traits<__node_pointer> __pointer_traits; public: typedef forward_iterator_tag iterator_category; typedef typename __pointer_traits::element_type::value_type value_type; typedef typename __pointer_traits::difference_type difference_type; typedef value_type& reference; typedef typename __pointer_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_i(this); #endif } #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_local_iterator(const __hash_local_iterator& __i) : __node_(__i.__node_), __bucket_(__i.__bucket_), __bucket_count_(__i.__bucket_count_) { __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY ~__hash_local_iterator() { __get_db()->__erase_i(this); } _LIBCPP_INLINE_VISIBILITY __hash_local_iterator& operator=(const __hash_local_iterator& __i) { if (this != &__i) { __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; __bucket_ = __i.__bucket_; __bucket_count_ = __i.__bucket_count_; } return *this; } #endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container local_iterator"); #endif return __node_->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container local_iterator"); #endif return pointer_traits::pointer_to(__node_->__value_); } _LIBCPP_INLINE_VISIBILITY __hash_local_iterator& operator++() { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to increment non-incrementable unordered container local_iterator"); #endif __node_ = __node_->__next_; if (__node_ != nullptr && __constrain_hash(__node_->__hash_, __bucket_count_) != __bucket_) __node_ = nullptr; return *this; } _LIBCPP_INLINE_VISIBILITY __hash_local_iterator operator++(int) { __hash_local_iterator __t(*this); ++(*this); return __t; } friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_local_iterator& __x, const __hash_local_iterator& __y) { return __x.__node_ == __y.__node_; } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_local_iterator& __x, const __hash_local_iterator& __y) {return !(__x == __y);} private: #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_local_iterator(__node_pointer __node, size_t __bucket, size_t __bucket_count, const void* __c) _NOEXCEPT : __node_(__node), __bucket_(__bucket), __bucket_count_(__bucket_count) { __get_db()->__insert_ic(this, __c); if (__node_ != nullptr) __node_ = __node_->__next_; } #else _LIBCPP_INLINE_VISIBILITY __hash_local_iterator(__node_pointer __node, size_t __bucket, size_t __bucket_count) _NOEXCEPT : __node_(__node), __bucket_(__bucket), __bucket_count_(__bucket_count) { if (__node_ != nullptr) __node_ = __node_->__next_; } #endif template friend class __hash_table; template friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; }; template class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator { typedef _ConstNodePtr __node_pointer; __node_pointer __node_; size_t __bucket_; size_t __bucket_count_; typedef pointer_traits<__node_pointer> __pointer_traits; typedef typename __pointer_traits::element_type __node; typedef typename remove_const<__node>::type __non_const_node; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__non_const_node> #else rebind<__non_const_node>::other #endif __non_const_node_pointer; typedef __hash_local_iterator<__non_const_node_pointer> __non_const_iterator; public: typedef forward_iterator_tag iterator_category; typedef typename remove_const< typename __pointer_traits::element_type::value_type >::type value_type; typedef typename __pointer_traits::difference_type difference_type; typedef const value_type& reference; typedef typename __pointer_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_i(this); #endif } _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_), __bucket_(__x.__bucket_), __bucket_count_(__x.__bucket_count_) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__iterator_copy(this, &__x); #endif } #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(const __hash_const_local_iterator& __i) : __node_(__i.__node_), __bucket_(__i.__bucket_), __bucket_count_(__i.__bucket_count_) { __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY ~__hash_const_local_iterator() { __get_db()->__erase_i(this); } _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i) { if (this != &__i) { __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; __bucket_ = __i.__bucket_; __bucket_count_ = __i.__bucket_count_; } return *this; } #endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); #endif return __node_->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); #endif return pointer_traits::pointer_to(__node_->__value_); } _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator& operator++() { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to increment non-incrementable unordered container const_local_iterator"); #endif __node_ = __node_->__next_; if (__node_ != nullptr && __constrain_hash(__node_->__hash_, __bucket_count_) != __bucket_) __node_ = nullptr; return *this; } _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator operator++(int) { __hash_const_local_iterator __t(*this); ++(*this); return __t; } friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) { return __x.__node_ == __y.__node_; } friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) {return !(__x == __y);} private: #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(__node_pointer __node, size_t __bucket, size_t __bucket_count, const void* __c) _NOEXCEPT : __node_(__node), __bucket_(__bucket), __bucket_count_(__bucket_count) { __get_db()->__insert_ic(this, __c); if (__node_ != nullptr) __node_ = __node_->__next_; } #else _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(__node_pointer __node, size_t __bucket, size_t __bucket_count) _NOEXCEPT : __node_(__node), __bucket_(__bucket), __bucket_count_(__bucket_count) { if (__node_ != nullptr) __node_ = __node_->__next_; } #endif template friend class __hash_table; template friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; }; template class __bucket_list_deallocator { typedef _Alloc allocator_type; typedef allocator_traits __alloc_traits; typedef typename __alloc_traits::size_type size_type; __compressed_pair __data_; public: typedef typename __alloc_traits::pointer pointer; _LIBCPP_INLINE_VISIBILITY __bucket_list_deallocator() _NOEXCEPT_(is_nothrow_default_constructible::value) : __data_(0) {} _LIBCPP_INLINE_VISIBILITY __bucket_list_deallocator(const allocator_type& __a, size_type __size) _NOEXCEPT_(is_nothrow_copy_constructible::value) : __data_(__size, __a) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY __bucket_list_deallocator(__bucket_list_deallocator&& __x) _NOEXCEPT_(is_nothrow_move_constructible::value) : __data_(_VSTD::move(__x.__data_)) { __x.size() = 0; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY size_type& size() _NOEXCEPT {return __data_.first();} _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT {return __data_.first();} _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT {return __data_.second();} _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return __data_.second();} _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { __alloc_traits::deallocate(__alloc(), __p, size()); } }; template class __hash_map_node_destructor; template class __hash_node_destructor { typedef _Alloc allocator_type; typedef allocator_traits __alloc_traits; typedef typename __alloc_traits::value_type::value_type value_type; public: typedef typename __alloc_traits::pointer pointer; private: allocator_type& __na_; __hash_node_destructor& operator=(const __hash_node_destructor&); public: bool __value_constructed; _LIBCPP_INLINE_VISIBILITY explicit __hash_node_destructor(allocator_type& __na, bool __constructed = false) _NOEXCEPT : __na_(__na), __value_constructed(__constructed) {} _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { if (__value_constructed) __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_)); if (__p) __alloc_traits::deallocate(__na_, __p, 1); } template friend class __hash_map_node_destructor; }; template class __hash_table { public: typedef _Tp value_type; typedef _Hash hasher; typedef _Equal key_equal; typedef _Alloc allocator_type; private: typedef allocator_traits __alloc_traits; public: typedef value_type& reference; typedef const value_type& const_reference; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; typedef typename __alloc_traits::size_type size_type; typedef typename __alloc_traits::difference_type difference_type; 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 allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; typedef typename __node_traits::pointer __node_const_pointer; typedef __hash_node_base<__node_pointer> __first_node; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__first_node> #else rebind<__first_node>::other #endif __node_base_pointer; 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 __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; typedef typename __bucket_list_deleter::pointer __node_pointer_pointer; // --- Member data begin --- __bucket_list __bucket_list_; __compressed_pair<__first_node, __node_allocator> __p1_; __compressed_pair __p2_; __compressed_pair __p3_; // --- Member data end --- _LIBCPP_INLINE_VISIBILITY size_type& size() _NOEXCEPT {return __p2_.first();} public: _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT {return __p2_.first();} _LIBCPP_INLINE_VISIBILITY hasher& hash_function() _NOEXCEPT {return __p2_.second();} _LIBCPP_INLINE_VISIBILITY const hasher& hash_function() const _NOEXCEPT {return __p2_.second();} _LIBCPP_INLINE_VISIBILITY float& max_load_factor() _NOEXCEPT {return __p3_.first();} _LIBCPP_INLINE_VISIBILITY float max_load_factor() const _NOEXCEPT {return __p3_.first();} _LIBCPP_INLINE_VISIBILITY key_equal& key_eq() _NOEXCEPT {return __p3_.second();} _LIBCPP_INLINE_VISIBILITY const key_equal& key_eq() const _NOEXCEPT {return __p3_.second();} _LIBCPP_INLINE_VISIBILITY __node_allocator& __node_alloc() _NOEXCEPT {return __p1_.second();} _LIBCPP_INLINE_VISIBILITY const __node_allocator& __node_alloc() const _NOEXCEPT {return __p1_.second();} public: typedef __hash_iterator<__node_pointer> iterator; typedef __hash_const_iterator<__node_pointer> const_iterator; typedef __hash_local_iterator<__node_pointer> local_iterator; typedef __hash_const_local_iterator<__node_pointer> const_local_iterator; __hash_table() _NOEXCEPT_( is_nothrow_default_constructible<__bucket_list>::value && is_nothrow_default_constructible<__first_node>::value && is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_default_constructible::value && is_nothrow_default_constructible::value); __hash_table(const hasher& __hf, const key_equal& __eql); __hash_table(const hasher& __hf, const key_equal& __eql, const allocator_type& __a); explicit __hash_table(const allocator_type& __a); __hash_table(const __hash_table& __u); __hash_table(const __hash_table& __u, const allocator_type& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __hash_table(__hash_table&& __u) _NOEXCEPT_( is_nothrow_move_constructible<__bucket_list>::value && is_nothrow_move_constructible<__first_node>::value && is_nothrow_move_constructible<__node_allocator>::value && is_nothrow_move_constructible::value && is_nothrow_move_constructible::value); __hash_table(__hash_table&& __u, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~__hash_table(); __hash_table& operator=(const __hash_table& __u); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __hash_table& operator=(__hash_table&& __u) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable<__node_allocator>::value && is_nothrow_move_assignable::value && is_nothrow_move_assignable::value); #endif template void __assign_unique(_InputIterator __first, _InputIterator __last); template void __assign_multi(_InputIterator __first, _InputIterator __last); _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT { return allocator_traits<__pointer_allocator>::max_size( __bucket_list_.get_deleter().__alloc()); } pair __node_insert_unique(__node_pointer __nd); iterator __node_insert_multi(__node_pointer __nd); iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) template pair __emplace_unique(_Args&&... __args); template iterator __emplace_multi(_Args&&... __args); template iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) pair __insert_unique(const value_type& __x); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template pair __insert_unique(_Pp&& __x); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template iterator __insert_multi(_Pp&& __x); template iterator __insert_multi(const_iterator __p, _Pp&& __x); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES iterator __insert_multi(const value_type& __x); iterator __insert_multi(const_iterator __p, const value_type& __x); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void clear() _NOEXCEPT; void rehash(size_type __n); _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) {rehash(static_cast(ceil(__n / max_load_factor())));} _LIBCPP_INLINE_VISIBILITY size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); } iterator begin() _NOEXCEPT; iterator end() _NOEXCEPT; const_iterator begin() const _NOEXCEPT; const_iterator end() const _NOEXCEPT; template _LIBCPP_INLINE_VISIBILITY size_type bucket(const _Key& __k) const { _LIBCPP_ASSERT(bucket_count() > 0, "unordered container::bucket(key) called when bucket_count() == 0"); return __constrain_hash(hash_function()(__k), bucket_count()); } template iterator find(const _Key& __x); template const_iterator find(const _Key& __x) const; typedef __hash_node_destructor<__node_allocator> _Dp; typedef unique_ptr<__node, _Dp> __node_holder; iterator erase(const_iterator __p); iterator erase(const_iterator __first, const_iterator __last); template size_type __erase_unique(const _Key& __k); template size_type __erase_multi(const _Key& __k); __node_holder remove(const_iterator __p) _NOEXCEPT; template size_type __count_unique(const _Key& __k) const; template size_type __count_multi(const _Key& __k) const; template pair __equal_range_unique(const _Key& __k); template pair __equal_range_unique(const _Key& __k) const; template pair __equal_range_multi(const _Key& __k); template pair __equal_range_multi(const _Key& __k) const; 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); _LIBCPP_INLINE_VISIBILITY size_type max_bucket_count() const _NOEXCEPT {return __pointer_alloc_traits::max_size(__bucket_list_.get_deleter().__alloc());} size_type bucket_size(size_type __n) const; _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT { size_type __bc = bucket_count(); return __bc != 0 ? (float)size() / __bc : 0.f; } _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT { _LIBCPP_ASSERT(__mlf > 0, "unordered container::max_load_factor(lf) called with lf <= 0"); max_load_factor() = _VSTD::max(__mlf, load_factor()); } _LIBCPP_INLINE_VISIBILITY local_iterator begin(size_type __n) { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::begin(n) called with n >= bucket_count()"); #if _LIBCPP_DEBUG_LEVEL >= 2 return local_iterator(__bucket_list_[__n], __n, bucket_count(), this); #else return local_iterator(__bucket_list_[__n], __n, bucket_count()); #endif } _LIBCPP_INLINE_VISIBILITY local_iterator end(size_type __n) { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::end(n) called with n >= bucket_count()"); #if _LIBCPP_DEBUG_LEVEL >= 2 return local_iterator(nullptr, __n, bucket_count(), this); #else return local_iterator(nullptr, __n, bucket_count()); #endif } _LIBCPP_INLINE_VISIBILITY const_local_iterator cbegin(size_type __n) const { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::cbegin(n) called with n >= bucket_count()"); #if _LIBCPP_DEBUG_LEVEL >= 2 return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this); #else return const_local_iterator(__bucket_list_[__n], __n, bucket_count()); #endif } _LIBCPP_INLINE_VISIBILITY const_local_iterator cend(size_type __n) const { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::cend(n) called with n >= bucket_count()"); #if _LIBCPP_DEBUG_LEVEL >= 2 return const_local_iterator(nullptr, __n, bucket_count(), this); #else return const_local_iterator(nullptr, __n, bucket_count()); #endif } #if _LIBCPP_DEBUG_LEVEL >= 2 bool __dereferenceable(const const_iterator* __i) const; bool __decrementable(const const_iterator* __i) const; bool __addable(const const_iterator* __i, ptrdiff_t __n) const; bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; #endif // _LIBCPP_DEBUG_LEVEL >= 2 private: void __rehash(size_type __n); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template __node_holder __construct_node(_Args&& ...__args); #endif // _LIBCPP_HAS_NO_VARIADICS __node_holder __construct_node(value_type&& __v, size_t __hash); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES __node_holder __construct_node(const value_type& __v); #endif __node_holder __construct_node(const value_type& __v, size_t __hash); _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __hash_table& __u) {__copy_assign_alloc(__u, integral_constant());} void __copy_assign_alloc(const __hash_table& __u, true_type); _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __hash_table&, false_type) {} void __move_assign(__hash_table& __u, false_type); void __move_assign(__hash_table& __u, true_type) _NOEXCEPT_( is_nothrow_move_assignable<__node_allocator>::value && is_nothrow_move_assignable::value && is_nothrow_move_assignable::value); _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__hash_table& __u) _NOEXCEPT_( !__node_traits::propagate_on_container_move_assignment::value || (is_nothrow_move_assignable<__pointer_allocator>::value && is_nothrow_move_assignable<__node_allocator>::value)) {__move_assign_alloc(__u, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__hash_table& __u, true_type) _NOEXCEPT_( is_nothrow_move_assignable<__pointer_allocator>::value && is_nothrow_move_assignable<__node_allocator>::value) { __bucket_list_.get_deleter().__alloc() = _VSTD::move(__u.__bucket_list_.get_deleter().__alloc()); __node_alloc() = _VSTD::move(__u.__node_alloc()); } _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; template friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; template friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; template inline _LIBCPP_INLINE_VISIBILITY __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() _NOEXCEPT_( is_nothrow_default_constructible<__bucket_list>::value && is_nothrow_default_constructible<__first_node>::value && is_nothrow_default_constructible::value && is_nothrow_default_constructible::value) : __p2_(0), __p3_(1.0f) { } template inline _LIBCPP_INLINE_VISIBILITY __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql) : __bucket_list_(nullptr, __bucket_list_deleter()), __p1_(), __p2_(0, __hf), __p3_(1.0f, __eql) { } template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), __p1_(__node_allocator(__a)), __p2_(0, __hf), __p3_(1.0f, __eql) { } template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), __p1_(__node_allocator(__a)), __p2_(0), __p3_(1.0f) { } template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) : __bucket_list_(nullptr, __bucket_list_deleter(allocator_traits<__pointer_allocator>:: select_on_container_copy_construction( __u.__bucket_list_.get_deleter().__alloc()), 0)), __p1_(allocator_traits<__node_allocator>:: select_on_container_copy_construction(__u.__node_alloc())), __p2_(0, __u.hash_function()), __p3_(__u.__p3_) { } template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), __p1_(__node_allocator(__a)), __p2_(0, __u.hash_function()), __p3_(__u.__p3_) { } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_( is_nothrow_move_constructible<__bucket_list>::value && is_nothrow_move_constructible<__first_node>::value && is_nothrow_move_constructible::value && is_nothrow_move_constructible::value) : __bucket_list_(_VSTD::move(__u.__bucket_list_)), __p1_(_VSTD::move(__u.__p1_)), __p2_(_VSTD::move(__u.__p2_)), __p3_(_VSTD::move(__u.__p3_)) { if (size() > 0) { __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __u.__p1_.first().__next_ = nullptr; __u.size() = 0; } } template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), __p1_(__node_allocator(__a)), __p2_(0, _VSTD::move(__u.hash_function())), __p3_(_VSTD::move(__u.__p3_)) { if (__a == allocator_type(__u.__node_alloc())) { __bucket_list_.reset(__u.__bucket_list_.release()); __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); __u.__bucket_list_.get_deleter().size() = 0; if (__u.size() > 0) { __p1_.first().__next_ = __u.__p1_.first().__next_; __u.__p1_.first().__next_ = nullptr; __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); size() = __u.size(); __u.size() = 0; } } } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { __deallocate(__p1_.first().__next_); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__erase_c(this); #endif } template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc( const __hash_table& __u, true_type) { if (__node_alloc() != __u.__node_alloc()) { clear(); __bucket_list_.reset(); __bucket_list_.get_deleter().size() = 0; } __bucket_list_.get_deleter().__alloc() = __u.__bucket_list_.get_deleter().__alloc(); __node_alloc() = __u.__node_alloc(); } template __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u) { if (this != &__u) { __copy_assign_alloc(__u); hash_function() = __u.hash_function(); key_eq() = __u.key_eq(); max_load_factor() = __u.max_load_factor(); __assign_multi(__u.begin(), __u.end()); } return *this; } template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np) _NOEXCEPT { __node_allocator& __na = __node_alloc(); while (__np != nullptr) { __node_pointer __next = __np->__next_; #if _LIBCPP_DEBUG_LEVEL >= 2 __c_node* __c = __get_db()->__find_c_and_lock(this); for (__i_node** __p = __c->end_; __p != __c->beg_; ) { --__p; iterator* __i = static_cast((*__p)->__i_); if (__i->__node_ == __np) { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); #endif __node_traits::destroy(__na, _VSTD::addressof(__np->__value_)); __node_traits::deallocate(__na, __np, 1); __np = __next; } } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_pointer __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT { size_type __bc = bucket_count(); for (size_type __i = 0; __i < __bc; ++__i) __bucket_list_[__i] = nullptr; size() = 0; __node_pointer __cache = __p1_.first().__next_; __p1_.first().__next_ = nullptr; return __cache; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __hash_table& __u, true_type) _NOEXCEPT_( is_nothrow_move_assignable<__node_allocator>::value && is_nothrow_move_assignable::value && is_nothrow_move_assignable::value) { clear(); __bucket_list_.reset(__u.__bucket_list_.release()); __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); __u.__bucket_list_.get_deleter().size() = 0; __move_assign_alloc(__u); size() = __u.size(); hash_function() = _VSTD::move(__u.hash_function()); max_load_factor() = __u.max_load_factor(); key_eq() = _VSTD::move(__u.key_eq()); __p1_.first().__next_ = __u.__p1_.first().__next_; if (size() > 0) { __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __u.__p1_.first().__next_ = nullptr; __u.size() = 0; } #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->swap(this, &__u); #endif } template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __hash_table& __u, false_type) { if (__node_alloc() == __u.__node_alloc()) __move_assign(__u, true_type()); else { hash_function() = _VSTD::move(__u.hash_function()); key_eq() = _VSTD::move(__u.key_eq()); max_load_factor() = __u.max_load_factor(); if (bucket_count() != 0) { __node_pointer __cache = __detach(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS const_iterator __i = __u.begin(); while (__cache != nullptr && __u.size() != 0) { __cache->__value_ = _VSTD::move(__u.remove(__i++)->__value_); __node_pointer __next = __cache->__next_; __node_insert_multi(__cache); __cache = __next; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __deallocate(__cache); throw; } #endif // _LIBCPP_NO_EXCEPTIONS __deallocate(__cache); } const_iterator __i = __u.begin(); while (__u.size() != 0) { __node_holder __h = __construct_node(_VSTD::move(__u.remove(__i++)->__value_)); __node_insert_multi(__h.get()); __h.release(); } } } template inline _LIBCPP_INLINE_VISIBILITY __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable<__node_allocator>::value && is_nothrow_move_assignable::value && is_nothrow_move_assignable::value) { __move_assign(__u, integral_constant()); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, _InputIterator __last) { if (bucket_count() != 0) { __node_pointer __cache = __detach(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__value_ = *__first; __node_pointer __next = __cache->__next_; __node_insert_unique(__cache); __cache = __next; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __deallocate(__cache); throw; } #endif // _LIBCPP_NO_EXCEPTIONS __deallocate(__cache); } for (; __first != __last; ++__first) __insert_unique(*__first); } template template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, _InputIterator __last) { if (bucket_count() != 0) { __node_pointer __cache = __detach(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__value_ = *__first; __node_pointer __next = __cache->__next_; __node_insert_multi(__cache); __cache = __next; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __deallocate(__cache); throw; } #endif // _LIBCPP_NO_EXCEPTIONS __deallocate(__cache); } for (; __first != __last; ++__first) __insert_multi(*__first); } template inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(__p1_.first().__next_, this); #else return iterator(__p1_.first().__next_); #endif } template inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(nullptr, this); #else return iterator(nullptr); #endif } template inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 return const_iterator(__p1_.first().__next_, this); #else return const_iterator(__p1_.first().__next_); #endif } template inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 return const_iterator(nullptr, this); #else return const_iterator(nullptr); #endif } template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT { if (size() > 0) { __deallocate(__p1_.first().__next_); __p1_.first().__next_ = nullptr; size_type __bc = bucket_count(); for (size_type __i = 0; __i < __bc; ++__i) __bucket_list_[__i] = nullptr; size() = 0; } } template pair::iterator, bool> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __nd) { __nd->__hash_ = hash_function()(__nd->__value_); size_type __bc = bucket_count(); bool __inserted = false; __node_pointer __ndptr; size_t __chash; if (__bc != 0) { __chash = __constrain_hash(__nd->__hash_, __bc); __ndptr = __bucket_list_[__chash]; if (__ndptr != nullptr) { for (__ndptr = __ndptr->__next_; __ndptr != nullptr && __constrain_hash(__ndptr->__hash_, __bc) == __chash; __ndptr = __ndptr->__next_) { if (key_eq()(__ndptr->__value_, __nd->__value_)) goto __done; } } } { if (size()+1 > __bc * max_load_factor() || __bc == 0) { rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); __chash = __constrain_hash(__nd->__hash_, __bc); } // insert_after __bucket_list_[__chash], or __first_node if bucket is null __node_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __nd->__next_ = __pn->__next_; __pn->__next_ = __nd; // fix up __bucket_list_ __bucket_list_[__chash] = __pn; if (__nd->__next_ != nullptr) __bucket_list_[__constrain_hash(__nd->__next_->__hash_, __bc)] = __nd; } else { __nd->__next_ = __pn->__next_; __pn->__next_ = __nd; } __ndptr = __nd; // increment size ++size(); __inserted = true; } __done: #if _LIBCPP_DEBUG_LEVEL >= 2 return pair(iterator(__ndptr, this), __inserted); #else return pair(iterator(__ndptr), __inserted); #endif } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __cp) { __cp->__hash_ = hash_function()(__cp->__value_); size_type __bc = bucket_count(); if (size()+1 > __bc * max_load_factor() || __bc == 0) { rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } size_t __chash = __constrain_hash(__cp->__hash_, __bc); __node_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __cp->__next_ = __pn->__next_; __pn->__next_ = __cp; // fix up __bucket_list_ __bucket_list_[__chash] = __pn; if (__cp->__next_ != nullptr) __bucket_list_[__constrain_hash(__cp->__next_->__hash_, __bc)] = __cp; } else { for (bool __found = false; __pn->__next_ != nullptr && __constrain_hash(__pn->__next_->__hash_, __bc) == __chash; __pn = __pn->__next_) { // __found key_eq() action // false false loop // true true loop // false true set __found to true // true false break if (__found != (__pn->__next_->__hash_ == __cp->__hash_ && key_eq()(__pn->__next_->__value_, __cp->__value_))) { if (!__found) __found = true; else break; } } __cp->__next_ = __pn->__next_; __pn->__next_ = __cp; if (__cp->__next_ != nullptr) { size_t __nhash = __constrain_hash(__cp->__next_->__hash_, __bc); if (__nhash != __chash) __bucket_list_[__nhash] = __cp; } } ++size(); #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(__cp, this); #else return iterator(__cp); #endif } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( const_iterator __p, __node_pointer __cp) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" " referring to this unordered container"); #endif if (__p != end() && key_eq()(*__p, __cp->__value_)) { __node_pointer __np = __p.__node_; __cp->__hash_ = __np->__hash_; size_type __bc = bucket_count(); if (size()+1 > __bc * max_load_factor() || __bc == 0) { rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } size_t __chash = __constrain_hash(__cp->__hash_, __bc); __node_pointer __pp = __bucket_list_[__chash]; while (__pp->__next_ != __np) __pp = __pp->__next_; __cp->__next_ = __np; __pp->__next_ = __cp; ++size(); #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(__cp, this); #else return iterator(__cp); #endif } return __node_insert_multi(__cp); } template pair::iterator, bool> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x) { size_t __hash = hash_function()(__x); size_type __bc = bucket_count(); bool __inserted = false; __node_pointer __nd; size_t __chash; if (__bc != 0) { __chash = __constrain_hash(__hash, __bc); __nd = __bucket_list_[__chash]; if (__nd != nullptr) { for (__nd = __nd->__next_; __nd != nullptr && __constrain_hash(__nd->__hash_, __bc) == __chash; __nd = __nd->__next_) { if (key_eq()(__nd->__value_, __x)) goto __done; } } } { __node_holder __h = __construct_node(__x, __hash); if (size()+1 > __bc * max_load_factor() || __bc == 0) { rehash(_VSTD::max(2 * __bc + !__is_power2(__bc), size_type(ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); __chash = __constrain_hash(__hash, __bc); } // insert_after __bucket_list_[__chash], or __first_node if bucket is null __node_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); __h->__next_ = __pn->__next_; __pn->__next_ = __h.get(); // fix up __bucket_list_ __bucket_list_[__chash] = __pn; if (__h->__next_ != nullptr) __bucket_list_[__constrain_hash(__h->__next_->__hash_, __bc)] = __h.get(); } else { __h->__next_ = __pn->__next_; __pn->__next_ = __h.get(); } __nd = __h.release(); // increment size ++size(); __inserted = true; } __done: #if _LIBCPP_DEBUG_LEVEL >= 2 return pair(iterator(__nd, this), __inserted); #else return pair(iterator(__nd), __inserted); #endif } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template template pair::iterator, bool> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique(_Args&&... __args) { __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); pair __r = __node_insert_unique(__h.get()); if (__r.second) __h.release(); return __r; } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_multi(_Args&&... __args) { __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); iterator __r = __node_insert_multi(__h.get()); __h.release(); return __r; } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( const_iterator __p, _Args&&... __args) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" " referring to this unordered container"); #endif __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); iterator __r = __node_insert_multi(__p, __h.get()); __h.release(); return __r; } #endif // _LIBCPP_HAS_NO_VARIADICS template template pair::iterator, bool> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(_Pp&& __x) { __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x)); pair __r = __node_insert_unique(__h.get()); if (__r.second) __h.release(); return __r; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(_Pp&& __x) { __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x)); iterator __r = __node_insert_multi(__h.get()); __h.release(); return __r; } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p, _Pp&& __x) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container::insert(const_iterator, rvalue) called with an iterator not" " referring to this unordered container"); #endif __node_holder __h = __construct_node(_VSTD::forward<_Pp>(__x)); iterator __r = __node_insert_multi(__p, __h.get()); __h.release(); return __r; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const value_type& __x) { __node_holder __h = __construct_node(__x); iterator __r = __node_insert_multi(__h.get()); __h.release(); return __r; } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p, const value_type& __x) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container::insert(const_iterator, lvalue) called with an iterator not" " referring to this unordered container"); #endif __node_holder __h = __construct_node(__x); iterator __r = __node_insert_multi(__p, __h.get()); __h.release(); return __r; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n) { if (__n == 1) __n = 2; else if (__n & (__n - 1)) __n = __next_prime(__n); size_type __bc = bucket_count(); if (__n > __bc) __rehash(__n); else if (__n < __bc) { __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()))) ); if (__n < __bc) __rehash(__n); } } template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__invalidate_all(this); #endif // _LIBCPP_DEBUG_LEVEL >= 2 __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); __bucket_list_.reset(__nbc > 0 ? __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); __bucket_list_.get_deleter().size() = __nbc; if (__nbc > 0) { for (size_type __i = 0; __i < __nbc; ++__i) __bucket_list_[__i] = nullptr; __node_pointer __pp(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()))); __node_pointer __cp = __pp->__next_; if (__cp != nullptr) { size_type __chash = __constrain_hash(__cp->__hash_, __nbc); __bucket_list_[__chash] = __pp; size_type __phash = __chash; for (__pp = __cp, __cp = __cp->__next_; __cp != nullptr; __cp = __pp->__next_) { __chash = __constrain_hash(__cp->__hash_, __nbc); if (__chash == __phash) __pp = __cp; else { if (__bucket_list_[__chash] == nullptr) { __bucket_list_[__chash] = __pp; __pp = __cp; __phash = __chash; } else { __node_pointer __np = __cp; for (; __np->__next_ != nullptr && key_eq()(__cp->__value_, __np->__next_->__value_); __np = __np->__next_) ; __pp->__next_ = __np->__next_; __np->__next_ = __bucket_list_[__chash]->__next_; __bucket_list_[__chash]->__next_ = __cp; } } } } } } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) { size_t __hash = hash_function()(__k); size_type __bc = bucket_count(); if (__bc != 0) { size_t __chash = __constrain_hash(__hash, __bc); __node_pointer __nd = __bucket_list_[__chash]; if (__nd != nullptr) { for (__nd = __nd->__next_; __nd != nullptr && __constrain_hash(__nd->__hash_, __bc) == __chash; __nd = __nd->__next_) { if (key_eq()(__nd->__value_, __k)) #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(__nd, this); #else return iterator(__nd); #endif } } } return end(); } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const { size_t __hash = hash_function()(__k); size_type __bc = bucket_count(); if (__bc != 0) { size_t __chash = __constrain_hash(__hash, __bc); __node_const_pointer __nd = __bucket_list_[__chash]; if (__nd != nullptr) { for (__nd = __nd->__next_; __nd != nullptr && __constrain_hash(__nd->__hash_, __bc) == __chash; __nd = __nd->__next_) { if (key_eq()(__nd->__value_, __k)) #if _LIBCPP_DEBUG_LEVEL >= 2 return const_iterator(__nd, this); #else return const_iterator(__nd); #endif } } } return end(); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_Args>(__args)...); __h.get_deleter().__value_constructed = true; __h->__hash_ = hash_function()(__h->__value_); __h->__next_ = nullptr; return __h; } #endif // _LIBCPP_HAS_NO_VARIADICS template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v, size_t __hash) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::move(__v)); __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; return __h; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v); __h.get_deleter().__value_constructed = true; __h->__hash_ = hash_function()(__h->__value_); __h->__next_ = nullptr; return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v, size_t __hash) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v); __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; return _VSTD::move(__h); // explicitly moved for C++03 } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) { __node_pointer __np = __p.__node_; #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container erase(iterator) called with an iterator not" " referring to this container"); _LIBCPP_ASSERT(__p != end(), "unordered container erase(iterator) called with a non-dereferenceable iterator"); iterator __r(__np, this); #else iterator __r(__np); #endif ++__r; remove(__p); return __r; } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, const_iterator __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, "unodered container::erase(iterator, iterator) called with an iterator not" " referring to this unodered container"); _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, "unodered container::erase(iterator, iterator) called with an iterator not" " referring to this unodered container"); #endif for (const_iterator __p = __first; __first != __last; __p = __first) { ++__first; erase(__p); } __node_pointer __np = __last.__node_; #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator (__np, this); #else return iterator (__np); #endif } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_unique(const _Key& __k) { iterator __i = find(__k); if (__i == end()) return 0; erase(__i); return 1; } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_multi(const _Key& __k) { size_type __r = 0; iterator __i = find(__k); if (__i != end()) { iterator __e = end(); do { erase(__i++); ++__r; } while (__i != __e && key_eq()(*__i, __k)); } return __r; } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT { // current node __node_pointer __cn = __p.__node_; size_type __bc = bucket_count(); size_t __chash = __constrain_hash(__cn->__hash_, __bc); // find previous node __node_pointer __pn = __bucket_list_[__chash]; for (; __pn->__next_ != __cn; __pn = __pn->__next_) ; // Fix up __bucket_list_ // if __pn is not in same bucket (before begin is not in same bucket) && // if __cn->__next_ is not in same bucket (nullptr is not in same bucket) if (__pn == static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())) || __constrain_hash(__pn->__hash_, __bc) != __chash) { if (__cn->__next_ == nullptr || __constrain_hash(__cn->__next_->__hash_, __bc) != __chash) __bucket_list_[__chash] = nullptr; } // if __cn->__next_ is not in same bucket (nullptr is in same bucket) if (__cn->__next_ != nullptr) { size_t __nhash = __constrain_hash(__cn->__next_->__hash_, __bc); if (__nhash != __chash) __bucket_list_[__nhash] = __pn; } // remove __cn __pn->__next_ = __cn->__next_; __cn->__next_ = nullptr; --size(); #if _LIBCPP_DEBUG_LEVEL >= 2 __c_node* __c = __get_db()->__find_c_and_lock(this); for (__i_node** __p = __c->end_; __p != __c->beg_; ) { --__p; iterator* __i = static_cast((*__p)->__i_); if (__i->__node_ == __cn) { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); #endif return __node_holder(__cn, _Dp(__node_alloc(), true)); } template template inline _LIBCPP_INLINE_VISIBILITY typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const { return static_cast(find(__k) != end()); } template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_multi(const _Key& __k) const { size_type __r = 0; const_iterator __i = find(__k); if (__i != end()) { const_iterator __e = end(); do { ++__i; ++__r; } while (__i != __e && key_eq()(*__i, __k)); } return __r; } template template pair::iterator, typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique( const _Key& __k) { iterator __i = find(__k); iterator __j = __i; if (__i != end()) ++__j; return pair(__i, __j); } template template pair::const_iterator, typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique( const _Key& __k) const { const_iterator __i = find(__k); const_iterator __j = __i; if (__i != end()) ++__j; return pair(__i, __j); } template template pair::iterator, typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( const _Key& __k) { iterator __i = find(__k); iterator __j = __i; if (__i != end()) { iterator __e = end(); do { ++__j; } while (__j != __e && key_eq()(*__j, __k)); } return pair(__i, __j); } template template pair::const_iterator, typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( const _Key& __k) const { const_iterator __i = find(__k); const_iterator __j = __i; if (__i != end()) { const_iterator __e = end(); do { ++__j; } while (__j != __e && key_eq()(*__j, __k)); } return pair(__i, __j); } 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) { { __node_pointer_pointer __npp = __bucket_list_.release(); __bucket_list_.reset(__u.__bucket_list_.release()); __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(), __u.__bucket_list_.get_deleter().__alloc()); __swap_alloc(__node_alloc(), __u.__node_alloc()); _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_); __p2_.swap(__u.__p2_); __p3_.swap(__u.__p3_); if (size() > 0) __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())); if (__u.size() > 0) __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash_, __u.bucket_count())] = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__u.__p1_.first())); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->swap(this, &__u); #endif } template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::bucket_size(n) called with n >= bucket_count()"); __node_const_pointer __np = __bucket_list_[__n]; size_type __bc = bucket_count(); size_type __r = 0; if (__np != nullptr) { for (__np = __np->__next_; __np != nullptr && __constrain_hash(__np->__hash_, __bc) == __n; __np = __np->__next_, ++__r) ; } return __r; } template inline _LIBCPP_INLINE_VISIBILITY void swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x, __hash_table<_Tp, _Hash, _Equal, _Alloc>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } #if _LIBCPP_DEBUG_LEVEL >= 2 template bool __hash_table<_Tp, _Hash, _Equal, _Alloc>::__dereferenceable(const const_iterator* __i) const { return __i->__node_ != nullptr; } template bool __hash_table<_Tp, _Hash, _Equal, _Alloc>::__decrementable(const const_iterator*) const { return false; } template bool __hash_table<_Tp, _Hash, _Equal, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const { return false; } template bool __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const { return false; } #endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP__HASH_TABLE libcxx/include/iosfwd0000644000175000017500000001667612266757730016131 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- iosfwd -----------------------------------===// // // The 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_IOSFWD #define _LIBCPP_IOSFWD /* iosfwd synopsis namespace std { template struct char_traits; template class allocator; class ios_base; template > class basic_ios; template > class basic_streambuf; template > class basic_istream; template > class basic_ostream; template > class basic_iostream; template , class Allocator = allocator > class basic_stringbuf; template , class Allocator = allocator > class basic_istringstream; template , class Allocator = allocator > class basic_ostringstream; template , class Allocator = allocator > class basic_stringstream; template > class basic_filebuf; template > class basic_ifstream; template > class basic_ofstream; template > class basic_fstream; template > class istreambuf_iterator; template > class ostreambuf_iterator; typedef basic_ios ios; typedef basic_ios wios; typedef basic_streambuf streambuf; typedef basic_istream istream; typedef basic_ostream ostream; typedef basic_iostream iostream; typedef basic_stringbuf stringbuf; typedef basic_istringstream istringstream; typedef basic_ostringstream ostringstream; typedef basic_stringstream stringstream; typedef basic_filebuf filebuf; typedef basic_ifstream ifstream; typedef basic_ofstream ofstream; typedef basic_fstream fstream; typedef basic_streambuf wstreambuf; typedef basic_istream wistream; typedef basic_ostream wostream; typedef basic_iostream wiostream; typedef basic_stringbuf wstringbuf; typedef basic_istringstream wistringstream; typedef basic_ostringstream wostringstream; typedef basic_stringstream wstringstream; typedef basic_filebuf wfilebuf; typedef basic_ifstream wifstream; typedef basic_ofstream wofstream; typedef basic_fstream wfstream; template class fpos; typedef fpos::state_type> streampos; typedef fpos::state_type> wstreampos; } // std */ #include <__config> #include // for mbstate_t #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS ios_base; template struct _LIBCPP_TYPE_VIS_ONLY char_traits; template class _LIBCPP_TYPE_VIS_ONLY allocator; template > class _LIBCPP_TYPE_VIS_ONLY basic_ios; template > class _LIBCPP_TYPE_VIS_ONLY basic_streambuf; template > class _LIBCPP_TYPE_VIS_ONLY basic_istream; template > class _LIBCPP_TYPE_VIS_ONLY basic_ostream; template > class _LIBCPP_TYPE_VIS_ONLY basic_iostream; template , class _Allocator = allocator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf; template , class _Allocator = allocator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY basic_istringstream; template , class _Allocator = allocator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream; template , class _Allocator = allocator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY basic_stringstream; template > class _LIBCPP_TYPE_VIS_ONLY basic_filebuf; template > class _LIBCPP_TYPE_VIS_ONLY basic_ifstream; template > class _LIBCPP_TYPE_VIS_ONLY basic_ofstream; template > class _LIBCPP_TYPE_VIS_ONLY basic_fstream; template > class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator; template > class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator; typedef basic_ios ios; typedef basic_ios wios; typedef basic_streambuf streambuf; typedef basic_istream istream; typedef basic_ostream ostream; typedef basic_iostream iostream; typedef basic_stringbuf stringbuf; typedef basic_istringstream istringstream; typedef basic_ostringstream ostringstream; typedef basic_stringstream stringstream; typedef basic_filebuf filebuf; typedef basic_ifstream ifstream; typedef basic_ofstream ofstream; typedef basic_fstream fstream; typedef basic_streambuf wstreambuf; typedef basic_istream wistream; typedef basic_ostream wostream; typedef basic_iostream wiostream; typedef basic_stringbuf wstringbuf; typedef basic_istringstream wistringstream; typedef basic_ostringstream wostringstream; typedef basic_stringstream wstringstream; typedef basic_filebuf wfilebuf; typedef basic_ifstream wifstream; typedef basic_ofstream wofstream; typedef basic_fstream wfstream; template class _LIBCPP_TYPE_VIS_ONLY fpos; typedef fpos streampos; typedef fpos wstreampos; #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS typedef fpos u16streampos; typedef fpos u32streampos; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS typedef long long streamoff; // for char_traits in template class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > class _LIBCPP_TYPE_VIS_ONLY basic_string; typedef basic_string, allocator > string; typedef basic_string, allocator > wstring; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_IOSFWD libcxx/include/clocale0000644000175000017500000000164112266757731016223 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- clocale ----------------------------------===// // // The 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_CLOCALE #define _LIBCPP_CLOCALE /* clocale synopsis Macros: LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME NULL namespace std { struct lconv; char* setlocale(int category, const char* locale); lconv* localeconv(); } // std */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD using ::lconv; using ::setlocale; using ::localeconv; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CLOCALE libcxx/include/__mutex_base0000644000175000017500000002624412266757731017261 0ustar sylvestresylvestre// -*- 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. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP___MUTEX_BASE #define _LIBCPP___MUTEX_BASE #include <__config> #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS mutex { pthread_mutex_t __m_; public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {} #else mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;} #endif ~mutex(); private: mutex(const mutex&);// = delete; mutex& operator=(const mutex&);// = delete; public: void lock(); bool try_lock() _NOEXCEPT; void unlock() _NOEXCEPT; typedef pthread_mutex_t* native_handle_type; _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;} }; struct _LIBCPP_TYPE_VIS defer_lock_t {}; struct _LIBCPP_TYPE_VIS try_to_lock_t {}; struct _LIBCPP_TYPE_VIS adopt_lock_t {}; #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MUTEX) extern const defer_lock_t defer_lock; extern const try_to_lock_t try_to_lock; extern const adopt_lock_t adopt_lock; #else constexpr defer_lock_t defer_lock = defer_lock_t(); constexpr try_to_lock_t try_to_lock = try_to_lock_t(); constexpr adopt_lock_t adopt_lock = adopt_lock_t(); #endif template class _LIBCPP_TYPE_VIS_ONLY lock_guard { public: typedef _Mutex mutex_type; private: mutex_type& __m_; public: _LIBCPP_INLINE_VISIBILITY explicit lock_guard(mutex_type& __m) : __m_(__m) {__m_.lock();} _LIBCPP_INLINE_VISIBILITY lock_guard(mutex_type& __m, adopt_lock_t) : __m_(__m) {} _LIBCPP_INLINE_VISIBILITY ~lock_guard() {__m_.unlock();} private: lock_guard(lock_guard const&);// = delete; lock_guard& operator=(lock_guard const&);// = delete; }; template class _LIBCPP_TYPE_VIS_ONLY unique_lock { public: typedef _Mutex mutex_type; private: mutex_type* __m_; bool __owns_; public: _LIBCPP_INLINE_VISIBILITY unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} _LIBCPP_INLINE_VISIBILITY explicit unique_lock(mutex_type& __m) : __m_(&__m), __owns_(true) {__m_->lock();} _LIBCPP_INLINE_VISIBILITY unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT : __m_(&__m), __owns_(false) {} _LIBCPP_INLINE_VISIBILITY unique_lock(mutex_type& __m, try_to_lock_t) : __m_(&__m), __owns_(__m.try_lock()) {} _LIBCPP_INLINE_VISIBILITY unique_lock(mutex_type& __m, adopt_lock_t) : __m_(&__m), __owns_(true) {} template _LIBCPP_INLINE_VISIBILITY unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) : __m_(&__m), __owns_(__m.try_lock_until(__t)) {} template _LIBCPP_INLINE_VISIBILITY unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) : __m_(&__m), __owns_(__m.try_lock_for(__d)) {} _LIBCPP_INLINE_VISIBILITY ~unique_lock() { if (__owns_) __m_->unlock(); } private: unique_lock(unique_lock const&); // = delete; unique_lock& operator=(unique_lock const&); // = delete; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY unique_lock(unique_lock&& __u) _NOEXCEPT : __m_(__u.__m_), __owns_(__u.__owns_) {__u.__m_ = nullptr; __u.__owns_ = false;} _LIBCPP_INLINE_VISIBILITY unique_lock& operator=(unique_lock&& __u) _NOEXCEPT { if (__owns_) __m_->unlock(); __m_ = __u.__m_; __owns_ = __u.__owns_; __u.__m_ = nullptr; __u.__owns_ = false; return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void lock(); bool try_lock(); template bool try_lock_for(const chrono::duration<_Rep, _Period>& __d); template bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); void unlock(); _LIBCPP_INLINE_VISIBILITY void swap(unique_lock& __u) _NOEXCEPT { _VSTD::swap(__m_, __u.__m_); _VSTD::swap(__owns_, __u.__owns_); } _LIBCPP_INLINE_VISIBILITY mutex_type* release() _NOEXCEPT { mutex_type* __m = __m_; __m_ = nullptr; __owns_ = false; return __m; } _LIBCPP_INLINE_VISIBILITY bool owns_lock() const _NOEXCEPT {return __owns_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool () const _NOEXCEPT {return __owns_;} _LIBCPP_INLINE_VISIBILITY mutex_type* mutex() const _NOEXCEPT {return __m_;} }; template void unique_lock<_Mutex>::lock() { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::lock: references null mutex"); if (__owns_) __throw_system_error(EDEADLK, "unique_lock::lock: already locked"); __m_->lock(); __owns_ = true; } template bool unique_lock<_Mutex>::try_lock() { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex"); if (__owns_) __throw_system_error(EDEADLK, "unique_lock::try_lock: already locked"); __owns_ = __m_->try_lock(); return __owns_; } template template bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex"); if (__owns_) __throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked"); __owns_ = __m_->try_lock_for(__d); return __owns_; } template template bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex"); if (__owns_) __throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked"); __owns_ = __m_->try_lock_until(__t); return __owns_; } template void unique_lock<_Mutex>::unlock() { if (!__owns_) __throw_system_error(EPERM, "unique_lock::unlock: not locked"); __m_->unlock(); __owns_ = false; } template inline _LIBCPP_INLINE_VISIBILITY void swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT {__x.swap(__y);} //enum class cv_status _LIBCPP_DECLARE_STRONG_ENUM(cv_status) { no_timeout, timeout }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) class _LIBCPP_TYPE_VIS condition_variable { pthread_cond_t __cv_; public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {} #else condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;} #endif ~condition_variable(); private: condition_variable(const condition_variable&); // = delete; condition_variable& operator=(const condition_variable&); // = delete; public: void notify_one() _NOEXCEPT; void notify_all() _NOEXCEPT; void wait(unique_lock& __lk); template void wait(unique_lock& __lk, _Predicate __pred); template cv_status wait_until(unique_lock& __lk, const chrono::time_point<_Clock, _Duration>& __t); template bool wait_until(unique_lock& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred); template cv_status wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d); template bool wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); typedef pthread_cond_t* native_handle_type; _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;} private: void __do_timed_wait(unique_lock& __lk, chrono::time_point); }; template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < chrono::__is_duration<_To>::value, _To >::type __ceil(chrono::duration<_Rep, _Period> __d) { using namespace chrono; _To __r = duration_cast<_To>(__d); if (__r < __d) ++__r; return __r; } template void condition_variable::wait(unique_lock& __lk, _Predicate __pred) { while (!__pred()) wait(__lk); } template cv_status condition_variable::wait_until(unique_lock& __lk, const chrono::time_point<_Clock, _Duration>& __t) { using namespace chrono; wait_for(__lk, __t - _Clock::now()); return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout; } template bool condition_variable::wait_until(unique_lock& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) { while (!__pred()) { if (wait_until(__lk, __t) == cv_status::timeout) return __pred(); } return true; } template cv_status condition_variable::wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d) { using namespace chrono; if (__d <= __d.zero()) return cv_status::timeout; typedef time_point > __sys_tpf; typedef time_point __sys_tpi; __sys_tpf _Max = __sys_tpi::max(); system_clock::time_point __s_now = system_clock::now(); steady_clock::time_point __c_now = steady_clock::now(); if (_Max - __d > __s_now) __do_timed_wait(__lk, __s_now + __ceil(__d)); else __do_timed_wait(__lk, __sys_tpi::max()); return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : cv_status::timeout; } template inline _LIBCPP_INLINE_VISIBILITY bool condition_variable::wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred) { return wait_until(__lk, chrono::steady_clock::now() + __d, _VSTD::move(__pred)); } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___MUTEX_BASE libcxx/include/csignal0000644000175000017500000000166712266757730016250 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- csignal ----------------------------------===// // // The 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_CSIGNAL #define _LIBCPP_CSIGNAL /* csignal synopsis Macros: SIG_DFL SIG_ERR SIG_IGN SIGABRT SIGFPE SIGILL SIGINT SIGSEGV SIGTERM namespace std { Types: sig_atomic_t void (*signal(int sig, void (*func)(int)))(int); int raise(int sig); } // std */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD using ::sig_atomic_t; using ::signal; using ::raise; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CSIGNAL libcxx/include/functional0000644000175000017500000021070412266757730016764 0ustar sylvestresylvestre// -*- C++ -*- //===------------------------ functional ----------------------------------===// // // The 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_FUNCTIONAL #define _LIBCPP_FUNCTIONAL /* functional synopsis namespace std { template struct unary_function { typedef Arg argument_type; typedef Result result_type; }; template struct binary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Result result_type; }; template class reference_wrapper : public unary_function // if wrapping a unary functor : public binary_function // if wraping a binary functor { public: // types typedef T type; typedef see below result_type; // Not always defined // construct/copy/destroy reference_wrapper(T&) noexcept; reference_wrapper(T&&) = delete; // do not bind to temps reference_wrapper(const reference_wrapper& x) noexcept; // assignment reference_wrapper& operator=(const reference_wrapper& x) noexcept; // access operator T& () const noexcept; T& get() const noexcept; // invoke template typename result_of::type operator() (ArgTypes&&...) const; }; template reference_wrapper ref(T& t) noexcept; template void ref(const T&& t) = delete; template reference_wrapper ref(reference_wrappert) noexcept; template reference_wrapper cref(const T& t) noexcept; template void cref(const T&& t) = delete; template reference_wrapper cref(reference_wrapper t) noexcept; template // in C++14 struct plus : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct minus : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct multiplies : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct divides : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct modulus : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct negate : unary_function { T operator()(const T& x) const; }; template // in C++14 struct equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct not_equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct greater : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct less : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct greater_equal : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct less_equal : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct logical_and : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct logical_or : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct logical_not : unary_function { bool operator()(const T& x) const; }; template // in C++14 struct bit_and : unary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct bit_or : unary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct bit_xor : unary_function { bool operator()(const T& x, const T& y) const; }; template // C++14 struct bit_xor : unary_function { bool operator()(const T& x) const; }; template class unary_negate : public unary_function { public: explicit unary_negate(const Predicate& pred); bool operator()(const typename Predicate::argument_type& x) const; }; template unary_negate not1(const Predicate& pred); template class binary_negate : public binary_function { public: explicit binary_negate(const Predicate& pred); bool operator()(const typename Predicate::first_argument_type& x, const typename Predicate::second_argument_type& y) const; }; template binary_negate not2(const Predicate& pred); template struct is_bind_expression; template struct is_placeholder; template unspecified bind(Fn&&, BoundArgs&&...); template unspecified bind(Fn&&, BoundArgs&&...); namespace placeholders { // M is the implementation-defined number of placeholders extern unspecified _1; extern unspecified _2; . . . extern unspecified _Mp; } template class binder1st : public unary_function { protected: Operation op; typename Operation::first_argument_type value; public: binder1st(const Operation& x, const typename Operation::first_argument_type y); typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; }; template binder1st bind1st(const Operation& op, const T& x); template class binder2nd : public unary_function { protected: Operation op; typename Operation::second_argument_type value; public: binder2nd(const Operation& x, const typename Operation::second_argument_type y); typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; }; template binder2nd bind2nd(const Operation& op, const T& x); template class pointer_to_unary_function : public unary_function { public: explicit pointer_to_unary_function(Result (*f)(Arg)); Result operator()(Arg x) const; }; template pointer_to_unary_function ptr_fun(Result (*f)(Arg)); template class pointer_to_binary_function : public binary_function { public: explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); Result operator()(Arg1 x, Arg2 y) const; }; template pointer_to_binary_function ptr_fun(Result (*f)(Arg1,Arg2)); template class mem_fun_t : public unary_function { public: explicit mem_fun_t(S (T::*p)()); S operator()(T* p) const; }; template class mem_fun1_t : public binary_function { public: explicit mem_fun1_t(S (T::*p)(A)); S operator()(T* p, A x) const; }; template mem_fun_t mem_fun(S (T::*f)()); template mem_fun1_t mem_fun(S (T::*f)(A)); template class mem_fun_ref_t : public unary_function { public: explicit mem_fun_ref_t(S (T::*p)()); S operator()(T& p) const; }; template class mem_fun1_ref_t : public binary_function { public: explicit mem_fun1_ref_t(S (T::*p)(A)); S operator()(T& p, A x) const; }; template mem_fun_ref_t mem_fun_ref(S (T::*f)()); template mem_fun1_ref_t mem_fun_ref(S (T::*f)(A)); template class const_mem_fun_t : public unary_function { public: explicit const_mem_fun_t(S (T::*p)() const); S operator()(const T* p) const; }; template class const_mem_fun1_t : public binary_function { public: explicit const_mem_fun1_t(S (T::*p)(A) const); S operator()(const T* p, A x) const; }; template const_mem_fun_t mem_fun(S (T::*f)() const); template const_mem_fun1_t mem_fun(S (T::*f)(A) const); template class const_mem_fun_ref_t : public unary_function { public: explicit const_mem_fun_ref_t(S (T::*p)() const); S operator()(const T& p) const; }; template class const_mem_fun1_ref_t : public binary_function { public: explicit const_mem_fun1_ref_t(S (T::*p)(A) const); S operator()(const T& p, A x) const; }; template const_mem_fun_ref_t mem_fun_ref(S (T::*f)() const); template const_mem_fun1_ref_t mem_fun_ref(S (T::*f)(A) const); template unspecified mem_fn(R T::*); class bad_function_call : public exception { }; template class function; // undefined template class function : public unary_function // iff sizeof...(ArgTypes) == 1 and // ArgTypes contains T1 : public binary_function // iff sizeof...(ArgTypes) == 2 and // ArgTypes contains T1 and T2 { public: typedef R result_type; // construct/copy/destroy: function() noexcept; function(nullptr_t) noexcept; function(const function&); function(function&&) noexcept; template function(F); template function(allocator_arg_t, const Alloc&) noexcept; template function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; template function(allocator_arg_t, const Alloc&, const function&); template function(allocator_arg_t, const Alloc&, function&&); template function(allocator_arg_t, const Alloc&, F); function& operator=(const function&); function& operator=(function&&) noexcept; function& operator=(nullptr_t) noexcept; template function& operator=(F&&); template function& operator=(reference_wrapper) noexcept; ~function(); // function modifiers: void swap(function&) noexcept; template void assign(F&&, const Alloc&); // function capacity: explicit operator bool() const noexcept; // function invocation: R operator()(ArgTypes...) const; // function target access: const std::type_info& target_type() const noexcept; template T* target() noexcept; template const T* target() const noexcept; }; // Null pointer comparisons: template bool operator==(const function&, nullptr_t) noexcept; template bool operator==(nullptr_t, const function&) noexcept; template bool operator!=(const function&, nullptr_t) noexcept; template bool operator!=(nullptr_t, const function&) noexcept; // specialized algorithms: template void swap(function&, function&) noexcept; template struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template struct hash; } // std POLICY: For non-variadic implementations, the number of arguments is limited to 3. It is hoped that the need for non-variadic implementations will be minimal. */ #include <__config> #include #include #include #include #include #include <__functional_base> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return -__x;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TYPE_VIS_ONLY negate { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const { return -_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif // less in <__functional_base> #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const {return !__x;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} }; #if _LIBCPP_STD_VER > 11 template <> 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); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return ~__x;} }; template <> 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); } typedef void is_transparent; }; #endif template class _LIBCPP_TYPE_VIS_ONLY unary_negate : public unary_function { _Predicate __pred_; public: _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred) : __pred_(__pred) {} _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const {return !__pred_(__x);} }; template inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY unary_negate<_Predicate> not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} template class _LIBCPP_TYPE_VIS_ONLY binary_negate : public binary_function { _Predicate __pred_; public: _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 binary_negate(const _Predicate& __pred) : __pred_(__pred) {} _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x, const typename _Predicate::second_argument_type& __y) const {return !__pred_(__x, __y);} }; template inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY binary_negate<_Predicate> not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} template class _LIBCPP_TYPE_VIS_ONLY binder1st : public unary_function { protected: __Operation op; typename __Operation::first_argument_type value; public: _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, const typename __Operation::first_argument_type __y) : op(__x), value(__y) {} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() (typename __Operation::second_argument_type& __x) const {return op(value, __x);} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() (const typename __Operation::second_argument_type& __x) const {return op(value, __x);} }; template inline _LIBCPP_INLINE_VISIBILITY binder1st<__Operation> bind1st(const __Operation& __op, const _Tp& __x) {return binder1st<__Operation>(__op, __x);} template class _LIBCPP_TYPE_VIS_ONLY binder2nd : public unary_function { protected: __Operation op; typename __Operation::second_argument_type value; public: _LIBCPP_INLINE_VISIBILITY binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) : op(__x), value(__y) {} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() ( typename __Operation::first_argument_type& __x) const {return op(__x, value);} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() (const typename __Operation::first_argument_type& __x) const {return op(__x, value);} }; template inline _LIBCPP_INLINE_VISIBILITY binder2nd<__Operation> bind2nd(const __Operation& __op, const _Tp& __x) {return binder2nd<__Operation>(__op, __x);} template class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function : public unary_function<_Arg, _Result> { _Result (*__f_)(_Arg); public: _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const {return __f_(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY pointer_to_unary_function<_Arg,_Result> ptr_fun(_Result (*__f)(_Arg)) {return pointer_to_unary_function<_Arg,_Result>(__f);} template class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function : public binary_function<_Arg1, _Arg2, _Result> { _Result (*__f_)(_Arg1, _Arg2); public: _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const {return __f_(__x, __y);} }; template inline _LIBCPP_INLINE_VISIBILITY pointer_to_binary_function<_Arg1,_Arg2,_Result> ptr_fun(_Result (*__f)(_Arg1,_Arg2)) {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} template class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp> { _Sp (_Tp::*__p_)(); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const {return (__p->*__p_)();} }; template class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const {return (__p->*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY mem_fun_t<_Sp,_Tp> mem_fun(_Sp (_Tp::*__f)()) {return mem_fun_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY mem_fun1_t<_Sp,_Tp,_Ap> mem_fun(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)(); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const {return (__p.*__p_)();} }; template class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const {return (__p.*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY mem_fun_ref_t<_Sp,_Tp> mem_fun_ref(_Sp (_Tp::*__f)()) {return mem_fun_ref_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} template class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function { _Sp (_Tp::*__p_)() const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const {return (__p->*__p_)();} }; template class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function { _Sp (_Tp::*__p_)(_Ap) const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const {return (__p->*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun_t<_Sp,_Tp> mem_fun(_Sp (_Tp::*__f)() const) {return const_mem_fun_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun1_t<_Sp,_Tp,_Ap> mem_fun(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)() const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const {return (__p.*__p_)();} }; template class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const {return (__p.*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun_ref_t<_Sp,_Tp> mem_fun_ref(_Sp (_Tp::*__f)() const) {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} #ifdef _LIBCPP_HAS_NO_VARIADICS #include <__functional_03> #else // _LIBCPP_HAS_NO_VARIADICS template class __mem_fn : public __weak_result_type<_Tp> { public: // types typedef _Tp type; private: type __f_; public: _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} // invoke template _LIBCPP_INLINE_VISIBILITY typename __invoke_return::type operator() (_ArgTypes&&... __args) { return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); } }; template inline _LIBCPP_INLINE_VISIBILITY __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::* __pm) { return __mem_fn<_Rp _Tp::*>(__pm); } // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call : public exception { }; template class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { template struct __maybe_derive_from_unary_function { }; template struct __maybe_derive_from_unary_function<_Rp(_A1)> : public unary_function<_A1, _Rp> { }; template struct __maybe_derive_from_binary_function { }; template struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> : public binary_function<_A1, _A2, _Rp> { }; template class __base; template class __base<_Rp(_ArgTypes...)> { __base(const __base&); __base& operator=(const __base&); public: _LIBCPP_INLINE_VISIBILITY __base() {} _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} virtual __base* __clone() const = 0; virtual void __clone(__base*) const = 0; virtual void destroy() _NOEXCEPT = 0; virtual void destroy_deallocate() _NOEXCEPT = 0; virtual _Rp operator()(_ArgTypes&& ...) = 0; #ifndef _LIBCPP_NO_RTTI virtual const void* target(const type_info&) const _NOEXCEPT = 0; virtual const std::type_info& target_type() const _NOEXCEPT = 0; #endif // _LIBCPP_NO_RTTI }; template class __func; template class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> { __compressed_pair<_Fp, _Alloc> __f_; public: _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp&& __f) : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), _VSTD::forward_as_tuple()) {} _LIBCPP_INLINE_VISIBILITY explicit __func(const _Fp& __f, const _Alloc& __a) : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), _VSTD::forward_as_tuple(__a)) {} _LIBCPP_INLINE_VISIBILITY explicit __func(const _Fp& __f, _Alloc&& __a) : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), _VSTD::forward_as_tuple(_VSTD::move(__a))) {} _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp&& __f, _Alloc&& __a) : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), _VSTD::forward_as_tuple(_VSTD::move(__a))) {} virtual __base<_Rp(_ArgTypes...)>* __clone() const; virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; virtual void destroy() _NOEXCEPT; virtual void destroy_deallocate() _NOEXCEPT; virtual _Rp operator()(_ArgTypes&& ... __arg); #ifndef _LIBCPP_NO_RTTI virtual const void* target(const type_info&) const _NOEXCEPT; virtual const std::type_info& target_type() const _NOEXCEPT; #endif // _LIBCPP_NO_RTTI }; template __base<_Rp(_ArgTypes...)>* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const { typedef typename _Alloc::template rebind<__func>::other _Ap; _Ap __a(__f_.second()); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); return __hold.release(); } template void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const { ::new (__p) __func(__f_.first(), __f_.second()); } template void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT { __f_.~__compressed_pair<_Fp, _Alloc>(); } template void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT { typedef typename _Alloc::template rebind<__func>::other _Ap; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(this, 1); } template _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) { return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); } #ifndef _LIBCPP_NO_RTTI template const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT { if (__ti == typeid(_Fp)) return &__f_.first(); return (const void*)0; } template const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT { return typeid(_Fp); } #endif // _LIBCPP_NO_RTTI } // __function template class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> { typedef __function::__base<_Rp(_ArgTypes...)> __base; typename aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; template _LIBCPP_INLINE_VISIBILITY static bool __not_null(const _Fp&) {return true;} template _LIBCPP_INLINE_VISIBILITY static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;} template _LIBCPP_INLINE_VISIBILITY static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;} template _LIBCPP_INLINE_VISIBILITY static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;} template _LIBCPP_INLINE_VISIBILITY static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;} template _LIBCPP_INLINE_VISIBILITY static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} template _LIBCPP_INLINE_VISIBILITY static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;} template ::value && __invokable<_Fp&, _ArgTypes...>::value> struct __callable; template struct __callable<_Fp, true> { static const bool value = is_convertible::type, _Rp>::value; }; template struct __callable<_Fp, false> { static const bool value = false; }; public: typedef _Rp result_type; // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY function() _NOEXCEPT : __f_(0) {} _LIBCPP_INLINE_VISIBILITY function(nullptr_t) _NOEXCEPT : __f_(0) {} function(const function&); function(function&&) _NOEXCEPT; template function(_Fp, typename enable_if < __callable<_Fp>::value && !is_same<_Fp, function>::value >::type* = 0); template _LIBCPP_INLINE_VISIBILITY function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} template _LIBCPP_INLINE_VISIBILITY function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} template function(allocator_arg_t, const _Alloc&, const function&); template function(allocator_arg_t, const _Alloc&, function&&); template function(allocator_arg_t, const _Alloc& __a, _Fp __f, typename enable_if<__callable<_Fp>::value>::type* = 0); function& operator=(const function&); function& operator=(function&&) _NOEXCEPT; function& operator=(nullptr_t) _NOEXCEPT; template typename enable_if < __callable::type>::value && !is_same::type, function>::value, function& >::type operator=(_Fp&&); ~function(); // function modifiers: void swap(function&) _NOEXCEPT; template _LIBCPP_INLINE_VISIBILITY void assign(_Fp&& __f, const _Alloc& __a) {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} // function capacity: _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} // deleted overloads close possible hole in the type system template bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; template bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; public: // function invocation: _Rp operator()(_ArgTypes...) const; #ifndef _LIBCPP_NO_RTTI // function target access: const std::type_info& target_type() const _NOEXCEPT; template _Tp* target() _NOEXCEPT; template const _Tp* target() const _NOEXCEPT; #endif // _LIBCPP_NO_RTTI }; template function<_Rp(_ArgTypes...)>::function(const function& __f) { if (__f.__f_ == 0) __f_ = 0; else if (__f.__f_ == (const __base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__clone(__f_); } else __f_ = __f.__f_->__clone(); } template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, const function& __f) { if (__f.__f_ == 0) __f_ = 0; else if (__f.__f_ == (const __base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__clone(__f_); } else __f_ = __f.__f_->__clone(); } template function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT { if (__f.__f_ == 0) __f_ = 0; else if (__f.__f_ == (__base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__clone(__f_); } else { __f_ = __f.__f_; __f.__f_ = 0; } } template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, function&& __f) { if (__f.__f_ == 0) __f_ = 0; else if (__f.__f_ == (__base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__clone(__f_); } else { __f_ = __f.__f_; __f.__f_ = 0; } } template template function<_Rp(_ArgTypes...)>::function(_Fp __f, typename enable_if < __callable<_Fp>::value && !is_same<_Fp, function>::value >::type*) : __f_(0) { if (__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) { __f_ = (__base*)&__buf_; ::new (__f_) _FF(_VSTD::move(__f)); } else { typedef allocator<_FF> _Ap; _Ap __a; typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); __f_ = __hold.release(); } } } template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, typename enable_if<__callable<_Fp>::value>::type*) : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; if (__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) { __f_ = (__base*)&__buf_; ::new (__f_) _FF(_VSTD::move(__f)); } else { typedef typename __alloc_traits::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind_alloc<_FF> #else rebind_alloc<_FF>::other #endif _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); __f_ = __hold.release(); } } } template function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(const function& __f) { function(__f).swap(*this); return *this; } template function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT { if (__f_ == (__base*)&__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); __f_ = 0; if (__f.__f_ == 0) __f_ = 0; else if (__f.__f_ == (__base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__clone(__f_); } else { __f_ = __f.__f_; __f.__f_ = 0; } return *this; } template function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT { if (__f_ == (__base*)&__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); __f_ = 0; return *this; } template template typename enable_if < function<_Rp(_ArgTypes...)>::template __callable::type>::value && !is_same::type, function<_Rp(_ArgTypes...)>>::value, function<_Rp(_ArgTypes...)>& >::type function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) { function(_VSTD::forward<_Fp>(__f)).swap(*this); return *this; } template function<_Rp(_ArgTypes...)>::~function() { if (__f_ == (__base*)&__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); } template void function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT { if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) { typename aligned_storage::type __tempbuf; __base* __t = (__base*)&__tempbuf; __f_->__clone(__t); __f_->destroy(); __f_ = 0; __f.__f_->__clone((__base*)&__buf_); __f.__f_->destroy(); __f.__f_ = 0; __f_ = (__base*)&__buf_; __t->__clone((__base*)&__f.__buf_); __t->destroy(); __f.__f_ = (__base*)&__f.__buf_; } else if (__f_ == (__base*)&__buf_) { __f_->__clone((__base*)&__f.__buf_); __f_->destroy(); __f_ = __f.__f_; __f.__f_ = (__base*)&__f.__buf_; } else if (__f.__f_ == (__base*)&__f.__buf_) { __f.__f_->__clone((__base*)&__buf_); __f.__f_->destroy(); __f.__f_ = __f_; __f_ = (__base*)&__buf_; } else _VSTD::swap(__f_, __f.__f_); } template _Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { #ifndef _LIBCPP_NO_EXCEPTIONS if (__f_ == 0) throw bad_function_call(); #endif // _LIBCPP_NO_EXCEPTIONS return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); } #ifndef _LIBCPP_NO_RTTI template const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT { if (__f_ == 0) return typeid(void); return __f_->target_type(); } template template _Tp* function<_Rp(_ArgTypes...)>::target() _NOEXCEPT { if (__f_ == 0) return (_Tp*)0; return (_Tp*)__f_->target(typeid(_Tp)); } template template const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT { if (__f_ == 0) return (const _Tp*)0; return (const _Tp*)__f_->target(typeid(_Tp)); } #endif // _LIBCPP_NO_RTTI template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} template inline _LIBCPP_INLINE_VISIBILITY bool operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} template inline _LIBCPP_INLINE_VISIBILITY void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {return __x.swap(__y);} template struct __is_bind_expression : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression::type> {}; template struct __is_placeholder : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY is_placeholder : public __is_placeholder::type> {}; namespace placeholders { template struct __ph {}; _LIBCPP_FUNC_VIS extern __ph<1> _1; _LIBCPP_FUNC_VIS extern __ph<2> _2; _LIBCPP_FUNC_VIS extern __ph<3> _3; _LIBCPP_FUNC_VIS extern __ph<4> _4; _LIBCPP_FUNC_VIS extern __ph<5> _5; _LIBCPP_FUNC_VIS extern __ph<6> _6; _LIBCPP_FUNC_VIS extern __ph<7> _7; _LIBCPP_FUNC_VIS extern __ph<8> _8; _LIBCPP_FUNC_VIS extern __ph<9> _9; _LIBCPP_FUNC_VIS extern __ph<10> _10; } // placeholders template struct __is_placeholder > : public integral_constant {}; template inline _LIBCPP_INLINE_VISIBILITY _Tp& __mu(reference_wrapper<_Tp> __t, _Uj&) { return __t.get(); } template inline _LIBCPP_INLINE_VISIBILITY typename __invoke_of<_Ti&, _Uj...>::type __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) { return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_bind_expression<_Ti>::value, typename __invoke_of<_Ti&, _Uj...>::type >::type __mu(_Ti& __ti, tuple<_Uj...>& __uj) { typedef typename __make_tuple_indices::type __indices; return __mu_expand(__ti, __uj, __indices()); } template struct __mu_return2 {}; template struct __mu_return2 { typedef typename tuple_element::value - 1, _Uj>::type type; }; template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < 0 < is_placeholder<_Ti>::value, typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type >::type __mu(_Ti&, _Uj& __uj) { const size_t _Indx = is_placeholder<_Ti>::value - 1; return _VSTD::forward::type>(get<_Indx>(__uj)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < !is_bind_expression<_Ti>::value && is_placeholder<_Ti>::value == 0 && !__is_reference_wrapper<_Ti>::value, _Ti& >::type __mu(_Ti& __ti, _Uj&) { return __ti; } template struct ____mu_return; template struct ____mu_return_invokable // false { typedef __nat type; }; template struct ____mu_return_invokable { typedef typename __invoke_of<_Ti&, _Uj...>::type type; }; template struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> > : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> { }; template struct ____mu_return<_Ti, false, false, true, _TupleUj> { typedef typename tuple_element::value - 1, _TupleUj>::type&& type; }; template struct ____mu_return<_Ti, true, false, false, _TupleUj> { typedef typename _Ti::type& type; }; template struct ____mu_return<_Ti, false, false, false, _TupleUj> { typedef _Ti& type; }; template struct __mu_return : public ____mu_return<_Ti, __is_reference_wrapper<_Ti>::value, is_bind_expression<_Ti>::value, 0 < is_placeholder<_Ti>::value && is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, _TupleUj> { }; template struct _is_valid_bind_return { static const bool value = false; }; template 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> { static const bool value = __invokable<_Fp, typename __mu_return::type...>::value; }; template ::value> struct __bind_return; template struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> { typedef typename __invoke_of < _Fp&, typename __mu_return < _BoundArgs, _TupleUj >::type... >::type type; }; template struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> { typedef typename __invoke_of < _Fp&, typename __mu_return < const _BoundArgs, _TupleUj >::type... >::type type; }; template inline _LIBCPP_INLINE_VISIBILITY typename __bind_return<_Fp, _BoundArgs, _Args>::type __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _Args&& __args) { return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...); } template class __bind : public __weak_result_type::type> { protected: typedef typename decay<_Fp>::type _Fd; typedef tuple::type...> _Td; private: _Fd __f_; _Td __bound_args_; typedef typename __make_tuple_indices::type __indices; public: #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS _LIBCPP_INLINE_VISIBILITY __bind(const __bind& __b) : __f_(__b.__f_), __bound_args_(__b.__bound_args_) {} _LIBCPP_INLINE_VISIBILITY __bind& operator=(const __bind& __b) { __f_ = __b.__f_; __bound_args_ = __b.__bound_args_; return *this; } _LIBCPP_INLINE_VISIBILITY __bind(__bind&& __b) : __f_(_VSTD::move(__b.__f_)), __bound_args_(_VSTD::move(__b.__bound_args_)) {} _LIBCPP_INLINE_VISIBILITY __bind& operator=(__bind&& __b) { __f_ = _VSTD::move(__b.__f_); __bound_args_ = _VSTD::move(__b.__bound_args_); return *this; } #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS template ::value && !is_same::type, __bind>::value >::type> _LIBCPP_INLINE_VISIBILITY explicit __bind(_Gp&& __f, _BA&& ...__bound_args) : __f_(_VSTD::forward<_Gp>(__f)), __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} template _LIBCPP_INLINE_VISIBILITY typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type operator()(_Args&& ...__args) { return __apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); } template _LIBCPP_INLINE_VISIBILITY typename __bind_return >::type operator()(_Args&& ...__args) const { return __apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); } }; template struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; template class __bind_r : public __bind<_Fp, _BoundArgs...> { typedef __bind<_Fp, _BoundArgs...> base; typedef typename base::_Fd _Fd; typedef typename base::_Td _Td; public: typedef _Rp result_type; #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS _LIBCPP_INLINE_VISIBILITY __bind_r(const __bind_r& __b) : base(_VSTD::forward(__b)) {} _LIBCPP_INLINE_VISIBILITY __bind_r& operator=(const __bind_r& __b) { base::operator=(_VSTD::forward(__b)); return *this; } _LIBCPP_INLINE_VISIBILITY __bind_r(__bind_r&& __b) : base(_VSTD::forward(__b)) {} _LIBCPP_INLINE_VISIBILITY __bind_r& operator=(__bind_r&& __b) { base::operator=(_VSTD::forward(__b)); return *this; } #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS template ::value && !is_same::type, __bind_r>::value >::type> _LIBCPP_INLINE_VISIBILITY explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) : base(_VSTD::forward<_Gp>(__f), _VSTD::forward<_BA>(__bound_args)...) {} template _LIBCPP_INLINE_VISIBILITY typename enable_if < is_convertible >::type, result_type>::value, result_type >::type operator()(_Args&& ...__args) { return base::operator()(_VSTD::forward<_Args>(__args)...); } template _LIBCPP_INLINE_VISIBILITY typename enable_if < is_convertible >::type, result_type>::value, result_type >::type operator()(_Args&& ...__args) const { return base::operator()(_VSTD::forward<_Args>(__args)...); } }; template struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; template inline _LIBCPP_INLINE_VISIBILITY __bind<_Fp, _BoundArgs...> bind(_Fp&& __f, _BoundArgs&&... __bound_args) { typedef __bind<_Fp, _BoundArgs...> type; return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); } template inline _LIBCPP_INLINE_VISIBILITY __bind_r<_Rp, _Fp, _BoundArgs...> bind(_Fp&& __f, _BoundArgs&&... __bound_args) { typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); } #endif // _LIBCPP_HAS_NO_VARIADICS template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(bool __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(char __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(signed char __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast(__v);} }; #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast(__v);} }; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(short __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(int __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(long __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function { _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast(__v);} }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { _LIBCPP_INLINE_VISIBILITY size_t operator()(float __v) const _NOEXCEPT { // -0.0 and 0.0 should return same hash if (__v == 0) return 0; return __scalar_hash::operator()(__v); } }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { _LIBCPP_INLINE_VISIBILITY size_t operator()(double __v) const _NOEXCEPT { // -0.0 and 0.0 should return same hash if (__v == 0) return 0; return __scalar_hash::operator()(__v); } }; template <> struct _LIBCPP_TYPE_VIS_ONLY hash : public __scalar_hash { _LIBCPP_INLINE_VISIBILITY size_t operator()(long double __v) const _NOEXCEPT { // -0.0 and 0.0 should return same hash if (__v == 0) return 0; #if defined(__i386__) // Zero out padding bits union { long double __t; struct { size_t __a; size_t __b; size_t __c; size_t __d; }; } __u; __u.__a = 0; __u.__b = 0; __u.__c = 0; __u.__d = 0; __u.__t = __v; return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d; #elif defined(__x86_64__) // Zero out padding bits union { long double __t; struct { size_t __a; size_t __b; }; } __u; __u.__a = 0; __u.__b = 0; __u.__t = __v; return __u.__a ^ __u.__b; #else return __scalar_hash::operator()(__v); #endif } }; #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TYPE_VIS_ONLY hash : public unary_function<_Tp, size_t> { static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types"); _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp __v) const _NOEXCEPT { typedef typename underlying_type<_Tp>::type type; return hash{}(static_cast(__v)); } }; #endif // struct hash in _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_FUNCTIONAL libcxx/include/valarray0000644000175000017500000040514212266757731016446 0ustar sylvestresylvestre// -*- C++ -*- //===-------------------------- valarray ----------------------------------===// // // The 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_VALARRAY #define _LIBCPP_VALARRAY /* valarray synopsis namespace std { template class valarray { public: typedef T value_type; // construct/destroy: valarray(); explicit valarray(size_t n); valarray(const value_type& x, size_t n); valarray(const value_type* px, size_t n); valarray(const valarray& v); valarray(valarray&& v) noexcept; valarray(const slice_array& sa); valarray(const gslice_array& ga); valarray(const mask_array& ma); valarray(const indirect_array& ia); valarray(initializer_list il); ~valarray(); // assignment: valarray& operator=(const valarray& v); valarray& operator=(valarray&& v) noexcept; valarray& operator=(initializer_list il); valarray& operator=(const value_type& x); valarray& operator=(const slice_array& sa); valarray& operator=(const gslice_array& ga); valarray& operator=(const mask_array& ma); valarray& operator=(const indirect_array& ia); // element access: const value_type& operator[](size_t i) const; value_type& operator[](size_t i); // subset operations: valarray operator[](slice s) const; slice_array operator[](slice s); valarray operator[](const gslice& gs) const; gslice_array operator[](const gslice& gs); valarray operator[](const valarray& vb) const; mask_array operator[](const valarray& vb); valarray operator[](const valarray& vs) const; indirect_array operator[](const valarray& vs); // unary operators: valarray operator+() const; valarray operator-() const; valarray operator~() const; valarray operator!() const; // computed assignment: valarray& operator*= (const value_type& x); valarray& operator/= (const value_type& x); valarray& operator%= (const value_type& x); valarray& operator+= (const value_type& x); valarray& operator-= (const value_type& x); valarray& operator^= (const value_type& x); valarray& operator&= (const value_type& x); valarray& operator|= (const value_type& x); valarray& operator<<=(const value_type& x); valarray& operator>>=(const value_type& x); valarray& operator*= (const valarray& v); valarray& operator/= (const valarray& v); valarray& operator%= (const valarray& v); valarray& operator+= (const valarray& v); valarray& operator-= (const valarray& v); valarray& operator^= (const valarray& v); valarray& operator|= (const valarray& v); valarray& operator&= (const valarray& v); valarray& operator<<=(const valarray& v); valarray& operator>>=(const valarray& v); // member functions: void swap(valarray& v) noexcept; size_t size() const; value_type sum() const; value_type min() const; value_type max() const; valarray shift (int i) const; valarray cshift(int i) const; valarray apply(value_type f(value_type)) const; valarray apply(value_type f(const value_type&)) const; void resize(size_t n, value_type x = value_type()); }; class slice { public: slice(); slice(size_t start, size_t size, size_t stride); size_t start() const; size_t size() const; size_t stride() const; }; template class slice_array { public: typedef T value_type; const slice_array& operator=(const slice_array& sa) const; void operator= (const valarray& v) const; void operator*= (const valarray& v) const; void operator/= (const valarray& v) const; void operator%= (const valarray& v) const; void operator+= (const valarray& v) const; void operator-= (const valarray& v) const; void operator^= (const valarray& v) const; void operator&= (const valarray& v) const; void operator|= (const valarray& v) const; void operator<<=(const valarray& v) const; void operator>>=(const valarray& v) const; void operator=(const value_type& x) const; slice_array() = delete; }; class gslice { public: gslice(); gslice(size_t start, const valarray& size, const valarray& stride); size_t start() const; valarray size() const; valarray stride() const; }; template class gslice_array { public: typedef T value_type; void operator= (const valarray& v) const; void operator*= (const valarray& v) const; void operator/= (const valarray& v) const; void operator%= (const valarray& v) const; void operator+= (const valarray& v) const; void operator-= (const valarray& v) const; void operator^= (const valarray& v) const; void operator&= (const valarray& v) const; void operator|= (const valarray& v) const; void operator<<=(const valarray& v) const; void operator>>=(const valarray& v) const; gslice_array(const gslice_array& ga); ~gslice_array(); const gslice_array& operator=(const gslice_array& ga) const; void operator=(const value_type& x) const; gslice_array() = delete; }; template class mask_array { public: typedef T value_type; void operator= (const valarray& v) const; void operator*= (const valarray& v) const; void operator/= (const valarray& v) const; void operator%= (const valarray& v) const; void operator+= (const valarray& v) const; void operator-= (const valarray& v) const; void operator^= (const valarray& v) const; void operator&= (const valarray& v) const; void operator|= (const valarray& v) const; void operator<<=(const valarray& v) const; void operator>>=(const valarray& v) const; mask_array(const mask_array& ma); ~mask_array(); const mask_array& operator=(const mask_array& ma) const; void operator=(const value_type& x) const; mask_array() = delete; }; template class indirect_array { public: typedef T value_type; void operator= (const valarray& v) const; void operator*= (const valarray& v) const; void operator/= (const valarray& v) const; void operator%= (const valarray& v) const; void operator+= (const valarray& v) const; void operator-= (const valarray& v) const; void operator^= (const valarray& v) const; void operator&= (const valarray& v) const; void operator|= (const valarray& v) const; void operator<<=(const valarray& v) const; void operator>>=(const valarray& v) const; indirect_array(const indirect_array& ia); ~indirect_array(); const indirect_array& operator=(const indirect_array& ia) const; void operator=(const value_type& x) const; indirect_array() = delete; }; template void swap(valarray& x, valarray& y) noexcept; template valarray operator* (const valarray& x, const valarray& y); template valarray operator* (const valarray& x, const T& y); template valarray operator* (const T& x, const valarray& y); template valarray operator/ (const valarray& x, const valarray& y); template valarray operator/ (const valarray& x, const T& y); template valarray operator/ (const T& x, const valarray& y); template valarray operator% (const valarray& x, const valarray& y); template valarray operator% (const valarray& x, const T& y); template valarray operator% (const T& x, const valarray& y); template valarray operator+ (const valarray& x, const valarray& y); template valarray operator+ (const valarray& x, const T& y); template valarray operator+ (const T& x, const valarray& y); template valarray operator- (const valarray& x, const valarray& y); template valarray operator- (const valarray& x, const T& y); template valarray operator- (const T& x, const valarray& y); template valarray operator^ (const valarray& x, const valarray& y); template valarray operator^ (const valarray& x, const T& y); template valarray operator^ (const T& x, const valarray& y); template valarray operator& (const valarray& x, const valarray& y); template valarray operator& (const valarray& x, const T& y); template valarray operator& (const T& x, const valarray& y); template valarray operator| (const valarray& x, const valarray& y); template valarray operator| (const valarray& x, const T& y); template valarray operator| (const T& x, const valarray& y); template valarray operator<<(const valarray& x, const valarray& y); template valarray operator<<(const valarray& x, const T& y); template valarray operator<<(const T& x, const valarray& y); template valarray operator>>(const valarray& x, const valarray& y); template valarray operator>>(const valarray& x, const T& y); template valarray operator>>(const T& x, const valarray& y); template valarray operator&&(const valarray& x, const valarray& y); template valarray operator&&(const valarray& x, const T& y); template valarray operator&&(const T& x, const valarray& y); template valarray operator||(const valarray& x, const valarray& y); template valarray operator||(const valarray& x, const T& y); template valarray operator||(const T& x, const valarray& y); template valarray operator==(const valarray& x, const valarray& y); template valarray operator==(const valarray& x, const T& y); template valarray operator==(const T& x, const valarray& y); template valarray operator!=(const valarray& x, const valarray& y); template valarray operator!=(const valarray& x, const T& y); template valarray operator!=(const T& x, const valarray& y); template valarray operator< (const valarray& x, const valarray& y); template valarray operator< (const valarray& x, const T& y); template valarray operator< (const T& x, const valarray& y); template valarray operator> (const valarray& x, const valarray& y); template valarray operator> (const valarray& x, const T& y); template valarray operator> (const T& x, const valarray& y); template valarray operator<=(const valarray& x, const valarray& y); template valarray operator<=(const valarray& x, const T& y); template valarray operator<=(const T& x, const valarray& y); template valarray operator>=(const valarray& x, const valarray& y); template valarray operator>=(const valarray& x, const T& y); template valarray operator>=(const T& x, const valarray& y); template valarray abs (const valarray& x); template valarray acos (const valarray& x); template valarray asin (const valarray& x); template valarray atan (const valarray& x); template valarray atan2(const valarray& x, const valarray& y); template valarray atan2(const valarray& x, const T& y); template valarray atan2(const T& x, const valarray& y); template valarray cos (const valarray& x); template valarray cosh (const valarray& x); template valarray exp (const valarray& x); template valarray log (const valarray& x); template valarray log10(const valarray& x); template valarray pow(const valarray& x, const valarray& y); template valarray pow(const valarray& x, const T& y); template valarray pow(const T& x, const valarray& y); template valarray sin (const valarray& x); template valarray sinh (const valarray& x); template valarray sqrt (const valarray& x); template valarray tan (const valarray& x); template valarray tanh (const valarray& x); template unspecified1 begin(valarray& v); template unspecified2 begin(const valarray& v); template unspecified1 end(valarray& v); template unspecified2 end(const valarray& v); } // std */ #include <__config> #include #include #include #include #include #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template class _LIBCPP_TYPE_VIS_ONLY valarray; class _LIBCPP_TYPE_VIS_ONLY slice { size_t __start_; size_t __size_; size_t __stride_; public: _LIBCPP_INLINE_VISIBILITY slice() : __start_(0), __size_(0), __stride_(0) {} _LIBCPP_INLINE_VISIBILITY slice(size_t __start, size_t __size, size_t __stride) : __start_(__start), __size_(__size), __stride_(__stride) {} _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;} }; template class _LIBCPP_TYPE_VIS_ONLY slice_array; class _LIBCPP_TYPE_VIS gslice; template class _LIBCPP_TYPE_VIS_ONLY gslice_array; template class _LIBCPP_TYPE_VIS_ONLY mask_array; template class _LIBCPP_TYPE_VIS_ONLY indirect_array; template _LIBCPP_INLINE_VISIBILITY _Tp* begin(valarray<_Tp>& __v); template _LIBCPP_INLINE_VISIBILITY const _Tp* begin(const valarray<_Tp>& __v); template _LIBCPP_INLINE_VISIBILITY _Tp* end(valarray<_Tp>& __v); template _LIBCPP_INLINE_VISIBILITY const _Tp* end(const valarray<_Tp>& __v); template struct _UnaryOp { typedef typename _Op::result_type result_type; typedef typename _A0::value_type value_type; _Op __op_; _A0 __a0_; _LIBCPP_INLINE_VISIBILITY _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} }; template struct _BinaryOp { typedef typename _Op::result_type result_type; typedef typename _A0::value_type value_type; _Op __op_; _A0 __a0_; _A1 __a1_; _LIBCPP_INLINE_VISIBILITY _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1) : __op_(__op), __a0_(__a0), __a1_(__a1) {} _LIBCPP_INLINE_VISIBILITY value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} }; template class __scalar_expr { public: typedef _Tp value_type; typedef const _Tp& result_type; private: const value_type& __t_; size_t __s_; public: _LIBCPP_INLINE_VISIBILITY explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t) const {return __t_;} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __s_;} }; template struct __unary_plus : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return +__x;} }; template struct __bit_not : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return ~__x;} }; template struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x << __y;} }; template struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x >> __y;} }; template struct __apply_expr : unary_function<_Tp, _Tp> { private: _Fp __f_; public: _LIBCPP_INLINE_VISIBILITY explicit __apply_expr(_Fp __f) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return __f_(__x);} }; template struct __abs_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return abs(__x);} }; template struct __acos_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return acos(__x);} }; template struct __asin_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return asin(__x);} }; template struct __atan_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return atan(__x);} }; template struct __atan2_expr : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return atan2(__x, __y);} }; template struct __cos_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return cos(__x);} }; template struct __cosh_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return cosh(__x);} }; template struct __exp_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return exp(__x);} }; template struct __log_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return log(__x);} }; template struct __log10_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return log10(__x);} }; template struct __pow_expr : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return pow(__x, __y);} }; template struct __sin_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return sin(__x);} }; template struct __sinh_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return sinh(__x);} }; template struct __sqrt_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return sqrt(__x);} }; template struct __tan_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return tan(__x);} }; template struct __tanh_expr : unary_function<_Tp, _Tp> { _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return tanh(__x);} }; template class __slice_expr { typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; typedef value_type result_type; private: _ValExpr __expr_; size_t __start_; size_t __size_; size_t __stride_; _LIBCPP_INLINE_VISIBILITY __slice_expr(const slice& __sl, const _RmExpr& __e) : __expr_(__e), __start_(__sl.start()), __size_(__sl.size()), __stride_(__sl.stride()) {} public: _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __i) const {return __expr_[__start_ + __i * __stride_];} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} template friend class _LIBCPP_TYPE_VIS_ONLY valarray; }; template class __mask_expr; template class __indirect_expr; template class __shift_expr { typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; typedef value_type result_type; private: _ValExpr __expr_; size_t __size_; ptrdiff_t __ul_; ptrdiff_t __sn_; ptrdiff_t __n_; static const ptrdiff_t _Np = static_cast( sizeof(ptrdiff_t) * __CHAR_BIT__ - 1); _LIBCPP_INLINE_VISIBILITY __shift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()), __n_(__n) { ptrdiff_t __neg_n = static_cast(__n_ >> _Np); __sn_ = __neg_n | static_cast(static_cast(-__n_) >> _Np); __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n); } public: _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __j) const { ptrdiff_t __i = static_cast(__j); ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m); } _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} template friend class __val_expr; }; template class __cshift_expr { typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; typedef value_type result_type; private: _ValExpr __expr_; size_t __size_; size_t __m_; size_t __o1_; size_t __o2_; _LIBCPP_INLINE_VISIBILITY __cshift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()) { __n %= static_cast(__size_); if (__n >= 0) { __m_ = __size_ - __n; __o1_ = __n; __o2_ = __n - __size_; } else { __m_ = -__n; __o1_ = __n + __size_; __o2_ = __n; } } public: _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __i) const { if (__i < __m_) return __expr_[__i + __o1_]; return __expr_[__i + __o2_]; } _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} template friend class __val_expr; }; template class __val_expr; template struct __is_val_expr : false_type {}; template struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; template struct __is_val_expr > : true_type {}; template class _LIBCPP_TYPE_VIS_ONLY valarray { public: typedef _Tp value_type; typedef _Tp result_type; private: value_type* __begin_; value_type* __end_; public: // construct/destroy: _LIBCPP_INLINE_VISIBILITY valarray() : __begin_(0), __end_(0) {} explicit valarray(size_t __n); valarray(const value_type& __x, size_t __n); valarray(const value_type* __p, size_t __n); valarray(const valarray& __v); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES valarray(valarray&& __v) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS valarray(initializer_list __il); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS valarray(const slice_array& __sa); valarray(const gslice_array& __ga); valarray(const mask_array& __ma); valarray(const indirect_array& __ia); ~valarray(); // assignment: valarray& operator=(const valarray& __v); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES valarray& operator=(valarray&& __v) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS valarray& operator=(initializer_list); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS valarray& operator=(const value_type& __x); valarray& operator=(const slice_array& __sa); valarray& operator=(const gslice_array& __ga); valarray& operator=(const mask_array& __ma); valarray& operator=(const indirect_array& __ia); template valarray& operator=(const __val_expr<_ValExpr>& __v); // element access: _LIBCPP_INLINE_VISIBILITY const value_type& operator[](size_t __i) const {return __begin_[__i];} _LIBCPP_INLINE_VISIBILITY value_type& operator[](size_t __i) {return __begin_[__i];} // subset operations: __val_expr<__slice_expr > operator[](slice __s) const; slice_array operator[](slice __s); __val_expr<__indirect_expr > operator[](const gslice& __gs) const; gslice_array operator[](const gslice& __gs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __val_expr<__indirect_expr > operator[](gslice&& __gs) const; gslice_array operator[](gslice&& __gs); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES __val_expr<__mask_expr > operator[](const valarray& __vb) const; mask_array operator[](const valarray& __vb); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __val_expr<__mask_expr > operator[](valarray&& __vb) const; mask_array operator[](valarray&& __vb); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES __val_expr<__indirect_expr > operator[](const valarray& __vs) const; indirect_array operator[](const valarray& __vs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __val_expr<__indirect_expr > operator[](valarray&& __vs) const; indirect_array operator[](valarray&& __vs); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // unary operators: valarray operator+() const; valarray operator-() const; valarray operator~() const; valarray operator!() const; // computed assignment: valarray& operator*= (const value_type& __x); valarray& operator/= (const value_type& __x); valarray& operator%= (const value_type& __x); valarray& operator+= (const value_type& __x); valarray& operator-= (const value_type& __x); valarray& operator^= (const value_type& __x); valarray& operator&= (const value_type& __x); valarray& operator|= (const value_type& __x); valarray& operator<<=(const value_type& __x); valarray& operator>>=(const value_type& __x); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator*= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator/= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator%= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator+= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator-= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator^= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator|= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator&= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator<<= (const _Expr& __v); template typename enable_if < __is_val_expr<_Expr>::value, valarray& >::type operator>>= (const _Expr& __v); // member functions: void swap(valarray& __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_t size() const {return static_cast(__end_ - __begin_);} value_type sum() const; value_type min() const; value_type max() const; valarray shift (int __i) const; valarray cshift(int __i) const; valarray apply(value_type __f(value_type)) const; valarray apply(value_type __f(const value_type&)) const; void resize(size_t __n, value_type __x = value_type()); private: template friend class _LIBCPP_TYPE_VIS_ONLY valarray; template friend class _LIBCPP_TYPE_VIS_ONLY slice_array; template friend class _LIBCPP_TYPE_VIS_ONLY gslice_array; template friend class _LIBCPP_TYPE_VIS_ONLY mask_array; template friend class __mask_expr; template friend class _LIBCPP_TYPE_VIS_ONLY indirect_array; template friend class __indirect_expr; template friend class __val_expr; template friend _Up* begin(valarray<_Up>& __v); template friend const _Up* begin(const valarray<_Up>& __v); template friend _Up* end(valarray<_Up>& __v); template friend const _Up* end(const valarray<_Up>& __v); }; _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::valarray(size_t)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray::~valarray()) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray::resize(size_t, size_t)) template struct _UnaryOp<_Op, valarray<_Tp> > { typedef typename _Op::result_type result_type; typedef _Tp value_type; _Op __op_; const valarray<_Tp>& __a0_; _LIBCPP_INLINE_VISIBILITY _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} }; template struct _BinaryOp<_Op, valarray<_Tp>, _A1> { typedef typename _Op::result_type result_type; typedef _Tp value_type; _Op __op_; const valarray<_Tp>& __a0_; _A1 __a1_; _LIBCPP_INLINE_VISIBILITY _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1) : __op_(__op), __a0_(__a0), __a1_(__a1) {} _LIBCPP_INLINE_VISIBILITY value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} }; template struct _BinaryOp<_Op, _A0, valarray<_Tp> > { typedef typename _Op::result_type result_type; typedef _Tp value_type; _Op __op_; _A0 __a0_; const valarray<_Tp>& __a1_; _LIBCPP_INLINE_VISIBILITY _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1) : __op_(__op), __a0_(__a0), __a1_(__a1) {} _LIBCPP_INLINE_VISIBILITY value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} }; template struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > { typedef typename _Op::result_type result_type; typedef _Tp value_type; _Op __op_; const valarray<_Tp>& __a0_; const valarray<_Tp>& __a1_; _LIBCPP_INLINE_VISIBILITY _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1) : __op_(__op), __a0_(__a0), __a1_(__a1) {} _LIBCPP_INLINE_VISIBILITY value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __a0_.size();} }; // slice_array template class _LIBCPP_TYPE_VIS_ONLY slice_array { public: typedef _Tp value_type; private: value_type* __vp_; size_t __size_; size_t __stride_; public: template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator*=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator/=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator%=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator+=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator-=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator^=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator&=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator|=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator<<=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator>>=(const _Expr& __v) const; const slice_array& operator=(const slice_array& __sa) const; void operator=(const value_type& __x) const; private: _LIBCPP_INLINE_VISIBILITY slice_array(const slice& __sl, const valarray& __v) : __vp_(const_cast(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {} template friend class valarray; template friend class sliceExpr; }; template inline _LIBCPP_INLINE_VISIBILITY const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const { value_type* __t = __vp_; const value_type* __s = __sa.__vp_; for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) *__t = *__s; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t = __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator*=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t *= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator/=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t /= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator%=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t %= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator+=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t += __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator-=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t -= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator^=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t ^= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator&=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t &= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator|=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t |= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator<<=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t <<= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type slice_array<_Tp>::operator>>=(const _Expr& __v) const { value_type* __t = __vp_; for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) *__t >>= __v[__i]; } template inline _LIBCPP_INLINE_VISIBILITY void slice_array<_Tp>::operator=(const value_type& __x) const { value_type* __t = __vp_; for (size_t __n = __size_; __n; --__n, __t += __stride_) *__t = __x; } // gslice class _LIBCPP_TYPE_VIS gslice { valarray __size_; valarray __stride_; valarray __1d_; public: _LIBCPP_INLINE_VISIBILITY gslice() {} _LIBCPP_INLINE_VISIBILITY gslice(size_t __start, const valarray& __size, const valarray& __stride) : __size_(__size), __stride_(__stride) {__init(__start);} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY gslice(size_t __start, const valarray& __size, valarray&& __stride) : __size_(__size), __stride_(move(__stride)) {__init(__start);} _LIBCPP_INLINE_VISIBILITY gslice(size_t __start, valarray&& __size, const valarray& __stride) : __size_(move(__size)), __stride_(__stride) {__init(__start);} _LIBCPP_INLINE_VISIBILITY gslice(size_t __start, valarray&& __size, valarray&& __stride) : __size_(move(__size)), __stride_(move(__stride)) {__init(__start);} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // gslice(const gslice&) = default; // gslice(gslice&&) = default; // gslice& operator=(const gslice&) = default; // gslice& operator=(gslice&&) = default; _LIBCPP_INLINE_VISIBILITY size_t start() const {return __1d_.size() ? __1d_[0] : 0;} _LIBCPP_INLINE_VISIBILITY valarray size() const {return __size_;} _LIBCPP_INLINE_VISIBILITY valarray stride() const {return __stride_;} private: void __init(size_t __start); template friend class gslice_array; template friend class valarray; template friend class __val_expr; }; // gslice_array template class _LIBCPP_TYPE_VIS_ONLY gslice_array { public: typedef _Tp value_type; private: value_type* __vp_; valarray __1d_; public: template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator*=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator/=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator%=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator+=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator-=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator^=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator&=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator|=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator<<=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator>>=(const _Expr& __v) const; const gslice_array& operator=(const gslice_array& __ga) const; void operator=(const value_type& __x) const; // gslice_array(const gslice_array&) = default; // gslice_array(gslice_array&&) = default; // gslice_array& operator=(const gslice_array&) = default; // gslice_array& operator=(gslice_array&&) = default; private: _LIBCPP_INLINE_VISIBILITY gslice_array(const gslice& __gs, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(__gs.__1d_) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY gslice_array(gslice&& __gs, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(move(__gs.__1d_)) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend class valarray; }; template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] = __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator*=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] *= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator/=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] /= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator%=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] %= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator+=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] += __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator-=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] -= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator^=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] ^= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator&=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] &= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator|=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] |= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator<<=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] <<= __v[__j]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type gslice_array<_Tp>::operator>>=(const _Expr& __v) const { typedef const size_t* _Ip; size_t __j = 0; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) __vp_[*__i] >>= __v[__j]; } template inline _LIBCPP_INLINE_VISIBILITY const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const { typedef const size_t* _Ip; const value_type* __s = __ga.__vp_; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; __i != __e; ++__i, ++__j) __vp_[*__i] = __s[*__j]; return *this; } template inline _LIBCPP_INLINE_VISIBILITY void gslice_array<_Tp>::operator=(const value_type& __x) const { typedef const size_t* _Ip; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) __vp_[*__i] = __x; } // mask_array template class _LIBCPP_TYPE_VIS_ONLY mask_array { public: typedef _Tp value_type; private: value_type* __vp_; valarray __1d_; public: template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator*=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator/=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator%=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator+=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator-=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator^=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator&=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator|=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator<<=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator>>=(const _Expr& __v) const; const mask_array& operator=(const mask_array& __ma) const; void operator=(const value_type& __x) const; // mask_array(const mask_array&) = default; // mask_array(mask_array&&) = default; // mask_array& operator=(const mask_array&) = default; // mask_array& operator=(mask_array&&) = default; private: _LIBCPP_INLINE_VISIBILITY mask_array(const valarray& __vb, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(static_cast(count(__vb.__begin_, __vb.__end_, true))) { size_t __j = 0; for (size_t __i = 0; __i < __vb.size(); ++__i) if (__vb[__i]) __1d_[__j++] = __i; } template friend class valarray; }; template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] = __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator*=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] *= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator/=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] /= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator%=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] %= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator+=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] += __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator-=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] -= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator^=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] ^= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator&=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] &= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator|=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] |= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator<<=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] <<= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type mask_array<_Tp>::operator>>=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] >>= __v[__i]; } template inline _LIBCPP_INLINE_VISIBILITY const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; } template inline _LIBCPP_INLINE_VISIBILITY void mask_array<_Tp>::operator=(const value_type& __x) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] = __x; } template class __mask_expr { typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; typedef value_type result_type; private: _ValExpr __expr_; valarray __1d_; _LIBCPP_INLINE_VISIBILITY __mask_expr(const valarray& __vb, const _RmExpr& __e) : __expr_(__e), __1d_(static_cast(count(__vb.__begin_, __vb.__end_, true))) { size_t __j = 0; for (size_t __i = 0; __i < __vb.size(); ++__i) if (__vb[__i]) __1d_[__j++] = __i; } public: _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __i) const {return __expr_[__1d_[__i]];} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __1d_.size();} template friend class valarray; }; // indirect_array template class _LIBCPP_TYPE_VIS_ONLY indirect_array { public: typedef _Tp value_type; private: value_type* __vp_; valarray __1d_; public: template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator*=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator/=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator%=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator+=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator-=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator^=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator&=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator|=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator<<=(const _Expr& __v) const; template typename enable_if < __is_val_expr<_Expr>::value, void >::type operator>>=(const _Expr& __v) const; const indirect_array& operator=(const indirect_array& __ia) const; void operator=(const value_type& __x) const; // indirect_array(const indirect_array&) = default; // indirect_array(indirect_array&&) = default; // indirect_array& operator=(const indirect_array&) = default; // indirect_array& operator=(indirect_array&&) = default; private: _LIBCPP_INLINE_VISIBILITY indirect_array(const valarray& __ia, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(__ia) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY indirect_array(valarray&& __ia, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(move(__ia)) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend class valarray; }; template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] = __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator*=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] *= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator/=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] /= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator%=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] %= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator+=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] += __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator-=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] -= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator^=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] ^= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator&=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] &= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator|=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] |= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator<<=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] <<= __v[__i]; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, void >::type indirect_array<_Tp>::operator>>=(const _Expr& __v) const { size_t __n = __1d_.size(); for (size_t __i = 0; __i < __n; ++__i) __vp_[__1d_[__i]] >>= __v[__i]; } template inline _LIBCPP_INLINE_VISIBILITY const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const { typedef const size_t* _Ip; const value_type* __s = __ia.__vp_; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; __i != __e; ++__i, ++__j) __vp_[*__i] = __s[*__j]; return *this; } template inline _LIBCPP_INLINE_VISIBILITY void indirect_array<_Tp>::operator=(const value_type& __x) const { typedef const size_t* _Ip; for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) __vp_[*__i] = __x; } template class __indirect_expr { typedef typename remove_reference<_ValExpr>::type _RmExpr; public: typedef typename _RmExpr::value_type value_type; typedef value_type result_type; private: _ValExpr __expr_; valarray __1d_; _LIBCPP_INLINE_VISIBILITY __indirect_expr(const valarray& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY __indirect_expr(valarray&& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(move(__ia)) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES public: _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __i) const {return __expr_[__1d_[__i]];} _LIBCPP_INLINE_VISIBILITY size_t size() const {return __1d_.size();} template friend class _LIBCPP_TYPE_VIS_ONLY valarray; }; template class __val_expr { typedef typename remove_reference<_ValExpr>::type _RmExpr; _ValExpr __expr_; public: typedef typename _RmExpr::value_type value_type; typedef typename _RmExpr::result_type result_type; _LIBCPP_INLINE_VISIBILITY explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} _LIBCPP_INLINE_VISIBILITY result_type operator[](size_t __i) const {return __expr_[__i];} _LIBCPP_INLINE_VISIBILITY __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);} _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);} _LIBCPP_INLINE_VISIBILITY __val_expr<__mask_expr<_ValExpr> > operator[](const valarray& __vb) const {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);} _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray& __vs) const {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);} _LIBCPP_INLINE_VISIBILITY __val_expr<_UnaryOp<__unary_plus, _ValExpr> > operator+() const { typedef _UnaryOp<__unary_plus, _ValExpr> _NewExpr; return __val_expr<_NewExpr>(_NewExpr(__unary_plus(), __expr_)); } _LIBCPP_INLINE_VISIBILITY __val_expr<_UnaryOp, _ValExpr> > operator-() const { typedef _UnaryOp, _ValExpr> _NewExpr; return __val_expr<_NewExpr>(_NewExpr(negate(), __expr_)); } _LIBCPP_INLINE_VISIBILITY __val_expr<_UnaryOp<__bit_not, _ValExpr> > operator~() const { typedef _UnaryOp<__bit_not, _ValExpr> _NewExpr; return __val_expr<_NewExpr>(_NewExpr(__bit_not(), __expr_)); } _LIBCPP_INLINE_VISIBILITY __val_expr<_UnaryOp, _ValExpr> > operator!() const { typedef _UnaryOp, _ValExpr> _NewExpr; return __val_expr<_NewExpr>(_NewExpr(logical_not(), __expr_)); } operator valarray() const; _LIBCPP_INLINE_VISIBILITY size_t size() const {return __expr_.size();} _LIBCPP_INLINE_VISIBILITY result_type sum() const { size_t __n = __expr_.size(); result_type __r = __n ? __expr_[0] : result_type(); for (size_t __i = 1; __i < __n; ++__i) __r += __expr_[__i]; return __r; } _LIBCPP_INLINE_VISIBILITY result_type min() const { size_t __n = size(); result_type __r = __n ? (*this)[0] : result_type(); for (size_t __i = 1; __i < __n; ++__i) { result_type __x = __expr_[__i]; if (__x < __r) __r = __x; } return __r; } _LIBCPP_INLINE_VISIBILITY result_type max() const { size_t __n = size(); result_type __r = __n ? (*this)[0] : result_type(); for (size_t __i = 1; __i < __n; ++__i) { result_type __x = __expr_[__i]; if (__r < __x) __r = __x; } return __r; } _LIBCPP_INLINE_VISIBILITY __val_expr<__shift_expr<_ValExpr> > shift (int __i) const {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));} _LIBCPP_INLINE_VISIBILITY __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));} _LIBCPP_INLINE_VISIBILITY __val_expr<_UnaryOp<__apply_expr, _ValExpr> > apply(value_type __f(value_type)) const { typedef __apply_expr _Op; typedef _UnaryOp<_Op, _ValExpr> _NewExpr; return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); } _LIBCPP_INLINE_VISIBILITY __val_expr<_UnaryOp<__apply_expr, _ValExpr> > apply(value_type __f(const value_type&)) const { typedef __apply_expr _Op; typedef _UnaryOp<_Op, _ValExpr> _NewExpr; return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); } }; template __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const { valarray __r; size_t __n = __expr_.size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(result_type))); for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) ::new (__r.__end_) result_type(__expr_[__i]); } return __r; } // valarray template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>::valarray(size_t __n) : __begin_(0), __end_(0) { resize(__n); } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(0), __end_(0) { resize(__n, __x); } template valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(0), __end_(0) { if (__n) { __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __n; ++__end_, ++__p, --__n) ::new (__end_) value_type(*__p); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } template valarray<_Tp>::valarray(const valarray& __v) : __begin_(0), __end_(0) { if (__v.size()) { __begin_ = __end_ = static_cast(::operator new(__v.size() * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) ::new (__end_) value_type(*__p); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) { __v.__begin_ = __v.__end_ = nullptr; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template valarray<_Tp>::valarray(initializer_list __il) : __begin_(0), __end_(0) { size_t __n = __il.size(); if (__n) { __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n) ::new (__end_) value_type(*__p); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template valarray<_Tp>::valarray(const slice_array& __sa) : __begin_(0), __end_(0) { size_t __n = __sa.__size_; if (__n) { __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n) ::new (__end_) value_type(*__p); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } template valarray<_Tp>::valarray(const gslice_array& __ga) : __begin_(0), __end_(0) { size_t __n = __ga.__1d_.size(); if (__n) { __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ga.__vp_; for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new (__end_) value_type(__s[*__i]); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } template valarray<_Tp>::valarray(const mask_array& __ma) : __begin_(0), __end_(0) { size_t __n = __ma.__1d_.size(); if (__n) { __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ma.__vp_; for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new (__end_) value_type(__s[*__i]); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } template valarray<_Tp>::valarray(const indirect_array& __ia) : __begin_(0), __end_(0) { size_t __n = __ia.__1d_.size(); if (__n) { __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ia.__vp_; for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new (__end_) value_type(__s[*__i]); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>::~valarray() { resize(0); } template valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) { if (this != &__v) { if (size() != __v.size()) resize(__v.size()); _VSTD::copy(__v.__begin_, __v.__end_, __begin_); } return *this; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT { resize(0); __begin_ = __v.__begin_; __end_ = __v.__end_; __v.__begin_ = nullptr; __v.__end_ = nullptr; return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(initializer_list __il) { if (size() != __il.size()) resize(__il.size()); _VSTD::copy(__il.begin(), __il.end(), __begin_); return *this; } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) { _VSTD::fill(__begin_, __end_, __x); return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(const slice_array& __sa) { value_type* __t = __begin_; const value_type* __s = __sa.__vp_; for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t) *__t = *__s; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array& __ga) { typedef const size_t* _Ip; value_type* __t = __begin_; const value_type* __s = __ga.__vp_; for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__t) *__t = __s[*__i]; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(const mask_array& __ma) { typedef const size_t* _Ip; value_type* __t = __begin_; const value_type* __s = __ma.__vp_; for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__t) *__t = __s[*__i]; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array& __ia) { typedef const size_t* _Ip; value_type* __t = __begin_; const value_type* __s = __ia.__vp_; for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__t) *__t = __s[*__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) { size_t __n = __v.size(); if (size() != __n) resize(__n); value_type* __t = __begin_; for (size_t __i = 0; __i != __n; ++__t, ++__i) *__t = result_type(__v[__i]); return *this; } template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__slice_expr&> > valarray<_Tp>::operator[](slice __s) const { return __val_expr<__slice_expr >(__slice_expr(__s, *this)); } template inline _LIBCPP_INLINE_VISIBILITY slice_array<_Tp> valarray<_Tp>::operator[](slice __s) { return slice_array(__s, *this); } template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](const gslice& __gs) const { return __val_expr<__indirect_expr >(__indirect_expr(__gs.__1d_, *this)); } template inline _LIBCPP_INLINE_VISIBILITY gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) { return gslice_array(__gs, *this); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](gslice&& __gs) const { return __val_expr<__indirect_expr >(__indirect_expr(move(__gs.__1d_), *this)); } template inline _LIBCPP_INLINE_VISIBILITY gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) { return gslice_array(move(__gs), *this); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__mask_expr&> > valarray<_Tp>::operator[](const valarray& __vb) const { return __val_expr<__mask_expr >(__mask_expr(__vb, *this)); } template inline _LIBCPP_INLINE_VISIBILITY mask_array<_Tp> valarray<_Tp>::operator[](const valarray& __vb) { return mask_array(__vb, *this); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__mask_expr&> > valarray<_Tp>::operator[](valarray&& __vb) const { return __val_expr<__mask_expr >(__mask_expr(move(__vb), *this)); } template inline _LIBCPP_INLINE_VISIBILITY mask_array<_Tp> valarray<_Tp>::operator[](valarray&& __vb) { return mask_array(move(__vb), *this); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](const valarray& __vs) const { return __val_expr<__indirect_expr >(__indirect_expr(__vs, *this)); } template inline _LIBCPP_INLINE_VISIBILITY indirect_array<_Tp> valarray<_Tp>::operator[](const valarray& __vs) { return indirect_array(__vs, *this); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](valarray&& __vs) const { return __val_expr<__indirect_expr >(__indirect_expr(move(__vs), *this)); } template inline _LIBCPP_INLINE_VISIBILITY indirect_array<_Tp> valarray<_Tp>::operator[](valarray&& __vs) { return indirect_array(move(__vs), *this); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template valarray<_Tp> valarray<_Tp>::operator+() const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(+*__p); } return __r; } template valarray<_Tp> valarray<_Tp>::operator-() const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(-*__p); } return __r; } template valarray<_Tp> valarray<_Tp>::operator~() const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(~*__p); } return __r; } template valarray valarray<_Tp>::operator!() const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(bool))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) bool(!*__p); } return __r; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p *= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p /= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p %= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p += __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p -= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p ^= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p &= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p |= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p <<= __x; return *this; } template inline _LIBCPP_INLINE_VISIBILITY valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) { for (value_type* __p = __begin_; __p != __end_; ++__p) *__p >>= __x; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator*=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t *= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator/=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t /= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator%=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t %= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator+=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t += __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator-=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t -= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator^=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t ^= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator|=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t |= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator&=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t &= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator<<=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t <<= __v[__i]; return *this; } template template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, valarray<_Tp>& >::type valarray<_Tp>::operator>>=(const _Expr& __v) { size_t __i = 0; for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) *__t >>= __v[__i]; return *this; } template inline _LIBCPP_INLINE_VISIBILITY void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT { _VSTD::swap(__begin_, __v.__begin_); _VSTD::swap(__end_, __v.__end_); } template inline _LIBCPP_INLINE_VISIBILITY _Tp valarray<_Tp>::sum() const { if (__begin_ == __end_) return value_type(); const value_type* __p = __begin_; _Tp __r = *__p; for (++__p; __p != __end_; ++__p) __r += *__p; return __r; } template inline _LIBCPP_INLINE_VISIBILITY _Tp valarray<_Tp>::min() const { if (__begin_ == __end_) return value_type(); return *_VSTD::min_element(__begin_, __end_); } template inline _LIBCPP_INLINE_VISIBILITY _Tp valarray<_Tp>::max() const { if (__begin_ == __end_) return value_type(); return *_VSTD::max_element(__begin_, __end_); } template valarray<_Tp> valarray<_Tp>::shift(int __i) const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(value_type))); const value_type* __sb; value_type* __tb; value_type* __te; if (__i >= 0) { __i = _VSTD::min(__i, static_cast(__n)); __sb = __begin_ + __i; __tb = __r.__begin_; __te = __r.__begin_ + (__n - __i); } else { __i = _VSTD::min(-__i, static_cast(__n)); __sb = __begin_; __tb = __r.__begin_ + __i; __te = __r.__begin_ + __n; } for (; __r.__end_ != __tb; ++__r.__end_) ::new (__r.__end_) value_type(); for (; __r.__end_ != __te; ++__r.__end_, ++__sb) ::new (__r.__end_) value_type(*__sb); for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_) ::new (__r.__end_) value_type(); } return __r; } template valarray<_Tp> valarray<_Tp>::cshift(int __i) const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(value_type))); __i %= static_cast(__n); const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) ::new (__r.__end_) value_type(*__s); for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s) ::new (__r.__end_) value_type(*__s); } return __r; } template valarray<_Tp> valarray<_Tp>::apply(value_type __f(value_type)) const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(__f(*__p)); } return __r; } template valarray<_Tp> valarray<_Tp>::apply(value_type __f(const value_type&)) const { valarray __r; size_t __n = size(); if (__n) { __r.__begin_ = __r.__end_ = static_cast(::operator new(__n * sizeof(value_type))); for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) ::new (__r.__end_) value_type(__f(*__p)); } return __r; } template void valarray<_Tp>::resize(size_t __n, value_type __x) { if (__begin_ != nullptr) { while (__end_ != __begin_) (--__end_)->~value_type(); ::operator delete(__begin_); __begin_ = __end_ = nullptr; } if (__n) { __begin_ = __end_ = static_cast(::operator new(__n * sizeof(value_type))); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __n; --__n, ++__end_) ::new (__end_) value_type(__x); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { resize(0); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } } template inline _LIBCPP_INLINE_VISIBILITY void swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT { __x.swap(__y); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator*(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(multiplies(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator*(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(multiplies(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator*(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(multiplies(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator/(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(divides(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator/(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(divides(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator/(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(divides(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator%(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(modulus(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator%(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(modulus(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator%(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(modulus(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator+(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(plus(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator+(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(plus(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator+(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(plus(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator-(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(minus(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator-(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(minus(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator-(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(minus(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator^(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(bit_xor(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator^(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(bit_xor(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator^(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(bit_xor(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator&(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(bit_and(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator&(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(bit_and(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator&(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(bit_and(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator|(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(bit_or(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator|(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(bit_or(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator|(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(bit_or(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp<__bit_shift_left, _Expr1, _Expr2> > >::type operator<<(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp<__bit_shift_left, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(__bit_shift_left(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__bit_shift_left, _Expr, __scalar_expr > > >::type operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__bit_shift_left, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(__bit_shift_left(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__bit_shift_left, __scalar_expr, _Expr> > >::type operator<<(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__bit_shift_left, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__bit_shift_left(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp<__bit_shift_right, _Expr1, _Expr2> > >::type operator>>(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp<__bit_shift_right, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(__bit_shift_right(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__bit_shift_right, _Expr, __scalar_expr > > >::type operator>>(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__bit_shift_right, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(__bit_shift_right(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__bit_shift_right, __scalar_expr, _Expr> > >::type operator>>(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__bit_shift_right, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__bit_shift_right(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator&&(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(logical_and(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator&&(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(logical_and(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator&&(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(logical_and(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator||(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(logical_or(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator||(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(logical_or(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator||(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(logical_or(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator==(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(equal_to(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator==(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(equal_to(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator==(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(equal_to(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator!=(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(not_equal_to(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator!=(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(not_equal_to(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator!=(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(not_equal_to(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator<(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(less(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator<(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(less(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator<(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(less(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator>(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(greater(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator>(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(greater(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator>(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(greater(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator<=(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(less_equal(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator<=(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(less_equal(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator<=(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(less_equal(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp, _Expr1, _Expr2> > >::type operator>=(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(greater_equal(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, _Expr, __scalar_expr > > >::type operator>=(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(greater_equal(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp, __scalar_expr, _Expr> > >::type operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(greater_equal(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__abs_expr, _Expr> > >::type abs(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__abs_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__abs_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__acos_expr, _Expr> > >::type acos(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__acos_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__acos_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__asin_expr, _Expr> > >::type asin(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__asin_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__asin_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__atan_expr, _Expr> > >::type atan(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__atan_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__atan_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp<__atan2_expr, _Expr1, _Expr2> > >::type atan2(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp<__atan2_expr, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(__atan2_expr(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__atan2_expr, _Expr, __scalar_expr > > >::type atan2(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__atan2_expr, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(__atan2_expr(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__atan2_expr, __scalar_expr, _Expr> > >::type atan2(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__atan2_expr, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__atan2_expr(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__cos_expr, _Expr> > >::type cos(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__cos_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__cos_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__cosh_expr, _Expr> > >::type cosh(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__cosh_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__cosh_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__exp_expr, _Expr> > >::type exp(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__exp_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__exp_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__log_expr, _Expr> > >::type log(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__log_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__log_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__log10_expr, _Expr> > >::type log10(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__log10_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__log10_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, __val_expr<_BinaryOp<__pow_expr, _Expr1, _Expr2> > >::type pow(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; typedef _BinaryOp<__pow_expr, _Expr1, _Expr2> _Op; return __val_expr<_Op>(_Op(__pow_expr(), __x, __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__pow_expr, _Expr, __scalar_expr > > >::type pow(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__pow_expr, _Expr, __scalar_expr > _Op; return __val_expr<_Op>(_Op(__pow_expr(), __x, __scalar_expr(__y, __x.size()))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__pow_expr, __scalar_expr, _Expr> > >::type pow(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; typedef _BinaryOp<__pow_expr, __scalar_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__pow_expr(), __scalar_expr(__x, __y.size()), __y)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__sin_expr, _Expr> > >::type sin(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__sin_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__sin_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__sinh_expr, _Expr> > >::type sinh(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__sinh_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__sinh_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__sqrt_expr, _Expr> > >::type sqrt(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__sqrt_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__sqrt_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__tan_expr, _Expr> > >::type tan(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__tan_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__tan_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__tanh_expr, _Expr> > >::type tanh(const _Expr& __x) { typedef typename _Expr::value_type value_type; typedef _UnaryOp<__tanh_expr, _Expr> _Op; return __val_expr<_Op>(_Op(__tanh_expr(), __x)); } template inline _LIBCPP_INLINE_VISIBILITY _Tp* begin(valarray<_Tp>& __v) { return __v.__begin_; } template inline _LIBCPP_INLINE_VISIBILITY const _Tp* begin(const valarray<_Tp>& __v) { return __v.__begin_; } template inline _LIBCPP_INLINE_VISIBILITY _Tp* end(valarray<_Tp>& __v) { return __v.__end_; } template inline _LIBCPP_INLINE_VISIBILITY const _Tp* end(const valarray<_Tp>& __v) { return __v.__end_; } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_VALARRAY libcxx/include/__tree0000644000175000017500000024624312266757731016067 0ustar sylvestresylvestre// -*- 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. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP___TREE #define _LIBCPP___TREE #include <__config> #include #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template class __tree; 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; /* _NodePtr algorithms The algorithms taking _NodePtr are red black tree algorithms. Those algorithms taking a parameter named __root should assume that __root points to a proper red black tree (unless otherwise specified). Each algorithm herein assumes that __root->__parent_ points to a non-null structure which has a member __left_ which points back to __root. No other member is read or written to at __root->__parent_. __root->__parent_ will be referred to below (in comments only) as end_node. end_node->__left_ is an externably accessible lvalue for __root, and can be changed by node insertion and removal (without explicit reference to end_node). All nodes (with the exception of end_node), even the node referred to as __root, have a non-null __parent_ field. */ // Returns: true if __x is a left child of its parent, else false // Precondition: __x != nullptr. template inline _LIBCPP_INLINE_VISIBILITY bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT { return __x == __x->__parent_->__left_; } // Determintes if the subtree rooted at __x is a proper red black subtree. If // __x is a proper subtree, returns the black height (null counts as 1). If // __x is an improper subtree, returns 0. template unsigned __tree_sub_invariant(_NodePtr __x) { if (__x == nullptr) return 1; // parent consistency checked by caller // check __x->__left_ consistency if (__x->__left_ != nullptr && __x->__left_->__parent_ != __x) return 0; // check __x->__right_ consistency if (__x->__right_ != nullptr && __x->__right_->__parent_ != __x) return 0; // check __x->__left_ != __x->__right_ unless both are nullptr if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr) return 0; // If this is red, neither child can be red if (!__x->__is_black_) { if (__x->__left_ && !__x->__left_->__is_black_) return 0; if (__x->__right_ && !__x->__right_->__is_black_) return 0; } unsigned __h = __tree_sub_invariant(__x->__left_); if (__h == 0) return 0; // invalid left subtree if (__h != __tree_sub_invariant(__x->__right_)) return 0; // invalid or different height right subtree return __h + __x->__is_black_; // return black height of this node } // Determintes if the red black tree rooted at __root is a proper red black tree. // __root == nullptr is a proper tree. Returns true is __root is a proper // red black tree, else returns false. template bool __tree_invariant(_NodePtr __root) { if (__root == nullptr) return true; // check __x->__parent_ consistency if (__root->__parent_ == nullptr) return false; if (!__tree_is_left_child(__root)) return false; // root must be black if (!__root->__is_black_) return false; // do normal node checks return __tree_sub_invariant(__root) != 0; } // Returns: pointer to the left-most node under __x. // Precondition: __x != nullptr. template inline _LIBCPP_INLINE_VISIBILITY _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT { while (__x->__left_ != nullptr) __x = __x->__left_; return __x; } // Returns: pointer to the right-most node under __x. // Precondition: __x != nullptr. template inline _LIBCPP_INLINE_VISIBILITY _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT { while (__x->__right_ != nullptr) __x = __x->__right_; return __x; } // Returns: pointer to the next in-order node after __x. // Precondition: __x != nullptr. template _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT { if (__x->__right_ != nullptr) return __tree_min(__x->__right_); while (!__tree_is_left_child(__x)) __x = __x->__parent_; return __x->__parent_; } // Returns: pointer to the previous in-order node before __x. // Precondition: __x != nullptr. template _NodePtr __tree_prev(_NodePtr __x) _NOEXCEPT { if (__x->__left_ != nullptr) return __tree_max(__x->__left_); while (__tree_is_left_child(__x)) __x = __x->__parent_; return __x->__parent_; } // Returns: pointer to a node which has no children // Precondition: __x != nullptr. template _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT { while (true) { if (__x->__left_ != nullptr) { __x = __x->__left_; continue; } if (__x->__right_ != nullptr) { __x = __x->__right_; continue; } break; } return __x; } // Effects: Makes __x->__right_ the subtree root with __x as its left child // while preserving in-order order. // Precondition: __x->__right_ != nullptr template void __tree_left_rotate(_NodePtr __x) _NOEXCEPT { _NodePtr __y = __x->__right_; __x->__right_ = __y->__left_; if (__x->__right_ != nullptr) __x->__right_->__parent_ = __x; __y->__parent_ = __x->__parent_; if (__tree_is_left_child(__x)) __x->__parent_->__left_ = __y; else __x->__parent_->__right_ = __y; __y->__left_ = __x; __x->__parent_ = __y; } // Effects: Makes __x->__left_ the subtree root with __x as its right child // while preserving in-order order. // Precondition: __x->__left_ != nullptr template void __tree_right_rotate(_NodePtr __x) _NOEXCEPT { _NodePtr __y = __x->__left_; __x->__left_ = __y->__right_; if (__x->__left_ != nullptr) __x->__left_->__parent_ = __x; __y->__parent_ = __x->__parent_; if (__tree_is_left_child(__x)) __x->__parent_->__left_ = __y; else __x->__parent_->__right_ = __y; __y->__right_ = __x; __x->__parent_ = __y; } // Effects: Rebalances __root after attaching __x to a leaf. // Precondition: __root != nulptr && __x != nullptr. // __x has no children. // __x == __root or == a direct or indirect child of __root. // If __x were to be unlinked from __root (setting __root to // nullptr if __root == __x), __tree_invariant(__root) == true. // Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_ // may be different than the value passed in as __root. template void __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT { __x->__is_black_ = __x == __root; while (__x != __root && !__x->__parent_->__is_black_) { // __x->__parent_ != __root because __x->__parent_->__is_black == false if (__tree_is_left_child(__x->__parent_)) { _NodePtr __y = __x->__parent_->__parent_->__right_; if (__y != nullptr && !__y->__is_black_) { __x = __x->__parent_; __x->__is_black_ = true; __x = __x->__parent_; __x->__is_black_ = __x == __root; __y->__is_black_ = true; } else { if (!__tree_is_left_child(__x)) { __x = __x->__parent_; __tree_left_rotate(__x); } __x = __x->__parent_; __x->__is_black_ = true; __x = __x->__parent_; __x->__is_black_ = false; __tree_right_rotate(__x); break; } } else { _NodePtr __y = __x->__parent_->__parent_->__left_; if (__y != nullptr && !__y->__is_black_) { __x = __x->__parent_; __x->__is_black_ = true; __x = __x->__parent_; __x->__is_black_ = __x == __root; __y->__is_black_ = true; } else { if (__tree_is_left_child(__x)) { __x = __x->__parent_; __tree_right_rotate(__x); } __x = __x->__parent_; __x->__is_black_ = true; __x = __x->__parent_; __x->__is_black_ = false; __tree_left_rotate(__x); break; } } } } // Precondition: __root != nullptr && __z != nullptr. // __tree_invariant(__root) == true. // __z == __root or == a direct or indirect child of __root. // Effects: unlinks __z from the tree rooted at __root, rebalancing as needed. // Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_ // nor any of its children refer to __z. end_node->__left_ // may be different than the value passed in as __root. template void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT { // __z will be removed from the tree. Client still needs to destruct/deallocate it // __y is either __z, or if __z has two children, __tree_next(__z). // __y will have at most one child. // __y will be the initial hole in the tree (make the hole at a leaf) _NodePtr __y = (__z->__left_ == nullptr || __z->__right_ == nullptr) ? __z : __tree_next(__z); // __x is __y's possibly null single child _NodePtr __x = __y->__left_ != nullptr ? __y->__left_ : __y->__right_; // __w is __x's possibly null uncle (will become __x's sibling) _NodePtr __w = nullptr; // link __x to __y's parent, and find __w if (__x != nullptr) __x->__parent_ = __y->__parent_; if (__tree_is_left_child(__y)) { __y->__parent_->__left_ = __x; if (__y != __root) __w = __y->__parent_->__right_; else __root = __x; // __w == nullptr } else { __y->__parent_->__right_ = __x; // __y can't be root if it is a right child __w = __y->__parent_->__left_; } bool __removed_black = __y->__is_black_; // If we didn't remove __z, do so now by splicing in __y for __z, // but copy __z's color. This does not impact __x or __w. if (__y != __z) { // __z->__left_ != nulptr but __z->__right_ might == __x == nullptr __y->__parent_ = __z->__parent_; if (__tree_is_left_child(__z)) __y->__parent_->__left_ = __y; else __y->__parent_->__right_ = __y; __y->__left_ = __z->__left_; __y->__left_->__parent_ = __y; __y->__right_ = __z->__right_; if (__y->__right_ != nullptr) __y->__right_->__parent_ = __y; __y->__is_black_ = __z->__is_black_; if (__root == __z) __root = __y; } // There is no need to rebalance if we removed a red, or if we removed // the last node. if (__removed_black && __root != nullptr) { // Rebalance: // __x has an implicit black color (transferred from the removed __y) // associated with it, no matter what its color is. // If __x is __root (in which case it can't be null), it is supposed // to be black anyway, and if it is doubly black, then the double // can just be ignored. // If __x is red (in which case it can't be null), then it can absorb // the implicit black just by setting its color to black. // Since __y was black and only had one child (which __x points to), __x // is either red with no children, else null, otherwise __y would have // different black heights under left and right pointers. // if (__x == __root || __x != nullptr && !__x->__is_black_) if (__x != nullptr) __x->__is_black_ = true; else { // Else __x isn't root, and is "doubly black", even though it may // be null. __w can not be null here, else the parent would // see a black height >= 2 on the __x side and a black height // of 1 on the __w side (__w must be a non-null black or a red // with a non-null black child). while (true) { if (!__tree_is_left_child(__w)) // if x is left child { if (!__w->__is_black_) { __w->__is_black_ = true; __w->__parent_->__is_black_ = false; __tree_left_rotate(__w->__parent_); // __x is still valid // reset __root only if necessary if (__root == __w->__left_) __root = __w; // reset sibling, and it still can't be null __w = __w->__left_->__right_; } // __w->__is_black_ is now true, __w may have null children if ((__w->__left_ == nullptr || __w->__left_->__is_black_) && (__w->__right_ == nullptr || __w->__right_->__is_black_)) { __w->__is_black_ = false; __x = __w->__parent_; // __x can no longer be null if (__x == __root || !__x->__is_black_) { __x->__is_black_ = true; break; } // reset sibling, and it still can't be null __w = __tree_is_left_child(__x) ? __x->__parent_->__right_ : __x->__parent_->__left_; // continue; } else // __w has a red child { if (__w->__right_ == nullptr || __w->__right_->__is_black_) { // __w left child is non-null and red __w->__left_->__is_black_ = true; __w->__is_black_ = false; __tree_right_rotate(__w); // __w is known not to be root, so root hasn't changed // reset sibling, and it still can't be null __w = __w->__parent_; } // __w has a right red child, left child may be null __w->__is_black_ = __w->__parent_->__is_black_; __w->__parent_->__is_black_ = true; __w->__right_->__is_black_ = true; __tree_left_rotate(__w->__parent_); break; } } else { if (!__w->__is_black_) { __w->__is_black_ = true; __w->__parent_->__is_black_ = false; __tree_right_rotate(__w->__parent_); // __x is still valid // reset __root only if necessary if (__root == __w->__right_) __root = __w; // reset sibling, and it still can't be null __w = __w->__right_->__left_; } // __w->__is_black_ is now true, __w may have null children if ((__w->__left_ == nullptr || __w->__left_->__is_black_) && (__w->__right_ == nullptr || __w->__right_->__is_black_)) { __w->__is_black_ = false; __x = __w->__parent_; // __x can no longer be null if (!__x->__is_black_ || __x == __root) { __x->__is_black_ = true; break; } // reset sibling, and it still can't be null __w = __tree_is_left_child(__x) ? __x->__parent_->__right_ : __x->__parent_->__left_; // continue; } else // __w has a red child { if (__w->__left_ == nullptr || __w->__left_->__is_black_) { // __w right child is non-null and red __w->__right_->__is_black_ = true; __w->__is_black_ = false; __tree_left_rotate(__w); // __w is known not to be root, so root hasn't changed // reset sibling, and it still can't be null __w = __w->__parent_; } // __w has a left red child, right child may be null __w->__is_black_ = __w->__parent_->__is_black_; __w->__parent_->__is_black_ = true; __w->__left_->__is_black_ = true; __tree_right_rotate(__w->__parent_); break; } } } } } } template class __map_node_destructor; template class __tree_node_destructor { typedef _Allocator allocator_type; typedef allocator_traits __alloc_traits; typedef typename __alloc_traits::value_type::value_type value_type; public: typedef typename __alloc_traits::pointer pointer; private: allocator_type& __na_; __tree_node_destructor& operator=(const __tree_node_destructor&); public: bool __value_constructed; _LIBCPP_INLINE_VISIBILITY explicit __tree_node_destructor(allocator_type& __na) _NOEXCEPT : __na_(__na), __value_constructed(false) {} _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { if (__value_constructed) __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_)); if (__p) __alloc_traits::deallocate(__na_, __p, 1); } template friend class __map_node_destructor; }; // node template class __tree_end_node { public: typedef _Pointer pointer; pointer __left_; _LIBCPP_INLINE_VISIBILITY __tree_end_node() _NOEXCEPT : __left_() {} }; template class __tree_node_base : public __tree_end_node < typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__tree_node_base<_VoidPtr> > #else rebind<__tree_node_base<_VoidPtr> >::other #endif > { __tree_node_base(const __tree_node_base&); __tree_node_base& operator=(const __tree_node_base&); public: typedef typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__tree_node_base> #else rebind<__tree_node_base>::other #endif pointer; typedef typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif const_pointer; typedef __tree_end_node base; pointer __right_; pointer __parent_; bool __is_black_; _LIBCPP_INLINE_VISIBILITY __tree_node_base() _NOEXCEPT : __right_(), __parent_(), __is_black_(false) {} }; template class __tree_node : public __tree_node_base<_VoidPtr> { public: typedef __tree_node_base<_VoidPtr> base; typedef _Tp value_type; value_type __value_; #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) template _LIBCPP_INLINE_VISIBILITY explicit __tree_node(_Args&& ...__args) : __value_(_VSTD::forward<_Args>(__args)...) {} #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) _LIBCPP_INLINE_VISIBILITY explicit __tree_node(const value_type& __v) : __value_(__v) {} #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) }; template class _LIBCPP_TYPE_VIS_ONLY __map_iterator; template class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; template 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_; typedef pointer_traits<__node_pointer> __pointer_traits; public: typedef bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef _DiffType difference_type; typedef value_type& reference; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 : __ptr_(nullptr) #endif {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {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;} _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;} _LIBCPP_INLINE_VISIBILITY __tree_iterator operator--(int) {__tree_iterator __t(*this); --(*this); return __t;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __tree_iterator& __x, const __tree_iterator& __y) {return __x.__ptr_ == __y.__ptr_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y) {return !(__x == __y);} private: _LIBCPP_INLINE_VISIBILITY explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template friend class __tree; template friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; template friend class _LIBCPP_TYPE_VIS_ONLY __map_iterator; template friend class _LIBCPP_TYPE_VIS_ONLY map; template friend class _LIBCPP_TYPE_VIS_ONLY multimap; template friend class _LIBCPP_TYPE_VIS_ONLY set; template friend class _LIBCPP_TYPE_VIS_ONLY multiset; }; template 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_; typedef pointer_traits<__node_pointer> __pointer_traits; public: typedef bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef _DiffType difference_type; typedef const value_type& reference; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind #else rebind::other #endif pointer; _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 : __ptr_(nullptr) #endif {} private: typedef typename remove_const<__node>::type __non_const_node; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__non_const_node> #else rebind<__non_const_node>::other #endif __non_const_node_pointer; typedef __tree_iterator __non_const_iterator; public: _LIBCPP_INLINE_VISIBILITY __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {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;} _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;} _LIBCPP_INLINE_VISIBILITY __tree_const_iterator operator--(int) {__tree_const_iterator __t(*this); --(*this); return __t;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {return __x.__ptr_ == __y.__ptr_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {return !(__x == __y);} private: _LIBCPP_INLINE_VISIBILITY explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template friend class __tree; template friend class _LIBCPP_TYPE_VIS_ONLY map; template friend class _LIBCPP_TYPE_VIS_ONLY multimap; template friend class _LIBCPP_TYPE_VIS_ONLY set; template friend class _LIBCPP_TYPE_VIS_ONLY multiset; template friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; }; template class __tree { public: typedef _Tp value_type; typedef _Compare value_compare; typedef _Allocator allocator_type; typedef allocator_traits __alloc_traits; typedef typename __alloc_traits::pointer pointer; 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 typename __alloc_traits::void_pointer __void_pointer; 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 allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; typedef typename __node_traits::pointer __node_const_pointer; typedef typename __node_base::pointer __node_base_pointer; typedef typename __node_base::pointer __node_base_const_pointer; private: typedef typename __node_base::base __end_node_t; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__end_node_t> #else rebind<__end_node_t>::other #endif __end_node_ptr; typedef typename pointer_traits<__node_pointer>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES rebind<__end_node_t> #else rebind<__end_node_t>::other #endif __end_node_const_ptr; __node_pointer __begin_node_; __compressed_pair<__end_node_t, __node_allocator> __pair1_; __compressed_pair __pair3_; public: _LIBCPP_INLINE_VISIBILITY __node_pointer __end_node() _NOEXCEPT { return static_cast<__node_pointer> ( pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first()) ); } _LIBCPP_INLINE_VISIBILITY __node_const_pointer __end_node() const _NOEXCEPT { return static_cast<__node_const_pointer> ( pointer_traits<__end_node_const_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first())) ); } _LIBCPP_INLINE_VISIBILITY __node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();} private: _LIBCPP_INLINE_VISIBILITY const __node_allocator& __node_alloc() const _NOEXCEPT {return __pair1_.second();} _LIBCPP_INLINE_VISIBILITY __node_pointer& __begin_node() _NOEXCEPT {return __begin_node_;} _LIBCPP_INLINE_VISIBILITY const __node_pointer& __begin_node() const _NOEXCEPT {return __begin_node_;} public: _LIBCPP_INLINE_VISIBILITY allocator_type __alloc() const _NOEXCEPT {return allocator_type(__node_alloc());} private: _LIBCPP_INLINE_VISIBILITY size_type& size() _NOEXCEPT {return __pair3_.first();} public: _LIBCPP_INLINE_VISIBILITY const size_type& size() const _NOEXCEPT {return __pair3_.first();} _LIBCPP_INLINE_VISIBILITY value_compare& value_comp() _NOEXCEPT {return __pair3_.second();} _LIBCPP_INLINE_VISIBILITY const value_compare& value_comp() const _NOEXCEPT {return __pair3_.second();} public: _LIBCPP_INLINE_VISIBILITY __node_pointer __root() _NOEXCEPT {return static_cast<__node_pointer> (__end_node()->__left_);} _LIBCPP_INLINE_VISIBILITY __node_const_pointer __root() const _NOEXCEPT {return static_cast<__node_const_pointer>(__end_node()->__left_);} typedef __tree_iterator iterator; typedef __tree_const_iterator const_iterator; explicit __tree(const value_compare& __comp) _NOEXCEPT_( is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_copy_constructible::value); explicit __tree(const allocator_type& __a); __tree(const value_compare& __comp, const allocator_type& __a); __tree(const __tree& __t); __tree& operator=(const __tree& __t); template void __assign_unique(_InputIterator __first, _InputIterator __last); template void __assign_multi(_InputIterator __first, _InputIterator __last); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __tree(__tree&& __t) _NOEXCEPT_( is_nothrow_move_constructible<__node_allocator>::value && is_nothrow_move_constructible::value); __tree(__tree&& __t, const allocator_type& __a); __tree& operator=(__tree&& __t) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value && is_nothrow_move_assignable<__node_allocator>::value); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~__tree(); _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(__begin_node());} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return const_iterator(__begin_node());} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return iterator(__end_node());} _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(__end_node());} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {return __node_traits::max_size(__node_alloc());} void clear() _NOEXCEPT; void swap(__tree& __t) _NOEXCEPT_( __is_nothrow_swappable::value && (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value)); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template pair __emplace_unique(_Args&&... __args); template iterator __emplace_multi(_Args&&... __args); template iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args); template iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS template pair __insert_unique(_Vp&& __v); template iterator __insert_unique(const_iterator __p, _Vp&& __v); template iterator __insert_multi(_Vp&& __v); template iterator __insert_multi(const_iterator __p, _Vp&& __v); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES pair __insert_unique(const value_type& __v); iterator __insert_unique(const_iterator __p, const value_type& __v); iterator __insert_multi(const value_type& __v); iterator __insert_multi(const_iterator __p, const value_type& __v); pair __node_insert_unique(__node_pointer __nd); iterator __node_insert_unique(const_iterator __p, __node_pointer __nd); iterator __node_insert_multi(__node_pointer __nd); iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); iterator erase(const_iterator __p); iterator erase(const_iterator __f, const_iterator __l); template size_type __erase_unique(const _Key& __k); template size_type __erase_multi(const _Key& __k); void __insert_node_at(__node_base_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node); template iterator find(const _Key& __v); template const_iterator find(const _Key& __v) const; template size_type __count_unique(const _Key& __k) const; template size_type __count_multi(const _Key& __k) const; template _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const _Key& __v) {return __lower_bound(__v, __root(), __end_node());} template iterator __lower_bound(const _Key& __v, __node_pointer __root, __node_pointer __result); template _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const _Key& __v) const {return __lower_bound(__v, __root(), __end_node());} template const_iterator __lower_bound(const _Key& __v, __node_const_pointer __root, __node_const_pointer __result) const; template _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const _Key& __v) {return __upper_bound(__v, __root(), __end_node());} template iterator __upper_bound(const _Key& __v, __node_pointer __root, __node_pointer __result); template _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const _Key& __v) const {return __upper_bound(__v, __root(), __end_node());} template const_iterator __upper_bound(const _Key& __v, __node_const_pointer __root, __node_const_pointer __result) const; template pair __equal_range_unique(const _Key& __k); template pair __equal_range_unique(const _Key& __k) const; template pair __equal_range_multi(const _Key& __k); template pair __equal_range_multi(const _Key& __k) const; typedef __tree_node_destructor<__node_allocator> _Dp; typedef unique_ptr<__node, _Dp> __node_holder; __node_holder remove(const_iterator __p) _NOEXCEPT; private: typename __node_base::pointer& __find_leaf_low(typename __node_base::pointer& __parent, const value_type& __v); typename __node_base::pointer& __find_leaf_high(typename __node_base::pointer& __parent, const value_type& __v); typename __node_base::pointer& __find_leaf(const_iterator __hint, typename __node_base::pointer& __parent, const value_type& __v); template typename __node_base::pointer& __find_equal(typename __node_base::pointer& __parent, const _Key& __v); template typename __node_base::pointer& __find_equal(const_iterator __hint, typename __node_base::pointer& __parent, const _Key& __v); #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) template __node_holder __construct_node(_Args&& ...__args); #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) __node_holder __construct_node(const value_type& __v); #endif void destroy(__node_pointer __nd) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __tree& __t) {__copy_assign_alloc(__t, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __tree& __t, true_type) {__node_alloc() = __t.__node_alloc();} _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __tree& __t, false_type) {} void __move_assign(__tree& __t, false_type); void __move_assign(__tree& __t, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value && is_nothrow_move_assignable<__node_allocator>::value); _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__tree& __t) _NOEXCEPT_( !__node_traits::propagate_on_container_move_assignment::value || is_nothrow_move_assignable<__node_allocator>::value) {__move_assign_alloc(__t, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__tree& __t, true_type) _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {__node_alloc() = _VSTD::move(__t.__node_alloc());} _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); template friend class _LIBCPP_TYPE_VIS_ONLY map; template friend class _LIBCPP_TYPE_VIS_ONLY multimap; }; template __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_( is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_copy_constructible::value) : __pair3_(0, __comp) { __begin_node() = __end_node(); } template __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) : __pair1_(__node_allocator(__a)), __begin_node_(__node_pointer()), __pair3_(0) { __begin_node() = __end_node(); } template __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) : __pair1_(__node_allocator(__a)), __begin_node_(__node_pointer()), __pair3_(0, __comp) { __begin_node() = __end_node(); } // Precondition: size() != 0 template typename __tree<_Tp, _Compare, _Allocator>::__node_pointer __tree<_Tp, _Compare, _Allocator>::__detach() { __node_pointer __cache = __begin_node(); __begin_node() = __end_node(); __end_node()->__left_->__parent_ = nullptr; __end_node()->__left_ = nullptr; size() = 0; // __cache->__left_ == nullptr if (__cache->__right_ != nullptr) __cache = static_cast<__node_pointer>(__cache->__right_); // __cache->__left_ == nullptr // __cache->__right_ == nullptr return __cache; } // Precondition: __cache != nullptr // __cache->left_ == nullptr // __cache->right_ == nullptr // This is no longer a red-black tree template typename __tree<_Tp, _Compare, _Allocator>::__node_pointer __tree<_Tp, _Compare, _Allocator>::__detach(__node_pointer __cache) { if (__cache->__parent_ == nullptr) return nullptr; if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache))) { __cache->__parent_->__left_ = nullptr; __cache = static_cast<__node_pointer>(__cache->__parent_); if (__cache->__right_ == nullptr) return __cache; return static_cast<__node_pointer>(__tree_leaf(__cache->__right_)); } // __cache is right child __cache->__parent_->__right_ = nullptr; __cache = static_cast<__node_pointer>(__cache->__parent_); if (__cache->__left_ == nullptr) return __cache; return static_cast<__node_pointer>(__tree_leaf(__cache->__left_)); } template __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) { if (this != &__t) { value_comp() = __t.value_comp(); __copy_assign_alloc(__t); __assign_multi(__t.begin(), __t.end()); } return *this; } template template void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _InputIterator __last) { if (size() != 0) { __node_pointer __cache = __detach(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__value_ = *__first; __node_pointer __next = __detach(__cache); __node_insert_unique(__cache); __cache = __next; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { while (__cache->__parent_ != nullptr) __cache = static_cast<__node_pointer>(__cache->__parent_); destroy(__cache); throw; } #endif // _LIBCPP_NO_EXCEPTIONS if (__cache != nullptr) { while (__cache->__parent_ != nullptr) __cache = static_cast<__node_pointer>(__cache->__parent_); destroy(__cache); } } for (; __first != __last; ++__first) __insert_unique(*__first); } template template void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) { if (size() != 0) { __node_pointer __cache = __detach(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__value_ = *__first; __node_pointer __next = __detach(__cache); __node_insert_multi(__cache); __cache = __next; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { while (__cache->__parent_ != nullptr) __cache = static_cast<__node_pointer>(__cache->__parent_); destroy(__cache); throw; } #endif // _LIBCPP_NO_EXCEPTIONS if (__cache != nullptr) { while (__cache->__parent_ != nullptr) __cache = static_cast<__node_pointer>(__cache->__parent_); destroy(__cache); } } for (; __first != __last; ++__first) __insert_multi(*__first); } template __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) : __begin_node_(__node_pointer()), __pair1_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), __pair3_(0, __t.value_comp()) { __begin_node() = __end_node(); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( is_nothrow_move_constructible<__node_allocator>::value && is_nothrow_move_constructible::value) : __begin_node_(_VSTD::move(__t.__begin_node_)), __pair1_(_VSTD::move(__t.__pair1_)), __pair3_(_VSTD::move(__t.__pair3_)) { if (size() == 0) __begin_node() = __end_node(); else { __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); __t.__begin_node() = __t.__end_node(); __t.__end_node()->__left_ = nullptr; __t.size() = 0; } } template __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) : __pair1_(__node_allocator(__a)), __pair3_(0, _VSTD::move(__t.value_comp())) { if (__a == __t.__alloc()) { if (__t.size() == 0) __begin_node() = __end_node(); else { __begin_node() = __t.__begin_node(); __end_node()->__left_ = __t.__end_node()->__left_; __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); size() = __t.size(); __t.__begin_node() = __t.__end_node(); __t.__end_node()->__left_ = nullptr; __t.size() = 0; } } else { __begin_node() = __end_node(); } } template void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value && is_nothrow_move_assignable<__node_allocator>::value) { destroy(static_cast<__node_pointer>(__end_node()->__left_)); __begin_node_ = __t.__begin_node_; __pair1_.first() = __t.__pair1_.first(); __move_assign_alloc(__t); __pair3_ = _VSTD::move(__t.__pair3_); if (size() == 0) __begin_node() = __end_node(); else { __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); __t.__begin_node() = __t.__end_node(); __t.__end_node()->__left_ = nullptr; __t.size() = 0; } } template void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) { if (__node_alloc() == __t.__node_alloc()) __move_assign(__t, true_type()); else { value_comp() = _VSTD::move(__t.value_comp()); const_iterator __e = end(); if (size() != 0) { __node_pointer __cache = __detach(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS while (__cache != nullptr && __t.size() != 0) { __cache->__value_ = _VSTD::move(__t.remove(__t.begin())->__value_); __node_pointer __next = __detach(__cache); __node_insert_multi(__cache); __cache = __next; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { while (__cache->__parent_ != nullptr) __cache = static_cast<__node_pointer>(__cache->__parent_); destroy(__cache); throw; } #endif // _LIBCPP_NO_EXCEPTIONS if (__cache != nullptr) { while (__cache->__parent_ != nullptr) __cache = static_cast<__node_pointer>(__cache->__parent_); destroy(__cache); } } while (__t.size() != 0) __insert_multi(__e, _VSTD::move(__t.remove(__t.begin())->__value_)); } } template __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value && is_nothrow_move_assignable<__node_allocator>::value) { __move_assign(__t, integral_constant()); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template __tree<_Tp, _Compare, _Allocator>::~__tree() { destroy(__root()); } template void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { if (__nd != nullptr) { destroy(static_cast<__node_pointer>(__nd->__left_)); destroy(static_cast<__node_pointer>(__nd->__right_)); __node_allocator& __na = __node_alloc(); __node_traits::destroy(__na, _VSTD::addressof(__nd->__value_)); __node_traits::deallocate(__na, __nd, 1); } } 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)) { using _VSTD::swap; swap(__begin_node_, __t.__begin_node_); swap(__pair1_.first(), __t.__pair1_.first()); __swap_alloc(__node_alloc(), __t.__node_alloc()); __pair3_.swap(__t.__pair3_); if (size() == 0) __begin_node() = __end_node(); else __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node()); if (__t.size() == 0) __t.__begin_node() = __t.__end_node(); else __t.__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__t.__end_node()); } template void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT { destroy(__root()); size() = 0; __begin_node() = __end_node(); __end_node()->__left_ = nullptr; } // Find lower_bound place to insert // Set __parent to parent of null leaf // Return reference to null leaf template typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer& __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(typename __node_base::pointer& __parent, const value_type& __v) { __node_pointer __nd = __root(); if (__nd != nullptr) { while (true) { if (value_comp()(__nd->__value_, __v)) { if (__nd->__right_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__right_); else { __parent = static_cast<__node_base_pointer>(__nd); return __parent->__right_; } } else { if (__nd->__left_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__left_); else { __parent = static_cast<__node_base_pointer>(__nd); return __parent->__left_; } } } } __parent = static_cast<__node_base_pointer>(__end_node()); return __parent->__left_; } // Find upper_bound place to insert // Set __parent to parent of null leaf // Return reference to null leaf template typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer& __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(typename __node_base::pointer& __parent, const value_type& __v) { __node_pointer __nd = __root(); if (__nd != nullptr) { while (true) { if (value_comp()(__v, __nd->__value_)) { if (__nd->__left_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__left_); else { __parent = static_cast<__node_base_pointer>(__nd); return __parent->__left_; } } else { if (__nd->__right_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__right_); else { __parent = static_cast<__node_base_pointer>(__nd); return __parent->__right_; } } } } __parent = static_cast<__node_base_pointer>(__end_node()); return __parent->__left_; } // Find leaf place to insert closest to __hint // First check prior to __hint. // Next check after __hint. // Next do O(log N) search. // Set __parent to parent of null leaf // Return reference to null leaf template typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer& __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, typename __node_base::pointer& __parent, const value_type& __v) { if (__hint == end() || !value_comp()(*__hint, __v)) // check before { // __v <= *__hint const_iterator __prior = __hint; if (__prior == begin() || !value_comp()(__v, *--__prior)) { // *prev(__hint) <= __v <= *__hint if (__hint.__ptr_->__left_ == nullptr) { __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent->__left_; } else { __parent = static_cast<__node_base_pointer>(__prior.__ptr_); return __parent->__right_; } } // __v < *prev(__hint) return __find_leaf_high(__parent, __v); } // else __v > *__hint return __find_leaf_low(__parent, __v); } // Find place to insert if __v doesn't exist // Set __parent to parent of null leaf // Return reference to null leaf // If __v exists, set parent to node of __v and return reference to node of __v template template typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal(typename __node_base::pointer& __parent, const _Key& __v) { __node_pointer __nd = __root(); if (__nd != nullptr) { while (true) { if (value_comp()(__v, __nd->__value_)) { if (__nd->__left_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__left_); else { __parent = static_cast<__node_base_pointer>(__nd); return __parent->__left_; } } else if (value_comp()(__nd->__value_, __v)) { if (__nd->__right_ != nullptr) __nd = static_cast<__node_pointer>(__nd->__right_); else { __parent = static_cast<__node_base_pointer>(__nd); return __parent->__right_; } } else { __parent = static_cast<__node_base_pointer>(__nd); return __parent; } } } __parent = static_cast<__node_base_pointer>(__end_node()); return __parent->__left_; } // Find place to insert if __v doesn't exist // First check prior to __hint. // Next check after __hint. // Next do O(log N) search. // Set __parent to parent of null leaf // Return reference to null leaf // If __v exists, set parent to node of __v and return reference to node of __v template template typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, typename __node_base::pointer& __parent, const _Key& __v) { if (__hint == end() || value_comp()(__v, *__hint)) // check before { // __v < *__hint const_iterator __prior = __hint; if (__prior == begin() || value_comp()(*--__prior, __v)) { // *prev(__hint) < __v < *__hint if (__hint.__ptr_->__left_ == nullptr) { __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent->__left_; } else { __parent = static_cast<__node_base_pointer>(__prior.__ptr_); return __parent->__right_; } } // __v <= *prev(__hint) return __find_equal(__parent, __v); } else if (value_comp()(*__hint, __v)) // check after { // *__hint < __v const_iterator __next = _VSTD::next(__hint); if (__next == end() || value_comp()(__v, *__next)) { // *__hint < __v < *_VSTD::next(__hint) if (__hint.__ptr_->__right_ == nullptr) { __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent->__right_; } else { __parent = static_cast<__node_base_pointer>(__next.__ptr_); return __parent->__left_; } } // *next(__hint) <= __v return __find_equal(__parent, __v); } // else __v == *__hint __parent = static_cast<__node_base_pointer>(__hint.__ptr_); return __parent; } template void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(__node_base_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) { __new_node->__left_ = nullptr; __new_node->__right_ = nullptr; __new_node->__parent_ = __parent; __child = __new_node; if (__begin_node()->__left_ != nullptr) __begin_node() = static_cast<__node_pointer>(__begin_node()->__left_); __tree_balance_after_insert(__end_node()->__left_, __child); ++size(); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template template typename __tree<_Tp, _Compare, _Allocator>::__node_holder __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&& ...__args) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_Args>(__args)...); __h.get_deleter().__value_constructed = true; return __h; } template template pair::iterator, bool> __tree<_Tp, _Compare, _Allocator>::__emplace_unique(_Args&&... __args) { __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); __node_base_pointer __parent; __node_base_pointer& __child = __find_equal(__parent, __h->__value_); __node_pointer __r = static_cast<__node_pointer>(__child); bool __inserted = false; if (__child == nullptr) { __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); __inserted = true; } return pair(iterator(__r), __inserted); } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique(const_iterator __p, _Args&&... __args) { __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); __node_base_pointer __parent; __node_base_pointer& __child = __find_equal(__p, __parent, __h->__value_); __node_pointer __r = static_cast<__node_pointer>(__child); if (__child == nullptr) { __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); } return iterator(__r); } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(static_cast<__node_pointer>(__h.release())); } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) { __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(static_cast<__node_pointer>(__h.release())); } #endif // _LIBCPP_HAS_NO_VARIADICS template template pair::iterator, bool> __tree<_Tp, _Compare, _Allocator>::__insert_unique(_Vp&& __v) { __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v)); pair __r = __node_insert_unique(__h.get()); if (__r.second) __h.release(); return __r; } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, _Vp&& __v) { __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v)); iterator __r = __node_insert_unique(__p, __h.get()); if (__r.__ptr_ == __h.get()) __h.release(); return __r; } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__insert_multi(_Vp&& __v) { __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v)); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, _Vp&& __v) { __node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v)); __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename __tree<_Tp, _Compare, _Allocator>::__node_holder __tree<_Tp, _Compare, _Allocator>::__construct_node(const value_type& __v) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v); __h.get_deleter().__value_constructed = true; return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template pair::iterator, bool> __tree<_Tp, _Compare, _Allocator>::__insert_unique(const value_type& __v) { __node_base_pointer __parent; __node_base_pointer& __child = __find_equal(__parent, __v); __node_pointer __r = static_cast<__node_pointer>(__child); bool __inserted = false; if (__child == nullptr) { __node_holder __h = __construct_node(__v); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); __inserted = true; } return pair(iterator(__r), __inserted); } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, const value_type& __v) { __node_base_pointer __parent; __node_base_pointer& __child = __find_equal(__p, __parent, __v); __node_pointer __r = static_cast<__node_pointer>(__child); if (__child == nullptr) { __node_holder __h = __construct_node(__v); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); } return iterator(__r); } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__insert_multi(const value_type& __v) { __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __v); __node_holder __h = __construct_node(__v); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const value_type& __v) { __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __v); __node_holder __h = __construct_node(__v); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); return iterator(__h.release()); } template pair::iterator, bool> __tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd) { __node_base_pointer __parent; __node_base_pointer& __child = __find_equal(__parent, __nd->__value_); __node_pointer __r = static_cast<__node_pointer>(__child); bool __inserted = false; if (__child == nullptr) { __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); __r = __nd; __inserted = true; } return pair(iterator(__r), __inserted); } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__node_insert_unique(const_iterator __p, __node_pointer __nd) { __node_base_pointer __parent; __node_base_pointer& __child = __find_equal(__p, __parent, __nd->__value_); __node_pointer __r = static_cast<__node_pointer>(__child); if (__child == nullptr) { __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); __r = __nd; } return iterator(__r); } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__value_); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); return iterator(__nd); } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) { __node_base_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__value_); __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); return iterator(__nd); } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) { __node_pointer __np = __p.__ptr_; iterator __r(__np); ++__r; if (__begin_node() == __np) __begin_node() = __r.__ptr_; --size(); __node_allocator& __na = __node_alloc(); __node_traits::destroy(__na, const_cast(_VSTD::addressof(*__p))); __tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); __node_traits::deallocate(__na, __np, 1); return __r; } template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) { while (__f != __l) __f = erase(__f); return iterator(__l.__ptr_); } template template typename __tree<_Tp, _Compare, _Allocator>::size_type __tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) { iterator __i = find(__k); if (__i == end()) return 0; erase(__i); return 1; } template template typename __tree<_Tp, _Compare, _Allocator>::size_type __tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) { pair __p = __equal_range_multi(__k); size_type __r = 0; for (; __p.first != __p.second; ++__r) __p.first = erase(__p.first); return __r; } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) { iterator __p = __lower_bound(__v, __root(), __end_node()); if (__p != end() && !value_comp()(__v, *__p)) return __p; return end(); } template template typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const { const_iterator __p = __lower_bound(__v, __root(), __end_node()); if (__p != end() && !value_comp()(__v, *__p)) return __p; return end(); } template template typename __tree<_Tp, _Compare, _Allocator>::size_type __tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const { __node_const_pointer __result = __end_node(); __node_const_pointer __rt = __root(); while (__rt != nullptr) { if (value_comp()(__k, __rt->__value_)) { __result = __rt; __rt = static_cast<__node_const_pointer>(__rt->__left_); } else if (value_comp()(__rt->__value_, __k)) __rt = static_cast<__node_const_pointer>(__rt->__right_); else return 1; } return 0; } template 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) { if (value_comp()(__k, __rt->__value_)) { __result = __rt; __rt = static_cast<__node_const_pointer>(__rt->__left_); } else if (value_comp()(__rt->__value_, __k)) __rt = static_cast<__node_const_pointer>(__rt->__right_); else return _VSTD::distance( __lower_bound(__k, static_cast<__node_const_pointer>(__rt->__left_), __rt), __upper_bound(__k, static_cast<__node_const_pointer>(__rt->__right_), __result) ); } return 0; } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer __root, __node_pointer __result) { while (__root != nullptr) { if (!value_comp()(__root->__value_, __v)) { __result = __root; __root = static_cast<__node_pointer>(__root->__left_); } else __root = static_cast<__node_pointer>(__root->__right_); } return iterator(__result); } template template typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_const_pointer __root, __node_const_pointer __result) const { while (__root != nullptr) { if (!value_comp()(__root->__value_, __v)) { __result = __root; __root = static_cast<__node_const_pointer>(__root->__left_); } else __root = static_cast<__node_const_pointer>(__root->__right_); } return const_iterator(__result); } template template typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer __root, __node_pointer __result) { while (__root != nullptr) { if (value_comp()(__v, __root->__value_)) { __result = __root; __root = static_cast<__node_pointer>(__root->__left_); } else __root = static_cast<__node_pointer>(__root->__right_); } return iterator(__result); } template template typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_const_pointer __root, __node_const_pointer __result) const { while (__root != nullptr) { if (value_comp()(__v, __root->__value_)) { __result = __root; __root = static_cast<__node_const_pointer>(__root->__left_); } else __root = static_cast<__node_const_pointer>(__root->__right_); } return const_iterator(__result); } template template pair::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) { typedef pair _Pp; __node_pointer __result = __end_node(); __node_pointer __rt = __root(); while (__rt != nullptr) { if (value_comp()(__k, __rt->__value_)) { __result = __rt; __rt = static_cast<__node_pointer>(__rt->__left_); } else if (value_comp()(__rt->__value_, __k)) __rt = static_cast<__node_pointer>(__rt->__right_); else return _Pp(iterator(__rt), iterator( __rt->__right_ != nullptr ? static_cast<__node_pointer>(__tree_min(__rt->__right_)) : __result)); } return _Pp(iterator(__result), iterator(__result)); } template template pair::const_iterator, typename __tree<_Tp, _Compare, _Allocator>::const_iterator> __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const { typedef pair _Pp; __node_const_pointer __result = __end_node(); __node_const_pointer __rt = __root(); while (__rt != nullptr) { if (value_comp()(__k, __rt->__value_)) { __result = __rt; __rt = static_cast<__node_const_pointer>(__rt->__left_); } else if (value_comp()(__rt->__value_, __k)) __rt = static_cast<__node_const_pointer>(__rt->__right_); else return _Pp(const_iterator(__rt), const_iterator( __rt->__right_ != nullptr ? static_cast<__node_const_pointer>(__tree_min(__rt->__right_)) : __result)); } return _Pp(const_iterator(__result), const_iterator(__result)); } template template pair::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) { typedef pair _Pp; __node_pointer __result = __end_node(); __node_pointer __rt = __root(); while (__rt != nullptr) { if (value_comp()(__k, __rt->__value_)) { __result = __rt; __rt = static_cast<__node_pointer>(__rt->__left_); } else if (value_comp()(__rt->__value_, __k)) __rt = static_cast<__node_pointer>(__rt->__right_); else return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), __rt), __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); } return _Pp(iterator(__result), iterator(__result)); } template template pair::const_iterator, typename __tree<_Tp, _Compare, _Allocator>::const_iterator> __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const { typedef pair _Pp; __node_const_pointer __result = __end_node(); __node_const_pointer __rt = __root(); while (__rt != nullptr) { if (value_comp()(__k, __rt->__value_)) { __result = __rt; __rt = static_cast<__node_const_pointer>(__rt->__left_); } else if (value_comp()(__rt->__value_, __k)) __rt = static_cast<__node_const_pointer>(__rt->__right_); else return _Pp(__lower_bound(__k, static_cast<__node_const_pointer>(__rt->__left_), __rt), __upper_bound(__k, static_cast<__node_const_pointer>(__rt->__right_), __result)); } return _Pp(const_iterator(__result), const_iterator(__result)); } template typename __tree<_Tp, _Compare, _Allocator>::__node_holder __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT { __node_pointer __np = __p.__ptr_; if (__begin_node() == __np) { if (__np->__right_ != nullptr) __begin_node() = static_cast<__node_pointer>(__np->__right_); else __begin_node() = static_cast<__node_pointer>(__np->__parent_); } --size(); __tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); return __node_holder(__np, _Dp(__node_alloc())); } template inline _LIBCPP_INLINE_VISIBILITY void swap(__tree<_Tp, _Compare, _Allocator>& __x, __tree<_Tp, _Compare, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TREE libcxx/include/vector0000644000175000017500000032015012266757731016122 0ustar sylvestresylvestre// -*- C++ -*- //===------------------------------ vector --------------------------------===// // // The 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_VECTOR #define _LIBCPP_VECTOR /* vector synopsis namespace std { 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; vector() noexcept(is_nothrow_default_constructible::value); explicit vector(const allocator_type&); explicit vector(size_type n); explicit vector(size_type n, const allocator_type&); // C++14 vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); vector(const vector& x); vector(vector&& x) noexcept(is_nothrow_move_constructible::value); vector(initializer_list il); vector(initializer_list il, const allocator_type& a); ~vector(); vector& operator=(const vector& x); vector& operator=(vector&& x) noexcept( allocator_type::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); vector& operator=(initializer_list il); template void assign(InputIterator first, InputIterator last); void assign(size_type n, const value_type& u); void assign(initializer_list il); allocator_type get_allocator() const noexcept; iterator begin() noexcept; const_iterator begin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; const_reverse_iterator crbegin() const noexcept; const_reverse_iterator crend() const noexcept; size_type size() const noexcept; size_type max_size() const noexcept; size_type capacity() const noexcept; bool empty() const noexcept; void reserve(size_type n); void shrink_to_fit() noexcept; reference operator[](size_type n); const_reference operator[](size_type n) const; reference at(size_type n); const_reference at(size_type n) const; reference front(); const_reference front() const; reference back(); const_reference back() const; value_type* data() noexcept; const value_type* data() const noexcept; void push_back(const value_type& x); void push_back(value_type&& x); template void emplace_back(Args&&... args); void pop_back(); template iterator emplace(const_iterator position, Args&&... args); iterator insert(const_iterator position, const value_type& x); iterator insert(const_iterator position, value_type&& x); iterator insert(const_iterator position, size_type n, const value_type& x); template iterator insert(const_iterator position, InputIterator first, InputIterator last); iterator insert(const_iterator position, initializer_list il); iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; void resize(size_type sz); void resize(size_type sz, const value_type& c); void swap(vector&) noexcept(!allocator_type::propagate_on_container_swap::value || __is_nothrow_swappable::value); bool __invariants() const; }; template > class vector { public: typedef bool value_type; typedef Allocator allocator_type; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef typename allocator_type::size_type size_type; typedef typename allocator_type::difference_type difference_type; typedef iterator pointer; typedef const_iterator const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; class reference { public: reference(const reference&) noexcept; operator bool() const noexcept; reference& operator=(const bool x) noexcept; reference& operator=(const reference& x) noexcept; iterator operator&() const noexcept; void flip() noexcept; }; class const_reference { public: const_reference(const reference&) noexcept; operator bool() const noexcept; const_iterator operator&() const noexcept; }; vector() noexcept(is_nothrow_default_constructible::value); explicit vector(const allocator_type&); explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); vector(const vector& x); vector(vector&& x) noexcept(is_nothrow_move_constructible::value); vector(initializer_list il); vector(initializer_list il, const allocator_type& a); ~vector(); vector& operator=(const vector& x); vector& operator=(vector&& x) noexcept( allocator_type::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); vector& operator=(initializer_list il); template void assign(InputIterator first, InputIterator last); void assign(size_type n, const value_type& u); void assign(initializer_list il); allocator_type get_allocator() const noexcept; iterator begin() noexcept; const_iterator begin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; const_reverse_iterator crbegin() const noexcept; const_reverse_iterator crend() const noexcept; size_type size() const noexcept; size_type max_size() const noexcept; size_type capacity() const noexcept; bool empty() const noexcept; void reserve(size_type n); void shrink_to_fit() noexcept; reference operator[](size_type n); const_reference operator[](size_type n) const; reference at(size_type n); const_reference at(size_type n) const; reference front(); const_reference front() const; reference back(); const_reference back() const; void push_back(const value_type& x); template void emplace_back(Args&&... args); // C++14 void pop_back(); template iterator emplace(const_iterator position, Args&&... args); // C++14 iterator insert(const_iterator position, const value_type& x); iterator insert(const_iterator position, size_type n, const value_type& x); template iterator insert(const_iterator position, InputIterator first, InputIterator last); iterator insert(const_iterator position, initializer_list il); iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); void clear() noexcept; void resize(size_type sz); void resize(size_type sz, value_type x); void swap(vector&) noexcept(!allocator_type::propagate_on_container_swap::value || __is_nothrow_swappable::value); void flip() noexcept; bool __invariants() const; }; template struct hash>; template bool operator==(const vector& x, const vector& y); template bool operator< (const vector& x, const vector& y); template bool operator!=(const vector& x, const vector& y); template bool operator> (const vector& x, const vector& y); template bool operator>=(const vector& x, const vector& y); template bool operator<=(const vector& x, const vector& y); template void swap(vector& x, vector& y) noexcept(noexcept(x.swap(y))); } // std */ #include <__config> #include <__bit_reference> #include #include #include #include #include #include #include #include #include <__split_buffer> #include <__functional_base> #include <__undef_min_max> #ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template class __vector_base_common { protected: _LIBCPP_ALWAYS_INLINE __vector_base_common() {} void __throw_length_error() const; void __throw_out_of_range() const; }; template void __vector_base_common<__b>::__throw_length_error() const { #ifndef _LIBCPP_NO_EXCEPTIONS throw length_error("vector"); #else assert(!"vector length_error"); #endif } template void __vector_base_common<__b>::__throw_out_of_range() const { #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("vector"); #else assert(!"vector out_of_range"); #endif } #ifdef _LIBCPP_MSVC #pragma warning( push ) #pragma warning( disable: 4231 ) #endif // _LIBCPP_MSVC _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __vector_base_common) #ifdef _LIBCPP_MSVC #pragma warning( pop ) #endif // _LIBCPP_MSVC template class __vector_base : protected __vector_base_common { protected: typedef _Tp value_type; typedef _Allocator allocator_type; typedef allocator_traits __alloc_traits; typedef value_type& reference; typedef const value_type& const_reference; typedef typename __alloc_traits::size_type size_type; typedef typename __alloc_traits::difference_type difference_type; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; typedef pointer iterator; typedef const_pointer const_iterator; pointer __begin_; pointer __end_; __compressed_pair __end_cap_; _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT {return __end_cap_.second();} _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return __end_cap_.second();} _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} _LIBCPP_INLINE_VISIBILITY __vector_base() _NOEXCEPT_(is_nothrow_default_constructible::value); _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); ~__vector_base(); _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT {__destruct_at_end(__begin_);} _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT {return static_cast(__end_cap() - __begin_);} _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __vector_base& __c) {__copy_assign_alloc(__c, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__vector_base& __c) _NOEXCEPT_( !__alloc_traits::propagate_on_container_move_assignment::value || 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) { if (__alloc() != __c.__alloc()) { clear(); __alloc_traits::deallocate(__alloc(), __begin_, capacity()); __begin_ = __end_ = __end_cap() = nullptr; } __alloc() = __c.__alloc(); } _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __vector_base&, false_type) {} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__vector_base& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { __alloc() = _VSTD::move(__c.__alloc()); } _LIBCPP_INLINE_VISIBILITY 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 inline _LIBCPP_INLINE_VISIBILITY void __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { while (__new_last != __end_) __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_)); } template inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) { } template inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) : __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } template __vector_base<_Tp, _Allocator>::~__vector_base() { if (__begin_ != nullptr) { clear(); __alloc_traits::deallocate(__alloc(), __begin_, capacity()); } } template > class _LIBCPP_TYPE_VIS_ONLY vector : private __vector_base<_Tp, _Allocator> { private: typedef __vector_base<_Tp, _Allocator> __base; public: typedef vector __self; typedef _Tp value_type; typedef _Allocator allocator_type; typedef typename __base::__alloc_traits __alloc_traits; typedef typename __base::reference reference; typedef typename __base::const_reference const_reference; typedef typename __base::size_type size_type; typedef typename __base::difference_type difference_type; typedef typename __base::pointer pointer; typedef typename __base::const_pointer const_pointer; typedef __wrap_iter iterator; typedef __wrap_iter const_iterator; typedef _VSTD::reverse_iterator reverse_iterator; typedef _VSTD::reverse_iterator const_reverse_iterator; static_assert((is_same::value), "Allocator::value_type must be same type as value_type"); _LIBCPP_INLINE_VISIBILITY 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) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif } explicit vector(size_type __n); #if _LIBCPP_STD_VER > 11 explicit vector(size_type __n, const allocator_type& __a); #endif vector(size_type __n, const_reference __x); vector(size_type __n, const_reference __x, const allocator_type& __a); template vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, _InputIterator>::type __last); template vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); template vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value, _ForwardIterator>::type __last); template vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY vector(initializer_list __il); _LIBCPP_INLINE_VISIBILITY vector(initializer_list __il, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY ~vector() { __get_db()->__erase_c(this); } #endif vector(const vector& __x); vector(const vector& __x, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(const vector& __x); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY vector(vector&& __x) _NOEXCEPT_(is_nothrow_move_constructible::value); _LIBCPP_INLINE_VISIBILITY vector(vector&& __x, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __x) _NOEXCEPT_( __alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY vector& operator=(initializer_list __il) {assign(__il.begin(), __il.end()); return *this;} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template typename enable_if < __is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, void >::type assign(_InputIterator __first, _InputIterator __last); template typename enable_if < __is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value, void >::type assign(_ForwardIterator __first, _ForwardIterator __last); void assign(size_type __n, const_reference __u); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY void assign(initializer_list __il) {assign(__il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT {return this->__alloc();} _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT {return begin();} _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return end();} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT {return rend();} _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT {return static_cast(this->__end_ - this->__begin_);} _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT {return __base::capacity();} _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return this->__begin_ == this->__end_;} size_type max_size() const _NOEXCEPT; void reserve(size_type __n); void shrink_to_fit() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n); _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const; reference at(size_type __n); const_reference at(size_type __n) const; _LIBCPP_INLINE_VISIBILITY reference front() { _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); return *this->__begin_; } _LIBCPP_INLINE_VISIBILITY const_reference front() const { _LIBCPP_ASSERT(!empty(), "front() called for empty vector"); return *this->__begin_; } _LIBCPP_INLINE_VISIBILITY reference back() { _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); return *(this->__end_ - 1); } _LIBCPP_INLINE_VISIBILITY const_reference back() const { _LIBCPP_ASSERT(!empty(), "back() called for empty vector"); return *(this->__end_ - 1); } _LIBCPP_INLINE_VISIBILITY value_type* data() _NOEXCEPT {return _VSTD::__to_raw_pointer(this->__begin_);} _LIBCPP_INLINE_VISIBILITY const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(this->__begin_);} _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); #ifndef _LIBCPP_HAS_NO_VARIADICS template void emplace_back(_Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void pop_back(); iterator insert(const_iterator __position, const_reference __x); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES iterator insert(const_iterator __position, value_type&& __x); #ifndef _LIBCPP_HAS_NO_VARIADICS template iterator emplace(const_iterator __position, _Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES iterator insert(const_iterator __position, size_type __n, const_reference __x); template typename enable_if < __is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, iterator >::type insert(const_iterator __position, _InputIterator __first, _InputIterator __last); template typename enable_if < __is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value, iterator >::type insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __position, initializer_list __il) {return insert(__position, __il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); iterator erase(const_iterator __first, const_iterator __last); _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT { __base::clear(); __invalidate_all_iterators(); } void resize(size_type __sz); void resize(size_type __sz, const_reference __x); void swap(vector&) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); bool __invariants() const; #if _LIBCPP_DEBUG_LEVEL >= 2 bool __dereferenceable(const const_iterator* __i) const; bool __decrementable(const const_iterator* __i) const; bool __addable(const const_iterator* __i, ptrdiff_t __n) const; bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; #endif // _LIBCPP_DEBUG_LEVEL >= 2 private: _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); void allocate(size_type __n); void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; void __construct_at_end(size_type __n); void __construct_at_end(size_type __n, const_reference __x); template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, void >::type __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); void __move_construct_at_end(pointer __first, pointer __last); void __append(size_type __n); void __append(size_type __n, const_reference __x); _LIBCPP_INLINE_VISIBILITY iterator __make_iter(pointer __p) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; void __swap_out_circular_buffer(__split_buffer& __v); pointer __swap_out_circular_buffer(__split_buffer& __v, pointer __p); void __move_range(pointer __from_s, pointer __from_e, pointer __to); void __move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); void __move_assign(vector& __c, false_type); _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 __c_node* __c = __get_db()->__find_c_and_lock(this); for (__i_node** __p = __c->end_; __p != __c->beg_; ) { --__p; const_iterator* __i = static_cast((*__p)->__i_); if (__i->base() > __new_last) { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); #endif __base::__destruct_at_end(__new_last); } template void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __push_back_slow_path(_Up&& __x); #else __push_back_slow_path(_Up& __x); #endif #if !defined(_LIBCPP_HAS_NO_VARIADICS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) template void __emplace_back_slow_path(_Args&&... __args); #endif }; template void vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v) { __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_); _VSTD::swap(this->__begin_, __v.__begin_); _VSTD::swap(this->__end_, __v.__end_); _VSTD::swap(this->__end_cap(), __v.__end_cap()); __v.__first_ = __v.__begin_; __invalidate_all_iterators(); } template typename vector<_Tp, _Allocator>::pointer vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v, pointer __p) { pointer __r = __v.__begin_; __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_); __alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_); _VSTD::swap(this->__begin_, __v.__begin_); _VSTD::swap(this->__end_, __v.__end_); _VSTD::swap(this->__end_cap(), __v.__end_cap()); __v.__first_ = __v.__begin_; __invalidate_all_iterators(); return __r; } // Allocate space for __n objects // throws length_error if __n > max_size() // throws (probably bad_alloc) if memory run out // Precondition: __begin_ == __end_ == __end_cap() == 0 // Precondition: __n > 0 // Postcondition: capacity() == __n // Postcondition: size() == 0 template void vector<_Tp, _Allocator>::allocate(size_type __n) { if (__n > max_size()) this->__throw_length_error(); this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n); this->__end_cap() = this->__begin_ + __n; } template void vector<_Tp, _Allocator>::deallocate() _NOEXCEPT { if (this->__begin_ != nullptr) { clear(); __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity()); this->__begin_ = this->__end_ = this->__end_cap() = nullptr; } } template typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::max_size() const _NOEXCEPT { return _VSTD::min(__alloc_traits::max_size(this->__alloc()), numeric_limits::max() / 2); // end() >= begin(), always } // Precondition: __new_size > capacity() template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::__recommend(size_type __new_size) const { const size_type __ms = max_size(); if (__new_size > __ms) this->__throw_length_error(); const size_type __cap = capacity(); if (__cap >= __ms / 2) return __ms; return _VSTD::max(2*__cap, __new_size); } // Default constructs __n objects starting at __end_ // throws if construction throws // Precondition: __n > 0 // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) { allocator_type& __a = this->__alloc(); do { __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_)); ++this->__end_; --__n; } while (__n > 0); } // Copy constructs __n objects starting at __end_ from __x // throws if construction throws // Precondition: __n > 0 // Precondition: size() + __n <= capacity() // Postcondition: size() == old size() + __n // Postcondition: [i] == __x for all i in [size() - __n, __n) template inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { allocator_type& __a = this->__alloc(); do { __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x); ++this->__end_; --__n; } while (__n > 0); } template template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, void >::type vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) { allocator_type& __a = this->__alloc(); for (; __first != __last; ++__first) { __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); ++this->__end_; } } template void vector<_Tp, _Allocator>::__move_construct_at_end(pointer __first, pointer __last) { allocator_type& __a = this->__alloc(); for (; __first != __last; ++__first) { __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), _VSTD::move(*__first)); ++this->__end_; } } // Default constructs __n objects starting at __end_ // throws if construction throws // Postcondition: size() == size() + __n // Exception safety: strong. template void vector<_Tp, _Allocator>::__append(size_type __n) { if (static_cast(this->__end_cap() - this->__end_) >= __n) this->__construct_at_end(__n); else { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + __n), size(), __a); __v.__construct_at_end(__n); __swap_out_circular_buffer(__v); } } // Default constructs __n objects starting at __end_ // throws if construction throws // Postcondition: size() == size() + __n // Exception safety: strong. template void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) { if (static_cast(this->__end_cap() - this->__end_) >= __n) this->__construct_at_end(__n, __x); else { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + __n), size(), __a); __v.__construct_at_end(__n, __x); __swap_out_circular_buffer(__v); } } template vector<_Tp, _Allocator>::vector(size_type __n) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif if (__n > 0) { allocate(__n); __construct_at_end(__n); } } #if _LIBCPP_STD_VER > 11 template vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif if (__n > 0) { allocate(__n); __construct_at_end(__n); } } #endif template vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif if (__n > 0) { allocate(__n); __construct_at_end(__n, __x); } } template vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const allocator_type& __a) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif if (__n > 0) { allocate(__n); __construct_at_end(__n, __x); } } template template vector<_Tp, _Allocator>::vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, _InputIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif for (; __first != __last; ++__first) push_back(*__first); } template template vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value>::type*) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif for (; __first != __last; ++__first) push_back(*__first); } template template vector<_Tp, _Allocator>::vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value, _ForwardIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif size_type __n = static_cast(_VSTD::distance(__first, __last)); if (__n > 0) { allocate(__n); __construct_at_end(__first, __last); } } template template vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value>::type*) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif size_type __n = static_cast(_VSTD::distance(__first, __last)); if (__n > 0) { allocate(__n); __construct_at_end(__first, __last); } } template vector<_Tp, _Allocator>::vector(const vector& __x) : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif size_type __n = __x.size(); if (__n > 0) { allocate(__n); __construct_at_end(__x.__begin_, __x.__end_); } } template vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif size_type __n = __x.size(); if (__n > 0) { allocate(__n); __construct_at_end(__x.__begin_, __x.__end_); } } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) _NOEXCEPT_(is_nothrow_move_constructible::value) : __base(_VSTD::move(__x.__alloc())) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); __get_db()->swap(this, &__x); #endif this->__begin_ = __x.__begin_; this->__end_ = __x.__end_; this->__end_cap() = __x.__end_cap(); __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; } template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif if (__a == __x.__alloc()) { this->__begin_ = __x.__begin_; this->__end_ = __x.__end_; this->__end_cap() = __x.__end_cap(); __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->swap(this, &__x); #endif } else { typedef move_iterator _Ip; assign(_Ip(__x.begin()), _Ip(__x.end())); } } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif if (__il.size() > 0) { allocate(__il.size()); __construct_at_end(__il.begin(), __il.end()); } } template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il, const allocator_type& __a) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif if (__il.size() > 0) { allocate(__il.size()); __construct_at_end(__il.begin(), __il.end()); } } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) _NOEXCEPT_( __alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value) { __move_assign(__x, integral_constant()); return *this; } template void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) { if (__base::__alloc() != __c.__alloc()) { typedef move_iterator _Ip; assign(_Ip(__c.begin()), _Ip(__c.end())); } else __move_assign(__c, true_type()); } template void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { deallocate(); this->__begin_ = __c.__begin_; this->__end_ = __c.__end_; this->__end_cap() = __c.__end_cap(); __base::__move_assign_alloc(__c); __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->swap(this, &__c); #endif } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(const vector& __x) { if (this != &__x) { __base::__copy_assign_alloc(__x); assign(__x.__begin_, __x.__end_); } return *this; } template template typename enable_if < __is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< _Tp, typename iterator_traits<_InputIterator>::reference>::value, void >::type vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { clear(); for (; __first != __last; ++__first) push_back(*__first); } template template typename enable_if < __is_forward_iterator<_ForwardIterator>::value && is_constructible< _Tp, typename iterator_traits<_ForwardIterator>::reference>::value, void >::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()) { _ForwardIterator __mid = __last; bool __growing = false; if (static_cast(__new_size) > size()) { __growing = true; __mid = __first; _VSTD::advance(__mid, size()); } pointer __m = _VSTD::copy(__first, __mid, this->__begin_); if (__growing) __construct_at_end(__mid, __last); else this->__destruct_at_end(__m); } else { deallocate(); allocate(__recommend(static_cast(__new_size))); __construct_at_end(__first, __last); } } template void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { if (__n <= capacity()) { size_type __s = size(); _VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u); if (__n > __s) __construct_at_end(__n - __s, __u); else this->__destruct_at_end(this->__begin_ + __n); } else { deallocate(); allocate(__recommend(static_cast(__n))); __construct_at_end(__n, __u); } } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(this, __p); #else return iterator(__p); #endif } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 return const_iterator(this, __p); #else return const_iterator(__p); #endif } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT { return __make_iter(this->__begin_); } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::begin() const _NOEXCEPT { return __make_iter(this->__begin_); } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT { return __make_iter(this->__end_); } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::end() const _NOEXCEPT { return __make_iter(this->__end_); } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::operator[](size_type __n) { _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); return this->__begin_[__n]; } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::operator[](size_type __n) const { _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); return this->__begin_[__n]; } template typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::at(size_type __n) { if (__n >= size()) this->__throw_out_of_range(); return this->__begin_[__n]; } template typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::at(size_type __n) const { if (__n >= size()) this->__throw_out_of_range(); return this->__begin_[__n]; } template void vector<_Tp, _Allocator>::reserve(size_type __n) { if (__n > capacity()) { allocator_type& __a = this->__alloc(); __split_buffer __v(__n, size(), __a); __swap_out_circular_buffer(__v); } } template void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { if (capacity() > size()) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS allocator_type& __a = this->__alloc(); __split_buffer __v(size(), size(), __a); __swap_out_circular_buffer(__v); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } #endif // _LIBCPP_NO_EXCEPTIONS } } template template void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) #else vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) #endif { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + 1), size(), __a); // __v.push_back(_VSTD::forward<_Up>(__x)); __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Up>(__x)); __v.__end_++; __swap_out_circular_buffer(__v); } template inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(const_reference __x) { if (this->__end_ != this->__end_cap()) { __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), __x); ++this->__end_; } else __push_back_slow_path(__x); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(value_type&& __x) { if (this->__end_ < this->__end_cap()) { __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), _VSTD::move(__x)); ++this->__end_; } else __push_back_slow_path(_VSTD::move(__x)); } #ifndef _LIBCPP_HAS_NO_VARIADICS template template void vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + 1), size(), __a); // __v.emplace_back(_VSTD::forward<_Args>(__args)...); __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Args>(__args)...); __v.__end_++; __swap_out_circular_buffer(__v); } template template inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { if (this->__end_ < this->__end_cap()) { __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), _VSTD::forward<_Args>(__args)...); ++this->__end_; } else __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...); } #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::pop_back() { _LIBCPP_ASSERT(!empty(), "vector::pop_back called for empty vector"); this->__destruct_at_end(this->__end_ - 1); } template inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __position) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, "vector::erase(iterator) called with an iterator not" " referring to this vector"); #endif _LIBCPP_ASSERT(__position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator"); difference_type __ps = __position - cbegin(); pointer __p = this->__begin_ + __ps; iterator __r = __make_iter(__p); this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p)); return __r; } template typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, "vector::erase(iterator, iterator) called with an iterator not" " referring to this vector"); #endif _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); pointer __p = this->__begin_ + (__first - begin()); iterator __r = __make_iter(__p); if (__first != __last) this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); return __r; } template void vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) { pointer __old_last = this->__end_; difference_type __n = __old_last - __to; for (pointer __i = __from_s + __n; __i < __from_e; ++__i, ++this->__end_) __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), _VSTD::move(*__i)); _VSTD::move_backward(__from_s, __from_s + __n, __old_last); } template typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, "vector::insert(iterator, x) called with an iterator not" " referring to this vector"); #endif pointer __p = this->__begin_ + (__position - begin()); if (this->__end_ < this->__end_cap()) { if (__p == this->__end_) { __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), __x); ++this->__end_; } else { __move_range(__p, this->__end_, __p + 1); const_pointer __xr = pointer_traits::pointer_to(__x); if (__p <= __xr && __xr < this->__end_) ++__xr; *__p = *__xr; } } else { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + 1), __p - this->__begin_, __a); __v.push_back(__x); __p = __swap_out_circular_buffer(__v, __p); } return __make_iter(__p); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, "vector::insert(iterator, x) called with an iterator not" " referring to this vector"); #endif pointer __p = this->__begin_ + (__position - begin()); if (this->__end_ < this->__end_cap()) { if (__p == this->__end_) { __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), _VSTD::move(__x)); ++this->__end_; } else { __move_range(__p, this->__end_, __p + 1); *__p = _VSTD::move(__x); } } else { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + 1), __p - this->__begin_, __a); __v.push_back(_VSTD::move(__x)); __p = __swap_out_circular_buffer(__v, __p); } return __make_iter(__p); } #ifndef _LIBCPP_HAS_NO_VARIADICS template template typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, "vector::emplace(iterator, x) called with an iterator not" " referring to this vector"); #endif pointer __p = this->__begin_ + (__position - begin()); if (this->__end_ < this->__end_cap()) { if (__p == this->__end_) { __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(this->__end_), _VSTD::forward<_Args>(__args)...); ++this->__end_; } else { value_type __tmp(_VSTD::forward<_Args>(__args)...); __move_range(__p, this->__end_, __p + 1); *__p = _VSTD::move(__tmp); } } else { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + 1), __p - this->__begin_, __a); __v.emplace_back(_VSTD::forward<_Args>(__args)...); __p = __swap_out_circular_buffer(__v, __p); } return __make_iter(__p); } #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, "vector::insert(iterator, n, x) called with an iterator not" " referring to this vector"); #endif pointer __p = this->__begin_ + (__position - begin()); if (__n > 0) { if (__n <= static_cast(this->__end_cap() - this->__end_)) { size_type __old_n = __n; pointer __old_last = this->__end_; if (__n > static_cast(this->__end_ - __p)) { size_type __cx = __n - (this->__end_ - __p); __construct_at_end(__cx, __x); __n -= __cx; } if (__n > 0) { __move_range(__p, __old_last, __p + __old_n); const_pointer __xr = pointer_traits::pointer_to(__x); if (__p <= __xr && __xr < this->__end_) __xr += __old_n; _VSTD::fill_n(__p, __n, *__xr); } } else { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + __n), __p - this->__begin_, __a); __v.__construct_at_end(__n, __x); __p = __swap_out_circular_buffer(__v, __p); } } return __make_iter(__p); } template template typename enable_if < __is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< _Tp, typename iterator_traits<_InputIterator>::reference>::value, typename vector<_Tp, _Allocator>::iterator >::type vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, "vector::insert(iterator, range) called with an iterator not" " referring to this vector"); #endif difference_type __off = __position - begin(); pointer __p = this->__begin_ + __off; allocator_type& __a = this->__alloc(); pointer __old_last = this->__end_; for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) { __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); ++this->__end_; } __split_buffer __v(__a); if (__first != __last) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __v.__construct_at_end(__first, __last); difference_type __old_size = __old_last - this->__begin_; difference_type __old_p = __p - this->__begin_; reserve(__recommend(size() + __v.size())); __p = this->__begin_ + __old_p; __old_last = this->__begin_ + __old_size; #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { erase(__make_iter(__old_last), end()); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } __p = _VSTD::rotate(__p, __old_last, this->__end_); insert(__make_iter(__p), make_move_iterator(__v.begin()), make_move_iterator(__v.end())); return begin() + __off; } template template typename enable_if < __is_forward_iterator<_ForwardIterator>::value && is_constructible< _Tp, typename iterator_traits<_ForwardIterator>::reference>::value, typename vector<_Tp, _Allocator>::iterator >::type vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, "vector::insert(iterator, range) called with an iterator not" " referring to this vector"); #endif pointer __p = this->__begin_ + (__position - begin()); difference_type __n = _VSTD::distance(__first, __last); if (__n > 0) { if (__n <= this->__end_cap() - this->__end_) { size_type __old_n = __n; pointer __old_last = this->__end_; _ForwardIterator __m = __last; difference_type __dx = this->__end_ - __p; if (__n > __dx) { __m = __first; _VSTD::advance(__m, this->__end_ - __p); __construct_at_end(__m, __last); __n = __dx; } if (__n > 0) { __move_range(__p, __old_last, __p + __old_n); _VSTD::copy(__first, __m, __p); } } else { allocator_type& __a = this->__alloc(); __split_buffer __v(__recommend(size() + __n), __p - this->__begin_, __a); __v.__construct_at_end(__first, __last); __p = __swap_out_circular_buffer(__v, __p); } } return __make_iter(__p); } template void vector<_Tp, _Allocator>::resize(size_type __sz) { size_type __cs = size(); if (__cs < __sz) this->__append(__sz - __cs); else if (__cs > __sz) this->__destruct_at_end(this->__begin_ + __sz); } template void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) { size_type __cs = size(); if (__cs < __sz) this->__append(__sz - __cs, __x); else if (__cs > __sz) this->__destruct_at_end(this->__begin_ + __sz); } template void vector<_Tp, _Allocator>::swap(vector& __x) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value) { _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || this->__alloc() == __x.__alloc(), "vector::swap: Either propagate_on_container_swap must be true" " or the allocators must compare equal"); _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()); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->swap(this, &__x); #endif // _LIBCPP_DEBUG_LEVEL >= 2 } template bool vector<_Tp, _Allocator>::__invariants() const { if (this->__begin_ == nullptr) { if (this->__end_ != nullptr || this->__end_cap() != nullptr) return false; } else { if (this->__begin_ > this->__end_) return false; if (this->__begin_ == this->__end_cap()) return false; if (this->__end_ > this->__end_cap()) return false; } return true; } #if _LIBCPP_DEBUG_LEVEL >= 2 template bool vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const { return this->__begin_ <= __i->base() && __i->base() < this->__end_; } template bool vector<_Tp, _Allocator>::__decrementable(const const_iterator* __i) const { return this->__begin_ < __i->base() && __i->base() <= this->__end_; } template bool vector<_Tp, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const { const_pointer __p = __i->base() + __n; return this->__begin_ <= __p && __p <= this->__end_; } template bool vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const { const_pointer __p = __i->base() + __n; return this->__begin_ <= __p && __p < this->__end_; } #endif // _LIBCPP_DEBUG_LEVEL >= 2 template inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__invalidate_all_iterators() { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__invalidate_all(this); #endif // _LIBCPP_DEBUG_LEVEL >= 2 } // vector template class vector; template struct hash >; template struct __has_storage_type > { static const bool value = true; }; template class _LIBCPP_TYPE_VIS_ONLY vector : private __vector_base_common { public: typedef vector __self; typedef bool value_type; typedef _Allocator allocator_type; typedef allocator_traits __alloc_traits; typedef typename __alloc_traits::size_type size_type; typedef typename __alloc_traits::difference_type difference_type; typedef size_type __storage_type; typedef __bit_iterator pointer; typedef __bit_iterator const_pointer; typedef pointer iterator; typedef const_pointer const_iterator; typedef _VSTD::reverse_iterator reverse_iterator; 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 allocator_traits<__storage_allocator> __storage_traits; typedef typename __storage_traits::pointer __storage_pointer; typedef typename __storage_traits::const_pointer __const_storage_pointer; __storage_pointer __begin_; size_type __size_; __compressed_pair __cap_alloc_; public: typedef __bit_reference reference; typedef __bit_const_reference const_reference; private: _LIBCPP_INLINE_VISIBILITY size_type& __cap() _NOEXCEPT {return __cap_alloc_.first();} _LIBCPP_INLINE_VISIBILITY const size_type& __cap() const _NOEXCEPT {return __cap_alloc_.first();} _LIBCPP_INLINE_VISIBILITY __storage_allocator& __alloc() _NOEXCEPT {return __cap_alloc_.second();} _LIBCPP_INLINE_VISIBILITY const __storage_allocator& __alloc() const _NOEXCEPT {return __cap_alloc_.second();} static const unsigned __bits_per_word = static_cast(sizeof(__storage_type) * CHAR_BIT); _LIBCPP_INLINE_VISIBILITY static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT {return __n * __bits_per_word;} _LIBCPP_INLINE_VISIBILITY static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT {return (__n - 1) / __bits_per_word + 1;} public: _LIBCPP_INLINE_VISIBILITY vector() _NOEXCEPT_(is_nothrow_default_constructible::value); _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a); ~vector(); explicit vector(size_type __n); #if _LIBCPP_STD_VER > 11 explicit vector(size_type __n, const allocator_type& __a); #endif vector(size_type __n, const value_type& __v); vector(size_type __n, const value_type& __v, const allocator_type& __a); template vector(_InputIterator __first, _InputIterator __last, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value>::type* = 0); template vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value>::type* = 0); template vector(_ForwardIterator __first, _ForwardIterator __last, typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0); template vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0); vector(const vector& __v); vector(const vector& __v, const allocator_type& __a); vector& operator=(const vector& __v); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS vector(initializer_list __il); vector(initializer_list __il, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY vector(vector&& __v) _NOEXCEPT_(is_nothrow_move_constructible::value); vector(vector&& __v, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __v) _NOEXCEPT_( __alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY vector& operator=(initializer_list __il) {assign(__il.begin(), __il.end()); return *this;} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template typename enable_if < __is_input_iterator<_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value, void >::type assign(_InputIterator __first, _InputIterator __last); template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, void >::type assign(_ForwardIterator __first, _ForwardIterator __last); void assign(size_type __n, const value_type& __x); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY void assign(initializer_list __il) {assign(__il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT {return allocator_type(this->__alloc());} size_type max_size() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT {return __internal_cap_to_external(__cap());} _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT {return __size_;} _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return __size_ == 0;} void reserve(size_type __n); void shrink_to_fit() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __make_iter(0);} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __make_iter(0);} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __make_iter(__size_);} _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __make_iter(__size_);} _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT {return __make_iter(0);} _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return __make_iter(__size_);} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT {return rend();} _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);} _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);} reference at(size_type __n); const_reference at(size_type __n) const; _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);} _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);} _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);} _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} void push_back(const value_type& __x); #if _LIBCPP_STD_VER > 11 template _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) { push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); } #endif _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} #if _LIBCPP_STD_VER > 11 template _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args) { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); } #endif iterator insert(const_iterator __position, const value_type& __x); iterator insert(const_iterator __position, size_type __n, const value_type& __x); iterator insert(const_iterator __position, size_type __n, const_reference __x); template typename enable_if < __is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value, iterator >::type insert(const_iterator __position, _InputIterator __first, _InputIterator __last); template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, iterator >::type insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __position, initializer_list __il) {return insert(__position, __il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); iterator erase(const_iterator __first, const_iterator __last); _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT {__size_ = 0;} void swap(vector&) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); void resize(size_type __sz, value_type __x = false); void flip() _NOEXCEPT; bool __invariants() const; private: _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); void allocate(size_type __n); void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY static size_type __align_it(size_type __new_size) _NOEXCEPT {return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);}; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, void >::type __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); void __append(size_type __n, const_reference __x); _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_type __pos) _NOEXCEPT {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_type __pos) const _NOEXCEPT {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) _NOEXCEPT {return iterator(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word));} _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_type __pos) const _NOEXCEPT {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast(__pos % __bits_per_word));} _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {return begin() + (__p - cbegin());} _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __v) {__copy_assign_alloc(__v, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __c, true_type) { if (__alloc() != __c.__alloc()) deallocate(); __alloc() = __c.__alloc(); } _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector&, false_type) {} void __move_assign(vector& __c, false_type); void __move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(vector& __c) _NOEXCEPT_( !__storage_traits::propagate_on_container_move_assignment::value || is_nothrow_move_assignable::value) {__move_assign_alloc(__c, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { __alloc() = _VSTD::move(__c.__alloc()); } _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(vector&, false_type) _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; friend class __bit_const_reference; friend class __bit_iterator; friend class __bit_iterator; friend struct __bit_array; friend struct _LIBCPP_TYPE_VIS_ONLY hash; }; template inline _LIBCPP_INLINE_VISIBILITY void vector::__invalidate_all_iterators() { } // Allocate space for __n objects // throws length_error if __n > max_size() // throws (probably bad_alloc) if memory run out // Precondition: __begin_ == __end_ == __cap() == 0 // Precondition: __n > 0 // Postcondition: capacity() == __n // Postcondition: size() == 0 template void vector::allocate(size_type __n) { if (__n > max_size()) this->__throw_length_error(); __n = __external_cap_to_internal(__n); this->__begin_ = __storage_traits::allocate(this->__alloc(), __n); this->__size_ = 0; this->__cap() = __n; } template void vector::deallocate() _NOEXCEPT { if (this->__begin_ != nullptr) { __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); __invalidate_all_iterators(); this->__begin_ = nullptr; this->__size_ = this->__cap() = 0; } } template typename vector::size_type vector::max_size() const _NOEXCEPT { size_type __amax = __storage_traits::max_size(__alloc()); size_type __nmax = numeric_limits::max() / 2; // end() >= begin(), always if (__nmax / __bits_per_word <= __amax) return __nmax; return __internal_cap_to_external(__amax); } // Precondition: __new_size > capacity() template inline _LIBCPP_INLINE_VISIBILITY typename vector::size_type vector::__recommend(size_type __new_size) const { const size_type __ms = max_size(); if (__new_size > __ms) this->__throw_length_error(); const size_type __cap = capacity(); if (__cap >= __ms / 2) return __ms; return _VSTD::max(2*__cap, __align_it(__new_size)); } // Default constructs __n objects starting at __end_ // Precondition: __n > 0 // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template inline _LIBCPP_INLINE_VISIBILITY void vector::__construct_at_end(size_type __n, bool __x) { size_type __old_size = this->__size_; this->__size_ += __n; _VSTD::fill_n(__make_iter(__old_size), __n, __x); } template template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, void >::type vector::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) { size_type __old_size = this->__size_; this->__size_ += _VSTD::distance(__first, __last); _VSTD::copy(__first, __last, __make_iter(__old_size)); } template inline _LIBCPP_INLINE_VISIBILITY vector::vector() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), __size_(0), __cap_alloc_(0) { } template inline _LIBCPP_INLINE_VISIBILITY vector::vector(const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { } template vector::vector(size_type __n) : __begin_(nullptr), __size_(0), __cap_alloc_(0) { if (__n > 0) { allocate(__n); __construct_at_end(__n, false); } } #if _LIBCPP_STD_VER > 11 template vector::vector(size_type __n, const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { if (__n > 0) { allocate(__n); __construct_at_end(__n, false); } } #endif template vector::vector(size_type __n, const value_type& __x) : __begin_(nullptr), __size_(0), __cap_alloc_(0) { if (__n > 0) { allocate(__n); __construct_at_end(__n, __x); } } template vector::vector(size_type __n, const value_type& __x, const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { if (__n > 0) { allocate(__n); __construct_at_end(__n, __x); } } template template vector::vector(_InputIterator __first, _InputIterator __last, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value>::type*) : __begin_(nullptr), __size_(0), __cap_alloc_(0) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __first != __last; ++__first) push_back(*__first); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); __invalidate_all_iterators(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } template template vector::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value>::type*) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __first != __last; ++__first) push_back(*__first); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); __invalidate_all_iterators(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } template template vector::vector(_ForwardIterator __first, _ForwardIterator __last, typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) : __begin_(nullptr), __size_(0), __cap_alloc_(0) { size_type __n = static_cast(_VSTD::distance(__first, __last)); if (__n > 0) { allocate(__n); __construct_at_end(__first, __last); } } template template vector::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { size_type __n = static_cast(_VSTD::distance(__first, __last)); if (__n > 0) { allocate(__n); __construct_at_end(__first, __last); } } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template vector::vector(initializer_list __il) : __begin_(nullptr), __size_(0), __cap_alloc_(0) { size_type __n = static_cast(__il.size()); if (__n > 0) { allocate(__n); __construct_at_end(__il.begin(), __il.end()); } } template vector::vector(initializer_list __il, const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { size_type __n = static_cast(__il.size()); if (__n > 0) { allocate(__n); __construct_at_end(__il.begin(), __il.end()); } } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template vector::~vector() { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); __invalidate_all_iterators(); } template vector::vector(const vector& __v) : __begin_(nullptr), __size_(0), __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) { if (__v.size() > 0) { allocate(__v.size()); __construct_at_end(__v.begin(), __v.end()); } } template vector::vector(const vector& __v, const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { if (__v.size() > 0) { allocate(__v.size()); __construct_at_end(__v.begin(), __v.end()); } } template vector& vector::operator=(const vector& __v) { if (this != &__v) { __copy_assign_alloc(__v); if (__v.__size_) { if (__v.__size_ > capacity()) { deallocate(); allocate(__v.__size_); } _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); } __size_ = __v.__size_; } return *this; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY vector::vector(vector&& __v) _NOEXCEPT_(is_nothrow_move_constructible::value) : __begin_(__v.__begin_), __size_(__v.__size_), __cap_alloc_(__v.__cap_alloc_) { __v.__begin_ = nullptr; __v.__size_ = 0; __v.__cap() = 0; } template vector::vector(vector&& __v, const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { if (__a == allocator_type(__v.__alloc())) { this->__begin_ = __v.__begin_; this->__size_ = __v.__size_; this->__cap() = __v.__cap(); __v.__begin_ = nullptr; __v.__cap() = __v.__size_ = 0; } else if (__v.size() > 0) { allocate(__v.size()); __construct_at_end(__v.begin(), __v.end()); } } template inline _LIBCPP_INLINE_VISIBILITY vector& vector::operator=(vector&& __v) _NOEXCEPT_( __alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value) { __move_assign(__v, integral_constant()); return *this; } template void vector::__move_assign(vector& __c, false_type) { if (__alloc() != __c.__alloc()) assign(__c.begin(), __c.end()); else __move_assign(__c, true_type()); } template void vector::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { deallocate(); this->__begin_ = __c.__begin_; this->__size_ = __c.__size_; this->__cap() = __c.__cap(); __move_assign_alloc(__c); __c.__begin_ = nullptr; __c.__cap() = __c.__size_ = 0; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void vector::assign(size_type __n, const value_type& __x) { __size_ = 0; if (__n > 0) { size_type __c = capacity(); if (__n <= __c) __size_ = __n; else { vector __v(__alloc()); __v.reserve(__recommend(__n)); __v.__size_ = __n; swap(__v); } _VSTD::fill_n(begin(), __n, __x); } } template template typename enable_if < __is_input_iterator<_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value, void >::type vector::assign(_InputIterator __first, _InputIterator __last) { clear(); for (; __first != __last; ++__first) push_back(*__first); } template template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, void >::type vector::assign(_ForwardIterator __first, _ForwardIterator __last) { clear(); difference_type __n = _VSTD::distance(__first, __last); if (__n) { if (__n > capacity()) { deallocate(); allocate(__n); } __construct_at_end(__first, __last); } } template void vector::reserve(size_type __n) { if (__n > capacity()) { vector __v(this->__alloc()); __v.allocate(__n); __v.__construct_at_end(this->begin(), this->end()); swap(__v); __invalidate_all_iterators(); } } template void vector::shrink_to_fit() _NOEXCEPT { if (__external_cap_to_internal(size()) > __cap()) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS vector(*this, allocator_type(__alloc())).swap(*this); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } #endif // _LIBCPP_NO_EXCEPTIONS } } template typename vector::reference vector::at(size_type __n) { if (__n >= size()) this->__throw_out_of_range(); return (*this)[__n]; } template typename vector::const_reference vector::at(size_type __n) const { if (__n >= size()) this->__throw_out_of_range(); return (*this)[__n]; } template void vector::push_back(const value_type& __x) { if (this->__size_ == this->capacity()) reserve(__recommend(this->__size_ + 1)); ++this->__size_; back() = __x; } template typename vector::iterator vector::insert(const_iterator __position, const value_type& __x) { iterator __r; if (size() < capacity()) { const_iterator __old_end = end(); ++__size_; _VSTD::copy_backward(__position, __old_end, end()); __r = __const_iterator_cast(__position); } else { vector __v(__alloc()); __v.reserve(__recommend(__size_ + 1)); __v.__size_ = __size_ + 1; __r = _VSTD::copy(cbegin(), __position, __v.begin()); _VSTD::copy_backward(__position, cend(), __v.end()); swap(__v); } *__r = __x; return __r; } template typename vector::iterator vector::insert(const_iterator __position, size_type __n, const value_type& __x) { iterator __r; size_type __c = capacity(); if (__n <= __c && size() <= __c - __n) { const_iterator __old_end = end(); __size_ += __n; _VSTD::copy_backward(__position, __old_end, end()); __r = __const_iterator_cast(__position); } else { vector __v(__alloc()); __v.reserve(__recommend(__size_ + __n)); __v.__size_ = __size_ + __n; __r = _VSTD::copy(cbegin(), __position, __v.begin()); _VSTD::copy_backward(__position, cend(), __v.end()); swap(__v); } _VSTD::fill_n(__r, __n, __x); return __r; } template template typename enable_if < __is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value, typename vector::iterator >::type vector::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { difference_type __off = __position - begin(); iterator __p = __const_iterator_cast(__position); iterator __old_end = end(); for (; size() != capacity() && __first != __last; ++__first) { ++this->__size_; back() = *__first; } vector __v(__alloc()); if (__first != __last) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __v.assign(__first, __last); difference_type __old_size = static_cast(__old_end - begin()); difference_type __old_p = __p - begin(); reserve(__recommend(size() + __v.size())); __p = begin() + __old_p; __old_end = begin() + __old_size; #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { erase(__old_end, end()); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } __p = _VSTD::rotate(__p, __old_end, end()); insert(__p, __v.begin(), __v.end()); return begin() + __off; } template template typename enable_if < __is_forward_iterator<_ForwardIterator>::value, typename vector::iterator >::type vector::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { difference_type __n = _VSTD::distance(__first, __last); iterator __r; size_type __c = capacity(); if (__n <= __c && size() <= __c - __n) { const_iterator __old_end = end(); __size_ += __n; _VSTD::copy_backward(__position, __old_end, end()); __r = __const_iterator_cast(__position); } else { vector __v(__alloc()); __v.reserve(__recommend(__size_ + __n)); __v.__size_ = __size_ + __n; __r = _VSTD::copy(cbegin(), __position, __v.begin()); _VSTD::copy_backward(__position, cend(), __v.end()); swap(__v); } _VSTD::copy(__first, __last, __r); return __r; } template inline _LIBCPP_INLINE_VISIBILITY typename vector::iterator vector::erase(const_iterator __position) { iterator __r = __const_iterator_cast(__position); _VSTD::copy(__position + 1, this->cend(), __r); --__size_; return __r; } template typename vector::iterator vector::erase(const_iterator __first, const_iterator __last) { iterator __r = __const_iterator_cast(__first); difference_type __d = __last - __first; _VSTD::copy(__last, this->cend(), __r); __size_ -= __d; return __r; } template void vector::swap(vector& __x) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value) { _VSTD::swap(this->__begin_, __x.__begin_); _VSTD::swap(this->__size_, __x.__size_); _VSTD::swap(this->__cap(), __x.__cap()); __swap_alloc(this->__alloc(), __x.__alloc()); } template void vector::resize(size_type __sz, value_type __x) { size_type __cs = size(); if (__cs < __sz) { iterator __r; size_type __c = capacity(); size_type __n = __sz - __cs; if (__n <= __c && __cs <= __c - __n) { __r = end(); __size_ += __n; } else { vector __v(__alloc()); __v.reserve(__recommend(__size_ + __n)); __v.__size_ = __size_ + __n; __r = _VSTD::copy(cbegin(), cend(), __v.begin()); swap(__v); } _VSTD::fill_n(__r, __n, __x); } else __size_ = __sz; } template void vector::flip() _NOEXCEPT { // do middle whole words size_type __n = __size_; __storage_pointer __p = __begin_; for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) *__p = ~*__p; // do last partial word if (__n > 0) { __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); __storage_type __b = *__p & __m; *__p &= ~__m; *__p |= ~__b & __m; } } template bool vector::__invariants() const { if (this->__begin_ == nullptr) { if (this->__size_ != 0 || this->__cap() != 0) return false; } else { if (this->__cap() == 0) return false; if (this->__size_ > this->capacity()) return false; } return true; } template size_t vector::__hash_code() const _NOEXCEPT { size_t __h = 0; // do middle whole words size_type __n = __size_; __storage_pointer __p = __begin_; for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) __h ^= *__p; // do last partial word if (__n > 0) { const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); __h ^= *__p & __m; } return __h; } template struct _LIBCPP_TYPE_VIS_ONLY hash > : public unary_function, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(const vector& __vec) const _NOEXCEPT {return __vec.__hash_code();} }; template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { return !(__x == __y); } template inline _LIBCPP_INLINE_VISIBILITY bool operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } template inline _LIBCPP_INLINE_VISIBILITY bool operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { return __y < __x; } template inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { return !(__x < __y); } template inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { return !(__y < __x); } template inline _LIBCPP_INLINE_VISIBILITY void swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { __x.swap(__y); } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_VECTOR libcxx/include/random0000644000175000017500000067072312266757731016116 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- random -----------------------------------===// // // The 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_RANDOM #define _LIBCPP_RANDOM /* random synopsis #include namespace std { // Engines template class linear_congruential_engine { public: // types typedef UIntType result_type; // 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; // constructors and seeding functions explicit linear_congruential_engine(result_type s = default_seed); template explicit linear_congruential_engine(Sseq& q); void seed(result_type s = default_seed); template void seed(Sseq& q); // generating functions result_type operator()(); void discard(unsigned long long z); }; template bool operator==(const linear_congruential_engine& x, const linear_congruential_engine& y); template bool operator!=(const linear_congruential_engine& x, const linear_congruential_engine& y); template basic_ostream& operator<<(basic_ostream& os, const linear_congruential_engine& x); template basic_istream& operator>>(basic_istream& is, linear_congruential_engine& x); 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; // constructors and seeding functions explicit mersenne_twister_engine(result_type value = default_seed); template explicit mersenne_twister_engine(Sseq& q); void seed(result_type value = default_seed); template void seed(Sseq& q); // generating functions result_type operator()(); void discard(unsigned long long z); }; template bool operator==( const mersenne_twister_engine& x, const mersenne_twister_engine& y); template bool operator!=( const mersenne_twister_engine& x, const mersenne_twister_engine& y); template basic_ostream& operator<<(basic_ostream& os, const mersenne_twister_engine& x); template basic_istream& operator>>(basic_istream& is, mersenne_twister_engine& x); 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; // constructors and seeding functions explicit subtract_with_carry_engine(result_type value = default_seed); template explicit subtract_with_carry_engine(Sseq& q); void seed(result_type value = default_seed); template void seed(Sseq& q); // generating functions result_type operator()(); void discard(unsigned long long z); }; template bool operator==( const subtract_with_carry_engine& x, const subtract_with_carry_engine& y); template bool operator!=( const subtract_with_carry_engine& x, const subtract_with_carry_engine& y); 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); 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(); } // constructors and seeding functions discard_block_engine(); explicit discard_block_engine(const Engine& e); explicit discard_block_engine(Engine&& e); explicit discard_block_engine(result_type s); template explicit discard_block_engine(Sseq& q); void seed(); void seed(result_type s); template void seed(Sseq& q); // generating functions result_type operator()(); void discard(unsigned long long z); // property functions const Engine& base() const noexcept; }; template bool operator==( const discard_block_engine& x, const discard_block_engine& y); template bool operator!=( const discard_block_engine& x, const discard_block_engine& y); template basic_ostream& operator<<(basic_ostream& os, const discard_block_engine& x); template basic_istream& operator>>(basic_istream& is, discard_block_engine& x); 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; } // constructors and seeding functions independent_bits_engine(); explicit independent_bits_engine(const Engine& e); explicit independent_bits_engine(Engine&& e); explicit independent_bits_engine(result_type s); template explicit independent_bits_engine(Sseq& q); void seed(); void seed(result_type s); template void seed(Sseq& q); // generating functions result_type operator()(); void discard(unsigned long long z); // property functions const Engine& base() const noexcept; }; template bool operator==( const independent_bits_engine& x, const independent_bits_engine& y); template bool operator!=( const independent_bits_engine& x, const independent_bits_engine& y); template basic_ostream& operator<<(basic_ostream& os, const independent_bits_engine& x); template basic_istream& operator>>(basic_istream& is, independent_bits_engine& x); 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; } // constructors and seeding functions shuffle_order_engine(); explicit shuffle_order_engine(const Engine& e); explicit shuffle_order_engine(Engine&& e); explicit shuffle_order_engine(result_type s); template explicit shuffle_order_engine(Sseq& q); void seed(); void seed(result_type s); template void seed(Sseq& q); // generating functions result_type operator()(); void discard(unsigned long long z); // property functions const Engine& base() const noexcept; }; template bool operator==( const shuffle_order_engine& x, const shuffle_order_engine& y); template bool operator!=( const shuffle_order_engine& x, const shuffle_order_engine& y); template basic_ostream& operator<<(basic_ostream& os, const shuffle_order_engine& x); template basic_istream& operator>>(basic_istream& is, shuffle_order_engine& x); typedef linear_congruential_engine minstd_rand0; typedef linear_congruential_engine minstd_rand; typedef mersenne_twister_engine mt19937; typedef mersenne_twister_engine mt19937_64; typedef subtract_with_carry_engine ranlux24_base; typedef subtract_with_carry_engine ranlux48_base; typedef discard_block_engine ranlux24; typedef discard_block_engine ranlux48; typedef shuffle_order_engine knuth_b; typedef minstd_rand default_random_engine; // Generators class random_device { public: // types typedef unsigned int result_type; // generator characteristics static constexpr result_type min() { return numeric_limits::min(); } static constexpr result_type max() { return numeric_limits::max(); } // constructors explicit random_device(const string& token = "/dev/urandom"); // generating functions result_type operator()(); // property functions double entropy() const noexcept; // no copy functions random_device(const random_device& ) = delete; void operator=(const random_device& ) = delete; }; // Utilities class seed_seq { public: // types typedef uint_least32_t result_type; // constructors seed_seq(); template seed_seq(initializer_list il); template seed_seq(InputIterator begin, InputIterator end); // generating functions template void generate(RandomAccessIterator begin, RandomAccessIterator end); // property functions size_t size() const; template void param(OutputIterator dest) const; // no copy functions seed_seq(const seed_seq&) = delete; void operator=(const seed_seq& ) = delete; }; template RealType generate_canonical(URNG& g); // Distributions template class uniform_int_distribution { public: // types typedef IntType result_type; class param_type { public: typedef uniform_int_distribution distribution_type; explicit param_type(IntType a = 0, IntType b = numeric_limits::max()); result_type a() const; result_type b() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit uniform_int_distribution(IntType a = 0, IntType b = numeric_limits::max()); explicit uniform_int_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type a() const; result_type b() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const uniform_int_distribution& x, const uniform_int_distribution& y); friend bool operator!=(const uniform_int_distribution& x, const uniform_int_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const uniform_int_distribution& x); template friend basic_istream& operator>>(basic_istream& is, uniform_int_distribution& x); }; template class uniform_real_distribution { public: // types typedef RealType result_type; class param_type { public: typedef uniform_real_distribution distribution_type; explicit param_type(RealType a = 0, RealType b = 1); result_type a() const; result_type b() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); explicit uniform_real_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type a() const; result_type b() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const uniform_real_distribution& x, const uniform_real_distribution& y); friend bool operator!=(const uniform_real_distribution& x, const uniform_real_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const uniform_real_distribution& x); template friend basic_istream& operator>>(basic_istream& is, uniform_real_distribution& x); }; class bernoulli_distribution { public: // types typedef bool result_type; class param_type { public: typedef bernoulli_distribution distribution_type; explicit param_type(double p = 0.5); double p() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit bernoulli_distribution(double p = 0.5); explicit bernoulli_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions double p() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const bernoulli_distribution& x, const bernoulli_distribution& y); friend bool operator!=(const bernoulli_distribution& x, const bernoulli_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const bernoulli_distribution& x); template friend basic_istream& operator>>(basic_istream& is, bernoulli_distribution& x); }; template class binomial_distribution { public: // types typedef IntType result_type; class param_type { public: typedef binomial_distribution distribution_type; explicit param_type(IntType t = 1, double p = 0.5); IntType t() const; double p() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit binomial_distribution(IntType t = 1, double p = 0.5); explicit binomial_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions IntType t() const; double p() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const binomial_distribution& x, const binomial_distribution& y); friend bool operator!=(const binomial_distribution& x, const binomial_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const binomial_distribution& x); template friend basic_istream& operator>>(basic_istream& is, binomial_distribution& x); }; template class geometric_distribution { public: // types typedef IntType result_type; class param_type { public: typedef geometric_distribution distribution_type; explicit param_type(double p = 0.5); double p() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit geometric_distribution(double p = 0.5); explicit geometric_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions double p() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const geometric_distribution& x, const geometric_distribution& y); friend bool operator!=(const geometric_distribution& x, const geometric_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const geometric_distribution& x); template friend basic_istream& operator>>(basic_istream& is, geometric_distribution& x); }; template class negative_binomial_distribution { public: // types typedef IntType result_type; class param_type { public: typedef negative_binomial_distribution distribution_type; explicit param_type(result_type k = 1, double p = 0.5); result_type k() const; double p() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit negative_binomial_distribution(result_type k = 1, double p = 0.5); explicit negative_binomial_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type k() const; double p() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const negative_binomial_distribution& x, const negative_binomial_distribution& y); friend bool operator!=(const negative_binomial_distribution& x, const negative_binomial_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const negative_binomial_distribution& x); template friend basic_istream& operator>>(basic_istream& is, negative_binomial_distribution& x); }; template class poisson_distribution { public: // types typedef IntType result_type; class param_type { public: typedef poisson_distribution distribution_type; explicit param_type(double mean = 1.0); double mean() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit poisson_distribution(double mean = 1.0); explicit poisson_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions double mean() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const poisson_distribution& x, const poisson_distribution& y); friend bool operator!=(const poisson_distribution& x, const poisson_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const poisson_distribution& x); template friend basic_istream& operator>>(basic_istream& is, poisson_distribution& x); }; template class exponential_distribution { public: // types typedef RealType result_type; class param_type { public: typedef exponential_distribution distribution_type; explicit param_type(result_type lambda = 1.0); result_type lambda() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit exponential_distribution(result_type lambda = 1.0); explicit exponential_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type lambda() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const exponential_distribution& x, const exponential_distribution& y); friend bool operator!=(const exponential_distribution& x, const exponential_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const exponential_distribution& x); template friend basic_istream& operator>>(basic_istream& is, exponential_distribution& x); }; template class gamma_distribution { public: // types typedef RealType result_type; class param_type { public: typedef gamma_distribution distribution_type; explicit param_type(result_type alpha = 1, result_type beta = 1); result_type alpha() const; result_type beta() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit gamma_distribution(result_type alpha = 1, result_type beta = 1); explicit gamma_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type alpha() const; result_type beta() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const gamma_distribution& x, const gamma_distribution& y); friend bool operator!=(const gamma_distribution& x, const gamma_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const gamma_distribution& x); template friend basic_istream& operator>>(basic_istream& is, gamma_distribution& x); }; template class weibull_distribution { public: // types typedef RealType result_type; class param_type { public: typedef weibull_distribution distribution_type; explicit param_type(result_type alpha = 1, result_type beta = 1); result_type a() const; result_type b() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit weibull_distribution(result_type a = 1, result_type b = 1); explicit weibull_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type a() const; result_type b() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const weibull_distribution& x, const weibull_distribution& y); friend bool operator!=(const weibull_distribution& x, const weibull_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const weibull_distribution& x); template friend basic_istream& operator>>(basic_istream& is, weibull_distribution& x); }; template class extreme_value_distribution { public: // types typedef RealType result_type; class param_type { public: typedef extreme_value_distribution distribution_type; explicit param_type(result_type a = 0, result_type b = 1); result_type a() const; result_type b() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit extreme_value_distribution(result_type a = 0, result_type b = 1); explicit extreme_value_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type a() const; result_type b() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const extreme_value_distribution& x, const extreme_value_distribution& y); friend bool operator!=(const extreme_value_distribution& x, const extreme_value_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const extreme_value_distribution& x); template friend basic_istream& operator>>(basic_istream& is, extreme_value_distribution& x); }; template class normal_distribution { public: // types typedef RealType result_type; class param_type { public: typedef normal_distribution distribution_type; explicit param_type(result_type mean = 0, result_type stddev = 1); result_type mean() const; result_type stddev() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructors and reset functions explicit normal_distribution(result_type mean = 0, result_type stddev = 1); explicit normal_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type mean() const; result_type stddev() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const normal_distribution& x, const normal_distribution& y); friend bool operator!=(const normal_distribution& x, const normal_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const normal_distribution& x); template friend basic_istream& operator>>(basic_istream& is, normal_distribution& x); }; template class lognormal_distribution { public: // types typedef RealType result_type; class param_type { public: typedef lognormal_distribution distribution_type; explicit param_type(result_type m = 0, result_type s = 1); result_type m() const; result_type s() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit lognormal_distribution(result_type m = 0, result_type s = 1); explicit lognormal_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type m() const; result_type s() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const lognormal_distribution& x, const lognormal_distribution& y); friend bool operator!=(const lognormal_distribution& x, const lognormal_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const lognormal_distribution& x); template friend basic_istream& operator>>(basic_istream& is, lognormal_distribution& x); }; template class chi_squared_distribution { public: // types typedef RealType result_type; class param_type { public: typedef chi_squared_distribution distribution_type; explicit param_type(result_type n = 1); result_type n() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit chi_squared_distribution(result_type n = 1); explicit chi_squared_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type n() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const chi_squared_distribution& x, const chi_squared_distribution& y); friend bool operator!=(const chi_squared_distribution& x, const chi_squared_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const chi_squared_distribution& x); template friend basic_istream& operator>>(basic_istream& is, chi_squared_distribution& x); }; template class cauchy_distribution { public: // types typedef RealType result_type; class param_type { public: typedef cauchy_distribution distribution_type; explicit param_type(result_type a = 0, result_type b = 1); result_type a() const; result_type b() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit cauchy_distribution(result_type a = 0, result_type b = 1); explicit cauchy_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type a() const; result_type b() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const cauchy_distribution& x, const cauchy_distribution& y); friend bool operator!=(const cauchy_distribution& x, const cauchy_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const cauchy_distribution& x); template friend basic_istream& operator>>(basic_istream& is, cauchy_distribution& x); }; template class fisher_f_distribution { public: // types typedef RealType result_type; class param_type { public: typedef fisher_f_distribution distribution_type; explicit param_type(result_type m = 1, result_type n = 1); result_type m() const; result_type n() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit fisher_f_distribution(result_type m = 1, result_type n = 1); explicit fisher_f_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type m() const; result_type n() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const fisher_f_distribution& x, const fisher_f_distribution& y); friend bool operator!=(const fisher_f_distribution& x, const fisher_f_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const fisher_f_distribution& x); template friend basic_istream& operator>>(basic_istream& is, fisher_f_distribution& x); }; template class student_t_distribution { public: // types typedef RealType result_type; class param_type { public: typedef student_t_distribution distribution_type; explicit param_type(result_type n = 1); result_type n() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions explicit student_t_distribution(result_type n = 1); explicit student_t_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions result_type n() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const student_t_distribution& x, const student_t_distribution& y); friend bool operator!=(const student_t_distribution& x, const student_t_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const student_t_distribution& x); template friend basic_istream& operator>>(basic_istream& is, student_t_distribution& x); }; template class discrete_distribution { public: // types typedef IntType result_type; class param_type { public: typedef discrete_distribution distribution_type; param_type(); template param_type(InputIterator firstW, InputIterator lastW); param_type(initializer_list wl); template param_type(size_t nw, double xmin, double xmax, UnaryOperation fw); vector probabilities() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions discrete_distribution(); template discrete_distribution(InputIterator firstW, InputIterator lastW); discrete_distribution(initializer_list wl); template discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw); explicit discrete_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions vector probabilities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const discrete_distribution& x, const discrete_distribution& y); friend bool operator!=(const discrete_distribution& x, const discrete_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const discrete_distribution& x); template friend basic_istream& operator>>(basic_istream& is, discrete_distribution& x); }; template class piecewise_constant_distribution { // types typedef RealType result_type; class param_type { public: typedef piecewise_constant_distribution distribution_type; param_type(); template param_type(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template param_type(initializer_list bl, UnaryOperation fw); template param_type(size_t nw, result_type xmin, result_type xmax, UnaryOperation fw); vector intervals() const; vector densities() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions piecewise_constant_distribution(); template piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template piecewise_constant_distribution(initializer_list bl, UnaryOperation fw); template piecewise_constant_distribution(size_t nw, result_type xmin, result_type xmax, UnaryOperation fw); explicit piecewise_constant_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions vector intervals() const; vector densities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const piecewise_constant_distribution& x, const piecewise_constant_distribution& y); friend bool operator!=(const piecewise_constant_distribution& x, const piecewise_constant_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const piecewise_constant_distribution& x); template friend basic_istream& operator>>(basic_istream& is, piecewise_constant_distribution& x); }; template class piecewise_linear_distribution { // types typedef RealType result_type; class param_type { public: typedef piecewise_linear_distribution distribution_type; param_type(); template param_type(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template param_type(initializer_list bl, UnaryOperation fw); template param_type(size_t nw, result_type xmin, result_type xmax, UnaryOperation fw); vector intervals() const; vector densities() const; friend bool operator==(const param_type& x, const param_type& y); friend bool operator!=(const param_type& x, const param_type& y); }; // constructor and reset functions piecewise_linear_distribution(); template piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template piecewise_linear_distribution(initializer_list bl, UnaryOperation fw); template piecewise_linear_distribution(size_t nw, result_type xmin, result_type xmax, UnaryOperation fw); explicit piecewise_linear_distribution(const param_type& parm); void reset(); // generating functions template result_type operator()(URNG& g); template result_type operator()(URNG& g, const param_type& parm); // property functions vector intervals() const; vector densities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; friend bool operator==(const piecewise_linear_distribution& x, const piecewise_linear_distribution& y); friend bool operator!=(const piecewise_linear_distribution& x, const piecewise_linear_distribution& y); template friend basic_ostream& operator<<(basic_ostream& os, const piecewise_linear_distribution& x); template friend basic_istream& operator>>(basic_istream& is, piecewise_linear_distribution& x); }; } // std */ #include <__config> #include #include #include #include #include #include #include #include #include #include #include #include #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD // __is_seed_sequence template struct __is_seed_sequence { static _LIBCPP_CONSTEXPR const bool value = !is_convertible<_Sseq, typename _Engine::result_type>::value && !is_same::type, _Engine>::value; }; // linear_congruential_engine template (_Mp-__c)/__a)> struct __lce_ta; // 64 template struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> { typedef unsigned long long result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { // Schrage's algorithm const result_type __q = __m / __a; const result_type __r = __m % __a; const result_type __t0 = __a * (__x % __q); const result_type __t1 = __r * (__x / __q); __x = __t0 + (__t0 < __t1) * __m - __t1; __x += __c - (__x >= __m - __c) * __m; return __x; } }; template struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> { typedef unsigned long long result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { // Schrage's algorithm const result_type __q = __m / __a; const result_type __r = __m % __a; const result_type __t0 = __a * (__x % __q); const result_type __t1 = __r * (__x / __q); __x = __t0 + (__t0 < __t1) * __m - __t1; return __x; } }; template struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), false> { typedef unsigned long long result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { return (__a * __x + __c) % __m; } }; template struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false> { typedef unsigned long long result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { return __a * __x + __c; } }; // 32 template struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { const result_type __a = static_cast(_Ap); const result_type __c = static_cast(_Cp); const result_type __m = static_cast(_Mp); // Schrage's algorithm const result_type __q = __m / __a; const result_type __r = __m % __a; const result_type __t0 = __a * (__x % __q); const result_type __t1 = __r * (__x / __q); __x = __t0 + (__t0 < __t1) * __m - __t1; __x += __c - (__x >= __m - __c) * __m; return __x; } }; template struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { const result_type __a = static_cast(_Ap); const result_type __m = static_cast(_Mp); // Schrage's algorithm const result_type __q = __m / __a; const result_type __r = __m % __a; const result_type __t0 = __a * (__x % __q); const result_type __t1 = __r * (__x / __q); __x = __t0 + (__t0 < __t1) * __m - __t1; return __x; } }; template struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { const result_type __a = static_cast(_Ap); const result_type __c = static_cast(_Cp); const result_type __m = static_cast(_Mp); return (__a * __x + __c) % __m; } }; template struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> { typedef unsigned result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { const result_type __a = static_cast(_Ap); const result_type __c = static_cast(_Cp); return __a * __x + __c; } }; // 16 template struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> { typedef unsigned short result_type; _LIBCPP_INLINE_VISIBILITY static result_type next(result_type __x) { return static_cast(__lce_ta<__a, __c, __m, unsigned(~0)>::next(__x)); } }; template class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine; template _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); template class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine { public: // types typedef _UIntType result_type; private: result_type __x_; static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0); static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters"); static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters"); public: static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u; static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u; static_assert(_Min < _Max, "linear_congruential_engine invalid parameters"); // engine characteristics static _LIBCPP_CONSTEXPR const result_type multiplier = __a; static _LIBCPP_CONSTEXPR const result_type increment = __c; static _LIBCPP_CONSTEXPR const result_type modulus = __m; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type min() {return _Min;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type max() {return _Max;} static _LIBCPP_CONSTEXPR const result_type default_seed = 1u; // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY explicit linear_congruential_engine(result_type __s = default_seed) {seed(__s);} template _LIBCPP_INLINE_VISIBILITY explicit linear_congruential_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0) {seed(__q);} _LIBCPP_INLINE_VISIBILITY void seed(result_type __s = default_seed) {seed(integral_constant(), integral_constant(), __s);} template _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_seed_sequence<_Sseq, linear_congruential_engine>::value, void >::type seed(_Sseq& __q) {__seed(__q, integral_constant 0x100000000ull))>());} // generating functions _LIBCPP_INLINE_VISIBILITY result_type operator()() {return __x_ = static_cast(__lce_ta<__a, __c, __m, _Mp>::next(__x_));} _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const linear_congruential_engine& __x, const linear_congruential_engine& __y) {return __x.__x_ == __y.__x_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const linear_congruential_engine& __x, const linear_congruential_engine& __y) {return !(__x == __y);} private: _LIBCPP_INLINE_VISIBILITY void seed(true_type, true_type, result_type __s) {__x_ = __s == 0 ? 1 : __s;} _LIBCPP_INLINE_VISIBILITY void seed(true_type, false_type, result_type __s) {__x_ = __s;} _LIBCPP_INLINE_VISIBILITY void seed(false_type, true_type, result_type __s) {__x_ = __s % __m == 0 ? 1 : __s % __m;} _LIBCPP_INLINE_VISIBILITY void seed(false_type, false_type, result_type __s) {__x_ = __s % __m;} template void __seed(_Sseq& __q, integral_constant); template void __seed(_Sseq& __q, integral_constant); template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); }; template _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; template _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type linear_congruential_engine<_UIntType, __a, __c, __m>::increment; template _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; template _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; template template void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant) { const unsigned __k = 1; uint32_t __ar[__k+3]; __q.generate(__ar, __ar + __k + 3); result_type __s = static_cast(__ar[3] % __m); __x_ = __c == 0 && __s == 0 ? result_type(1) : __s; } template template void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant) { const unsigned __k = 2; uint32_t __ar[__k+3]; __q.generate(__ar, __ar + __k + 3); result_type __s = static_cast((__ar[3] + ((uint64_t)__ar[4] << 32)) % __m); __x_ = __c == 0 && __s == 0 ? result_type(1) : __s; } template inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const linear_congruential_engine<_UIntType, __a, __c, __m>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); __os.fill(__os.widen(' ')); return __os << __x.__x_; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_UIntType, __a, __c, __m>& __x) { __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); _UIntType __t; __is >> __t; if (!__is.fail()) __x.__x_ = __t; return __is; } typedef linear_congruential_engine minstd_rand0; typedef linear_congruential_engine minstd_rand; typedef minstd_rand default_random_engine; // mersenne_twister_engine template class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine; template bool operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template _LIBCPP_INLINE_VISIBILITY bool operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine { public: // types typedef _UIntType result_type; private: result_type __x_[__n]; size_t __i_; static_assert( 0 < __m, "mersenne_twister_engine invalid parameters"); static_assert(__m <= __n, "mersenne_twister_engine invalid parameters"); static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits::digits; static_assert(__w <= _Dt, "mersenne_twister_engine invalid parameters"); static_assert( 2 <= __w, "mersenne_twister_engine invalid parameters"); static_assert(__r <= __w, "mersenne_twister_engine invalid parameters"); static_assert(__u <= __w, "mersenne_twister_engine invalid parameters"); static_assert(__s <= __w, "mersenne_twister_engine invalid parameters"); static_assert(__t <= __w, "mersenne_twister_engine invalid parameters"); static_assert(__l <= __w, "mersenne_twister_engine invalid parameters"); public: static _LIBCPP_CONSTEXPR const result_type _Min = 0; static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : (result_type(1) << __w) - result_type(1); static_assert(_Min < _Max, "mersenne_twister_engine invalid parameters"); static_assert(__a <= _Max, "mersenne_twister_engine invalid parameters"); static_assert(__b <= _Max, "mersenne_twister_engine invalid parameters"); static_assert(__c <= _Max, "mersenne_twister_engine invalid parameters"); static_assert(__d <= _Max, "mersenne_twister_engine invalid parameters"); static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters"); // engine characteristics static _LIBCPP_CONSTEXPR const size_t word_size = __w; static _LIBCPP_CONSTEXPR const size_t state_size = __n; static _LIBCPP_CONSTEXPR const size_t shift_size = __m; static _LIBCPP_CONSTEXPR const size_t mask_bits = __r; static _LIBCPP_CONSTEXPR const result_type xor_mask = __a; static _LIBCPP_CONSTEXPR const size_t tempering_u = __u; static _LIBCPP_CONSTEXPR const result_type tempering_d = __d; static _LIBCPP_CONSTEXPR const size_t tempering_s = __s; static _LIBCPP_CONSTEXPR const result_type tempering_b = __b; static _LIBCPP_CONSTEXPR const size_t tempering_t = __t; static _LIBCPP_CONSTEXPR const result_type tempering_c = __c; static _LIBCPP_CONSTEXPR const size_t tempering_l = __l; static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type min() { return _Min; } _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type max() { return _Max; } static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY explicit mersenne_twister_engine(result_type __sd = default_seed) {seed(__sd);} template _LIBCPP_INLINE_VISIBILITY explicit mersenne_twister_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0) {seed(__q);} void seed(result_type __sd = default_seed); template _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_seed_sequence<_Sseq, mersenne_twister_engine>::value, void >::type seed(_Sseq& __q) {__seed(__q, integral_constant());} // generating functions result_type operator()(); _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} template friend bool operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template friend bool operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); private: template void __seed(_Sseq& __q, integral_constant); template void __seed(_Sseq& __q, integral_constant); template _LIBCPP_INLINE_VISIBILITY static typename enable_if < __count < __w, result_type >::type __lshift(result_type __x) {return (__x << __count) & _Max;} template _LIBCPP_INLINE_VISIBILITY static typename enable_if < (__count >= __w), result_type >::type __lshift(result_type) {return result_type(0);} template _LIBCPP_INLINE_VISIBILITY static typename enable_if < __count < _Dt, result_type >::type __rshift(result_type __x) {return __x >> __count;} template _LIBCPP_INLINE_VISIBILITY static typename enable_if < (__count >= _Dt), result_type >::type __rshift(result_type) {return result_type(0);} }; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits; template _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u; template _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s; template _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t; template _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c; template _LIBCPP_CONSTEXPR const size_t mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l; template _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::initialization_multiplier; template _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed; template void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::seed(result_type __sd) { // __w >= 2 __x_[0] = __sd & _Max; for (size_t __i = 1; __i < __n; ++__i) __x_[__i] = (__f * (__x_[__i-1] ^ __rshift<__w - 2>(__x_[__i-1])) + __i) & _Max; __i_ = 0; } template template void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant) { const unsigned __k = 1; uint32_t __ar[__n * __k]; __q.generate(__ar, __ar + __n * __k); for (size_t __i = 0; __i < __n; ++__i) __x_[__i] = static_cast(__ar[__i] & _Max); const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); __i_ = 0; if ((__x_[0] & ~__mask) == 0) { for (size_t __i = 1; __i < __n; ++__i) if (__x_[__i] != 0) return; __x_[0] = _Max; } } template template void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant) { const unsigned __k = 2; uint32_t __ar[__n * __k]; __q.generate(__ar, __ar + __n * __k); for (size_t __i = 0; __i < __n; ++__i) __x_[__i] = static_cast( (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); __i_ = 0; if ((__x_[0] & ~__mask) == 0) { for (size_t __i = 1; __i < __n; ++__i) if (__x_[__i] != 0) return; __x_[0] = _Max; } } template _UIntType mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() { const size_t __j = (__i_ + 1) % __n; const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); const result_type _Yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask); const size_t __k = (__i_ + __m) % __n; __x_[__i_] = __x_[__k] ^ __rshift<1>(_Yp) ^ (__a * (_Yp & 1)); result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d); __i_ = __j; __z ^= __lshift<__s>(__z) & __b; __z ^= __lshift<__t>(__z) & __c; return __z ^ __rshift<__l>(__z); } template bool operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y) { if (__x.__i_ == __y.__i_) return _VSTD::equal(__x.__x_, __x.__x_ + _Np, __y.__x_); if (__x.__i_ == 0 || __y.__i_ == 0) { size_t __j = _VSTD::min(_Np - __x.__i_, _Np - __y.__i_); if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, __y.__x_ + __y.__i_)) return false; if (__x.__i_ == 0) return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Np, __y.__x_); return _VSTD::equal(__x.__x_, __x.__x_ + (_Np - __j), __y.__x_ + __j); } if (__x.__i_ < __y.__i_) { size_t __j = _Np - __y.__i_; if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), __y.__x_ + __y.__i_)) return false; if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Np, __y.__x_)) return false; return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_, __y.__x_ + (_Np - (__x.__i_ + __j))); } size_t __j = _Np - __x.__i_; if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), __x.__x_ + __x.__i_)) return false; if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Np, __x.__x_)) return false; return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_, __x.__x_ + (_Np - (__y.__i_ + __j))); } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y) { return !(__x == __y); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.__x_[__x.__i_]; for (size_t __j = __x.__i_ + 1; __j < _Np; ++__j) __os << __sp << __x.__x_[__j]; for (size_t __j = 0; __j < __x.__i_; ++__j) __os << __sp << __x.__x_[__j]; return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x) { __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); _UI __t[_Np]; for (size_t __i = 0; __i < _Np; ++__i) __is >> __t[__i]; if (!__is.fail()) { for (size_t __i = 0; __i < _Np; ++__i) __x.__x_[__i] = __t[__i]; __x.__i_ = 0; } return __is; } typedef mersenne_twister_engine mt19937; typedef mersenne_twister_engine mt19937_64; // subtract_with_carry_engine template class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine; template bool operator==( const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); template _LIBCPP_INLINE_VISIBILITY bool operator!=( const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); template class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine { public: // types typedef _UIntType result_type; private: result_type __x_[__r]; result_type __c_; size_t __i_; static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits::digits; static_assert( 0 < __w, "subtract_with_carry_engine invalid parameters"); static_assert(__w <= _Dt, "subtract_with_carry_engine invalid parameters"); static_assert( 0 < __s, "subtract_with_carry_engine invalid parameters"); static_assert(__s < __r, "subtract_with_carry_engine invalid parameters"); public: static _LIBCPP_CONSTEXPR const result_type _Min = 0; static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : (result_type(1) << __w) - result_type(1); static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters"); // engine characteristics static _LIBCPP_CONSTEXPR const size_t word_size = __w; static _LIBCPP_CONSTEXPR const size_t short_lag = __s; static _LIBCPP_CONSTEXPR const size_t long_lag = __r; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type min() { return _Min; } _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type max() { return _Max; } static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY explicit subtract_with_carry_engine(result_type __sd = default_seed) {seed(__sd);} template _LIBCPP_INLINE_VISIBILITY explicit subtract_with_carry_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value>::type* = 0) {seed(__q);} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd = default_seed) {seed(__sd, integral_constant());} template _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, void >::type seed(_Sseq& __q) {__seed(__q, integral_constant());} // generating functions result_type operator()(); _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} template friend bool operator==( const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); template friend bool operator!=( const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); private: void seed(result_type __sd, integral_constant); void seed(result_type __sd, integral_constant); template void __seed(_Sseq& __q, integral_constant); template void __seed(_Sseq& __q, integral_constant); }; template _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size; template _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag; template _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag; template _LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed; template void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant) { linear_congruential_engine __e(__sd == 0u ? default_seed : __sd); for (size_t __i = 0; __i < __r; ++__i) __x_[__i] = static_cast(__e() & _Max); __c_ = __x_[__r-1] == 0; __i_ = 0; } template void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant) { linear_congruential_engine __e(__sd == 0u ? default_seed : __sd); for (size_t __i = 0; __i < __r; ++__i) { result_type __e0 = __e(); __x_[__i] = static_cast( (__e0 + ((uint64_t)__e() << 32)) & _Max); } __c_ = __x_[__r-1] == 0; __i_ = 0; } template template void subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, integral_constant) { const unsigned __k = 1; uint32_t __ar[__r * __k]; __q.generate(__ar, __ar + __r * __k); for (size_t __i = 0; __i < __r; ++__i) __x_[__i] = static_cast(__ar[__i] & _Max); __c_ = __x_[__r-1] == 0; __i_ = 0; } template template void subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, integral_constant) { const unsigned __k = 2; uint32_t __ar[__r * __k]; __q.generate(__ar, __ar + __r * __k); for (size_t __i = 0; __i < __r; ++__i) __x_[__i] = static_cast( (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); __c_ = __x_[__r-1] == 0; __i_ = 0; } template _UIntType subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()() { const result_type& __xs = __x_[(__i_ + (__r - __s)) % __r]; result_type& __xr = __x_[__i_]; result_type __new_c = __c_ == 0 ? __xs < __xr : __xs != 0 ? __xs <= __xr : 1; __xr = (__xs - __xr - __c_) & _Max; __c_ = __new_c; __i_ = (__i_ + 1) % __r; return __xr; } template bool operator==( const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y) { if (__x.__c_ != __y.__c_) return false; if (__x.__i_ == __y.__i_) return _VSTD::equal(__x.__x_, __x.__x_ + _Rp, __y.__x_); if (__x.__i_ == 0 || __y.__i_ == 0) { size_t __j = _VSTD::min(_Rp - __x.__i_, _Rp - __y.__i_); if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, __y.__x_ + __y.__i_)) return false; if (__x.__i_ == 0) return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Rp, __y.__x_); return _VSTD::equal(__x.__x_, __x.__x_ + (_Rp - __j), __y.__x_ + __j); } if (__x.__i_ < __y.__i_) { size_t __j = _Rp - __y.__i_; if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), __y.__x_ + __y.__i_)) return false; if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Rp, __y.__x_)) return false; return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_, __y.__x_ + (_Rp - (__x.__i_ + __j))); } size_t __j = _Rp - __x.__i_; if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), __x.__x_ + __x.__i_)) return false; if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Rp, __x.__x_)) return false; return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_, __x.__x_ + (_Rp - (__y.__i_ + __j))); } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=( const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y) { return !(__x == __y); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.__x_[__x.__i_]; for (size_t __j = __x.__i_ + 1; __j < _Rp; ++__j) __os << __sp << __x.__x_[__j]; for (size_t __j = 0; __j < __x.__i_; ++__j) __os << __sp << __x.__x_[__j]; __os << __sp << __x.__c_; return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x) { __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); _UI __t[_Rp+1]; for (size_t __i = 0; __i < _Rp+1; ++__i) __is >> __t[__i]; if (!__is.fail()) { for (size_t __i = 0; __i < _Rp; ++__i) __x.__x_[__i] = __t[__i]; __x.__c_ = __t[_Rp]; __x.__i_ = 0; } return __is; } typedef subtract_with_carry_engine ranlux24_base; typedef subtract_with_carry_engine ranlux48_base; // discard_block_engine template class _LIBCPP_TYPE_VIS_ONLY discard_block_engine { _Engine __e_; int __n_; static_assert( 0 < __r, "discard_block_engine invalid parameters"); static_assert(__r <= __p, "discard_block_engine invalid parameters"); public: // types typedef typename _Engine::result_type result_type; // engine characteristics static _LIBCPP_CONSTEXPR const size_t block_size = __p; static _LIBCPP_CONSTEXPR const size_t used_block = __r; #ifdef _LIBCPP_HAS_NO_CONSTEXPR static const result_type _Min = _Engine::_Min; static const result_type _Max = _Engine::_Max; #else static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min(); static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max(); #endif _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); } _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type max() { return _Engine::max(); } // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY discard_block_engine() : __n_(0) {} _LIBCPP_INLINE_VISIBILITY explicit discard_block_engine(const _Engine& __e) : __e_(__e), __n_(0) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit discard_block_engine(_Engine&& __e) : __e_(_VSTD::move(__e)), __n_(0) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {} template _LIBCPP_INLINE_VISIBILITY explicit discard_block_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, discard_block_engine>::value && !is_convertible<_Sseq, _Engine>::value>::type* = 0) : __e_(__q), __n_(0) {} _LIBCPP_INLINE_VISIBILITY void seed() {__e_.seed(); __n_ = 0;} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd) {__e_.seed(__sd); __n_ = 0;} template _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_seed_sequence<_Sseq, discard_block_engine>::value, void >::type seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;} // generating functions result_type operator()(); _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} // property functions _LIBCPP_INLINE_VISIBILITY const _Engine& base() const _NOEXCEPT {return __e_;} template friend bool operator==( const discard_block_engine<_Eng, _Pp, _Rp>& __x, const discard_block_engine<_Eng, _Pp, _Rp>& __y); template friend bool operator!=( const discard_block_engine<_Eng, _Pp, _Rp>& __x, const discard_block_engine<_Eng, _Pp, _Rp>& __y); template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const discard_block_engine<_Eng, _Pp, _Rp>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x); }; template _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size; template _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block; template typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() { if (__n_ >= __r) { __e_.discard(__p - __r); __n_ = 0; } ++__n_; return __e_(); } template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const discard_block_engine<_Eng, _Pp, _Rp>& __x, const discard_block_engine<_Eng, _Pp, _Rp>& __y) { return __x.__n_ == __y.__n_ && __x.__e_ == __y.__e_; } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x, const discard_block_engine<_Eng, _Pp, _Rp>& __y) { return !(__x == __y); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const discard_block_engine<_Eng, _Pp, _Rp>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); _CharT __sp = __os.widen(' '); __os.fill(__sp); return __os << __x.__e_ << __sp << __x.__n_; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x) { __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); _Eng __e; int __n; __is >> __e >> __n; if (!__is.fail()) { __x.__e_ = __e; __x.__n_ = __n; } return __is; } typedef discard_block_engine ranlux24; typedef discard_block_engine ranlux48; // independent_bits_engine template class _LIBCPP_TYPE_VIS_ONLY independent_bits_engine { template class __get_n { static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UI>::digits; static _LIBCPP_CONSTEXPR const size_t _Np = _Wp / _Mp + (_Wp % _Mp != 0); static _LIBCPP_CONSTEXPR const size_t _W0 = _Wp / _Np; static _LIBCPP_CONSTEXPR const _UI _Y0 = _W0 >= _Dt ? 0 : (_R0 >> _W0) << _W0; public: static _LIBCPP_CONSTEXPR const size_t value = _R0 - _Y0 > _Y0 / _Np ? _Np + 1 : _Np; }; public: // types typedef _UIntType result_type; private: _Engine __e_; static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits::digits; static_assert( 0 < __w, "independent_bits_engine invalid parameters"); static_assert(__w <= _Dt, "independent_bits_engine invalid parameters"); typedef typename _Engine::result_type _Engine_result_type; typedef typename conditional < sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type >::type _Working_result_type; #ifdef _LIBCPP_HAS_NO_CONSTEXPR static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min + _Working_result_type(1); #else static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min() + _Working_result_type(1); #endif static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value; static _LIBCPP_CONSTEXPR const size_t __n = __get_n<_Working_result_type, _Rp, __w, __m>::value; static _LIBCPP_CONSTEXPR const size_t __w0 = __w / __n; static _LIBCPP_CONSTEXPR const size_t __n0 = __n - __w % __n; static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits; static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits; static _LIBCPP_CONSTEXPR const _Working_result_type __y0 = __w0 >= _WDt ? 0 : (_Rp >> __w0) << __w0; static _LIBCPP_CONSTEXPR const _Working_result_type __y1 = __w0 >= _WDt - 1 ? 0 : (_Rp >> (__w0+1)) << (__w0+1); static _LIBCPP_CONSTEXPR const _Engine_result_type __mask0 = __w0 > 0 ? _Engine_result_type(~0) >> (_EDt - __w0) : _Engine_result_type(0); static _LIBCPP_CONSTEXPR const _Engine_result_type __mask1 = __w0 < _EDt - 1 ? _Engine_result_type(~0) >> (_EDt - (__w0 + 1)) : _Engine_result_type(~0); public: static _LIBCPP_CONSTEXPR const result_type _Min = 0; static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : (result_type(1) << __w) - result_type(1); static_assert(_Min < _Max, "independent_bits_engine invalid parameters"); // engine characteristics _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type min() { return _Min; } _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type max() { return _Max; } // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY independent_bits_engine() {} _LIBCPP_INLINE_VISIBILITY explicit independent_bits_engine(const _Engine& __e) : __e_(__e) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit independent_bits_engine(_Engine&& __e) : __e_(_VSTD::move(__e)) {} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit independent_bits_engine(result_type __sd) : __e_(__sd) {} template _LIBCPP_INLINE_VISIBILITY explicit independent_bits_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, independent_bits_engine>::value && !is_convertible<_Sseq, _Engine>::value>::type* = 0) : __e_(__q) {} _LIBCPP_INLINE_VISIBILITY void seed() {__e_.seed();} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd) {__e_.seed(__sd);} template _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_seed_sequence<_Sseq, independent_bits_engine>::value, void >::type seed(_Sseq& __q) {__e_.seed(__q);} // generating functions _LIBCPP_INLINE_VISIBILITY result_type operator()() {return __eval(integral_constant());} _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} // property functions _LIBCPP_INLINE_VISIBILITY const _Engine& base() const _NOEXCEPT {return __e_;} template friend bool operator==( const independent_bits_engine<_Eng, _Wp, _UI>& __x, const independent_bits_engine<_Eng, _Wp, _UI>& __y); template friend bool operator!=( const independent_bits_engine<_Eng, _Wp, _UI>& __x, const independent_bits_engine<_Eng, _Wp, _UI>& __y); template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const independent_bits_engine<_Eng, _Wp, _UI>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, independent_bits_engine<_Eng, _Wp, _UI>& __x); private: result_type __eval(false_type); result_type __eval(true_type); template _LIBCPP_INLINE_VISIBILITY static typename enable_if < __count < _Dt, result_type >::type __lshift(result_type __x) {return __x << __count;} template _LIBCPP_INLINE_VISIBILITY static typename enable_if < (__count >= _Dt), result_type >::type __lshift(result_type) {return result_type(0);} }; template inline _LIBCPP_INLINE_VISIBILITY _UIntType independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) { return static_cast(__e_() & __mask0); } template _UIntType independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) { result_type _Sp = 0; for (size_t __k = 0; __k < __n0; ++__k) { _Engine_result_type __u; do { __u = __e_() - _Engine::min(); } while (__u >= __y0); _Sp = static_cast(__lshift<__w0>(_Sp) + (__u & __mask0)); } for (size_t __k = __n0; __k < __n; ++__k) { _Engine_result_type __u; do { __u = __e_() - _Engine::min(); } while (__u >= __y1); _Sp = static_cast(__lshift<__w0+1>(_Sp) + (__u & __mask1)); } return _Sp; } template inline _LIBCPP_INLINE_VISIBILITY bool operator==( const independent_bits_engine<_Eng, _Wp, _UI>& __x, const independent_bits_engine<_Eng, _Wp, _UI>& __y) { return __x.base() == __y.base(); } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=( const independent_bits_engine<_Eng, _Wp, _UI>& __x, const independent_bits_engine<_Eng, _Wp, _UI>& __y) { return !(__x == __y); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const independent_bits_engine<_Eng, _Wp, _UI>& __x) { return __os << __x.base(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, independent_bits_engine<_Eng, _Wp, _UI>& __x) { _Eng __e; __is >> __e; if (!__is.fail()) __x.__e_ = __e; return __is; } // shuffle_order_engine template struct __ugcd { static _LIBCPP_CONSTEXPR const uint64_t value = __ugcd<_Yp, _Xp % _Yp>::value; }; template struct __ugcd<_Xp, 0> { static _LIBCPP_CONSTEXPR const uint64_t value = _Xp; }; template class __uratio { static_assert(_Dp != 0, "__uratio divide by 0"); static _LIBCPP_CONSTEXPR const uint64_t __gcd = __ugcd<_Np, _Dp>::value; public: static _LIBCPP_CONSTEXPR const uint64_t num = _Np / __gcd; static _LIBCPP_CONSTEXPR const uint64_t den = _Dp / __gcd; typedef __uratio type; }; template class _LIBCPP_TYPE_VIS_ONLY shuffle_order_engine { static_assert(0 < __k, "shuffle_order_engine invalid parameters"); public: // types typedef typename _Engine::result_type result_type; private: _Engine __e_; result_type _V_[__k]; result_type _Y_; public: // engine characteristics static _LIBCPP_CONSTEXPR const size_t table_size = __k; #ifdef _LIBCPP_HAS_NO_CONSTEXPR static const result_type _Min = _Engine::_Min; static const result_type _Max = _Engine::_Max; #else static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min(); static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max(); #endif static_assert(_Min < _Max, "shuffle_order_engine invalid parameters"); _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type min() { return _Min; } _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type max() { return _Max; } static _LIBCPP_CONSTEXPR const unsigned long long _Rp = _Max - _Min + 1ull; // constructors and seeding functions _LIBCPP_INLINE_VISIBILITY shuffle_order_engine() {__init();} _LIBCPP_INLINE_VISIBILITY explicit shuffle_order_engine(const _Engine& __e) : __e_(__e) {__init();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit shuffle_order_engine(_Engine&& __e) : __e_(_VSTD::move(__e)) {__init();} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();} template _LIBCPP_INLINE_VISIBILITY explicit shuffle_order_engine(_Sseq& __q, typename enable_if<__is_seed_sequence<_Sseq, shuffle_order_engine>::value && !is_convertible<_Sseq, _Engine>::value>::type* = 0) : __e_(__q) {__init();} _LIBCPP_INLINE_VISIBILITY void seed() {__e_.seed(); __init();} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd) {__e_.seed(__sd); __init();} template _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_seed_sequence<_Sseq, shuffle_order_engine>::value, void >::type seed(_Sseq& __q) {__e_.seed(__q); __init();} // generating functions _LIBCPP_INLINE_VISIBILITY result_type operator()() {return __eval(integral_constant());} _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} // property functions _LIBCPP_INLINE_VISIBILITY const _Engine& base() const _NOEXCEPT {return __e_;} private: template friend bool operator==( const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y); template friend bool operator!=( const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y); template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const shuffle_order_engine<_Eng, _Kp>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, shuffle_order_engine<_Eng, _Kp>& __x); _LIBCPP_INLINE_VISIBILITY void __init() { for (size_t __i = 0; __i < __k; ++__i) _V_[__i] = __e_(); _Y_ = __e_(); } _LIBCPP_INLINE_VISIBILITY result_type __eval(false_type) {return __eval2(integral_constant());} _LIBCPP_INLINE_VISIBILITY result_type __eval(true_type) {return __eval(__uratio<__k, _Rp>());} _LIBCPP_INLINE_VISIBILITY result_type __eval2(false_type) {return __eval(__uratio<__k/2, 0x8000000000000000ull>());} _LIBCPP_INLINE_VISIBILITY result_type __eval2(true_type) {return __evalf<__k, 0>();} template _LIBCPP_INLINE_VISIBILITY typename enable_if < (__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)), result_type >::type __eval(__uratio<_Np, _Dp>) {return __evalf<__uratio<_Np, _Dp>::num, __uratio<_Np, _Dp>::den>();} template _LIBCPP_INLINE_VISIBILITY typename enable_if < __uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min), result_type >::type __eval(__uratio<_Np, _Dp>) { const size_t __j = static_cast(__uratio<_Np, _Dp>::num * (_Y_ - _Min) / __uratio<_Np, _Dp>::den); _Y_ = _V_[__j]; _V_[__j] = __e_(); return _Y_; } template _LIBCPP_INLINE_VISIBILITY result_type __evalf() { const double _Fp = __d == 0 ? __n / (2. * 0x8000000000000000ull) : __n / (double)__d; const size_t __j = static_cast(_Fp * (_Y_ - _Min)); _Y_ = _V_[__j]; _V_[__j] = __e_(); return _Y_; } }; template _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size; template bool operator==( const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) { return __x._Y_ == __y._Y_ && _VSTD::equal(__x._V_, __x._V_ + _Kp, __y._V_) && __x.__e_ == __y.__e_; } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=( const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) { return !(__x == __y); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const shuffle_order_engine<_Eng, _Kp>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.__e_ << __sp << __x._V_[0]; for (size_t __i = 1; __i < _Kp; ++__i) __os << __sp << __x._V_[__i]; return __os << __sp << __x._Y_; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, shuffle_order_engine<_Eng, _Kp>& __x) { typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); _Eng __e; result_type _Vp[_Kp+1]; __is >> __e; for (size_t __i = 0; __i < _Kp+1; ++__i) __is >> _Vp[__i]; if (!__is.fail()) { __x.__e_ = __e; for (size_t __i = 0; __i < _Kp; ++__i) __x._V_[__i] = _Vp[__i]; __x._Y_ = _Vp[_Kp]; } return __is; } typedef shuffle_order_engine knuth_b; // random_device class _LIBCPP_TYPE_VIS random_device { #if !defined(_WIN32) int __f_; #endif // defined(_WIN32) public: // types typedef unsigned result_type; // generator characteristics static _LIBCPP_CONSTEXPR const result_type _Min = 0; static _LIBCPP_CONSTEXPR const result_type _Max = 0xFFFFFFFFu; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type min() { return _Min;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR result_type max() { return _Max;} // constructors explicit random_device(const string& __token = "/dev/urandom"); ~random_device(); // generating functions result_type operator()(); // property functions double entropy() const _NOEXCEPT; private: // no copy functions random_device(const random_device&); // = delete; random_device& operator=(const random_device&); // = delete; }; // seed_seq class _LIBCPP_TYPE_VIS_ONLY seed_seq { public: // types typedef uint32_t result_type; private: vector __v_; template void init(_InputIterator __first, _InputIterator __last); public: // constructors _LIBCPP_INLINE_VISIBILITY seed_seq() _NOEXCEPT {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY seed_seq(initializer_list<_Tp> __il) {init(__il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY seed_seq(_InputIterator __first, _InputIterator __last) {init(__first, __last);} // generating functions template void generate(_RandomAccessIterator __first, _RandomAccessIterator __last); // property functions _LIBCPP_INLINE_VISIBILITY size_t size() const _NOEXCEPT {return __v_.size();} template _LIBCPP_INLINE_VISIBILITY void param(_OutputIterator __dest) const {_VSTD::copy(__v_.begin(), __v_.end(), __dest);} private: // no copy functions seed_seq(const seed_seq&); // = delete; void operator=(const seed_seq&); // = delete; _LIBCPP_INLINE_VISIBILITY static result_type _Tp(result_type __x) {return __x ^ (__x >> 27);} }; template void seed_seq::init(_InputIterator __first, _InputIterator __last) { for (_InputIterator __s = __first; __s != __last; ++__s) __v_.push_back(*__s & 0xFFFFFFFF); } template void seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last) { if (__first != __last) { _VSTD::fill(__first, __last, 0x8b8b8b8b); const size_t __n = static_cast(__last - __first); const size_t __s = __v_.size(); const size_t __t = (__n >= 623) ? 11 : (__n >= 68) ? 7 : (__n >= 39) ? 5 : (__n >= 7) ? 3 : (__n - 1) / 2; const size_t __p = (__n - __t) / 2; const size_t __q = __p + __t; const size_t __m = _VSTD::max(__s + 1, __n); // __k = 0; { result_type __r = 1664525 * _Tp(__first[0] ^ __first[__p] ^ __first[__n - 1]); __first[__p] += __r; __r += __s; __first[__q] += __r; __first[0] = __r; } for (size_t __k = 1; __k <= __s; ++__k) { const size_t __kmodn = __k % __n; const size_t __kpmodn = (__k + __p) % __n; result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[(__k - 1) % __n]); __first[__kpmodn] += __r; __r += __kmodn + __v_[__k-1]; __first[(__k + __q) % __n] += __r; __first[__kmodn] = __r; } for (size_t __k = __s + 1; __k < __m; ++__k) { const size_t __kmodn = __k % __n; const size_t __kpmodn = (__k + __p) % __n; result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[(__k - 1) % __n]); __first[__kpmodn] += __r; __r += __kmodn; __first[(__k + __q) % __n] += __r; __first[__kmodn] = __r; } for (size_t __k = __m; __k < __m + __n; ++__k) { const size_t __kmodn = __k % __n; const size_t __kpmodn = (__k + __p) % __n; result_type __r = 1566083941 * _Tp(__first[__kmodn] + __first[__kpmodn] + __first[(__k - 1) % __n]); __first[__kpmodn] ^= __r; __r -= __kmodn; __first[(__k + __q) % __n] ^= __r; __first[__kmodn] = __r; } } } // generate_canonical template _RealType generate_canonical(_URNG& __g) { const size_t _Dt = numeric_limits<_RealType>::digits; const size_t __b = _Dt < __bits ? _Dt : __bits; #ifdef _LIBCPP_HAS_NO_CONSTEXPR const size_t __logR = __log2::value; #else const size_t __logR = __log2::value; #endif const size_t __k = __b / __logR + (__b % __logR != 0) + (__b == 0); const _RealType _Rp = _URNG::max() - _URNG::min() + _RealType(1); _RealType __base = _Rp; _RealType _Sp = __g() - _URNG::min(); for (size_t __i = 1; __i < __k; ++__i, __base *= _Rp) _Sp += (__g() - _URNG::min()) * __base; return _Sp / __base; } // uniform_int_distribution // in template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const uniform_int_distribution<_IT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); _CharT __sp = __os.widen(' '); __os.fill(__sp); return __os << __x.a() << __sp << __x.b(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, uniform_int_distribution<_IT>& __x) { typedef uniform_int_distribution<_IT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __a; result_type __b; __is >> __a >> __b; if (!__is.fail()) __x.param(param_type(__a, __b)); return __is; } // uniform_real_distribution template class _LIBCPP_TYPE_VIS_ONLY uniform_real_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; public: typedef uniform_real_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __a = 0, result_type __b = 1) : __a_(__a), __b_(__b) {} _LIBCPP_INLINE_VISIBILITY result_type a() const {return __a_;} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit uniform_real_distribution(result_type __a = 0, result_type __b = 1) : __p_(param_type(__a, __b)) {} _LIBCPP_INLINE_VISIBILITY explicit uniform_real_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type a() const {return __p_.a();} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __p_.b();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return a();} _LIBCPP_INLINE_VISIBILITY result_type max() const {return b();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const uniform_real_distribution& __x, const uniform_real_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const uniform_real_distribution& __x, const uniform_real_distribution& __y) {return !(__x == __y);} }; template template inline _LIBCPP_INLINE_VISIBILITY typename uniform_real_distribution<_RealType>::result_type uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { return (__p.b() - __p.a()) * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g) + __p.a(); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const uniform_real_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); return __os << __x.a() << __sp << __x.b(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, uniform_real_distribution<_RT>& __x) { typedef uniform_real_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __a; result_type __b; __is >> __a >> __b; if (!__is.fail()) __x.param(param_type(__a, __b)); return __is; } // bernoulli_distribution class _LIBCPP_TYPE_VIS_ONLY bernoulli_distribution { public: // types typedef bool result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { double __p_; public: typedef bernoulli_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(double __p = 0.5) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY double p() const {return __p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit bernoulli_distribution(double __p = 0.5) : __p_(param_type(__p)) {} _LIBCPP_INLINE_VISIBILITY explicit bernoulli_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY double p() const {return __p_.p();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return false;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return true;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const bernoulli_distribution& __x, const bernoulli_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const bernoulli_distribution& __x, const bernoulli_distribution& __y) {return !(__x == __y);} }; template inline _LIBCPP_INLINE_VISIBILITY bernoulli_distribution::result_type bernoulli_distribution::operator()(_URNG& __g, const param_type& __p) { uniform_real_distribution __gen; return __gen(__g) < __p.p(); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); return __os << __x.p(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x) { typedef bernoulli_distribution _Eng; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); double __p; __is >> __p; if (!__is.fail()) __x.param(param_type(__p)); return __is; } // binomial_distribution template class _LIBCPP_TYPE_VIS_ONLY binomial_distribution { public: // types typedef _IntType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __t_; double __p_; double __pr_; double __odds_ratio_; result_type __r0_; public: typedef binomial_distribution distribution_type; explicit param_type(result_type __t = 1, double __p = 0.5); _LIBCPP_INLINE_VISIBILITY result_type t() const {return __t_;} _LIBCPP_INLINE_VISIBILITY double p() const {return __p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__t_ == __y.__t_ && __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} friend class binomial_distribution; }; private: param_type __p_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit binomial_distribution(result_type __t = 1, double __p = 0.5) : __p_(param_type(__t, __p)) {} _LIBCPP_INLINE_VISIBILITY explicit binomial_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type t() const {return __p_.t();} _LIBCPP_INLINE_VISIBILITY double p() const {return __p_.p();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return t();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const binomial_distribution& __x, const binomial_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const binomial_distribution& __x, const binomial_distribution& __y) {return !(__x == __y);} }; template binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p) : __t_(__t), __p_(__p) { if (0 < __p_ && __p_ < 1) { __r0_ = static_cast((__t_ + 1) * __p_); __pr_ = _VSTD::exp(_VSTD::lgamma(__t_ + 1.) - _VSTD::lgamma(__r0_ + 1.) - _VSTD::lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) + (__t_ - __r0_) * _VSTD::log(1 - __p_)); __odds_ratio_ = __p_ / (1 - __p_); } } template template _IntType binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) { if (__pr.__t_ == 0 || __pr.__p_ == 0) return 0; if (__pr.__p_ == 1) return __pr.__t_; uniform_real_distribution __gen; double __u = __gen(__g) - __pr.__pr_; if (__u < 0) return __pr.__r0_; double __pu = __pr.__pr_; double __pd = __pu; result_type __ru = __pr.__r0_; result_type __rd = __ru; while (true) { if (__rd >= 1) { __pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1)); __u -= __pd; if (__u < 0) return __rd - 1; } --__rd; ++__ru; if (__ru <= __pr.__t_) { __pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru; __u -= __pu; if (__u < 0) return __ru; } } } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const binomial_distribution<_IntType>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); return __os << __x.t() << __sp << __x.p(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, binomial_distribution<_IntType>& __x) { typedef binomial_distribution<_IntType> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __t; double __p; __is >> __t >> __p; if (!__is.fail()) __x.param(param_type(__t, __p)); return __is; } // exponential_distribution template class _LIBCPP_TYPE_VIS_ONLY exponential_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __lambda_; public: typedef exponential_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __lambda = 1) : __lambda_(__lambda) {} _LIBCPP_INLINE_VISIBILITY result_type lambda() const {return __lambda_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__lambda_ == __y.__lambda_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit exponential_distribution(result_type __lambda = 1) : __p_(param_type(__lambda)) {} _LIBCPP_INLINE_VISIBILITY explicit exponential_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type lambda() const {return __p_.lambda();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const exponential_distribution& __x, const exponential_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const exponential_distribution& __x, const exponential_distribution& __y) {return !(__x == __y);} }; template template _RealType exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { return -_VSTD::log ( result_type(1) - _VSTD::generate_canonical::digits>(__g) ) / __p.lambda(); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const exponential_distribution<_RealType>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); return __os << __x.lambda(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, exponential_distribution<_RealType>& __x) { typedef exponential_distribution<_RealType> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __lambda; __is >> __lambda; if (!__is.fail()) __x.param(param_type(__lambda)); return __is; } // normal_distribution template class _LIBCPP_TYPE_VIS_ONLY normal_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __mean_; result_type __stddev_; public: typedef normal_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __mean = 0, result_type __stddev = 1) : __mean_(__mean), __stddev_(__stddev) {} _LIBCPP_INLINE_VISIBILITY result_type mean() const {return __mean_;} _LIBCPP_INLINE_VISIBILITY result_type stddev() const {return __stddev_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__mean_ == __y.__mean_ && __x.__stddev_ == __y.__stddev_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; result_type _V_; bool _V_hot_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit normal_distribution(result_type __mean = 0, result_type __stddev = 1) : __p_(param_type(__mean, __stddev)), _V_hot_(false) {} _LIBCPP_INLINE_VISIBILITY explicit normal_distribution(const param_type& __p) : __p_(__p), _V_hot_(false) {} _LIBCPP_INLINE_VISIBILITY void reset() {_V_hot_ = false;} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type mean() const {return __p_.mean();} _LIBCPP_INLINE_VISIBILITY result_type stddev() const {return __p_.stddev();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return -numeric_limits::infinity();} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const normal_distribution& __x, const normal_distribution& __y) {return __x.__p_ == __y.__p_ && __x._V_hot_ == __y._V_hot_ && (!__x._V_hot_ || __x._V_ == __y._V_);} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const normal_distribution& __x, const normal_distribution& __y) {return !(__x == __y);} template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const normal_distribution<_RT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, normal_distribution<_RT>& __x); }; template template _RealType normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { result_type _Up; if (_V_hot_) { _V_hot_ = false; _Up = _V_; } else { uniform_real_distribution _Uni(-1, 1); result_type __u; result_type __v; result_type __s; do { __u = _Uni(__g); __v = _Uni(__g); __s = __u * __u + __v * __v; } while (__s > 1 || __s == 0); result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s); _V_ = __v * _Fp; _V_hot_ = true; _Up = __u * _Fp; } return _Up * __p.stddev() + __p.mean(); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const normal_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_; if (__x._V_hot_) __os << __sp << __x._V_; return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, normal_distribution<_RT>& __x) { typedef normal_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __mean; result_type __stddev; result_type _Vp = 0; bool _V_hot = false; __is >> __mean >> __stddev >> _V_hot; if (_V_hot) __is >> _Vp; if (!__is.fail()) { __x.param(param_type(__mean, __stddev)); __x._V_hot_ = _V_hot; __x._V_ = _Vp; } return __is; } // lognormal_distribution template class _LIBCPP_TYPE_VIS_ONLY lognormal_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { normal_distribution __nd_; public: typedef lognormal_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __m = 0, result_type __s = 1) : __nd_(__m, __s) {} _LIBCPP_INLINE_VISIBILITY result_type m() const {return __nd_.mean();} _LIBCPP_INLINE_VISIBILITY result_type s() const {return __nd_.stddev();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__nd_ == __y.__nd_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} friend class lognormal_distribution; template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const lognormal_distribution<_RT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, lognormal_distribution<_RT>& __x); }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit lognormal_distribution(result_type __m = 0, result_type __s = 1) : __p_(param_type(__m, __s)) {} _LIBCPP_INLINE_VISIBILITY explicit lognormal_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {__p_.__nd_.reset();} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p) {return _VSTD::exp(const_cast&>(__p.__nd_)(__g));} // property functions _LIBCPP_INLINE_VISIBILITY result_type m() const {return __p_.m();} _LIBCPP_INLINE_VISIBILITY result_type s() const {return __p_.s();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const lognormal_distribution& __x, const lognormal_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const lognormal_distribution& __x, const lognormal_distribution& __y) {return !(__x == __y);} template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const lognormal_distribution<_RT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, lognormal_distribution<_RT>& __x); }; template inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const lognormal_distribution<_RT>& __x) { return __os << __x.__p_.__nd_; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, lognormal_distribution<_RT>& __x) { return __is >> __x.__p_.__nd_; } // poisson_distribution template class _LIBCPP_TYPE_VIS_ONLY poisson_distribution { public: // types typedef _IntType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { double __mean_; double __s_; double __d_; double __l_; double __omega_; double __c0_; double __c1_; double __c2_; double __c3_; double __c_; public: typedef poisson_distribution distribution_type; explicit param_type(double __mean = 1.0); _LIBCPP_INLINE_VISIBILITY double mean() const {return __mean_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__mean_ == __y.__mean_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} friend class poisson_distribution; }; private: param_type __p_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit poisson_distribution(double __mean = 1.0) : __p_(__mean) {} _LIBCPP_INLINE_VISIBILITY explicit poisson_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY double mean() const {return __p_.mean();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::max();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const poisson_distribution& __x, const poisson_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const poisson_distribution& __x, const poisson_distribution& __y) {return !(__x == __y);} }; template poisson_distribution<_IntType>::param_type::param_type(double __mean) : __mean_(__mean) { if (__mean_ < 10) { __s_ = 0; __d_ = 0; __l_ = _VSTD::exp(-__mean_); __omega_ = 0; __c3_ = 0; __c2_ = 0; __c1_ = 0; __c0_ = 0; __c_ = 0; } else { __s_ = _VSTD::sqrt(__mean_); __d_ = 6 * __mean_ * __mean_; __l_ = static_cast(__mean_ - 1.1484); __omega_ = .3989423 / __s_; double __b1_ = .4166667E-1 / __mean_; double __b2_ = .3 * __b1_ * __b1_; __c3_ = .1428571 * __b1_ * __b2_; __c2_ = __b2_ - 15. * __c3_; __c1_ = __b1_ - 6. * __b2_ + 45. * __c3_; __c0_ = 1. - __b1_ + 3. * __b2_ - 15. * __c3_; __c_ = .1069 / __mean_; } } template template _IntType poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) { result_type __x; uniform_real_distribution __urd; if (__pr.__mean_ < 10) { __x = 0; for (double __p = __urd(__urng); __p > __pr.__l_; ++__x) __p *= __urd(__urng); } else { double __difmuk; double __g = __pr.__mean_ + __pr.__s_ * normal_distribution()(__urng); double __u; if (__g > 0) { __x = static_cast(__g); if (__x >= __pr.__l_) return __x; __difmuk = __pr.__mean_ - __x; __u = __urd(__urng); if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk) return __x; } exponential_distribution __edist; for (bool __using_exp_dist = false; true; __using_exp_dist = true) { double __e; if (__using_exp_dist || __g < 0) { double __t; do { __e = __edist(__urng); __u = __urd(__urng); __u += __u - 1; __t = 1.8 + (__u < 0 ? -__e : __e); } while (__t <= -.6744); __x = __pr.__mean_ + __pr.__s_ * __t; __difmuk = __pr.__mean_ - __x; __using_exp_dist = true; } double __px; double __py; if (__x < 10) { const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880}; __px = -__pr.__mean_; __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x]; } else { double __del = .8333333E-1 / __x; __del -= 4.8 * __del * __del * __del; double __v = __difmuk / __x; if (_VSTD::abs(__v) > 0.25) __px = __x * _VSTD::log(1 + __v) - __difmuk - __del; else __px = __x * __v * __v * (((((((.1250060 * __v + -.1384794) * __v + .1421878) * __v + -.1661269) * __v + .2000118) * __v + -.2500068) * __v + .3333333) * __v + -.5) - __del; __py = .3989423 / _VSTD::sqrt(__x); } double __r = (0.5 - __difmuk) / __pr.__s_; double __r2 = __r * __r; double __fx = -0.5 * __r2; double __fy = __pr.__omega_ * (((__pr.__c3_ * __r2 + __pr.__c2_) * __r2 + __pr.__c1_) * __r2 + __pr.__c0_); if (__using_exp_dist) { if (__pr.__c_ * _VSTD::abs(__u) <= __py * _VSTD::exp(__px + __e) - __fy * _VSTD::exp(__fx + __e)) break; } else { if (__fy - __u * __fy <= __py * _VSTD::exp(__px - __fx)) break; } } } return __x; } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const poisson_distribution<_IntType>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); return __os << __x.mean(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, poisson_distribution<_IntType>& __x) { typedef poisson_distribution<_IntType> _Eng; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); double __mean; __is >> __mean; if (!__is.fail()) __x.param(param_type(__mean)); return __is; } // weibull_distribution template class _LIBCPP_TYPE_VIS_ONLY weibull_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; public: typedef weibull_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __a = 1, result_type __b = 1) : __a_(__a), __b_(__b) {} _LIBCPP_INLINE_VISIBILITY result_type a() const {return __a_;} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit weibull_distribution(result_type __a = 1, result_type __b = 1) : __p_(param_type(__a, __b)) {} _LIBCPP_INLINE_VISIBILITY explicit weibull_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p) {return __p.b() * _VSTD::pow(exponential_distribution()(__g), 1/__p.a());} // property functions _LIBCPP_INLINE_VISIBILITY result_type a() const {return __p_.a();} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __p_.b();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const weibull_distribution& __x, const weibull_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const weibull_distribution& __x, const weibull_distribution& __y) {return !(__x == __y);} }; template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const weibull_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.a() << __sp << __x.b(); return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, weibull_distribution<_RT>& __x) { typedef weibull_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __a; result_type __b; __is >> __a >> __b; if (!__is.fail()) __x.param(param_type(__a, __b)); return __is; } template class _LIBCPP_TYPE_VIS_ONLY extreme_value_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; public: typedef extreme_value_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __a = 0, result_type __b = 1) : __a_(__a), __b_(__b) {} _LIBCPP_INLINE_VISIBILITY result_type a() const {return __a_;} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit extreme_value_distribution(result_type __a = 0, result_type __b = 1) : __p_(param_type(__a, __b)) {} _LIBCPP_INLINE_VISIBILITY explicit extreme_value_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type a() const {return __p_.a();} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __p_.b();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return -numeric_limits::infinity();} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const extreme_value_distribution& __x, const extreme_value_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const extreme_value_distribution& __x, const extreme_value_distribution& __y) {return !(__x == __y);} }; template template _RealType extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { return __p.a() - __p.b() * _VSTD::log(-_VSTD::log(1-uniform_real_distribution()(__g))); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const extreme_value_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.a() << __sp << __x.b(); return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, extreme_value_distribution<_RT>& __x) { typedef extreme_value_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __a; result_type __b; __is >> __a >> __b; if (!__is.fail()) __x.param(param_type(__a, __b)); return __is; } // gamma_distribution template class _LIBCPP_TYPE_VIS_ONLY gamma_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __alpha_; result_type __beta_; public: typedef gamma_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __alpha = 1, result_type __beta = 1) : __alpha_(__alpha), __beta_(__beta) {} _LIBCPP_INLINE_VISIBILITY result_type alpha() const {return __alpha_;} _LIBCPP_INLINE_VISIBILITY result_type beta() const {return __beta_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__alpha_ == __y.__alpha_ && __x.__beta_ == __y.__beta_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit gamma_distribution(result_type __alpha = 1, result_type __beta = 1) : __p_(param_type(__alpha, __beta)) {} _LIBCPP_INLINE_VISIBILITY explicit gamma_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type alpha() const {return __p_.alpha();} _LIBCPP_INLINE_VISIBILITY result_type beta() const {return __p_.beta();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const gamma_distribution& __x, const gamma_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const gamma_distribution& __x, const gamma_distribution& __y) {return !(__x == __y);} }; template template _RealType gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { result_type __a = __p.alpha(); uniform_real_distribution __gen(0, 1); exponential_distribution __egen; result_type __x; if (__a == 1) __x = __egen(__g); else if (__a > 1) { const result_type __b = __a - 1; const result_type __c = 3 * __a - result_type(0.75); while (true) { const result_type __u = __gen(__g); const result_type __v = __gen(__g); const result_type __w = __u * (1 - __u); if (__w != 0) { const result_type __y = _VSTD::sqrt(__c / __w) * (__u - result_type(0.5)); __x = __b + __y; if (__x >= 0) { const result_type __z = 64 * __w * __w * __w * __v * __v; if (__z <= 1 - 2 * __y * __y / __x) break; if (_VSTD::log(__z) <= 2 * (__b * _VSTD::log(__x / __b) - __y)) break; } } } } else // __a < 1 { while (true) { const result_type __u = __gen(__g); const result_type __es = __egen(__g); if (__u <= 1 - __a) { __x = _VSTD::pow(__u, 1 / __a); if (__x <= __es) break; } else { const result_type __e = -_VSTD::log((1-__u)/__a); __x = _VSTD::pow(1 - __a + __a * __e, 1 / __a); if (__x <= __e + __es) break; } } } return __x * __p.beta(); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const gamma_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.alpha() << __sp << __x.beta(); return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, gamma_distribution<_RT>& __x) { typedef gamma_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __alpha; result_type __beta; __is >> __alpha >> __beta; if (!__is.fail()) __x.param(param_type(__alpha, __beta)); return __is; } // negative_binomial_distribution template class _LIBCPP_TYPE_VIS_ONLY negative_binomial_distribution { public: // types typedef _IntType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __k_; double __p_; public: typedef negative_binomial_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __k = 1, double __p = 0.5) : __k_(__k), __p_(__p) {} _LIBCPP_INLINE_VISIBILITY result_type k() const {return __k_;} _LIBCPP_INLINE_VISIBILITY double p() const {return __p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__k_ == __y.__k_ && __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit negative_binomial_distribution(result_type __k = 1, double __p = 0.5) : __p_(__k, __p) {} _LIBCPP_INLINE_VISIBILITY explicit negative_binomial_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type k() const {return __p_.k();} _LIBCPP_INLINE_VISIBILITY double p() const {return __p_.p();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::max();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const negative_binomial_distribution& __x, const negative_binomial_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const negative_binomial_distribution& __x, const negative_binomial_distribution& __y) {return !(__x == __y);} }; template template _IntType negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) { result_type __k = __pr.k(); double __p = __pr.p(); if (__k <= 21 * __p) { bernoulli_distribution __gen(__p); result_type __f = 0; result_type __s = 0; while (__s < __k) { if (__gen(__urng)) ++__s; else ++__f; } return __f; } return poisson_distribution(gamma_distribution (__k, (1-__p)/__p)(__urng))(__urng); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const negative_binomial_distribution<_IntType>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); return __os << __x.k() << __sp << __x.p(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, negative_binomial_distribution<_IntType>& __x) { typedef negative_binomial_distribution<_IntType> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __k; double __p; __is >> __k >> __p; if (!__is.fail()) __x.param(param_type(__k, __p)); return __is; } // geometric_distribution template class _LIBCPP_TYPE_VIS_ONLY geometric_distribution { public: // types typedef _IntType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { double __p_; public: typedef geometric_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(double __p = 0.5) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY double p() const {return __p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructors and reset functions _LIBCPP_INLINE_VISIBILITY explicit geometric_distribution(double __p = 0.5) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY explicit geometric_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p) {return negative_binomial_distribution(1, __p.p())(__g);} // property functions _LIBCPP_INLINE_VISIBILITY double p() const {return __p_.p();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::max();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const geometric_distribution& __x, const geometric_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const geometric_distribution& __x, const geometric_distribution& __y) {return !(__x == __y);} }; template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const geometric_distribution<_IntType>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); return __os << __x.p(); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, geometric_distribution<_IntType>& __x) { typedef geometric_distribution<_IntType> _Eng; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); double __p; __is >> __p; if (!__is.fail()) __x.param(param_type(__p)); return __is; } // chi_squared_distribution template class _LIBCPP_TYPE_VIS_ONLY chi_squared_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __n_; public: typedef chi_squared_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __n = 1) : __n_(__n) {} _LIBCPP_INLINE_VISIBILITY result_type n() const {return __n_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__n_ == __y.__n_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit chi_squared_distribution(result_type __n = 1) : __p_(param_type(__n)) {} _LIBCPP_INLINE_VISIBILITY explicit chi_squared_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p) {return gamma_distribution(__p.n() / 2, 2)(__g);} // property functions _LIBCPP_INLINE_VISIBILITY result_type n() const {return __p_.n();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const chi_squared_distribution& __x, const chi_squared_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const chi_squared_distribution& __x, const chi_squared_distribution& __y) {return !(__x == __y);} }; template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const chi_squared_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); __os << __x.n(); return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, chi_squared_distribution<_RT>& __x) { typedef chi_squared_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __n; __is >> __n; if (!__is.fail()) __x.param(param_type(__n)); return __is; } // cauchy_distribution template class _LIBCPP_TYPE_VIS_ONLY cauchy_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; public: typedef cauchy_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __a = 0, result_type __b = 1) : __a_(__a), __b_(__b) {} _LIBCPP_INLINE_VISIBILITY result_type a() const {return __a_;} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit cauchy_distribution(result_type __a = 0, result_type __b = 1) : __p_(param_type(__a, __b)) {} _LIBCPP_INLINE_VISIBILITY explicit cauchy_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type a() const {return __p_.a();} _LIBCPP_INLINE_VISIBILITY result_type b() const {return __p_.b();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return -numeric_limits::infinity();} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const cauchy_distribution& __x, const cauchy_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const cauchy_distribution& __x, const cauchy_distribution& __y) {return !(__x == __y);} }; template template inline _LIBCPP_INLINE_VISIBILITY _RealType cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { uniform_real_distribution __gen; // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g)); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const cauchy_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.a() << __sp << __x.b(); return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, cauchy_distribution<_RT>& __x) { typedef cauchy_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __a; result_type __b; __is >> __a >> __b; if (!__is.fail()) __x.param(param_type(__a, __b)); return __is; } // fisher_f_distribution template class _LIBCPP_TYPE_VIS_ONLY fisher_f_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __m_; result_type __n_; public: typedef fisher_f_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __m = 1, result_type __n = 1) : __m_(__m), __n_(__n) {} _LIBCPP_INLINE_VISIBILITY result_type m() const {return __m_;} _LIBCPP_INLINE_VISIBILITY result_type n() const {return __n_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__m_ == __y.__m_ && __x.__n_ == __y.__n_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1) : __p_(param_type(__m, __n)) {} _LIBCPP_INLINE_VISIBILITY explicit fisher_f_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type m() const {return __p_.m();} _LIBCPP_INLINE_VISIBILITY result_type n() const {return __p_.n();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const fisher_f_distribution& __x, const fisher_f_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const fisher_f_distribution& __x, const fisher_f_distribution& __y) {return !(__x == __y);} }; template template _RealType fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { gamma_distribution __gdm(__p.m() * result_type(.5)); gamma_distribution __gdn(__p.n() * result_type(.5)); return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g)); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const fisher_f_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); __os << __x.m() << __sp << __x.n(); return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, fisher_f_distribution<_RT>& __x) { typedef fisher_f_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __m; result_type __n; __is >> __m >> __n; if (!__is.fail()) __x.param(param_type(__m, __n)); return __is; } // student_t_distribution template class _LIBCPP_TYPE_VIS_ONLY student_t_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __n_; public: typedef student_t_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY explicit param_type(result_type __n = 1) : __n_(__n) {} _LIBCPP_INLINE_VISIBILITY result_type n() const {return __n_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__n_ == __y.__n_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; normal_distribution __nd_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY explicit student_t_distribution(result_type __n = 1) : __p_(param_type(__n)) {} _LIBCPP_INLINE_VISIBILITY explicit student_t_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {__nd_.reset();} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY result_type n() const {return __p_.n();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return -numeric_limits::infinity();} _LIBCPP_INLINE_VISIBILITY result_type max() const {return numeric_limits::infinity();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const student_t_distribution& __x, const student_t_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const student_t_distribution& __x, const student_t_distribution& __y) {return !(__x == __y);} }; template template _RealType student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { gamma_distribution __gd(__p.n() * .5, 2); return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g)); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const student_t_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); __os << __x.n(); return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, student_t_distribution<_RT>& __x) { typedef student_t_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); result_type __n; __is >> __n; if (!__is.fail()) __x.param(param_type(__n)); return __is; } // discrete_distribution template class _LIBCPP_TYPE_VIS_ONLY discrete_distribution { public: // types typedef _IntType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { vector __p_; public: typedef discrete_distribution distribution_type; _LIBCPP_INLINE_VISIBILITY param_type() {} template _LIBCPP_INLINE_VISIBILITY param_type(_InputIterator __f, _InputIterator __l) : __p_(__f, __l) {__init();} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY param_type(initializer_list __wl) : __p_(__wl.begin(), __wl.end()) {__init();} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template param_type(size_t __nw, double __xmin, double __xmax, _UnaryOperation __fw); vector probabilities() const; friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} private: void __init(); friend class discrete_distribution; template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const discrete_distribution<_IT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, discrete_distribution<_IT>& __x); }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY discrete_distribution() {} template _LIBCPP_INLINE_VISIBILITY discrete_distribution(_InputIterator __f, _InputIterator __l) : __p_(__f, __l) {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY discrete_distribution(initializer_list __wl) : __p_(__wl) {} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY discrete_distribution(size_t __nw, double __xmin, double __xmax, _UnaryOperation __fw) : __p_(__nw, __xmin, __xmax, __fw) {} _LIBCPP_INLINE_VISIBILITY explicit discrete_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY vector probabilities() const {return __p_.probabilities();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return 0;} _LIBCPP_INLINE_VISIBILITY result_type max() const {return __p_.__p_.size();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const discrete_distribution& __x, const discrete_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const discrete_distribution& __x, const discrete_distribution& __y) {return !(__x == __y);} template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const discrete_distribution<_IT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, discrete_distribution<_IT>& __x); }; template template discrete_distribution<_IntType>::param_type::param_type(size_t __nw, double __xmin, double __xmax, _UnaryOperation __fw) { if (__nw > 1) { __p_.reserve(__nw - 1); double __d = (__xmax - __xmin) / __nw; double __d2 = __d / 2; for (size_t __k = 0; __k < __nw; ++__k) __p_.push_back(__fw(__xmin + __k * __d + __d2)); __init(); } } template void discrete_distribution<_IntType>::param_type::__init() { if (!__p_.empty()) { if (__p_.size() > 1) { double __s = _VSTD::accumulate(__p_.begin(), __p_.end(), 0.0); for (_VSTD::vector::iterator __i = __p_.begin(), __e = __p_.end(); __i < __e; ++__i) *__i /= __s; vector __t(__p_.size() - 1); _VSTD::partial_sum(__p_.begin(), __p_.end() - 1, __t.begin()); swap(__p_, __t); } else { __p_.clear(); __p_.shrink_to_fit(); } } } template vector discrete_distribution<_IntType>::param_type::probabilities() const { size_t __n = __p_.size(); _VSTD::vector __p(__n+1); _VSTD::adjacent_difference(__p_.begin(), __p_.end(), __p.begin()); if (__n > 0) __p[__n] = 1 - __p_[__n-1]; else __p[0] = 1; return __p; } template template _IntType discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) { uniform_real_distribution __gen; return static_cast<_IntType>( _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) - __p.__p_.begin()); } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const discrete_distribution<_IT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); size_t __n = __x.__p_.__p_.size(); __os << __n; for (size_t __i = 0; __i < __n; ++__i) __os << __sp << __x.__p_.__p_[__i]; return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, discrete_distribution<_IT>& __x) { typedef discrete_distribution<_IT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; __is >> __n; vector __p(__n); for (size_t __i = 0; __i < __n; ++__i) __is >> __p[__i]; if (!__is.fail()) swap(__x.__p_.__p_, __p); return __is; } // piecewise_constant_distribution template class _LIBCPP_TYPE_VIS_ONLY piecewise_constant_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { vector __b_; vector __densities_; vector __areas_; public: typedef piecewise_constant_distribution distribution_type; param_type(); template param_type(_InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template param_type(initializer_list __bl, _UnaryOperation __fw); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template param_type(size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw); param_type & operator=(const param_type& __rhs); _LIBCPP_INLINE_VISIBILITY vector intervals() const {return __b_;} _LIBCPP_INLINE_VISIBILITY vector densities() const {return __densities_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} private: void __init(); friend class piecewise_constant_distribution; template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const piecewise_constant_distribution<_RT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, piecewise_constant_distribution<_RT>& __x); }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY piecewise_constant_distribution() {} template _LIBCPP_INLINE_VISIBILITY piecewise_constant_distribution(_InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) : __p_(__fB, __lB, __fW) {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY piecewise_constant_distribution(initializer_list __bl, _UnaryOperation __fw) : __p_(__bl, __fw) {} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY piecewise_constant_distribution(size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) : __p_(__nw, __xmin, __xmax, __fw) {} _LIBCPP_INLINE_VISIBILITY explicit piecewise_constant_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY vector intervals() const {return __p_.intervals();} _LIBCPP_INLINE_VISIBILITY vector densities() const {return __p_.densities();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return __p_.__b_.front();} _LIBCPP_INLINE_VISIBILITY result_type max() const {return __p_.__b_.back();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const piecewise_constant_distribution& __x, const piecewise_constant_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const piecewise_constant_distribution& __x, const piecewise_constant_distribution& __y) {return !(__x == __y);} template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const piecewise_constant_distribution<_RT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, piecewise_constant_distribution<_RT>& __x); }; template typename piecewise_constant_distribution<_RealType>::param_type & piecewise_constant_distribution<_RealType>::param_type::operator= (const param_type& __rhs) { // These can throw __b_.reserve (__rhs.__b_.size ()); __densities_.reserve(__rhs.__densities_.size()); __areas_.reserve (__rhs.__areas_.size()); // These can not throw __b_ = __rhs.__b_; __densities_ = __rhs.__densities_; __areas_ = __rhs.__areas_; return *this; } template void piecewise_constant_distribution<_RealType>::param_type::__init() { // __densities_ contains non-normalized areas result_type __total_area = _VSTD::accumulate(__densities_.begin(), __densities_.end(), result_type()); for (size_t __i = 0; __i < __densities_.size(); ++__i) __densities_[__i] /= __total_area; // __densities_ contains normalized areas __areas_.assign(__densities_.size(), result_type()); _VSTD::partial_sum(__densities_.begin(), __densities_.end() - 1, __areas_.begin() + 1); // __areas_ contains partial sums of normalized areas: [0, __densities_ - 1] __densities_.back() = 1 - __areas_.back(); // correct round off error for (size_t __i = 0; __i < __densities_.size(); ++__i) __densities_[__i] /= (__b_[__i+1] - __b_[__i]); // __densities_ now contains __densities_ } template piecewise_constant_distribution<_RealType>::param_type::param_type() : __b_(2), __densities_(1, 1.0), __areas_(1, 0.0) { __b_[1] = 1; } template template piecewise_constant_distribution<_RealType>::param_type::param_type( _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) : __b_(__fB, __lB) { if (__b_.size() < 2) { __b_.resize(2); __b_[0] = 0; __b_[1] = 1; __densities_.assign(1, 1.0); __areas_.assign(1, 0.0); } else { __densities_.reserve(__b_.size() - 1); for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW) __densities_.push_back(*__fW); __init(); } } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template template piecewise_constant_distribution<_RealType>::param_type::param_type( initializer_list __bl, _UnaryOperation __fw) : __b_(__bl.begin(), __bl.end()) { if (__b_.size() < 2) { __b_.resize(2); __b_[0] = 0; __b_[1] = 1; __densities_.assign(1, 1.0); __areas_.assign(1, 0.0); } else { __densities_.reserve(__b_.size() - 1); for (size_t __i = 0; __i < __b_.size() - 1; ++__i) __densities_.push_back(__fw((__b_[__i+1] + __b_[__i])*.5)); __init(); } } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template template piecewise_constant_distribution<_RealType>::param_type::param_type( size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) : __b_(__nw == 0 ? 2 : __nw + 1) { size_t __n = __b_.size() - 1; result_type __d = (__xmax - __xmin) / __n; __densities_.reserve(__n); for (size_t __i = 0; __i < __n; ++__i) { __b_[__i] = __xmin + __i * __d; __densities_.push_back(__fw(__b_[__i] + __d*.5)); } __b_[__n] = __xmax; __init(); } template template _RealType piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { typedef uniform_real_distribution _Gen; result_type __u = _Gen()(__g); ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), __u) - __p.__areas_.begin() - 1; return (__u - __p.__areas_[__k]) / __p.__densities_[__k] + __p.__b_[__k]; } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const piecewise_constant_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); size_t __n = __x.__p_.__b_.size(); __os << __n; for (size_t __i = 0; __i < __n; ++__i) __os << __sp << __x.__p_.__b_[__i]; __n = __x.__p_.__densities_.size(); __os << __sp << __n; for (size_t __i = 0; __i < __n; ++__i) __os << __sp << __x.__p_.__densities_[__i]; __n = __x.__p_.__areas_.size(); __os << __sp << __n; for (size_t __i = 0; __i < __n; ++__i) __os << __sp << __x.__p_.__areas_[__i]; return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, piecewise_constant_distribution<_RT>& __x) { typedef piecewise_constant_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; __is >> __n; vector __b(__n); for (size_t __i = 0; __i < __n; ++__i) __is >> __b[__i]; __is >> __n; vector __densities(__n); for (size_t __i = 0; __i < __n; ++__i) __is >> __densities[__i]; __is >> __n; vector __areas(__n); for (size_t __i = 0; __i < __n; ++__i) __is >> __areas[__i]; if (!__is.fail()) { swap(__x.__p_.__b_, __b); swap(__x.__p_.__densities_, __densities); swap(__x.__p_.__areas_, __areas); } return __is; } // piecewise_linear_distribution template class _LIBCPP_TYPE_VIS_ONLY piecewise_linear_distribution { public: // types typedef _RealType result_type; class _LIBCPP_TYPE_VIS_ONLY param_type { vector __b_; vector __densities_; vector __areas_; public: typedef piecewise_linear_distribution distribution_type; param_type(); template param_type(_InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW); #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template param_type(initializer_list __bl, _UnaryOperation __fw); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template param_type(size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw); param_type & operator=(const param_type& __rhs); _LIBCPP_INLINE_VISIBILITY vector intervals() const {return __b_;} _LIBCPP_INLINE_VISIBILITY vector densities() const {return __densities_;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const param_type& __x, const param_type& __y) {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} private: void __init(); friend class piecewise_linear_distribution; template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const piecewise_linear_distribution<_RT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, piecewise_linear_distribution<_RT>& __x); }; private: param_type __p_; public: // constructor and reset functions _LIBCPP_INLINE_VISIBILITY piecewise_linear_distribution() {} template _LIBCPP_INLINE_VISIBILITY piecewise_linear_distribution(_InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) : __p_(__fB, __lB, __fW) {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY piecewise_linear_distribution(initializer_list __bl, _UnaryOperation __fw) : __p_(__bl, __fw) {} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template _LIBCPP_INLINE_VISIBILITY piecewise_linear_distribution(size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) : __p_(__nw, __xmin, __xmax, __fw) {} _LIBCPP_INLINE_VISIBILITY explicit piecewise_linear_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} // generating functions template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY vector intervals() const {return __p_.intervals();} _LIBCPP_INLINE_VISIBILITY vector densities() const {return __p_.densities();} _LIBCPP_INLINE_VISIBILITY param_type param() const {return __p_;} _LIBCPP_INLINE_VISIBILITY void param(const param_type& __p) {__p_ = __p;} _LIBCPP_INLINE_VISIBILITY result_type min() const {return __p_.__b_.front();} _LIBCPP_INLINE_VISIBILITY result_type max() const {return __p_.__b_.back();} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const piecewise_linear_distribution& __x, const piecewise_linear_distribution& __y) {return __x.__p_ == __y.__p_;} friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const piecewise_linear_distribution& __x, const piecewise_linear_distribution& __y) {return !(__x == __y);} template friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const piecewise_linear_distribution<_RT>& __x); template friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, piecewise_linear_distribution<_RT>& __x); }; template typename piecewise_linear_distribution<_RealType>::param_type & piecewise_linear_distribution<_RealType>::param_type::operator= (const param_type& __rhs) { // These can throw __b_.reserve (__rhs.__b_.size ()); __densities_.reserve(__rhs.__densities_.size()); __areas_.reserve (__rhs.__areas_.size()); // These can not throw __b_ = __rhs.__b_; __densities_ = __rhs.__densities_; __areas_ = __rhs.__areas_; return *this; } template void piecewise_linear_distribution<_RealType>::param_type::__init() { __areas_.assign(__densities_.size() - 1, result_type()); result_type _Sp = 0; for (size_t __i = 0; __i < __areas_.size(); ++__i) { __areas_[__i] = (__densities_[__i+1] + __densities_[__i]) * (__b_[__i+1] - __b_[__i]) * .5; _Sp += __areas_[__i]; } for (size_t __i = __areas_.size(); __i > 1;) { --__i; __areas_[__i] = __areas_[__i-1] / _Sp; } __areas_[0] = 0; for (size_t __i = 1; __i < __areas_.size(); ++__i) __areas_[__i] += __areas_[__i-1]; for (size_t __i = 0; __i < __densities_.size(); ++__i) __densities_[__i] /= _Sp; } template piecewise_linear_distribution<_RealType>::param_type::param_type() : __b_(2), __densities_(2, 1.0), __areas_(1, 0.0) { __b_[1] = 1; } template template piecewise_linear_distribution<_RealType>::param_type::param_type( _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) : __b_(__fB, __lB) { if (__b_.size() < 2) { __b_.resize(2); __b_[0] = 0; __b_[1] = 1; __densities_.assign(2, 1.0); __areas_.assign(1, 0.0); } else { __densities_.reserve(__b_.size()); for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW) __densities_.push_back(*__fW); __init(); } } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template template piecewise_linear_distribution<_RealType>::param_type::param_type( initializer_list __bl, _UnaryOperation __fw) : __b_(__bl.begin(), __bl.end()) { if (__b_.size() < 2) { __b_.resize(2); __b_[0] = 0; __b_[1] = 1; __densities_.assign(2, 1.0); __areas_.assign(1, 0.0); } else { __densities_.reserve(__b_.size()); for (size_t __i = 0; __i < __b_.size(); ++__i) __densities_.push_back(__fw(__b_[__i])); __init(); } } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template template piecewise_linear_distribution<_RealType>::param_type::param_type( size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) : __b_(__nw == 0 ? 2 : __nw + 1) { size_t __n = __b_.size() - 1; result_type __d = (__xmax - __xmin) / __n; __densities_.reserve(__b_.size()); for (size_t __i = 0; __i < __n; ++__i) { __b_[__i] = __xmin + __i * __d; __densities_.push_back(__fw(__b_[__i])); } __b_[__n] = __xmax; __densities_.push_back(__fw(__b_[__n])); __init(); } template template _RealType piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { typedef uniform_real_distribution _Gen; result_type __u = _Gen()(__g); ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), __u) - __p.__areas_.begin() - 1; __u -= __p.__areas_[__k]; const result_type __dk = __p.__densities_[__k]; const result_type __dk1 = __p.__densities_[__k+1]; const result_type __deltad = __dk1 - __dk; const result_type __bk = __p.__b_[__k]; if (__deltad == 0) return __u / __dk + __bk; const result_type __bk1 = __p.__b_[__k+1]; const result_type __deltab = __bk1 - __bk; return (__bk * __dk1 - __bk1 * __dk + _VSTD::sqrt(__deltab * (__deltab * __dk * __dk + 2 * __deltad * __u))) / __deltad; } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const piecewise_linear_distribution<_RT>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left | ios_base::fixed | ios_base::scientific); _CharT __sp = __os.widen(' '); __os.fill(__sp); size_t __n = __x.__p_.__b_.size(); __os << __n; for (size_t __i = 0; __i < __n; ++__i) __os << __sp << __x.__p_.__b_[__i]; __n = __x.__p_.__densities_.size(); __os << __sp << __n; for (size_t __i = 0; __i < __n; ++__i) __os << __sp << __x.__p_.__densities_[__i]; __n = __x.__p_.__areas_.size(); __os << __sp << __n; for (size_t __i = 0; __i < __n; ++__i) __os << __sp << __x.__p_.__areas_[__i]; return __os; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, piecewise_linear_distribution<_RT>& __x) { typedef piecewise_linear_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; __is >> __n; vector __b(__n); for (size_t __i = 0; __i < __n; ++__i) __is >> __b[__i]; __is >> __n; vector __densities(__n); for (size_t __i = 0; __i < __n; ++__i) __is >> __densities[__i]; __is >> __n; vector __areas(__n); for (size_t __i = 0; __i < __n; ++__i) __is >> __areas[__i]; if (!__is.fail()) { swap(__x.__p_.__b_, __b); swap(__x.__p_.__densities_, __densities); swap(__x.__p_.__areas_, __areas); } return __is; } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_RANDOM libcxx/include/mutex0000644000175000017500000003273112266757731015767 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- mutex ------------------------------------===// // // The 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_MUTEX #define _LIBCPP_MUTEX /* mutex synopsis namespace std { class mutex { public: constexpr mutex() noexcept; ~mutex(); mutex(const mutex&) = delete; mutex& operator=(const mutex&) = delete; void lock(); bool try_lock(); void unlock(); typedef pthread_mutex_t* native_handle_type; native_handle_type native_handle(); }; class recursive_mutex { public: recursive_mutex(); ~recursive_mutex(); recursive_mutex(const recursive_mutex&) = delete; recursive_mutex& operator=(const recursive_mutex&) = delete; void lock(); bool try_lock() noexcept; void unlock(); typedef pthread_mutex_t* native_handle_type; native_handle_type native_handle(); }; class timed_mutex { public: timed_mutex(); ~timed_mutex(); timed_mutex(const timed_mutex&) = delete; timed_mutex& operator=(const timed_mutex&) = delete; void lock(); bool try_lock(); template bool try_lock_for(const chrono::duration& rel_time); template bool try_lock_until(const chrono::time_point& abs_time); void unlock(); }; class recursive_timed_mutex { public: recursive_timed_mutex(); ~recursive_timed_mutex(); recursive_timed_mutex(const recursive_timed_mutex&) = delete; recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; void lock(); bool try_lock() noexcept; template bool try_lock_for(const chrono::duration& rel_time); template bool try_lock_until(const chrono::time_point& abs_time); void unlock(); }; 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{}; template class lock_guard { public: typedef Mutex mutex_type; explicit lock_guard(mutex_type& m); lock_guard(mutex_type& m, adopt_lock_t); ~lock_guard(); lock_guard(lock_guard const&) = delete; lock_guard& operator=(lock_guard const&) = delete; }; template class unique_lock { public: typedef Mutex mutex_type; unique_lock() noexcept; explicit unique_lock(mutex_type& m); unique_lock(mutex_type& m, defer_lock_t) noexcept; unique_lock(mutex_type& m, try_to_lock_t); unique_lock(mutex_type& m, adopt_lock_t); template unique_lock(mutex_type& m, const chrono::time_point& abs_time); template unique_lock(mutex_type& m, const chrono::duration& rel_time); ~unique_lock(); unique_lock(unique_lock const&) = delete; unique_lock& operator=(unique_lock const&) = delete; unique_lock(unique_lock&& u) noexcept; unique_lock& operator=(unique_lock&& u) noexcept; void lock(); bool try_lock(); template bool try_lock_for(const chrono::duration& rel_time); template bool try_lock_until(const chrono::time_point& abs_time); void unlock(); void swap(unique_lock& u) noexcept; mutex_type* release() noexcept; bool owns_lock() const noexcept; explicit operator bool () const noexcept; mutex_type* mutex() const noexcept; }; template void swap(unique_lock& x, unique_lock& y) noexcept; template int try_lock(L1&, L2&, L3&...); template void lock(L1&, L2&, L3&...); struct once_flag { constexpr once_flag() noexcept; once_flag(const once_flag&) = delete; once_flag& operator=(const once_flag&) = delete; }; template void call_once(once_flag& flag, Callable&& func, Args&&... args); } // std */ #include <__config> #include <__mutex_base> #include #ifndef _LIBCPP_HAS_NO_VARIADICS #include #endif #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS recursive_mutex { pthread_mutex_t __m_; public: recursive_mutex(); ~recursive_mutex(); private: recursive_mutex(const recursive_mutex&); // = delete; recursive_mutex& operator=(const recursive_mutex&); // = delete; public: void lock(); bool try_lock() _NOEXCEPT; void unlock() _NOEXCEPT; typedef pthread_mutex_t* native_handle_type; _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;} }; class _LIBCPP_TYPE_VIS timed_mutex { mutex __m_; condition_variable __cv_; bool __locked_; public: timed_mutex(); ~timed_mutex(); private: timed_mutex(const timed_mutex&); // = delete; timed_mutex& operator=(const timed_mutex&); // = delete; public: void lock(); bool try_lock() _NOEXCEPT; template _LIBCPP_INLINE_VISIBILITY bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {return try_lock_until(chrono::steady_clock::now() + __d);} template bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); void unlock() _NOEXCEPT; }; template bool timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { using namespace chrono; unique_lock __lk(__m_); bool no_timeout = _Clock::now() < __t; while (no_timeout && __locked_) no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout; if (!__locked_) { __locked_ = true; return true; } return false; } class _LIBCPP_TYPE_VIS recursive_timed_mutex { mutex __m_; condition_variable __cv_; size_t __count_; pthread_t __id_; public: recursive_timed_mutex(); ~recursive_timed_mutex(); private: recursive_timed_mutex(const recursive_timed_mutex&); // = delete; recursive_timed_mutex& operator=(const recursive_timed_mutex&); // = delete; public: void lock(); bool try_lock() _NOEXCEPT; template _LIBCPP_INLINE_VISIBILITY bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {return try_lock_until(chrono::steady_clock::now() + __d);} template bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); void unlock() _NOEXCEPT; }; template bool recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { using namespace chrono; pthread_t __id = pthread_self(); unique_lock lk(__m_); if (pthread_equal(__id, __id_)) { if (__count_ == numeric_limits::max()) return false; ++__count_; return true; } bool no_timeout = _Clock::now() < __t; while (no_timeout && __count_ != 0) no_timeout = __cv_.wait_until(lk, __t) == cv_status::no_timeout; if (__count_ == 0) { __count_ = 1; __id_ = __id; return true; } return false; } template int try_lock(_L0& __l0, _L1& __l1) { unique_lock<_L0> __u0(__l0, try_to_lock); if (__u0.owns_lock()) { if (__l1.try_lock()) { __u0.release(); return -1; } else return 1; } return 0; } #ifndef _LIBCPP_HAS_NO_VARIADICS template int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { int __r = 0; unique_lock<_L0> __u0(__l0, try_to_lock); if (__u0.owns_lock()) { __r = try_lock(__l1, __l2, __l3...); if (__r == -1) __u0.release(); else ++__r; } return __r; } #endif // _LIBCPP_HAS_NO_VARIADICS template void lock(_L0& __l0, _L1& __l1) { while (true) { { unique_lock<_L0> __u0(__l0); if (__l1.try_lock()) { __u0.release(); break; } } sched_yield(); { unique_lock<_L1> __u1(__l1); if (__l0.try_lock()) { __u1.release(); break; } } sched_yield(); } } #ifndef _LIBCPP_HAS_NO_VARIADICS template void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3) { while (true) { switch (__i) { case 0: { unique_lock<_L0> __u0(__l0); __i = try_lock(__l1, __l2, __l3...); if (__i == -1) { __u0.release(); return; } } ++__i; sched_yield(); break; case 1: { unique_lock<_L1> __u1(__l1); __i = try_lock(__l2, __l3..., __l0); if (__i == -1) { __u1.release(); return; } } if (__i == sizeof...(_L3) + 1) __i = 0; else __i += 2; sched_yield(); break; default: __lock_first(__i - 2, __l2, __l3..., __l0, __l1); return; } } } template inline _LIBCPP_INLINE_VISIBILITY void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3) { __lock_first(0, __l0, __l1, __l2, __l3...); } #endif // _LIBCPP_HAS_NO_VARIADICS struct _LIBCPP_TYPE_VIS once_flag; #ifndef _LIBCPP_HAS_NO_VARIADICS template _LIBCPP_INLINE_VISIBILITY void call_once(once_flag&, _Callable&&, _Args&&...); #else // _LIBCPP_HAS_NO_VARIADICS template _LIBCPP_INLINE_VISIBILITY void call_once(once_flag&, _Callable); #endif // _LIBCPP_HAS_NO_VARIADICS struct _LIBCPP_TYPE_VIS_ONLY once_flag { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(0) {} private: once_flag(const once_flag&); // = delete; once_flag& operator=(const once_flag&); // = delete; unsigned long __state_; #ifndef _LIBCPP_HAS_NO_VARIADICS template friend void call_once(once_flag&, _Callable&&, _Args&&...); #else // _LIBCPP_HAS_NO_VARIADICS template friend void call_once(once_flag&, _Callable); #endif // _LIBCPP_HAS_NO_VARIADICS }; #ifndef _LIBCPP_HAS_NO_VARIADICS template class __call_once_param { _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 _LIBCPP_INLINE_VISIBILITY void operator()() { typedef typename __make_tuple_indices::value, 1>::type _Index; __execute(_Index()); } private: template _LIBCPP_INLINE_VISIBILITY void __execute(__tuple_indices<_Indices...>) { __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...); } }; #else template class __call_once_param { _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 _LIBCPP_INLINE_VISIBILITY void operator()() { __f_(); } }; #endif template void __call_once_proxy(void* __vp) { __call_once_param<_Fp>* __p = static_cast<__call_once_param<_Fp>*>(__vp); (*__p)(); } _LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*)); #ifndef _LIBCPP_HAS_NO_VARIADICS template inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) { if (__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))...)); __call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>); } } #else // _LIBCPP_HAS_NO_VARIADICS template inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, _Callable __func) { if (__flag.__state_ != ~0ul) { __call_once_param<_Callable> __p(__func); __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); } } #endif // _LIBCPP_HAS_NO_VARIADICS _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_MUTEX libcxx/include/ios0000644000175000017500000006040612266757731015417 0ustar sylvestresylvestre// -*- C++ -*- //===---------------------------- ios -------------------------------------===// // // The 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_IOS #define _LIBCPP_IOS /* ios synopsis #include namespace std { typedef OFF_T streamoff; typedef SZ_T streamsize; template class fpos; class ios_base { public: class failure; typedef T1 fmtflags; static constexpr fmtflags boolalpha; static constexpr fmtflags dec; static constexpr fmtflags fixed; static constexpr fmtflags hex; static constexpr fmtflags internal; static constexpr fmtflags left; static constexpr fmtflags oct; static constexpr fmtflags right; static constexpr fmtflags scientific; static constexpr fmtflags showbase; static constexpr fmtflags showpoint; static constexpr fmtflags showpos; static constexpr fmtflags skipws; static constexpr fmtflags unitbuf; static constexpr fmtflags uppercase; static constexpr fmtflags adjustfield; static constexpr fmtflags basefield; static constexpr fmtflags floatfield; typedef T2 iostate; static constexpr iostate badbit; static constexpr iostate eofbit; static constexpr iostate failbit; static constexpr iostate goodbit; typedef T3 openmode; static constexpr openmode app; static constexpr openmode ate; static constexpr openmode binary; static constexpr openmode in; static constexpr openmode out; static constexpr openmode trunc; typedef T4 seekdir; static constexpr seekdir beg; static constexpr seekdir cur; static constexpr seekdir end; class Init; // 27.5.2.2 fmtflags state: fmtflags flags() const; fmtflags flags(fmtflags fmtfl); fmtflags setf(fmtflags fmtfl); fmtflags setf(fmtflags fmtfl, fmtflags mask); void unsetf(fmtflags mask); streamsize precision() const; streamsize precision(streamsize prec); streamsize width() const; streamsize width(streamsize wide); // 27.5.2.3 locales: locale imbue(const locale& loc); locale getloc() const; // 27.5.2.5 storage: static int xalloc(); long& iword(int index); void*& pword(int index); // destructor virtual ~ios_base(); // 27.5.2.6 callbacks; enum event { erase_event, imbue_event, copyfmt_event }; typedef void (*event_callback)(event, ios_base&, int index); void register_callback(event_callback fn, int index); ios_base(const ios_base&) = delete; ios_base& operator=(const ios_base&) = delete; static bool sync_with_stdio(bool sync = true); protected: ios_base(); }; template > class basic_ios : public ios_base { public: // types: 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; operator unspecified-bool-type() const; bool operator!() const; iostate rdstate() const; void clear(iostate state = goodbit); void setstate(iostate state); bool good() const; bool eof() const; bool fail() const; bool bad() const; iostate exceptions() const; void exceptions(iostate except); // 27.5.4.1 Constructor/destructor: explicit basic_ios(basic_streambuf* sb); virtual ~basic_ios(); // 27.5.4.2 Members: basic_ostream* tie() const; basic_ostream* tie(basic_ostream* tiestr); basic_streambuf* rdbuf() const; basic_streambuf* rdbuf(basic_streambuf* sb); basic_ios& copyfmt(const basic_ios& rhs); char_type fill() const; char_type fill(char_type ch); locale imbue(const locale& loc); char narrow(char_type c, char dfault) const; char_type widen(char c) const; basic_ios(const basic_ios& ) = delete; basic_ios& operator=(const basic_ios&) = delete; protected: basic_ios(); void init(basic_streambuf* sb); void move(basic_ios& rhs); void swap(basic_ios& rhs) noexcept; void set_rdbuf(basic_streambuf* sb); }; // 27.5.5, manipulators: ios_base& boolalpha (ios_base& str); ios_base& noboolalpha(ios_base& str); ios_base& showbase (ios_base& str); ios_base& noshowbase (ios_base& str); ios_base& showpoint (ios_base& str); ios_base& noshowpoint(ios_base& str); ios_base& showpos (ios_base& str); ios_base& noshowpos (ios_base& str); ios_base& skipws (ios_base& str); ios_base& noskipws (ios_base& str); ios_base& uppercase (ios_base& str); ios_base& nouppercase(ios_base& str); ios_base& unitbuf (ios_base& str); ios_base& nounitbuf (ios_base& str); // 27.5.5.2 adjustfield: ios_base& internal (ios_base& str); ios_base& left (ios_base& str); ios_base& right (ios_base& str); // 27.5.5.3 basefield: ios_base& dec (ios_base& str); ios_base& hex (ios_base& str); ios_base& oct (ios_base& str); // 27.5.5.4 floatfield: ios_base& fixed (ios_base& str); ios_base& scientific (ios_base& str); ios_base& hexfloat (ios_base& str); ios_base& defaultfloat(ios_base& str); // 27.5.5.5 error reporting: enum class io_errc { stream = 1 }; concept_map ErrorCodeEnum { }; error_code make_error_code(io_errc e) noexcept; error_condition make_error_condition(io_errc e) noexcept; storage-class-specifier const error_category& iostream_category() noexcept; } // std */ #include <__config> #include #include <__locale> #include #if __has_feature(cxx_atomic) #include // for __xindex_ #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD typedef ptrdiff_t streamsize; class _LIBCPP_TYPE_VIS ios_base { public: class _LIBCPP_TYPE_VIS failure; typedef unsigned int fmtflags; static const fmtflags boolalpha = 0x0001; static const fmtflags dec = 0x0002; static const fmtflags fixed = 0x0004; static const fmtflags hex = 0x0008; static const fmtflags internal = 0x0010; static const fmtflags left = 0x0020; static const fmtflags oct = 0x0040; static const fmtflags right = 0x0080; static const fmtflags scientific = 0x0100; static const fmtflags showbase = 0x0200; static const fmtflags showpoint = 0x0400; static const fmtflags showpos = 0x0800; static const fmtflags skipws = 0x1000; static const fmtflags unitbuf = 0x2000; static const fmtflags uppercase = 0x4000; static const fmtflags adjustfield = left | right | internal; static const fmtflags basefield = dec | oct | hex; static const fmtflags floatfield = scientific | fixed; typedef unsigned int iostate; typedef iostate io_state; static const iostate badbit = 0x1; static const iostate eofbit = 0x2; static const iostate failbit = 0x4; static const iostate goodbit = 0x0; typedef unsigned int openmode; typedef openmode open_mode; static const openmode app = 0x01; static const openmode ate = 0x02; static const openmode binary = 0x04; static const openmode in = 0x08; static const openmode out = 0x10; static const openmode trunc = 0x20; enum seekdir {beg, cur, end}; typedef seekdir seek_dir; typedef _VSTD::streamoff streamoff; typedef _VSTD::streampos streampos; class _LIBCPP_TYPE_VIS Init; // 27.5.2.2 fmtflags state: _LIBCPP_INLINE_VISIBILITY fmtflags flags() const; _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); _LIBCPP_INLINE_VISIBILITY streamsize precision() const; _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); _LIBCPP_INLINE_VISIBILITY streamsize width() const; _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); // 27.5.2.3 locales: locale imbue(const locale& __loc); locale getloc() const; // 27.5.2.5 storage: static int xalloc(); long& iword(int __index); void*& pword(int __index); // destructor virtual ~ios_base(); // 27.5.2.6 callbacks; enum event { erase_event, imbue_event, copyfmt_event }; typedef void (*event_callback)(event, ios_base&, int __index); void register_callback(event_callback __fn, int __index); private: ios_base(const ios_base&); // = delete; ios_base& operator=(const ios_base&); // = delete; public: static bool sync_with_stdio(bool __sync = true); _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; void clear(iostate __state = goodbit); _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); _LIBCPP_INLINE_VISIBILITY bool good() const; _LIBCPP_INLINE_VISIBILITY bool eof() const; _LIBCPP_INLINE_VISIBILITY bool fail() const; _LIBCPP_INLINE_VISIBILITY bool bad() const; _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); void __set_badbit_and_consider_rethrow(); void __set_failbit_and_consider_rethrow(); protected: _LIBCPP_INLINE_VISIBILITY ios_base() {// purposefully does no initialization } void init(void* __sb); _LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;} _LIBCPP_ALWAYS_INLINE void rdbuf(void* __sb) { __rdbuf_ = __sb; clear(); } void __call_callbacks(event); void copyfmt(const ios_base&); void move(ios_base&); void swap(ios_base&) _NOEXCEPT; _LIBCPP_ALWAYS_INLINE void set_rdbuf(void* __sb) { __rdbuf_ = __sb; } private: // All data members must be scalars fmtflags __fmtflags_; streamsize __precision_; streamsize __width_; iostate __rdstate_; iostate __exceptions_; void* __rdbuf_; void* __loc_; event_callback* __fn_; int* __index_; size_t __event_size_; size_t __event_cap_; #if __has_feature(cxx_atomic) static atomic __xindex_; #else static int __xindex_; #endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; void** __parray_; size_t __parray_size_; size_t __parray_cap_; }; //enum class io_errc _LIBCPP_DECLARE_STRONG_ENUM(io_errc) { stream = 1 }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) template <> struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public true_type { }; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public true_type { }; #endif _LIBCPP_FUNC_VIS const error_category& iostream_category() _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY error_code make_error_code(io_errc __e) _NOEXCEPT { return error_code(static_cast(__e), iostream_category()); } inline _LIBCPP_INLINE_VISIBILITY error_condition make_error_condition(io_errc __e) _NOEXCEPT { return error_condition(static_cast(__e), iostream_category()); } class _LIBCPP_EXCEPTION_ABI ios_base::failure : public system_error { public: explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); virtual ~failure() throw(); }; class _LIBCPP_TYPE_VIS ios_base::Init { public: Init(); ~Init(); }; // fmtflags inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::flags() const { return __fmtflags_; } inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::flags(fmtflags __fmtfl) { fmtflags __r = __fmtflags_; __fmtflags_ = __fmtfl; return __r; } inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::setf(fmtflags __fmtfl) { fmtflags __r = __fmtflags_; __fmtflags_ |= __fmtfl; return __r; } inline _LIBCPP_INLINE_VISIBILITY void ios_base::unsetf(fmtflags __mask) { __fmtflags_ &= ~__mask; } inline _LIBCPP_INLINE_VISIBILITY ios_base::fmtflags ios_base::setf(fmtflags __fmtfl, fmtflags __mask) { fmtflags __r = __fmtflags_; unsetf(__mask); __fmtflags_ |= __fmtfl & __mask; return __r; } // precision inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::precision() const { return __precision_; } inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::precision(streamsize __prec) { streamsize __r = __precision_; __precision_ = __prec; return __r; } // width inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::width() const { return __width_; } inline _LIBCPP_INLINE_VISIBILITY streamsize ios_base::width(streamsize __wide) { streamsize __r = __width_; __width_ = __wide; return __r; } // iostate inline _LIBCPP_INLINE_VISIBILITY ios_base::iostate ios_base::rdstate() const { return __rdstate_; } inline _LIBCPP_INLINE_VISIBILITY void ios_base::setstate(iostate __state) { clear(__rdstate_ | __state); } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::good() const { return __rdstate_ == 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::eof() const { return (__rdstate_ & eofbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::fail() const { return (__rdstate_ & (failbit | badbit)) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::bad() const { return (__rdstate_ & badbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY ios_base::iostate ios_base::exceptions() const { return __exceptions_; } inline _LIBCPP_INLINE_VISIBILITY void ios_base::exceptions(iostate __iostate) { __exceptions_ = __iostate; clear(__rdstate_); } template class _LIBCPP_TYPE_VIS_ONLY basic_ios : public ios_base { 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; _LIBCPP_ALWAYS_INLINE _LIBCPP_EXPLICIT operator bool() const {return !fail();} _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);} _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);} _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();} _LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();} _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();} _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} _LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} // 27.5.4.1 Constructor/destructor: _LIBCPP_INLINE_VISIBILITY explicit basic_ios(basic_streambuf* __sb); virtual ~basic_ios(); // 27.5.4.2 Members: _LIBCPP_INLINE_VISIBILITY basic_ostream* tie() const; _LIBCPP_INLINE_VISIBILITY basic_ostream* tie(basic_ostream* __tiestr); _LIBCPP_INLINE_VISIBILITY basic_streambuf* rdbuf() const; _LIBCPP_INLINE_VISIBILITY basic_streambuf* rdbuf(basic_streambuf* __sb); basic_ios& copyfmt(const basic_ios& __rhs); _LIBCPP_INLINE_VISIBILITY char_type fill() const; _LIBCPP_INLINE_VISIBILITY char_type fill(char_type __ch); _LIBCPP_INLINE_VISIBILITY locale imbue(const locale& __loc); _LIBCPP_INLINE_VISIBILITY char narrow(char_type __c, char __dfault) const; _LIBCPP_INLINE_VISIBILITY char_type widen(char __c) const; protected: _LIBCPP_ALWAYS_INLINE basic_ios() {// purposefully does no initialization } _LIBCPP_INLINE_VISIBILITY void init(basic_streambuf* __sb); _LIBCPP_INLINE_VISIBILITY void move(basic_ios& __rhs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_ALWAYS_INLINE void move(basic_ios&& __rhs) {move(__rhs);} #endif _LIBCPP_INLINE_VISIBILITY void swap(basic_ios& __rhs) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void set_rdbuf(basic_streambuf* __sb); private: basic_ostream* __tie_; mutable int_type __fill_; }; template inline _LIBCPP_INLINE_VISIBILITY basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf* __sb) { init(__sb); } template basic_ios<_CharT, _Traits>::~basic_ios() { } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::init(basic_streambuf* __sb) { ios_base::init(__sb); __tie_ = 0; __fill_ = traits_type::eof(); } template inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>* basic_ios<_CharT, _Traits>::tie() const { return __tie_; } template inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>* basic_ios<_CharT, _Traits>::tie(basic_ostream* __tiestr) { basic_ostream* __r = __tie_; __tie_ = __tiestr; return __r; } template inline _LIBCPP_INLINE_VISIBILITY basic_streambuf<_CharT, _Traits>* basic_ios<_CharT, _Traits>::rdbuf() const { return static_cast*>(ios_base::rdbuf()); } template inline _LIBCPP_INLINE_VISIBILITY basic_streambuf<_CharT, _Traits>* basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf* __sb) { basic_streambuf* __r = rdbuf(); ios_base::rdbuf(__sb); return __r; } template inline _LIBCPP_INLINE_VISIBILITY locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) { locale __r = getloc(); ios_base::imbue(__loc); if (rdbuf()) rdbuf()->pubimbue(__loc); return __r; } template inline _LIBCPP_INLINE_VISIBILITY char basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const { return use_facet >(getloc()).narrow(__c, __dfault); } template inline _LIBCPP_INLINE_VISIBILITY _CharT basic_ios<_CharT, _Traits>::widen(char __c) const { return use_facet >(getloc()).widen(__c); } template inline _LIBCPP_INLINE_VISIBILITY _CharT basic_ios<_CharT, _Traits>::fill() const { if (traits_type::eq_int_type(traits_type::eof(), __fill_)) __fill_ = widen(' '); return __fill_; } template inline _LIBCPP_INLINE_VISIBILITY _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) { char_type __r = __fill_; __fill_ = __ch; return __r; } template basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) { if (this != &__rhs) { __call_callbacks(erase_event); ios_base::copyfmt(__rhs); __tie_ = __rhs.__tie_; __fill_ = __rhs.__fill_; __call_callbacks(copyfmt_event); exceptions(__rhs.exceptions()); } return *this; } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::move(basic_ios& __rhs) { ios_base::move(__rhs); __tie_ = __rhs.__tie_; __rhs.__tie_ = 0; __fill_ = __rhs.__fill_; } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT { ios_base::swap(__rhs); _VSTD::swap(__tie_, __rhs.__tie_); _VSTD::swap(__fill_, __rhs.__fill_); } template inline _LIBCPP_INLINE_VISIBILITY void basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf* __sb) { ios_base::set_rdbuf(__sb); } inline _LIBCPP_INLINE_VISIBILITY ios_base& boolalpha(ios_base& __str) { __str.setf(ios_base::boolalpha); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noboolalpha(ios_base& __str) { __str.unsetf(ios_base::boolalpha); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& showbase(ios_base& __str) { __str.setf(ios_base::showbase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noshowbase(ios_base& __str) { __str.unsetf(ios_base::showbase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& showpoint(ios_base& __str) { __str.setf(ios_base::showpoint); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noshowpoint(ios_base& __str) { __str.unsetf(ios_base::showpoint); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& showpos(ios_base& __str) { __str.setf(ios_base::showpos); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noshowpos(ios_base& __str) { __str.unsetf(ios_base::showpos); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& skipws(ios_base& __str) { __str.setf(ios_base::skipws); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& noskipws(ios_base& __str) { __str.unsetf(ios_base::skipws); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& uppercase(ios_base& __str) { __str.setf(ios_base::uppercase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& nouppercase(ios_base& __str) { __str.unsetf(ios_base::uppercase); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& unitbuf(ios_base& __str) { __str.setf(ios_base::unitbuf); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& nounitbuf(ios_base& __str) { __str.unsetf(ios_base::unitbuf); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& internal(ios_base& __str) { __str.setf(ios_base::internal, ios_base::adjustfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& left(ios_base& __str) { __str.setf(ios_base::left, ios_base::adjustfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& right(ios_base& __str) { __str.setf(ios_base::right, ios_base::adjustfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& dec(ios_base& __str) { __str.setf(ios_base::dec, ios_base::basefield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& hex(ios_base& __str) { __str.setf(ios_base::hex, ios_base::basefield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& oct(ios_base& __str) { __str.setf(ios_base::oct, ios_base::basefield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& fixed(ios_base& __str) { __str.setf(ios_base::fixed, ios_base::floatfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& scientific(ios_base& __str) { __str.setf(ios_base::scientific, ios_base::floatfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& hexfloat(ios_base& __str) { __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); return __str; } inline _LIBCPP_INLINE_VISIBILITY ios_base& defaultfloat(ios_base& __str) { __str.unsetf(ios_base::floatfield); return __str; } template class __save_flags { typedef basic_ios<_CharT, _Traits> __stream_type; typedef typename __stream_type::fmtflags fmtflags; __stream_type& __stream_; fmtflags __fmtflags_; _CharT __fill_; __save_flags(const __save_flags&); __save_flags& operator=(const __save_flags&); public: _LIBCPP_INLINE_VISIBILITY explicit __save_flags(__stream_type& __stream) : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {} _LIBCPP_INLINE_VISIBILITY ~__save_flags() { __stream_.flags(__fmtflags_); __stream_.fill(__fill_); } }; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_IOS libcxx/include/condition_variable0000644000175000017500000001630412266757730020455 0ustar sylvestresylvestre// -*- C++ -*- //===---------------------- condition_variable ----------------------------===// // // The 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_CONDITION_VARIABLE #define _LIBCPP_CONDITION_VARIABLE /* condition_variable synopsis namespace std { enum class cv_status { no_timeout, timeout }; class condition_variable { public: condition_variable(); ~condition_variable(); condition_variable(const condition_variable&) = delete; condition_variable& operator=(const condition_variable&) = delete; void notify_one() noexcept; void notify_all() noexcept; void wait(unique_lock& lock); template void wait(unique_lock& lock, Predicate pred); template cv_status wait_until(unique_lock& lock, const chrono::time_point& abs_time); template bool wait_until(unique_lock& lock, const chrono::time_point& abs_time, Predicate pred); template cv_status wait_for(unique_lock& lock, const chrono::duration& rel_time); template bool wait_for(unique_lock& lock, const chrono::duration& rel_time, Predicate pred); typedef pthread_cond_t* native_handle_type; native_handle_type native_handle(); }; void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk); class condition_variable_any { public: condition_variable_any(); ~condition_variable_any(); condition_variable_any(const condition_variable_any&) = delete; condition_variable_any& operator=(const condition_variable_any&) = delete; void notify_one() noexcept; void notify_all() noexcept; template void wait(Lock& lock); template void wait(Lock& lock, Predicate pred); template cv_status wait_until(Lock& lock, const chrono::time_point& abs_time); template bool wait_until(Lock& lock, const chrono::time_point& abs_time, Predicate pred); template cv_status wait_for(Lock& lock, const chrono::duration& rel_time); template bool wait_for(Lock& lock, const chrono::duration& rel_time, Predicate pred); }; } // std */ #include <__config> #include <__mutex_base> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS condition_variable_any { condition_variable __cv_; shared_ptr __mut_; public: condition_variable_any(); void notify_one() _NOEXCEPT; void notify_all() _NOEXCEPT; template void wait(_Lock& __lock); template void wait(_Lock& __lock, _Predicate __pred); template cv_status wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t); template bool wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred); template cv_status wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d); template bool wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); }; inline _LIBCPP_INLINE_VISIBILITY condition_variable_any::condition_variable_any() : __mut_(make_shared()) {} inline _LIBCPP_INLINE_VISIBILITY void condition_variable_any::notify_one() _NOEXCEPT { {lock_guard __lx(*__mut_);} __cv_.notify_one(); } inline _LIBCPP_INLINE_VISIBILITY void condition_variable_any::notify_all() _NOEXCEPT { {lock_guard __lx(*__mut_);} __cv_.notify_all(); } struct __lock_external { template void operator()(_Lock* __m) {__m->lock();} }; template void condition_variable_any::wait(_Lock& __lock) { shared_ptr __mut = __mut_; unique_lock __lk(*__mut); __lock.unlock(); unique_ptr<_Lock, __lock_external> __lxx(&__lock); lock_guard > __lx(__lk, adopt_lock); __cv_.wait(__lk); } // __mut_.unlock(), __lock.lock() template inline _LIBCPP_INLINE_VISIBILITY void condition_variable_any::wait(_Lock& __lock, _Predicate __pred) { while (!__pred()) wait(__lock); } template cv_status condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t) { shared_ptr __mut = __mut_; unique_lock __lk(*__mut); __lock.unlock(); unique_ptr<_Lock, __lock_external> __lxx(&__lock); lock_guard > __lx(__lk, adopt_lock); return __cv_.wait_until(__lk, __t); } // __mut_.unlock(), __lock.lock() template inline _LIBCPP_INLINE_VISIBILITY bool condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) { while (!__pred()) if (wait_until(__lock, __t) == cv_status::timeout) return __pred(); return true; } template inline _LIBCPP_INLINE_VISIBILITY cv_status condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d) { return wait_until(__lock, chrono::steady_clock::now() + __d); } template inline _LIBCPP_INLINE_VISIBILITY bool condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred) { return wait_until(__lock, chrono::steady_clock::now() + __d, _VSTD::move(__pred)); } _LIBCPP_FUNC_VIS void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk); _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CONDITION_VARIABLE libcxx/include/cwctype0000644000175000017500000001407512266757731016304 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- cwctype ----------------------------------===// // // The 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_CWCTYPE #define _LIBCPP_CWCTYPE /* cwctype synopsis Macros: WEOF namespace std { Types: wint_t wctrans_t wctype_t int iswalnum(wint_t wc); int iswalpha(wint_t wc); int iswblank(wint_t wc); // C99 int iswcntrl(wint_t wc); int iswdigit(wint_t wc); int iswgraph(wint_t wc); int iswlower(wint_t wc); int iswprint(wint_t wc); int iswpunct(wint_t wc); int iswspace(wint_t wc); int iswupper(wint_t wc); int iswxdigit(wint_t wc); int iswctype(wint_t wc, wctype_t desc); wctype_t wctype(const char* property); wint_t towlower(wint_t wc); wint_t towupper(wint_t wc); wint_t towctrans(wint_t wc, wctrans_t desc); wctrans_t wctrans(const char* property); } // std */ #include <__config> #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD using ::wint_t; using ::wctrans_t; using ::wctype_t; #ifdef iswalnum inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalnum(wint_t __wc) {return iswalnum(__wc);} #undef iswalnum inline _LIBCPP_INLINE_VISIBILITY int iswalnum(wint_t __wc) {return __libcpp_iswalnum(__wc);} #else // iswalnum using ::iswalnum; #endif #ifdef iswalpha inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalpha(wint_t __wc) {return iswalpha(__wc);} #undef iswalpha inline _LIBCPP_INLINE_VISIBILITY int iswalpha(wint_t __wc) {return __libcpp_iswalpha(__wc);} #else // iswalpha using ::iswalpha; #endif #ifdef iswblank inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswblank(wint_t __wc) {return iswblank(__wc);} #undef iswblank inline _LIBCPP_INLINE_VISIBILITY int iswblank(wint_t __wc) {return __libcpp_iswblank(__wc);} #else // iswblank using ::iswblank; #endif #ifdef iswcntrl inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswcntrl(wint_t __wc) {return iswcntrl(__wc);} #undef iswcntrl inline _LIBCPP_INLINE_VISIBILITY int iswcntrl(wint_t __wc) {return __libcpp_iswcntrl(__wc);} #else // iswcntrl using ::iswcntrl; #endif #ifdef iswdigit inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswdigit(wint_t __wc) {return iswdigit(__wc);} #undef iswdigit inline _LIBCPP_INLINE_VISIBILITY int iswdigit(wint_t __wc) {return __libcpp_iswdigit(__wc);} #else // iswdigit using ::iswdigit; #endif #ifdef iswgraph inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswgraph(wint_t __wc) {return iswgraph(__wc);} #undef iswgraph inline _LIBCPP_INLINE_VISIBILITY int iswgraph(wint_t __wc) {return __libcpp_iswgraph(__wc);} #else // iswgraph using ::iswgraph; #endif #ifdef iswlower inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswlower(wint_t __wc) {return iswlower(__wc);} #undef iswlower inline _LIBCPP_INLINE_VISIBILITY int iswlower(wint_t __wc) {return __libcpp_iswlower(__wc);} #else // iswlower using ::iswlower; #endif #ifdef iswprint inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswprint(wint_t __wc) {return iswprint(__wc);} #undef iswprint inline _LIBCPP_INLINE_VISIBILITY int iswprint(wint_t __wc) {return __libcpp_iswprint(__wc);} #else // iswprint using ::iswprint; #endif #ifdef iswpunct inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswpunct(wint_t __wc) {return iswpunct(__wc);} #undef iswpunct inline _LIBCPP_INLINE_VISIBILITY int iswpunct(wint_t __wc) {return __libcpp_iswpunct(__wc);} #else // iswpunct using ::iswpunct; #endif #ifdef iswspace inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswspace(wint_t __wc) {return iswspace(__wc);} #undef iswspace inline _LIBCPP_INLINE_VISIBILITY int iswspace(wint_t __wc) {return __libcpp_iswspace(__wc);} #else // iswspace using ::iswspace; #endif #ifdef iswupper inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswupper(wint_t __wc) {return iswupper(__wc);} #undef iswupper inline _LIBCPP_INLINE_VISIBILITY int iswupper(wint_t __wc) {return __libcpp_iswupper(__wc);} #else // iswupper using ::iswupper; #endif #ifdef iswxdigit inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswxdigit(wint_t __wc) {return iswxdigit(__wc);} #undef iswxdigit inline _LIBCPP_INLINE_VISIBILITY int iswxdigit(wint_t __wc) {return __libcpp_iswxdigit(__wc);} #else // iswxdigit using ::iswxdigit; #endif #ifdef iswctype inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswctype(wint_t __w, wctype_t __d) {return iswctype(__w, __d);} #undef iswctype inline _LIBCPP_INLINE_VISIBILITY int iswctype(wint_t __w, wctype_t __d) {return __libcpp_iswctype(__w, __d);} #else // iswctype using ::iswctype; #endif #ifdef wctype inline _LIBCPP_INLINE_VISIBILITY wctype_t __libcpp_wctype(const char* __p) {return wctype(__p);} #undef wctype inline _LIBCPP_INLINE_VISIBILITY wctype_t wctype(const char* __p) {return __libcpp_wctype(__p);} #else // wctype using ::wctype; #endif #ifdef towlower inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towlower(wint_t __wc) {return towlower(__wc);} #undef towlower inline _LIBCPP_INLINE_VISIBILITY wint_t towlower(wint_t __wc) {return __libcpp_towlower(__wc);} #else // towlower using ::towlower; #endif #ifdef towupper inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towupper(wint_t __wc) {return towupper(__wc);} #undef towupper inline _LIBCPP_INLINE_VISIBILITY wint_t towupper(wint_t __wc) {return __libcpp_towupper(__wc);} #else // towupper using ::towupper; #endif #ifdef towctrans inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towctrans(wint_t __wc, wctype_t __d) {return towctrans(__wc, __d);} #undef towctrans inline _LIBCPP_INLINE_VISIBILITY wint_t towctrans(wint_t __wc, wctype_t __d) {return __libcpp_towctrans(__wc, __d);} #else // towctrans using ::towctrans; #endif #ifdef wctrans inline _LIBCPP_INLINE_VISIBILITY wctrans_t __libcpp_wctrans(const char* __p) {return wctrans(__p);} #undef wctrans inline _LIBCPP_INLINE_VISIBILITY wctrans_t wctrans(const char* __p) {return __libcpp_wctrans(__p);} #else // wctrans using ::wctrans; #endif _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CWCTYPE libcxx/include/ctime0000644000175000017500000000251512266757730015722 0ustar sylvestresylvestre// -*- C++ -*- //===---------------------------- ctime -----------------------------------===// // // The 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_CTIME #define _LIBCPP_CTIME /* ctime synopsis Macros: NULL CLOCKS_PER_SEC namespace std { Types: clock_t size_t time_t tm clock_t clock(); double difftime(time_t time1, time_t time0); time_t mktime(tm* timeptr); time_t time(time_t* timer); char* asctime(const tm* timeptr); char* ctime(const time_t* timer); tm* gmtime(const time_t* timer); tm* localtime(const time_t* timer); size_t strftime(char* restrict s, size_t maxsize, const char* restrict format, const tm* restrict timeptr); } // std */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD using ::clock_t; using ::size_t; using ::time_t; using ::tm; using ::clock; using ::difftime; using ::mktime; using ::time; using ::asctime; using ::ctime; using ::gmtime; using ::localtime; using ::strftime; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CTIME libcxx/include/algorithm0000644000175000017500000060033112266757731016610 0ustar sylvestresylvestre// -*- 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_ALGORITHM #define _LIBCPP_ALGORITHM /* algorithm synopsis #include namespace std { template bool all_of(InputIterator first, InputIterator last, Predicate pred); template bool any_of(InputIterator first, InputIterator last, Predicate pred); template bool none_of(InputIterator first, InputIterator last, Predicate pred); template Function for_each(InputIterator first, InputIterator last, Function f); template InputIterator find(InputIterator first, InputIterator last, const T& value); template InputIterator find_if(InputIterator first, InputIterator last, Predicate pred); template InputIterator find_if_not(InputIterator first, InputIterator last, Predicate pred); template ForwardIterator1 find_end(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template ForwardIterator1 find_end(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); template ForwardIterator1 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template ForwardIterator1 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); template ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last); template ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); template typename iterator_traits::difference_type count(InputIterator first, InputIterator last, const T& value); template typename iterator_traits::difference_type count_if(InputIterator first, InputIterator last, Predicate pred); template pair mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); template pair mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); // **C++14** template pair mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); template pair mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred); // **C++14** template bool equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); template bool equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); // **C++14** template bool equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); template bool equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred); // **C++14** template bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); template bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); // **C++14** template bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, BinaryPredicate pred); template bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); // **C++14** template ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); template ForwardIterator search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value); template ForwardIterator search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value, BinaryPredicate pred); template OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result); template OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred); template OutputIterator copy_n(InputIterator first, Size n, OutputIterator result); template BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result); template ForwardIterator2 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); template void iter_swap(ForwardIterator1 a, ForwardIterator2 b); template OutputIterator transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op); template OutputIterator transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation binary_op); template void replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value); template void replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value); template OutputIterator replace_copy(InputIterator first, InputIterator last, OutputIterator result, const T& old_value, const T& new_value); template OutputIterator replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value); template void fill(ForwardIterator first, ForwardIterator last, const T& value); template OutputIterator fill_n(OutputIterator first, Size n, const T& value); template void generate(ForwardIterator first, ForwardIterator last, Generator gen); template OutputIterator generate_n(OutputIterator first, Size n, Generator gen); template ForwardIterator remove(ForwardIterator first, ForwardIterator last, const T& value); template ForwardIterator remove_if(ForwardIterator first, ForwardIterator last, Predicate pred); template OutputIterator remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value); template OutputIterator remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred); template ForwardIterator unique(ForwardIterator first, ForwardIterator last); template ForwardIterator unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); template OutputIterator unique_copy(InputIterator first, InputIterator last, OutputIterator result); template OutputIterator unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred); template void reverse(BidirectionalIterator first, BidirectionalIterator last); template OutputIterator reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result); template ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last); template OutputIterator rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result); template void random_shuffle(RandomAccessIterator first, RandomAccessIterator last); template void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator& rand); template void shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); template bool is_partitioned(InputIterator first, InputIterator last, Predicate pred); template ForwardIterator partition(ForwardIterator first, ForwardIterator last, Predicate pred); template pair partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); template ForwardIterator stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred); template ForwardIterator partition_point(ForwardIterator first, ForwardIterator last, Predicate pred); template bool is_sorted(ForwardIterator first, ForwardIterator last); template bool is_sorted(ForwardIterator first, ForwardIterator last, Compare comp); template ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last); template ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp); template void sort(RandomAccessIterator first, RandomAccessIterator last); template void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template void stable_sort(RandomAccessIterator first, RandomAccessIterator last); template void stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); template void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); template RandomAccessIterator partial_sort_copy(InputIterator first, InputIterator last, RandomAccessIterator result_first, RandomAccessIterator result_last); template RandomAccessIterator partial_sort_copy(InputIterator first, InputIterator last, RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp); template void nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last); template void nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp); template ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& value); template ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& value); template ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template pair equal_range(ForwardIterator first, ForwardIterator last, const T& value); template pair equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template bool binary_search(ForwardIterator first, ForwardIterator last, const T& value); template bool binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); template OutputIterator merge(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template OutputIterator merge(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template void inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last); template void inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp); template bool includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); template bool includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp); template OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result); template OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); template void push_heap(RandomAccessIterator first, RandomAccessIterator last); template void push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template void pop_heap(RandomAccessIterator first, RandomAccessIterator last); template void pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template void make_heap(RandomAccessIterator first, RandomAccessIterator last); template void make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template void sort_heap(RandomAccessIterator first, RandomAccessIterator last); template void sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); template bool is_heap(RandomAccessIterator first, RandomAccessiterator last); template bool is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp); template RandomAccessIterator is_heap_until(RandomAccessIterator first, RandomAccessiterator last); template RandomAccessIterator is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp); template ForwardIterator min_element(ForwardIterator first, ForwardIterator last); template ForwardIterator min_element(ForwardIterator first, ForwardIterator last, Compare comp); template const T& min(const T& a, const T& b); template const T& min(const T& a, const T& b, Compare comp); template T min(initializer_list t); template T min(initializer_list t, Compare comp); template ForwardIterator max_element(ForwardIterator first, ForwardIterator last); template ForwardIterator max_element(ForwardIterator first, ForwardIterator last, Compare comp); template const T& max(const T& a, const T& b); template const T& max(const T& a, const T& b, Compare comp); template T max(initializer_list t); template T max(initializer_list t, Compare comp); template pair minmax_element(ForwardIterator first, ForwardIterator last); template pair minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); template pair minmax(const T& a, const T& b); template pair minmax(const T& a, const T& b, Compare comp); template pair minmax(initializer_list t); template pair minmax(initializer_list t, Compare comp); template bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); template bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp); template bool next_permutation(BidirectionalIterator first, BidirectionalIterator last); template bool next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); template bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last); template bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); } // std */ #include <__config> #include #include #include #include #include #include #include #if defined(__IBMCPP__) #include "support/ibm/support.h" #endif #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include "support/win32/support.h" #endif #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template struct __equal_to { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;} }; template struct __equal_to<_T1, _T1> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} }; template struct __equal_to { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} }; template struct __equal_to<_T1, const _T1> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} }; template struct __less { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;} _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;} }; template struct __less<_T1, _T1> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} }; template struct __less { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} }; template struct __less<_T1, const _T1> { _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} }; template class __negate { private: _Predicate __p_; public: _LIBCPP_INLINE_VISIBILITY __negate() {} _LIBCPP_INLINE_VISIBILITY explicit __negate(_Predicate __p) : __p_(__p) {} template _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x) {return !__p_(__x);} template _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) {return !__p_(__x, __y);} }; #ifdef _LIBCPP_DEBUG template struct __debug_less { _Compare __comp_; __debug_less(_Compare& __c) : __comp_(__c) {} template bool operator()(const _Tp& __x, const _Up& __y) { bool __r = __comp_(__x, __y); if (__r) _LIBCPP_ASSERT(!__comp_(__y, __x), "Comparator does not induce a strict weak ordering"); return __r; } }; #endif // _LIBCPP_DEBUG // Precondition: __x != 0 inline _LIBCPP_INLINE_VISIBILITY unsigned __ctz(unsigned __x) { return static_cast(__builtin_ctz(__x)); } inline _LIBCPP_INLINE_VISIBILITY unsigned long __ctz(unsigned long __x) { return static_cast(__builtin_ctzl(__x)); } inline _LIBCPP_INLINE_VISIBILITY unsigned long long __ctz(unsigned long long __x) { return static_cast(__builtin_ctzll(__x)); } // Precondition: __x != 0 inline _LIBCPP_INLINE_VISIBILITY unsigned __clz(unsigned __x) { return static_cast(__builtin_clz(__x)); } inline _LIBCPP_INLINE_VISIBILITY unsigned long __clz(unsigned long __x) { return static_cast(__builtin_clzl (__x)); } inline _LIBCPP_INLINE_VISIBILITY unsigned long long __clz(unsigned long long __x) { return static_cast(__builtin_clzll(__x)); } inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned __x) {return __builtin_popcount (__x);} inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long __x) {return __builtin_popcountl (__x);} inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {return __builtin_popcountll(__x);} // all_of template inline _LIBCPP_INLINE_VISIBILITY bool all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (!__pred(*__first)) return false; return true; } // any_of template inline _LIBCPP_INLINE_VISIBILITY bool any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (__pred(*__first)) return true; return false; } // none_of template inline _LIBCPP_INLINE_VISIBILITY bool none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (__pred(*__first)) return false; return true; } // for_each template inline _LIBCPP_INLINE_VISIBILITY _Function for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); return _VSTD::move(__f); // explicitly moved for (emulated) C++03 } // find template inline _LIBCPP_INLINE_VISIBILITY _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { for (; __first != __last; ++__first) if (*__first == __value_) break; return __first; } // find_if template inline _LIBCPP_INLINE_VISIBILITY _InputIterator find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (__pred(*__first)) break; return __first; } // find_if_not template inline _LIBCPP_INLINE_VISIBILITY _InputIterator find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (!__pred(*__first)) break; return __first; } // find_end template _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) { // modeled after search algorithm _ForwardIterator1 __r = __last1; // __last1 is the "default" answer if (__first2 == __last2) return __r; while (true) { while (true) { if (__first1 == __last1) // if source exhausted return last correct answer return __r; // (or __last1 if never found) if (__pred(*__first1, *__first2)) break; ++__first1; } // *__first1 matches *__first2, now match elements after here _ForwardIterator1 __m1 = __first1; _ForwardIterator2 __m2 = __first2; while (true) { if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one __r = __first1; ++__first1; break; } if (++__m1 == __last1) // Source exhausted, return last answer return __r; if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first { ++__first1; break; } // else there is a match, check next elements } } } template _BidirectionalIterator1 __find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BinaryPredicate __pred, bidirectional_iterator_tag, bidirectional_iterator_tag) { // modeled after search algorithm (in reverse) if (__first2 == __last2) return __last1; // Everything matches an empty sequence _BidirectionalIterator1 __l1 = __last1; _BidirectionalIterator2 __l2 = __last2; --__l2; while (true) { // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks while (true) { if (__first1 == __l1) // return __last1 if no element matches *__first2 return __last1; if (__pred(*--__l1, *__l2)) break; } // *__l1 matches *__l2, now match elements before here _BidirectionalIterator1 __m1 = __l1; _BidirectionalIterator2 __m2 = __l2; while (true) { if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern) return __m1; if (__m1 == __first1) // Otherwise if source exhaused, pattern not found return __last1; if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1 { break; } // else there is a match, check next elements } } } template _RandomAccessIterator1 __find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) { // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2; if (__len2 == 0) return __last1; typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1; if (__len1 < __len2) return __last1; const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here _RandomAccessIterator1 __l1 = __last1; _RandomAccessIterator2 __l2 = __last2; --__l2; while (true) { while (true) { if (__s == __l1) return __last1; if (__pred(*--__l1, *__l2)) break; } _RandomAccessIterator1 __m1 = __l1; _RandomAccessIterator2 __m2 = __l2; while (true) { if (__m2 == __first2) return __m1; // no need to check range on __m1 because __s guarantees we have enough source if (!__pred(*--__m1, *--__m2)) { break; } } } } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { return _VSTD::__find_end::type> (__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), typename iterator_traits<_ForwardIterator2>::iterator_category()); } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); } // find_first_of template _ForwardIterator1 find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { for (; __first1 != __last1; ++__first1) for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) if (__pred(*__first1, *__j)) return __first1; return __last1; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator1 find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; return _VSTD::find_first_of(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); } // adjacent_find template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { if (__first != __last) { _ForwardIterator __i = __first; while (++__i != __last) { if (__pred(*__first, *__i)) return __first; __first = __i; } } return __last; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type __v; return _VSTD::adjacent_find(__first, __last, __equal_to<__v>()); } // count template inline _LIBCPP_INLINE_VISIBILITY typename iterator_traits<_InputIterator>::difference_type count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { typename iterator_traits<_InputIterator>::difference_type __r(0); for (; __first != __last; ++__first) if (*__first == __value_) ++__r; return __r; } // count_if template inline _LIBCPP_INLINE_VISIBILITY typename iterator_traits<_InputIterator>::difference_type count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { typename iterator_traits<_InputIterator>::difference_type __r(0); for (; __first != __last; ++__first) if (__pred(*__first)) ++__r; return __r; } // mismatch template inline _LIBCPP_INLINE_VISIBILITY pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { for (; __first1 != __last1; ++__first1, ++__first2) if (!__pred(*__first1, *__first2)) break; return pair<_InputIterator1, _InputIterator2>(__first1, __first2); } template inline _LIBCPP_INLINE_VISIBILITY pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { typedef typename iterator_traits<_InputIterator1>::value_type __v1; typedef typename iterator_traits<_InputIterator2>::value_type __v2; return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>()); } #if _LIBCPP_STD_VER > 11 template inline _LIBCPP_INLINE_VISIBILITY pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred) { for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) if (!__pred(*__first1, *__first2)) break; return pair<_InputIterator1, _InputIterator2>(__first1, __first2); } template inline _LIBCPP_INLINE_VISIBILITY pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { typedef typename iterator_traits<_InputIterator1>::value_type __v1; typedef typename iterator_traits<_InputIterator2>::value_type __v2; return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); } #endif // equal template inline _LIBCPP_INLINE_VISIBILITY bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { for (; __first1 != __last1; ++__first1, ++__first2) if (!__pred(*__first1, *__first2)) return false; return true; } template inline _LIBCPP_INLINE_VISIBILITY bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { typedef typename iterator_traits<_InputIterator1>::value_type __v1; typedef typename iterator_traits<_InputIterator2>::value_type __v2; return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>()); } #if _LIBCPP_STD_VER > 11 template inline _LIBCPP_INLINE_VISIBILITY bool __equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred, input_iterator_tag, input_iterator_tag ) { for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) if (!__pred(*__first1, *__first2)) return false; return __first1 == __last1 && __first2 == __last2; } template inline _LIBCPP_INLINE_VISIBILITY bool __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag ) { if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) return false; return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2, typename add_lvalue_reference<_BinaryPredicate>::type> (__first1, __last1, __first2, __pred ); } template inline _LIBCPP_INLINE_VISIBILITY bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred ) { return _VSTD::__equal::type> (__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(), typename iterator_traits<_InputIterator2>::iterator_category()); } template inline _LIBCPP_INLINE_VISIBILITY bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { typedef typename iterator_traits<_InputIterator1>::value_type __v1; typedef typename iterator_traits<_InputIterator2>::value_type __v2; return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(), typename iterator_traits<_InputIterator1>::iterator_category(), typename iterator_traits<_InputIterator2>::iterator_category()); } #endif // is_permutation template bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { // shorten sequences as much as possible by lopping of any equal parts for (; __first1 != __last1; ++__first1, ++__first2) if (!__pred(*__first1, *__first2)) goto __not_done; return true; __not_done: // __first1 != __last1 && *__first1 != *__first2 typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1; _D1 __l1 = _VSTD::distance(__first1, __last1); if (__l1 == _D1(1)) return false; _ForwardIterator2 __last2 = _VSTD::next(__first2, __l1); // For each element in [f1, l1) see if there are the same number of // equal elements in [f2, l2) for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) { // Have we already counted the number of *__i in [f1, l1)? for (_ForwardIterator1 __j = __first1; __j != __i; ++__j) if (__pred(*__j, *__i)) goto __next_iter; { // Count number of *__i in [f2, l2) _D1 __c2 = 0; for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) if (__pred(*__i, *__j)) ++__c2; if (__c2 == 0) return false; // Count number of *__i in [__i, l1) (we can start with 1) _D1 __c1 = 1; for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j) if (__pred(*__i, *__j)) ++__c1; if (__c1 != __c2) return false; } __next_iter:; } return true; } template inline _LIBCPP_INLINE_VISIBILITY bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>()); } #if _LIBCPP_STD_VER > 11 template bool __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag ) { // shorten sequences as much as possible by lopping of any equal parts for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) if (!__pred(*__first1, *__first2)) goto __not_done; return __first1 == __last1 && __first2 == __last2; __not_done: // __first1 != __last1 && __first2 != __last2 && *__first1 != *__first2 typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1; _D1 __l1 = _VSTD::distance(__first1, __last1); typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2; _D2 __l2 = _VSTD::distance(__first2, __last2); if (__l1 != __l2) return false; // For each element in [f1, l1) see if there are the same number of // equal elements in [f2, l2) for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) { // Have we already counted the number of *__i in [f1, l1)? for (_ForwardIterator1 __j = __first1; __j != __i; ++__j) if (__pred(*__j, *__i)) goto __next_iter; { // Count number of *__i in [f2, l2) _D1 __c2 = 0; for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) if (__pred(*__i, *__j)) ++__c2; if (__c2 == 0) return false; // Count number of *__i in [__i, l1) (we can start with 1) _D1 __c1 = 1; for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j) if (__pred(*__i, *__j)) ++__c1; if (__c1 != __c2) return false; } __next_iter:; } return true; } template bool __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1, _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag ) { if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) return false; return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2, typename add_lvalue_reference<_BinaryPredicate>::type> (__first1, __last1, __first2, __pred ); } template inline _LIBCPP_INLINE_VISIBILITY bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred ) { return _VSTD::__is_permutation::type> (__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), typename iterator_traits<_ForwardIterator2>::iterator_category()); } template inline _LIBCPP_INLINE_VISIBILITY bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; return _VSTD::__is_permutation(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(), typename iterator_traits<_ForwardIterator1>::iterator_category(), typename iterator_traits<_ForwardIterator2>::iterator_category()); } #endif // search template _ForwardIterator1 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) { if (__first2 == __last2) return __first1; // Everything matches an empty sequence while (true) { // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks while (true) { if (__first1 == __last1) // return __last1 if no element matches *__first2 return __last1; if (__pred(*__first1, *__first2)) break; ++__first1; } // *__first1 matches *__first2, now match elements after here _ForwardIterator1 __m1 = __first1; _ForwardIterator2 __m2 = __first2; while (true) { if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern) return __first1; if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found return __last1; if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1 { ++__first1; break; } // else there is a match, check next elements } } } template _RandomAccessIterator1 __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) { typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type _D1; typedef typename std::iterator_traits<_RandomAccessIterator2>::difference_type _D2; // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern _D2 __len2 = __last2 - __first2; if (__len2 == 0) return __first1; _D1 __len1 = __last1 - __first1; if (__len1 < __len2) return __last1; const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here while (true) { #if !_LIBCPP_UNROLL_LOOPS while (true) { if (__first1 == __s) return __last1; if (__pred(*__first1, *__first2)) break; ++__first1; } #else // !_LIBCPP_UNROLL_LOOPS for (_D1 __loop_unroll = (__s - __first1) / 4; __loop_unroll > 0; --__loop_unroll) { if (__pred(*__first1, *__first2)) goto __phase2; if (__pred(*++__first1, *__first2)) goto __phase2; if (__pred(*++__first1, *__first2)) goto __phase2; if (__pred(*++__first1, *__first2)) goto __phase2; ++__first1; } switch (__s - __first1) { case 3: if (__pred(*__first1, *__first2)) break; ++__first1; case 2: if (__pred(*__first1, *__first2)) break; ++__first1; case 1: if (__pred(*__first1, *__first2)) break; case 0: return __last1; } __phase2: #endif // !_LIBCPP_UNROLL_LOOPS _RandomAccessIterator1 __m1 = __first1; _RandomAccessIterator2 __m2 = __first2; #if !_LIBCPP_UNROLL_LOOPS while (true) { if (++__m2 == __last2) return __first1; ++__m1; // no need to check range on __m1 because __s guarantees we have enough source if (!__pred(*__m1, *__m2)) { ++__first1; break; } } #else // !_LIBCPP_UNROLL_LOOPS ++__m2; ++__m1; for (_D2 __loop_unroll = (__last2 - __m2) / 4; __loop_unroll > 0; --__loop_unroll) { if (!__pred(*__m1, *__m2)) goto __continue; if (!__pred(*++__m1, *++__m2)) goto __continue; if (!__pred(*++__m1, *++__m2)) goto __continue; if (!__pred(*++__m1, *++__m2)) goto __continue; ++__m1; ++__m2; } switch (__last2 - __m2) { case 3: if (!__pred(*__m1, *__m2)) break; ++__m1; ++__m2; case 2: if (!__pred(*__m1, *__m2)) break; ++__m1; ++__m2; case 1: if (!__pred(*__m1, *__m2)) break; case 0: return __first1; } __continue: ++__first1; #endif // !_LIBCPP_UNROLL_LOOPS } } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { return _VSTD::__search::type> (__first1, __last1, __first2, __last2, __pred, typename std::iterator_traits<_ForwardIterator1>::iterator_category(), typename std::iterator_traits<_ForwardIterator2>::iterator_category()); } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { typedef typename std::iterator_traits<_ForwardIterator1>::value_type __v1; typedef typename std::iterator_traits<_ForwardIterator2>::value_type __v2; return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); } // search_n template _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred, forward_iterator_tag) { if (__count <= 0) return __first; while (true) { // Find first element in sequence that matchs __value_, with a mininum of loop checks while (true) { if (__first == __last) // return __last if no element matches __value_ return __last; if (__pred(*__first, __value_)) break; ++__first; } // *__first matches __value_, now match elements after here _ForwardIterator __m = __first; _Size __c(0); while (true) { if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) return __first; if (++__m == __last) // Otherwise if source exhaused, pattern not found return __last; if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first { __first = __m; ++__first; break; } // else there is a match, check next elements } } } template _RandomAccessIterator __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred, random_access_iterator_tag) { if (__count <= 0) return __first; _Size __len = static_cast<_Size>(__last - __first); if (__len < __count) return __last; const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here while (true) { // Find first element in sequence that matchs __value_, with a mininum of loop checks while (true) { if (__first >= __s) // return __last if no element matches __value_ return __last; if (__pred(*__first, __value_)) break; ++__first; } // *__first matches __value_, now match elements after here _RandomAccessIterator __m = __first; _Size __c(0); while (true) { if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) return __first; ++__m; // no need to check range on __m because __s guarantees we have enough source if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first { __first = __m; ++__first; break; } // else there is a match, check next elements } } } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator 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()); } template inline _LIBCPP_INLINE_VISIBILITY _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>()); } // copy template struct __libcpp_is_trivial_iterator { static const bool value = is_pointer<_Iter>::value; }; template struct __libcpp_is_trivial_iterator > { static const bool value = is_pointer<_Iter>::value; }; template struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> > { static const bool value = is_pointer<_Iter>::value; }; template inline _LIBCPP_INLINE_VISIBILITY _Iter __unwrap_iter(_Iter __i) { return __i; } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_trivially_copy_assignable<_Tp>::value, _Tp* >::type __unwrap_iter(move_iterator<_Tp*> __i) { return __i.base(); } #if _LIBCPP_DEBUG_LEVEL < 2 template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_trivially_copy_assignable<_Tp>::value, _Tp* >::type __unwrap_iter(__wrap_iter<_Tp*> __i) { return __i.base(); } #endif // _LIBCPP_DEBUG_LEVEL < 2 template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { for (; __first != __last; ++__first, ++__result) *__result = *__first; return __result; } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_same::type, _Up>::value && is_trivially_copy_assignable<_Up>::value, _Up* >::type __copy(_Tp* __first, _Tp* __last, _Up* __result) { const size_t __n = static_cast(__last - __first); _VSTD::memmove(__result, __first, __n * sizeof(_Up)); return __result + __n; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { return _VSTD::__copy(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); } // copy_backward template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) { while (__first != __last) *--__result = *--__last; return __result; } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_same::type, _Up>::value && is_trivially_copy_assignable<_Up>::value, _Up* >::type __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)); return __result; } template inline _LIBCPP_INLINE_VISIBILITY _BidirectionalIterator2 copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) { return _VSTD::__copy_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); } // copy_if template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) { for (; __first != __last; ++__first) { if (__pred(*__first)) { *__result = *__first; ++__result; } } return __result; } // copy_n template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_input_iterator<_InputIterator>::value && !__is_random_access_iterator<_InputIterator>::value, _OutputIterator >::type copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) { if (__n > 0) { *__result = *__first; ++__result; for (--__n; __n > 0; --__n) { ++__first; *__result = *__first; ++__result; } } return __result; } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_random_access_iterator<_InputIterator>::value, _OutputIterator >::type copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) { return _VSTD::copy(__first, __first + __n, __result); } // move template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { for (; __first != __last; ++__first, ++__result) *__result = _VSTD::move(*__first); return __result; } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_same::type, _Up>::value && is_trivially_copy_assignable<_Up>::value, _Up* >::type __move(_Tp* __first, _Tp* __last, _Up* __result) { const size_t __n = static_cast(__last - __first); _VSTD::memmove(__result, __first, __n * sizeof(_Up)); return __result + __n; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { return _VSTD::__move(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); } // move_backward template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { while (__first != __last) *--__result = _VSTD::move(*--__last); return __result; } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_same::type, _Up>::value && is_trivially_copy_assignable<_Up>::value, _Up* >::type __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)); return __result; } template inline _LIBCPP_INLINE_VISIBILITY _BidirectionalIterator2 move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) { return _VSTD::__move_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); } // iter_swap // moved to for better swap / noexcept support // transform template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op) { for (; __first != __last; ++__first, ++__result) *__result = __op(*__first); return __result; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _OutputIterator __result, _BinaryOperation __binary_op) { for (; __first1 != __last1; ++__first1, ++__first2, ++__result) *__result = __binary_op(*__first1, *__first2); return __result; } // replace template inline _LIBCPP_INLINE_VISIBILITY void replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value) { for (; __first != __last; ++__first) if (*__first == __old_value) *__first = __new_value; } // replace_if template inline _LIBCPP_INLINE_VISIBILITY void replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value) { for (; __first != __last; ++__first) if (__pred(*__first)) *__first = __new_value; } // replace_copy template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __old_value, const _Tp& __new_value) { for (; __first != __last; ++__first, ++__result) if (*__first == __old_value) *__result = __new_value; else *__result = *__first; return __result; } // replace_copy_if template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred, const _Tp& __new_value) { for (; __first != __last; ++__first, ++__result) if (__pred(*__first)) *__result = __new_value; else *__result = *__first; return __result; } // fill_n template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) { for (; __n > 0; ++__first, --__n) *__first = __value_; return __first; } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_integral<_Tp>::value && sizeof(_Tp) == 1 && !is_same<_Tp, bool>::value && is_integral<_Up>::value && sizeof(_Up) == 1, _Tp* >::type __fill_n(_Tp* __first, _Size __n,_Up __value_) { if (__n > 0) _VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n)); return __first + __n; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) { return _VSTD::__fill_n(__first, __n, __value_); } // fill template inline _LIBCPP_INLINE_VISIBILITY void __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag) { for (; __first != __last; ++__first) *__first = __value_; } template inline _LIBCPP_INLINE_VISIBILITY void __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag) { _VSTD::fill_n(__first, __last - __first, __value_); } template inline _LIBCPP_INLINE_VISIBILITY void fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category()); } // generate template inline _LIBCPP_INLINE_VISIBILITY void generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { for (; __first != __last; ++__first) *__first = __gen(); } // generate_n template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator generate_n(_OutputIterator __first, _Size __n, _Generator __gen) { for (; __n > 0; ++__first, --__n) *__first = __gen(); return __first; } // remove template _ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { __first = _VSTD::find(__first, __last, __value_); if (__first != __last) { _ForwardIterator __i = __first; while (++__i != __last) { if (!(*__i == __value_)) { *__first = _VSTD::move(*__i); ++__first; } } } return __first; } // remove_if template _ForwardIterator remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type> (__first, __last, __pred); if (__first != __last) { _ForwardIterator __i = __first; while (++__i != __last) { if (!__pred(*__i)) { *__first = _VSTD::move(*__i); ++__first; } } } return __first; } // remove_copy template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_) { for (; __first != __last; ++__first) { if (!(*__first == __value_)) { *__result = *__first; ++__result; } } return __result; } // remove_copy_if template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) { for (; __first != __last; ++__first) { if (!__pred(*__first)) { *__result = *__first; ++__result; } } return __result; } // unique template _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type> (__first, __last, __pred); if (__first != __last) { // ... a a ? ... // f i _ForwardIterator __i = __first; for (++__i; ++__i != __last;) if (!__pred(*__first, *__i)) *++__first = _VSTD::move(*__i); ++__first; } return __first; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type __v; return _VSTD::unique(__first, __last, __equal_to<__v>()); } // unique_copy template _OutputIterator __unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred, input_iterator_tag, output_iterator_tag) { if (__first != __last) { typename iterator_traits<_InputIterator>::value_type __t(*__first); *__result = __t; ++__result; while (++__first != __last) { if (!__pred(__t, *__first)) { __t = *__first; *__result = __t; ++__result; } } } return __result; } template _OutputIterator __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred, forward_iterator_tag, output_iterator_tag) { if (__first != __last) { _ForwardIterator __i = __first; *__result = *__i; ++__result; while (++__first != __last) { if (!__pred(*__i, *__first)) { *__result = *__first; ++__result; __i = __first; } } } return __result; } template _ForwardIterator __unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred, input_iterator_tag, forward_iterator_tag) { if (__first != __last) { *__result = *__first; while (++__first != __last) if (!__pred(*__result, *__first)) *++__result = *__first; ++__result; } return __result; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) { return _VSTD::__unique_copy::type> (__first, __last, __result, __pred, typename iterator_traits<_InputIterator>::iterator_category(), typename iterator_traits<_OutputIterator>::iterator_category()); } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { typedef typename iterator_traits<_InputIterator>::value_type __v; return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>()); } // reverse template inline _LIBCPP_INLINE_VISIBILITY void __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag) { while (__first != __last) { if (__first == --__last) break; swap(*__first, *__last); ++__first; } } template inline _LIBCPP_INLINE_VISIBILITY void __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag) { if (__first != __last) for (; __first < --__last; ++__first) swap(*__first, *__last); } template inline _LIBCPP_INLINE_VISIBILITY void reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) { _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category()); } // reverse_copy template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) { for (; __first != __last; ++__result) *__result = *--__last; return __result; } // rotate template _ForwardIterator __rotate_left(_ForwardIterator __first, _ForwardIterator __last) { typedef typename iterator_traits<_ForwardIterator>::value_type value_type; value_type __tmp = _VSTD::move(*__first); _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first); *__lm1 = _VSTD::move(__tmp); return __lm1; } template _BidirectionalIterator __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last) { typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; _BidirectionalIterator __lm1 = _VSTD::prev(__last); value_type __tmp = _VSTD::move(*__lm1); _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last); *__first = _VSTD::move(__tmp); return __fp1; } template _ForwardIterator __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) { _ForwardIterator __i = __middle; while (true) { swap(*__first, *__i); ++__first; if (++__i == __last) break; if (__first == __middle) __middle = __i; } _ForwardIterator __r = __first; if (__first != __middle) { __i = __middle; while (true) { swap(*__first, *__i); ++__first; if (++__i == __last) { if (__first == __middle) break; __i = __middle; } else if (__first == __middle) __middle = __i; } } return __r; } template inline _LIBCPP_INLINE_VISIBILITY _Integral __gcd(_Integral __x, _Integral __y) { do { _Integral __t = __x % __y; __x = __y; __y = __t; } while (__y); return __x; } template _RandomAccessIterator __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; const difference_type __m1 = __middle - __first; const difference_type __m2 = __last - __middle; if (__m1 == __m2) { _VSTD::swap_ranges(__first, __middle, __middle); return __middle; } const difference_type __g = _VSTD::__gcd(__m1, __m2); for (_RandomAccessIterator __p = __first + __g; __p != __first;) { value_type __t(_VSTD::move(*--__p)); _RandomAccessIterator __p1 = __p; _RandomAccessIterator __p2 = __p1 + __m1; do { *__p1 = _VSTD::move(*__p2); __p1 = __p2; const difference_type __d = __last - __p2; if (__m1 < __d) __p2 += __m1; else __p2 = __first + (__m1 - __d); } while (__p2 != __p); *__p1 = _VSTD::move(__t); } return __first + __m2; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _VSTD::forward_iterator_tag) { typedef typename _VSTD::iterator_traits<_ForwardIterator>::value_type value_type; if (_VSTD::is_trivially_move_assignable::value) { if (_VSTD::next(__first) == __middle) return _VSTD::__rotate_left(__first, __last); } return _VSTD::__rotate_forward(__first, __middle, __last); } template inline _LIBCPP_INLINE_VISIBILITY _BidirectionalIterator __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _VSTD::bidirectional_iterator_tag) { typedef typename _VSTD::iterator_traits<_BidirectionalIterator>::value_type value_type; if (_VSTD::is_trivially_move_assignable::value) { if (_VSTD::next(__first) == __middle) return _VSTD::__rotate_left(__first, __last); if (_VSTD::next(__middle) == __last) return _VSTD::__rotate_right(__first, __last); } return _VSTD::__rotate_forward(__first, __middle, __last); } template inline _LIBCPP_INLINE_VISIBILITY _RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _VSTD::random_access_iterator_tag) { typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::value_type value_type; if (_VSTD::is_trivially_move_assignable::value) { if (_VSTD::next(__first) == __middle) return _VSTD::__rotate_left(__first, __last); if (_VSTD::next(__middle) == __last) return _VSTD::__rotate_right(__first, __last); return _VSTD::__rotate_gcd(__first, __middle, __last); } return _VSTD::__rotate_forward(__first, __middle, __last); } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) { if (__first == __middle) return __last; if (__middle == __last) return __first; return _VSTD::__rotate(__first, __middle, __last, typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category()); } // rotate_copy template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result) { return _VSTD::copy(__first, __middle, _VSTD::copy(__middle, __last, __result)); } // min_element template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { _ForwardIterator __i = __first; while (++__i != __last) if (__comp(*__i, *__first)) __first = __i; } return __first; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::min_element(__first, __last, __less::value_type>()); } // min template inline _LIBCPP_INLINE_VISIBILITY const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { return __comp(__b, __a) ? __b : __a; } template inline _LIBCPP_INLINE_VISIBILITY const _Tp& min(const _Tp& __a, const _Tp& __b) { return _VSTD::min(__a, __b, __less<_Tp>()); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY _Tp min(initializer_list<_Tp> __t, _Compare __comp) { return *_VSTD::min_element(__t.begin(), __t.end(), __comp); } template inline _LIBCPP_INLINE_VISIBILITY _Tp min(initializer_list<_Tp> __t) { return *_VSTD::min_element(__t.begin(), __t.end()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // max_element template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { _ForwardIterator __i = __first; while (++__i != __last) if (__comp(*__first, *__i)) __first = __i; } return __first; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::max_element(__first, __last, __less::value_type>()); } // max template inline _LIBCPP_INLINE_VISIBILITY const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) { return __comp(__a, __b) ? __b : __a; } template inline _LIBCPP_INLINE_VISIBILITY const _Tp& max(const _Tp& __a, const _Tp& __b) { return _VSTD::max(__a, __b, __less<_Tp>()); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY _Tp max(initializer_list<_Tp> __t, _Compare __comp) { return *_VSTD::max_element(__t.begin(), __t.end(), __comp); } template inline _LIBCPP_INLINE_VISIBILITY _Tp max(initializer_list<_Tp> __t) { return *_VSTD::max_element(__t.begin(), __t.end()); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // minmax_element template std::pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { std::pair<_ForwardIterator, _ForwardIterator> __result(__first, __first); if (__first != __last) { if (++__first != __last) { if (__comp(*__first, *__result.first)) __result.first = __first; else __result.second = __first; while (++__first != __last) { _ForwardIterator __i = __first; if (++__first == __last) { if (__comp(*__i, *__result.first)) __result.first = __i; else if (!__comp(*__i, *__result.second)) __result.second = __i; break; } else { if (__comp(*__first, *__i)) { if (__comp(*__first, *__result.first)) __result.first = __first; if (!__comp(*__i, *__result.second)) __result.second = __i; } else { if (__comp(*__i, *__result.first)) __result.first = __i; if (!__comp(*__first, *__result.second)) __result.second = __first; } } } } } return __result; } template inline _LIBCPP_INLINE_VISIBILITY std::pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::minmax_element(__first, __last, __less::value_type>()); } // minmax template inline _LIBCPP_INLINE_VISIBILITY pair minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) { return __comp(__b, __a) ? pair(__b, __a) : pair(__a, __b); } template inline _LIBCPP_INLINE_VISIBILITY pair minmax(const _Tp& __a, const _Tp& __b) { return _VSTD::minmax(__a, __b, __less<_Tp>()); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template inline _LIBCPP_INLINE_VISIBILITY pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t) { pair __p = _VSTD::minmax_element(__t.begin(), __t.end()); return pair<_Tp, _Tp>(*__p.first, *__p.second); } template inline _LIBCPP_INLINE_VISIBILITY pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) { pair __p = _VSTD::minmax_element(__t.begin(), __t.end(), __comp); return pair<_Tp, _Tp>(*__p.first, *__p.second); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // random_shuffle // __independent_bits_engine template struct __log2_imp { static const size_t value = _Xp & ((unsigned long long)(1) << _Rp) ? _Rp : __log2_imp<_Xp, _Rp - 1>::value; }; template struct __log2_imp<_Xp, 0> { static const size_t value = 0; }; template struct __log2_imp<0, _Rp> { static const size_t value = _Rp + 1; }; template struct __log2 { static const size_t value = __log2_imp<_Xp, sizeof(_UI) * __CHAR_BIT__ - 1>::value; }; template class __independent_bits_engine { public: // types typedef _UIntType result_type; private: typedef typename _Engine::result_type _Engine_result_type; typedef typename conditional < sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type >::type _Working_result_type; _Engine& __e_; size_t __w_; size_t __w0_; size_t __n_; size_t __n0_; _Working_result_type __y0_; _Working_result_type __y1_; _Engine_result_type __mask0_; _Engine_result_type __mask1_; #ifdef _LIBCPP_HAS_NO_CONSTEXPR static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min + _Working_result_type(1); #else static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min() + _Working_result_type(1); #endif static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value; static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits; static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits; public: // constructors and seeding functions __independent_bits_engine(_Engine& __e, size_t __w); // generating functions result_type operator()() {return __eval(integral_constant());} private: result_type __eval(false_type); result_type __eval(true_type); }; template __independent_bits_engine<_Engine, _UIntType> ::__independent_bits_engine(_Engine& __e, size_t __w) : __e_(__e), __w_(__w) { __n_ = __w_ / __m + (__w_ % __m != 0); __w0_ = __w_ / __n_; if (_Rp == 0) __y0_ = _Rp; else if (__w0_ < _WDt) __y0_ = (_Rp >> __w0_) << __w0_; else __y0_ = 0; if (_Rp - __y0_ > __y0_ / __n_) { ++__n_; __w0_ = __w_ / __n_; if (__w0_ < _WDt) __y0_ = (_Rp >> __w0_) << __w0_; else __y0_ = 0; } __n0_ = __n_ - __w_ % __n_; if (__w0_ < _WDt - 1) __y1_ = (_Rp >> (__w0_ + 1)) << (__w0_ + 1); else __y1_ = 0; __mask0_ = __w0_ > 0 ? _Engine_result_type(~0) >> (_EDt - __w0_) : _Engine_result_type(0); __mask1_ = __w0_ < _EDt - 1 ? _Engine_result_type(~0) >> (_EDt - (__w0_ + 1)) : _Engine_result_type(~0); } template inline _UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(false_type) { return static_cast(__e_() & __mask0_); } template _UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) { result_type _Sp = 0; for (size_t __k = 0; __k < __n0_; ++__k) { _Engine_result_type __u; do { __u = __e_() - _Engine::min(); } while (__u >= __y0_); if (__w0_ < _WDt) _Sp <<= __w0_; else _Sp = 0; _Sp += __u & __mask0_; } for (size_t __k = __n0_; __k < __n_; ++__k) { _Engine_result_type __u; do { __u = __e_() - _Engine::min(); } while (__u >= __y1_); if (__w0_ < _WDt - 1) _Sp <<= __w0_ + 1; else _Sp = 0; _Sp += __u & __mask1_; } return _Sp; } // uniform_int_distribution template class uniform_int_distribution { public: // types typedef _IntType result_type; class param_type { result_type __a_; result_type __b_; public: typedef uniform_int_distribution distribution_type; explicit param_type(result_type __a = 0, result_type __b = numeric_limits::max()) : __a_(__a), __b_(__b) {} result_type a() const {return __a_;} result_type b() const {return __b_;} friend bool operator==(const param_type& __x, const param_type& __y) {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} friend bool operator!=(const param_type& __x, const param_type& __y) {return !(__x == __y);} }; private: param_type __p_; public: // constructors and reset functions explicit uniform_int_distribution(result_type __a = 0, result_type __b = numeric_limits::max()) : __p_(param_type(__a, __b)) {} explicit uniform_int_distribution(const param_type& __p) : __p_(__p) {} void reset() {} // generating functions template result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} template result_type operator()(_URNG& __g, const param_type& __p); // property functions result_type a() const {return __p_.a();} result_type b() const {return __p_.b();} param_type param() const {return __p_;} void param(const param_type& __p) {__p_ = __p;} result_type min() const {return a();} result_type max() const {return b();} friend bool operator==(const uniform_int_distribution& __x, const uniform_int_distribution& __y) {return __x.__p_ == __y.__p_;} friend bool operator!=(const uniform_int_distribution& __x, const uniform_int_distribution& __y) {return !(__x == __y);} }; template template typename uniform_int_distribution<_IntType>::result_type uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) { typedef typename conditional::type _UIntType; const _UIntType _Rp = __p.b() - __p.a() + _UIntType(1); if (_Rp == 1) return __p.a(); const size_t _Dt = numeric_limits<_UIntType>::digits; typedef __independent_bits_engine<_URNG, _UIntType> _Eng; if (_Rp == 0) return static_cast(_Eng(__g, _Dt)()); size_t __w = _Dt - __clz(_Rp) - 1; if ((_Rp & (_UIntType(~0) >> (_Dt - __w))) != 0) ++__w; _Eng __e(__g, __w); _UIntType __u; do { __u = __e(); } while (__u >= _Rp); return static_cast(__u + __p.a()); } class _LIBCPP_TYPE_VIS __rs_default; _LIBCPP_FUNC_VIS __rs_default __rs_get(); class _LIBCPP_TYPE_VIS __rs_default { static unsigned __c_; __rs_default(); public: typedef uint_fast32_t result_type; static const result_type _Min = 0; static const result_type _Max = 0xFFFFFFFF; __rs_default(const __rs_default&); ~__rs_default(); result_type operator()(); static _LIBCPP_CONSTEXPR result_type min() {return _Min;} static _LIBCPP_CONSTEXPR result_type max() {return _Max;} friend _LIBCPP_FUNC_VIS __rs_default __rs_get(); }; _LIBCPP_FUNC_VIS __rs_default __rs_get(); template void random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef uniform_int_distribution _Dp; typedef typename _Dp::param_type _Pp; difference_type __d = __last - __first; if (__d > 1) { _Dp __uid; __rs_default __g = __rs_get(); for (--__last, --__d; __first < __last; ++__first, --__d) { difference_type __i = __uid(__g, _Pp(0, __d)); if (__i != difference_type(0)) swap(*__first, *(__first + __i)); } } } template void random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _RandomNumberGenerator&& __rand) #else _RandomNumberGenerator& __rand) #endif { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; difference_type __d = __last - __first; if (__d > 1) { for (--__last; __first < __last; ++__first, --__d) { difference_type __i = __rand(__d); swap(*__first, *(__first + __i)); } } } template void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _UniformRandomNumberGenerator&& __g) #else _UniformRandomNumberGenerator& __g) #endif { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef uniform_int_distribution _Dp; typedef typename _Dp::param_type _Pp; difference_type __d = __last - __first; if (__d > 1) { _Dp __uid; for (--__last, --__d; __first < __last; ++__first, --__d) { difference_type __i = __uid(__g, _Pp(0, __d)); if (__i != difference_type(0)) swap(*__first, *(__first + __i)); } } } template bool is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (!__pred(*__first)) break; for (; __first != __last; ++__first) if (__pred(*__first)) return false; return true; } // partition template _ForwardIterator __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) { while (true) { if (__first == __last) return __first; if (!__pred(*__first)) break; ++__first; } for (_ForwardIterator __p = __first; ++__p != __last;) { if (__pred(*__p)) { swap(*__first, *__p); ++__first; } } return __first; } template _BidirectionalIterator __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) { while (true) { while (true) { if (__first == __last) return __first; if (!__pred(*__first)) break; ++__first; } do { if (__first == --__last) return __first; } while (!__pred(*__last)); swap(*__first, *__last); ++__first; } } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { return _VSTD::__partition::type> (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); } // partition_copy template pair<_OutputIterator1, _OutputIterator2> partition_copy(_InputIterator __first, _InputIterator __last, _OutputIterator1 __out_true, _OutputIterator2 __out_false, _Predicate __pred) { for (; __first != __last; ++__first) { if (__pred(*__first)) { *__out_true = *__first; ++__out_true; } else { *__out_false = *__first; ++__out_false; } } return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false); } // partition_point template _ForwardIterator partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; difference_type __len = _VSTD::distance(__first, __last); while (__len != 0) { difference_type __l2 = __len / 2; _ForwardIterator __m = __first; _VSTD::advance(__m, __l2); if (__pred(*__m)) { __first = ++__m; __len -= __l2 + 1; } else __len = __l2; } return __first; } // stable_partition template _ForwardIterator __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, _Distance __len, _Pair __p, forward_iterator_tag __fit) { // *__first is known to be false // __len >= 1 if (__len == 1) return __first; if (__len == 2) { _ForwardIterator __m = __first; if (__pred(*++__m)) { swap(*__first, *__m); return __m; } return __first; } if (__len <= __p.second) { // The buffer is big enough to use typedef typename iterator_traits<_ForwardIterator>::value_type value_type; __destruct_n __d(0); unique_ptr __h(__p.first, __d); // Move the falses into the temporary buffer, and the trues to the front of the line // Update __first to always point to the end of the trues value_type* __t = __p.first; ::new(__t) value_type(_VSTD::move(*__first)); __d.__incr((value_type*)0); ++__t; _ForwardIterator __i = __first; while (++__i != __last) { if (__pred(*__i)) { *__first = _VSTD::move(*__i); ++__first; } else { ::new(__t) value_type(_VSTD::move(*__i)); __d.__incr((value_type*)0); ++__t; } } // All trues now at start of range, all falses in buffer // Move falses back into range, but don't mess up __first which points to first false __i = __first; for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, ++__i) *__i = _VSTD::move(*__t2); // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer return __first; } // Else not enough buffer, do in place // __len >= 3 _ForwardIterator __m = __first; _Distance __len2 = __len / 2; // __len2 >= 2 _VSTD::advance(__m, __len2); // recurse on [__first, __m), *__first know to be false // F????????????????? // f m l typedef typename add_lvalue_reference<_Predicate>::type _PredRef; _ForwardIterator __first_false = __stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit); // TTTFFFFF?????????? // f ff m l // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true _ForwardIterator __m1 = __m; _ForwardIterator __second_false = __last; _Distance __len_half = __len - __len2; while (__pred(*__m1)) { if (++__m1 == __last) goto __second_half_done; --__len_half; } // TTTFFFFFTTTF?????? // f ff m m1 l __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit); __second_half_done: // TTTFFFFFTTTTTFFFFF // f ff m sf l return _VSTD::rotate(__first_false, __m, __second_false); // TTTTTTTTFFFFFFFFFF // | } struct __return_temporary_buffer { template _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);} }; template _ForwardIterator __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) { const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment // Either prove all true and return __first or point to first false while (true) { if (__first == __last) return __first; if (!__pred(*__first)) break; ++__first; } // We now have a reduced range [__first, __last) // *__first is known to be false typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; typedef typename iterator_traits<_ForwardIterator>::value_type value_type; difference_type __len = _VSTD::distance(__first, __last); pair __p(0, 0); unique_ptr __h; if (__len >= __alloc_limit) { __p = _VSTD::get_temporary_buffer(__len); __h.reset(__p.first); } return __stable_partition::type> (__first, __last, __pred, __len, __p, forward_iterator_tag()); } template _BidirectionalIterator __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, _Distance __len, _Pair __p, bidirectional_iterator_tag __bit) { // *__first is known to be false // *__last is known to be true // __len >= 2 if (__len == 2) { swap(*__first, *__last); return __last; } if (__len == 3) { _BidirectionalIterator __m = __first; if (__pred(*++__m)) { swap(*__first, *__m); swap(*__m, *__last); return __last; } swap(*__m, *__last); swap(*__first, *__m); return __m; } if (__len <= __p.second) { // The buffer is big enough to use typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; __destruct_n __d(0); unique_ptr __h(__p.first, __d); // Move the falses into the temporary buffer, and the trues to the front of the line // Update __first to always point to the end of the trues value_type* __t = __p.first; ::new(__t) value_type(_VSTD::move(*__first)); __d.__incr((value_type*)0); ++__t; _BidirectionalIterator __i = __first; while (++__i != __last) { if (__pred(*__i)) { *__first = _VSTD::move(*__i); ++__first; } else { ::new(__t) value_type(_VSTD::move(*__i)); __d.__incr((value_type*)0); ++__t; } } // move *__last, known to be true *__first = _VSTD::move(*__i); __i = ++__first; // All trues now at start of range, all falses in buffer // Move falses back into range, but don't mess up __first which points to first false for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, ++__i) *__i = _VSTD::move(*__t2); // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer return __first; } // Else not enough buffer, do in place // __len >= 4 _BidirectionalIterator __m = __first; _Distance __len2 = __len / 2; // __len2 >= 2 _VSTD::advance(__m, __len2); // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false // F????????????????T // f m l _BidirectionalIterator __m1 = __m; _BidirectionalIterator __first_false = __first; _Distance __len_half = __len2; while (!__pred(*--__m1)) { if (__m1 == __first) goto __first_half_done; --__len_half; } // F???TFFF?????????T // f m1 m l typedef typename add_lvalue_reference<_Predicate>::type _PredRef; __first_false = __stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit); __first_half_done: // TTTFFFFF?????????T // f ff m l // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true __m1 = __m; _BidirectionalIterator __second_false = __last; ++__second_false; __len_half = __len - __len2; while (__pred(*__m1)) { if (++__m1 == __last) goto __second_half_done; --__len_half; } // TTTFFFFFTTTF?????T // f ff m m1 l __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit); __second_half_done: // TTTFFFFFTTTTTFFFFF // f ff m sf l return _VSTD::rotate(__first_false, __m, __second_false); // TTTTTTTTFFFFFFFFFF // | } template _BidirectionalIterator __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) { typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; const difference_type __alloc_limit = 4; // might want to make this a function of trivial assignment // Either prove all true and return __first or point to first false while (true) { if (__first == __last) return __first; if (!__pred(*__first)) break; ++__first; } // __first points to first false, everything prior to __first is already set. // Either prove [__first, __last) is all false and return __first, or point __last to last true do { if (__first == --__last) return __first; } while (!__pred(*__last)); // We now have a reduced range [__first, __last] // *__first is known to be false // *__last is known to be true // __len >= 2 difference_type __len = _VSTD::distance(__first, __last) + 1; pair __p(0, 0); unique_ptr __h; if (__len >= __alloc_limit) { __p = _VSTD::get_temporary_buffer(__len); __h.reset(__p.first); } return __stable_partition::type> (__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { return __stable_partition::type> (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); } // is_sorted_until template _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { _ForwardIterator __i = __first; while (++__i != __last) { if (__comp(*__i, *__first)) return __i; __first = __i; } } return __last; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::is_sorted_until(__first, __last, __less::value_type>()); } // is_sorted template inline _LIBCPP_INLINE_VISIBILITY bool is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { return _VSTD::is_sorted_until(__first, __last, __comp) == __last; } template inline _LIBCPP_INLINE_VISIBILITY bool is_sorted(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::is_sorted(__first, __last, __less::value_type>()); } // sort // stable, 2-3 compares, 0-2 swaps template unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c) { unsigned __r = 0; if (!__c(*__y, *__x)) // if x <= y { if (!__c(*__z, *__y)) // if y <= z return __r; // x <= y && y <= z // x <= y && y > z swap(*__y, *__z); // x <= z && y < z __r = 1; if (__c(*__y, *__x)) // if x > y { swap(*__x, *__y); // x < y && y <= z __r = 2; } return __r; // x <= y && y < z } if (__c(*__z, *__y)) // x > y, if y > z { swap(*__x, *__z); // x < y && y < z __r = 1; return __r; } swap(*__x, *__y); // x > y && y <= z __r = 1; // x < y && x <= z if (__c(*__z, *__y)) // if y > z { swap(*__y, *__z); // x <= y && y < z __r = 2; } return __r; } // x <= y && y <= z // stable, 3-6 compares, 0-5 swaps template unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _Compare __c) { unsigned __r = __sort3<_Compare>(__x1, __x2, __x3, __c); if (__c(*__x4, *__x3)) { swap(*__x3, *__x4); ++__r; if (__c(*__x3, *__x2)) { swap(*__x2, *__x3); ++__r; if (__c(*__x2, *__x1)) { swap(*__x1, *__x2); ++__r; } } } return __r; } // stable, 4-10 compares, 0-9 swaps template unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c) { unsigned __r = __sort4<_Compare>(__x1, __x2, __x3, __x4, __c); if (__c(*__x5, *__x4)) { swap(*__x4, *__x5); ++__r; if (__c(*__x4, *__x3)) { swap(*__x3, *__x4); ++__r; if (__c(*__x3, *__x2)) { swap(*__x2, *__x3); ++__r; if (__c(*__x2, *__x1)) { swap(*__x1, *__x2); ++__r; } } } } return __r; } // Assumes size > 0 template void __selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp) { _BirdirectionalIterator __lm1 = __last; for (--__lm1; __first != __lm1; ++__first) { _BirdirectionalIterator __i = _VSTD::min_element<_BirdirectionalIterator, typename add_lvalue_reference<_Compare>::type> (__first, __last, __comp); if (__i != __first) swap(*__first, *__i); } } template void __insertion_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp) { typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type; if (__first != __last) { _BirdirectionalIterator __i = __first; for (++__i; __i != __last; ++__i) { _BirdirectionalIterator __j = __i; value_type __t(_VSTD::move(*__j)); for (_BirdirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j) *__j = _VSTD::move(*__k); *__j = _VSTD::move(__t); } } } template void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; _RandomAccessIterator __j = __first+2; __sort3<_Compare>(__first, __first+1, __j, __comp); for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) { if (__comp(*__i, *__j)) { value_type __t(_VSTD::move(*__i)); _RandomAccessIterator __k = __j; __j = __i; do { *__j = _VSTD::move(*__k); __j = __k; } while (__j != __first && __comp(__t, *--__k)); *__j = _VSTD::move(__t); } __j = __i; } } template bool __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { switch (__last - __first) { case 0: case 1: return true; case 2: if (__comp(*--__last, *__first)) swap(*__first, *__last); return true; case 3: _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); return true; case 4: _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); return true; case 5: _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); return true; } typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; _RandomAccessIterator __j = __first+2; __sort3<_Compare>(__first, __first+1, __j, __comp); const unsigned __limit = 8; unsigned __count = 0; for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) { if (__comp(*__i, *__j)) { value_type __t(_VSTD::move(*__i)); _RandomAccessIterator __k = __j; __j = __i; do { *__j = _VSTD::move(*__k); __j = __k; } while (__j != __first && __comp(__t, *--__k)); *__j = _VSTD::move(__t); if (++__count == __limit) return ++__i == __last; } __j = __i; } return true; } template void __insertion_sort_move(_BirdirectionalIterator __first1, _BirdirectionalIterator __last1, typename iterator_traits<_BirdirectionalIterator>::value_type* __first2, _Compare __comp) { typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type; if (__first1 != __last1) { __destruct_n __d(0); unique_ptr __h(__first2, __d); value_type* __last2 = __first2; ::new(__last2) value_type(_VSTD::move(*__first1)); __d.__incr((value_type*)0); for (++__last2; ++__first1 != __last1; ++__last2) { value_type* __j2 = __last2; value_type* __i2 = __j2; if (__comp(*__first1, *--__i2)) { ::new(__j2) value_type(_VSTD::move(*__i2)); __d.__incr((value_type*)0); for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2) *__j2 = _VSTD::move(*__i2); *__j2 = _VSTD::move(*__first1); } else { ::new(__j2) value_type(_VSTD::move(*__first1)); __d.__incr((value_type*)0); } } __h.release(); } } template void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { // _Compare is known to be a reference type typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; const difference_type __limit = is_trivially_copy_constructible::value && is_trivially_copy_assignable::value ? 30 : 6; while (true) { __restart: difference_type __len = __last - __first; switch (__len) { case 0: case 1: return; case 2: if (__comp(*--__last, *__first)) swap(*__first, *__last); return; case 3: _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); return; case 4: _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); return; case 5: _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); return; } if (__len <= __limit) { _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp); return; } // __len > 5 _RandomAccessIterator __m = __first; _RandomAccessIterator __lm1 = __last; --__lm1; unsigned __n_swaps; { difference_type __delta; if (__len >= 1000) { __delta = __len/2; __m += __delta; __delta /= 2; __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp); } else { __delta = __len/2; __m += __delta; __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp); } } // *__m is median // partition [__first, __m) < *__m and *__m <= [__m, __last) // (this inhibits tossing elements equivalent to __m around unnecessarily) _RandomAccessIterator __i = __first; _RandomAccessIterator __j = __lm1; // j points beyond range to be tested, *__m is known to be <= *__lm1 // The search going up is known to be guarded but the search coming down isn't. // Prime the downward search with a guard. if (!__comp(*__i, *__m)) // if *__first == *__m { // *__first == *__m, *__first doesn't go in first part // manually guard downward moving __j against __i while (true) { if (__i == --__j) { // *__first == *__m, *__m <= all other elements // Parition instead into [__first, __i) == *__first and *__first < [__i, __last) ++__i; // __first + 1 __j = __last; if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1) { while (true) { if (__i == __j) return; // [__first, __last) all equivalent elements if (__comp(*__first, *__i)) { swap(*__i, *__j); ++__n_swaps; ++__i; break; } ++__i; } } // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1 if (__i == __j) return; while (true) { while (!__comp(*__first, *__i)) ++__i; while (__comp(*__first, *--__j)) ; if (__i >= __j) break; swap(*__i, *__j); ++__n_swaps; ++__i; } // [__first, __i) == *__first and *__first < [__i, __last) // The first part is sorted, sort the secod part // _VSTD::__sort<_Compare>(__i, __last, __comp); __first = __i; goto __restart; } if (__comp(*__j, *__m)) { swap(*__i, *__j); ++__n_swaps; break; // found guard for downward moving __j, now use unguarded partition } } } // It is known that *__i < *__m ++__i; // j points beyond range to be tested, *__m is known to be <= *__lm1 // if not yet partitioned... if (__i < __j) { // known that *(__i - 1) < *__m // known that __i <= __m while (true) { // __m still guards upward moving __i while (__comp(*__i, *__m)) ++__i; // It is now known that a guard exists for downward moving __j while (!__comp(*--__j, *__m)) ; if (__i > __j) break; swap(*__i, *__j); ++__n_swaps; // It is known that __m != __j // If __m just moved, follow it if (__m == __i) __m = __j; ++__i; } } // [__first, __i) < *__m and *__m <= [__i, __last) if (__i != __m && __comp(*__m, *__i)) { swap(*__i, *__m); ++__n_swaps; } // [__first, __i) < *__i and *__i <= [__i+1, __last) // If we were given a perfect partition, see if insertion sort is quick... if (__n_swaps == 0) { bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp); if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp)) { if (__fs) return; __last = __i; continue; } else { if (__fs) { __first = ++__i; continue; } } } // sort smaller range with recursive call and larger with tail recursion elimination if (__i - __first < __last - __i) { _VSTD::__sort<_Compare>(__first, __i, __comp); // _VSTD::__sort<_Compare>(__i+1, __last, __comp); __first = ++__i; } else { _VSTD::__sort<_Compare>(__i+1, __last, __comp); // _VSTD::__sort<_Compare>(__first, __i, __comp); __last = __i; } } } // This forwarder keeps the top call and the recursive calls using the same instantiation, forcing a reference _Compare template inline _LIBCPP_INLINE_VISIBILITY void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort<_Comp_ref>(__first, __last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort<_Comp_ref>(__first, __last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { _VSTD::sort(__first, __last, __less::value_type>()); } template inline _LIBCPP_INLINE_VISIBILITY void sort(_Tp** __first, _Tp** __last) { _VSTD::sort((size_t*)__first, (size_t*)__last, __less()); } template inline _LIBCPP_INLINE_VISIBILITY void sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last) { _VSTD::sort(__first.base(), __last.base()); } template inline _LIBCPP_INLINE_VISIBILITY void sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last, _Compare __comp) { typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; _VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp); } #ifdef _LIBCPP_MSVC #pragma warning( push ) #pragma warning( disable: 4231) #endif // _LIBCPP_MSVC _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, char*>(char*, char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, signed char*>(signed char*, signed char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, short*>(short*, short*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, int*>(int*, int*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned*>(unsigned*, unsigned*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long*>(long*, long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long long*>(long long*, long long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, float*>(float*, float*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, double*>(double*, double*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long double*>(long double*, long double*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, char*>(char*, char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, signed char*>(signed char*, signed char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, short*>(short*, short*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, int*>(int*, int*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned*>(unsigned*, unsigned*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long*>(long*, long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long long*>(long long*, long long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, float*>(float*, float*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, double*>(double*, double*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long double*>(long double*, long double*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&)) #ifdef _LIBCPP_MSVC #pragma warning( pop ) #endif // _LIBCPP_MSVC // lower_bound template _ForwardIterator __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; difference_type __len = _VSTD::distance(__first, __last); while (__len != 0) { difference_type __l2 = __len / 2; _ForwardIterator __m = __first; _VSTD::advance(__m, __l2); if (__comp(*__m, __value_)) { __first = ++__m; __len -= __l2 + 1; } else __len = __l2; } return __first; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lower_bound<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { return _VSTD::lower_bound(__first, __last, __value_, __less::value_type, _Tp>()); } // upper_bound template _ForwardIterator __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; difference_type __len = _VSTD::distance(__first, __last); while (__len != 0) { difference_type __l2 = __len / 2; _ForwardIterator __m = __first; _VSTD::advance(__m, __l2); if (__comp(__value_, *__m)) __len = __l2; else { __first = ++__m; __len -= __l2 + 1; } } return __first; } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __upper_bound<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { return _VSTD::upper_bound(__first, __last, __value_, __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>()); } // equal_range template pair<_ForwardIterator, _ForwardIterator> __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; difference_type __len = _VSTD::distance(__first, __last); while (__len != 0) { difference_type __l2 = __len / 2; _ForwardIterator __m = __first; _VSTD::advance(__m, __l2); if (__comp(*__m, __value_)) { __first = ++__m; __len -= __l2 + 1; } else if (__comp(__value_, *__m)) { __last = __m; __len = __l2; } else { _ForwardIterator __mp1 = __m; return pair<_ForwardIterator, _ForwardIterator> ( __lower_bound<_Compare>(__first, __m, __value_, __comp), __upper_bound<_Compare>(++__mp1, __last, __value_, __comp) ); } } return pair<_ForwardIterator, _ForwardIterator>(__first, __first); } template inline _LIBCPP_INLINE_VISIBILITY pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __equal_range<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __equal_range<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { return _VSTD::equal_range(__first, __last, __value_, __less::value_type, _Tp>()); } // binary_search template inline _LIBCPP_INLINE_VISIBILITY bool __binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { __first = __lower_bound<_Compare>(__first, __last, __value_, __comp); return __first != __last && !__comp(__value_, *__first); } template inline _LIBCPP_INLINE_VISIBILITY bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __binary_search<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __binary_search<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { return _VSTD::binary_search(__first, __last, __value_, __less::value_type, _Tp>()); } // merge template _OutputIterator __merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { for (; __first1 != __last1; ++__result) { if (__first2 == __last2) return _VSTD::copy(__first1, __last1, __result); if (__comp(*__first2, *__first1)) { *__result = *__first2; ++__first2; } else { *__result = *__first1; ++__first1; } } return _VSTD::copy(__first2, __last2, __result); } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { typedef typename iterator_traits<_InputIterator1>::value_type __v1; typedef typename iterator_traits<_InputIterator2>::value_type __v2; return merge(__first1, __last1, __first2, __last2, __result, __less<__v1, __v2>()); } // inplace_merge template void __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1, typename iterator_traits<_BidirectionalIterator>::difference_type __len2, 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) { value_type* __p = __buff; for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), ++__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); } else { value_type* __p = __buff; for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), ++__i, ++__p) ::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)); } } template void __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1, 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; // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0 for (; true; ++__first, --__len1) { if (__len1 == 0) return; 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 // all elements in: // [__first, __m1) <= [__middle, __m2) // [__middle, __m2) < [__m1, __middle) // [__m1, __middle) <= [__m2, __last) // and __m1 or __m2 is in the middle of its range _BidirectionalIterator __m1; // "median" of [__first, __middle) _BidirectionalIterator __m2; // "median" of [__middle, __last) difference_type __len11; // distance(__first, __m1) difference_type __len21; // distance(__middle, __m2) // binary search smaller range if (__len1 < __len2) { // __len >= 1, __len2 >= 2 __len21 = __len2 / 2; __m2 = __middle; _VSTD::advance(__m2, __len21); __m1 = __upper_bound<_Compare>(__first, __middle, *__m2, __comp); __len11 = _VSTD::distance(__first, __m1); } else { if (__len1 == 1) { // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1 // It is known *__first > *__middle swap(*__first, *__middle); return; } // __len1 >= 2, __len2 >= 1 __len11 = __len1 / 2; __m1 = __first; _VSTD::advance(__m1, __len11); __m2 = __lower_bound<_Compare>(__middle, __last, *__m1, __comp); __len21 = _VSTD::distance(__middle, __m2); } difference_type __len12 = __len1 - __len11; // distance(__m1, __middle) difference_type __len22 = __len2 - __len21; // distance(__m2, __last) // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) // swap middle two partitions __middle = _VSTD::rotate(__m1, __middle, __m2); // __len12 and __len21 now have swapped meanings // merge smaller range with recurisve call and larger with tail recursion elimination if (__len11 + __len21 < __len12 + __len22) { __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); // __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); __first = __middle; __middle = __m2; __len1 = __len12; __len2 = __len22; } else { __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); // __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); __last = __middle; __middle = __m1; __len1 = __len11; __len2 = __len21; } } } template struct __inplace_merge_switch { static const unsigned value = is_trivially_copy_assignable<_Tp>::value; }; template inline _LIBCPP_INLINE_VISIBILITY void inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) { typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; 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); } #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __c, __len1, __len2, __buf.first, __buf.second); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2, __buf.first, __buf.second); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) { _VSTD::inplace_merge(__first, __middle, __last, __less::value_type>()); } // stable_sort template void __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp) { typedef typename iterator_traits<_InputIterator1>::value_type value_type; __destruct_n __d(0); unique_ptr __h(__result, __d); for (; true; ++__result) { if (__first1 == __last1) { for (; __first2 != __last2; ++__first2, ++__result, __d.__incr((value_type*)0)) ::new (__result) value_type(_VSTD::move(*__first2)); __h.release(); return; } if (__first2 == __last2) { for (; __first1 != __last1; ++__first1, ++__result, __d.__incr((value_type*)0)) ::new (__result) value_type(_VSTD::move(*__first1)); __h.release(); return; } if (__comp(*__first2, *__first1)) { ::new (__result) value_type(_VSTD::move(*__first2)); __d.__incr((value_type*)0); ++__first2; } else { ::new (__result) value_type(_VSTD::move(*__first1)); __d.__incr((value_type*)0); ++__first1; } } } template void __merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { for (; __first1 != __last1; ++__result) { if (__first2 == __last2) { for (; __first1 != __last1; ++__first1, ++__result) *__result = _VSTD::move(*__first1); return; } if (__comp(*__first2, *__first1)) { *__result = _VSTD::move(*__first2); ++__first2; } else { *__result = _VSTD::move(*__first1); ++__first1; } } for (; __first2 != __last2; ++__first2, ++__result) *__result = _VSTD::move(*__first2); } template void __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, typename iterator_traits<_RandomAccessIterator>::difference_type __len, typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size); template void __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp, typename iterator_traits<_RandomAccessIterator>::difference_type __len, typename iterator_traits<_RandomAccessIterator>::value_type* __first2) { typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; switch (__len) { case 0: return; case 1: ::new(__first2) value_type(_VSTD::move(*__first1)); return; case 2: __destruct_n __d(0); unique_ptr __h2(__first2, __d); if (__comp(*--__last1, *__first1)) { ::new(__first2) value_type(_VSTD::move(*__last1)); __d.__incr((value_type*)0); ++__first2; ::new(__first2) value_type(_VSTD::move(*__first1)); } else { ::new(__first2) value_type(_VSTD::move(*__first1)); __d.__incr((value_type*)0); ++__first2; ::new(__first2) value_type(_VSTD::move(*__last1)); } __h2.release(); return; } if (__len <= 8) { __insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp); return; } typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; _RandomAccessIterator __m = __first1 + __l2; __stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2); __stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2); __merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp); } template struct __stable_sort_switch { static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value; }; template void __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, typename iterator_traits<_RandomAccessIterator>::difference_type __len, typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size) { typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; switch (__len) { case 0: case 1: return; case 2: if (__comp(*--__last, *__first)) swap(*__first, *__last); return; } if (__len <= static_cast(__stable_sort_switch::value)) { __insertion_sort<_Compare>(__first, __last, __comp); return; } typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; _RandomAccessIterator __m = __first + __l2; if (__len <= __buff_size) { __destruct_n __d(0); unique_ptr __h2(__buff, __d); __stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff); __d.__set(__l2, (value_type*)0); __stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2); __d.__set(__len, (value_type*)0); __merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp); // __merge<_Compare>(move_iterator(__buff), // move_iterator(__buff + __l2), // move_iterator<_RandomAccessIterator>(__buff + __l2), // move_iterator<_RandomAccessIterator>(__buff + __len), // __first, __comp); return; } __stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size); __stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size); __inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size); } template inline _LIBCPP_INLINE_VISIBILITY void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; difference_type __len = __last - __first; pair __buf(0, 0); unique_ptr __h; if (__len > static_cast(__stable_sort_switch::value)) { __buf = _VSTD::get_temporary_buffer(__len); __h.reset(__buf.first); } #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __stable_sort<_Comp_ref>(__first, __last, __c, __len, __buf.first, __buf.second); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { _VSTD::stable_sort(__first, __last, __less::value_type>()); } // is_heap_until template _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::difference_type difference_type; difference_type __len = __last - __first; difference_type __p = 0; difference_type __c = 1; _RandomAccessIterator __pp = __first; while (__c < __len) { _RandomAccessIterator __cp = __first + __c; if (__comp(*__pp, *__cp)) return __cp; ++__c; ++__cp; if (__c == __len) return __last; if (__comp(*__pp, *__cp)) return __cp; ++__p; ++__pp; __c = 2 * __p + 1; } return __last; } template inline _LIBCPP_INLINE_VISIBILITY _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { return _VSTD::is_heap_until(__first, __last, __less::value_type>()); } // is_heap template inline _LIBCPP_INLINE_VISIBILITY bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { return _VSTD::is_heap_until(__first, __last, __comp) == __last; } template inline _LIBCPP_INLINE_VISIBILITY bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { return _VSTD::is_heap(__first, __last, __less::value_type>()); } // push_heap template void __push_heap_front(_RandomAccessIterator __first, _RandomAccessIterator, _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) { difference_type __p = 0; _RandomAccessIterator __pp = __first; difference_type __c = 2; _RandomAccessIterator __cp = __first + __c; if (__c == __len || __comp(*__cp, *(__cp - 1))) { --__c; --__cp; } if (__comp(*__pp, *__cp)) { value_type __t(_VSTD::move(*__pp)); do { *__pp = _VSTD::move(*__cp); __pp = __cp; __p = __c; __c = (__p + 1) * 2; if (__c > __len) break; __cp = __first + __c; if (__c == __len || __comp(*__cp, *(__cp - 1))) { --__c; --__cp; } } while (__comp(__t, *__cp)); *__pp = _VSTD::move(__t); } } } template void __push_heap_back(_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) { __len = (__len - 2) / 2; _RandomAccessIterator __ptr = __first + __len; if (__comp(*__ptr, *--__last)) { value_type __t(_VSTD::move(*__last)); do { *__last = _VSTD::move(*__ptr); __last = __ptr; if (__len == 0) break; __len = (__len - 1) / 2; __ptr = __first + __len; } while (__comp(*__ptr, __t)); *__last = _VSTD::move(__t); } } } template inline _LIBCPP_INLINE_VISIBILITY void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __push_heap_back<_Comp_ref>(__first, __last, __c, __last - __first); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { _VSTD::push_heap(__first, __last, __less::value_type>()); } // pop_heap template inline _LIBCPP_INLINE_VISIBILITY void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, typename iterator_traits<_RandomAccessIterator>::difference_type __len) { if (__len > 1) { swap(*__first, *--__last); __push_heap_front<_Compare>(__first, __last, __comp, __len-1); } } template inline _LIBCPP_INLINE_VISIBILITY void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __pop_heap<_Comp_ref>(__first, __last, __c, __last - __first); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { _VSTD::pop_heap(__first, __last, __less::value_type>()); } // make_heap template void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; difference_type __n = __last - __first; if (__n > 1) { __last = __first; ++__last; for (difference_type __i = 1; __i < __n;) __push_heap_back<_Compare>(__first, ++__last, __comp, ++__i); } } template inline _LIBCPP_INLINE_VISIBILITY void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __make_heap<_Comp_ref>(__first, __last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __make_heap<_Comp_ref>(__first, __last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { _VSTD::make_heap(__first, __last, __less::value_type>()); } // sort_heap template void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; for (difference_type __n = __last - __first; __n > 1; --__last, --__n) __pop_heap<_Compare>(__first, __last, __comp, __n); } template inline _LIBCPP_INLINE_VISIBILITY void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort_heap<_Comp_ref>(__first, __last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort_heap<_Comp_ref>(__first, __last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { _VSTD::sort_heap(__first, __last, __less::value_type>()); } // partial_sort template void __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { __make_heap<_Compare>(__first, __middle, __comp); typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first; for (_RandomAccessIterator __i = __middle; __i != __last; ++__i) { if (__comp(*__i, *__first)) { swap(*__i, *__first); __push_heap_front<_Compare>(__first, __middle, __comp, __len); } } __sort_heap<_Compare>(__first, __middle, __comp); } template inline _LIBCPP_INLINE_VISIBILITY void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __partial_sort<_Comp_ref>(__first, __middle, __last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __partial_sort<_Comp_ref>(__first, __middle, __last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) { _VSTD::partial_sort(__first, __middle, __last, __less::value_type>()); } // partial_sort_copy template _RandomAccessIterator __partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { _RandomAccessIterator __r = __result_first; if (__r != __result_last) { typename iterator_traits<_RandomAccessIterator>::difference_type __len = 0; for (; __first != __last && __r != __result_last; ++__first, ++__r, ++__len) *__r = *__first; __make_heap<_Compare>(__result_first, __r, __comp); for (; __first != __last; ++__first) if (__comp(*__first, *__result_first)) { *__result_first = *__first; __push_heap_front<_Compare>(__result_first, __r, __comp, __len); } __sort_heap<_Compare>(__result_first, __r, __comp); } return __r; } template inline _LIBCPP_INLINE_VISIBILITY _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last) { return _VSTD::partial_sort_copy(__first, __last, __result_first, __result_last, __less::value_type>()); } // nth_element template void __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { // _Compare is known to be a reference type typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; const difference_type __limit = 7; while (true) { __restart: if (__nth == __last) return; difference_type __len = __last - __first; switch (__len) { case 0: case 1: return; case 2: if (__comp(*--__last, *__first)) swap(*__first, *__last); return; case 3: { _RandomAccessIterator __m = __first; _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp); return; } } if (__len <= __limit) { __selection_sort<_Compare>(__first, __last, __comp); return; } // __len > __limit >= 3 _RandomAccessIterator __m = __first + __len/2; _RandomAccessIterator __lm1 = __last; unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp); // *__m is median // partition [__first, __m) < *__m and *__m <= [__m, __last) // (this inhibits tossing elements equivalent to __m around unnecessarily) _RandomAccessIterator __i = __first; _RandomAccessIterator __j = __lm1; // j points beyond range to be tested, *__lm1 is known to be <= *__m // The search going up is known to be guarded but the search coming down isn't. // Prime the downward search with a guard. if (!__comp(*__i, *__m)) // if *__first == *__m { // *__first == *__m, *__first doesn't go in first part // manually guard downward moving __j against __i while (true) { if (__i == --__j) { // *__first == *__m, *__m <= all other elements // Parition instead into [__first, __i) == *__first and *__first < [__i, __last) ++__i; // __first + 1 __j = __last; if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1) { while (true) { if (__i == __j) return; // [__first, __last) all equivalent elements if (__comp(*__first, *__i)) { swap(*__i, *__j); ++__n_swaps; ++__i; break; } ++__i; } } // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1 if (__i == __j) return; while (true) { while (!__comp(*__first, *__i)) ++__i; while (__comp(*__first, *--__j)) ; if (__i >= __j) break; swap(*__i, *__j); ++__n_swaps; ++__i; } // [__first, __i) == *__first and *__first < [__i, __last) // The first part is sorted, if (__nth < __i) return; // __nth_element the secod part // __nth_element<_Compare>(__i, __nth, __last, __comp); __first = __i; goto __restart; } if (__comp(*__j, *__m)) { swap(*__i, *__j); ++__n_swaps; break; // found guard for downward moving __j, now use unguarded partition } } } ++__i; // j points beyond range to be tested, *__lm1 is known to be <= *__m // if not yet partitioned... if (__i < __j) { // known that *(__i - 1) < *__m while (true) { // __m still guards upward moving __i while (__comp(*__i, *__m)) ++__i; // It is now known that a guard exists for downward moving __j while (!__comp(*--__j, *__m)) ; if (__i >= __j) break; swap(*__i, *__j); ++__n_swaps; // It is known that __m != __j // If __m just moved, follow it if (__m == __i) __m = __j; ++__i; } } // [__first, __i) < *__m and *__m <= [__i, __last) if (__i != __m && __comp(*__m, *__i)) { swap(*__i, *__m); ++__n_swaps; } // [__first, __i) < *__i and *__i <= [__i+1, __last) if (__nth == __i) return; if (__n_swaps == 0) { // We were given a perfectly partitioned sequence. Coincidence? if (__nth < __i) { // Check for [__first, __i) already sorted __j = __m = __first; while (++__j != __i) { if (__comp(*__j, *__m)) // not yet sorted, so sort goto not_sorted; __m = __j; } // [__first, __i) sorted return; } else { // Check for [__i, __last) already sorted __j = __m = __i; while (++__j != __last) { if (__comp(*__j, *__m)) // not yet sorted, so sort goto not_sorted; __m = __j; } // [__i, __last) sorted return; } } not_sorted: // __nth_element on range containing __nth if (__nth < __i) { // __nth_element<_Compare>(__first, __nth, __i, __comp); __last = __i; } else { // __nth_element<_Compare>(__i+1, __nth, __last, __comp); __first = ++__i; } } } template inline _LIBCPP_INLINE_VISIBILITY void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __nth_element<_Comp_ref>(__first, __nth, __last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __nth_element<_Comp_ref>(__first, __nth, __last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) { _VSTD::nth_element(__first, __nth, __last, __less::value_type>()); } // includes template bool __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { for (; __first2 != __last2; ++__first1) { if (__first1 == __last1 || __comp(*__first2, *__first1)) return false; if (!__comp(*__first1, *__first2)) ++__first2; } return true; } template inline _LIBCPP_INLINE_VISIBILITY bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { return _VSTD::includes(__first1, __last1, __first2, __last2, __less::value_type, typename iterator_traits<_InputIterator2>::value_type>()); } // set_union template _OutputIterator __set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { for (; __first1 != __last1; ++__result) { if (__first2 == __last2) return _VSTD::copy(__first1, __last1, __result); if (__comp(*__first2, *__first1)) { *__result = *__first2; ++__first2; } else { *__result = *__first1; if (!__comp(*__first1, *__first2)) ++__first2; ++__first1; } } return _VSTD::copy(__first2, __last2, __result); } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { return _VSTD::set_union(__first1, __last1, __first2, __last2, __result, __less::value_type, typename iterator_traits<_InputIterator2>::value_type>()); } // set_intersection template _OutputIterator __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1 && __first2 != __last2) { if (__comp(*__first1, *__first2)) ++__first1; else { if (!__comp(*__first2, *__first1)) { *__result = *__first1; ++__result; ++__first1; } ++__first2; } } return __result; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result, __less::value_type, typename iterator_traits<_InputIterator2>::value_type>()); } // set_difference template _OutputIterator __set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1) { if (__first2 == __last2) return _VSTD::copy(__first1, __last1, __result); if (__comp(*__first1, *__first2)) { *__result = *__first1; ++__result; ++__first1; } else { if (!__comp(*__first2, *__first1)) ++__first1; ++__first2; } } return __result; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result, __less::value_type, typename iterator_traits<_InputIterator2>::value_type>()); } // set_symmetric_difference template _OutputIterator __set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { while (__first1 != __last1) { if (__first2 == __last2) return _VSTD::copy(__first1, __last1, __result); if (__comp(*__first1, *__first2)) { *__result = *__first1; ++__result; ++__first1; } else { if (__comp(*__first2, *__first1)) { *__result = *__first2; ++__result; } else ++__first1; ++__first2; } } return _VSTD::copy(__first2, __last2, __result); } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __less::value_type, typename iterator_traits<_InputIterator2>::value_type>()); } // lexicographical_compare template bool __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { for (; __first2 != __last2; ++__first1, ++__first2) { if (__first1 == __last1 || __comp(*__first1, *__first2)) return true; if (__comp(*__first2, *__first1)) return false; } return false; } template inline _LIBCPP_INLINE_VISIBILITY bool lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY bool lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { return _VSTD::lexicographical_compare(__first1, __last1, __first2, __last2, __less::value_type, typename iterator_traits<_InputIterator2>::value_type>()); } // next_permutation template bool __next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { _BidirectionalIterator __i = __last; if (__first == __last || __first == --__i) return false; while (true) { _BidirectionalIterator __ip1 = __i; if (__comp(*--__i, *__ip1)) { _BidirectionalIterator __j = __last; while (!__comp(*__i, *--__j)) ; swap(*__i, *__j); _VSTD::reverse(__ip1, __last); return true; } if (__i == __first) { _VSTD::reverse(__first, __last); return false; } } } template inline _LIBCPP_INLINE_VISIBILITY bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __next_permutation<_Comp_ref>(__first, __last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __next_permutation<_Comp_ref>(__first, __last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) { return _VSTD::next_permutation(__first, __last, __less::value_type>()); } // prev_permutation template bool __prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { _BidirectionalIterator __i = __last; if (__first == __last || __first == --__i) return false; while (true) { _BidirectionalIterator __ip1 = __i; if (__comp(*__ip1, *--__i)) { _BidirectionalIterator __j = __last; while (!__comp(*--__j, *__i)) ; swap(*__i, *__j); _VSTD::reverse(__ip1, __last); return true; } if (__i == __first) { _VSTD::reverse(__first, __last); return false; } } } template inline _LIBCPP_INLINE_VISIBILITY bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { #ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __prev_permutation<_Comp_ref>(__first, __last, __c); #else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __prev_permutation<_Comp_ref>(__first, __last, __comp); #endif // _LIBCPP_DEBUG } template inline _LIBCPP_INLINE_VISIBILITY bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) { return _VSTD::prev_permutation(__first, __last, __less::value_type>()); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_integral<_Tp>::value, _Tp >::type __rotate_left(_Tp __t, _Tp __n = 1) { const unsigned __bits = static_cast(sizeof(_Tp) * __CHAR_BIT__ - 1); __n &= __bits; return static_cast<_Tp>((__t << __n) | (static_cast::type>(__t) >> (__bits - __n))); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < is_integral<_Tp>::value, _Tp >::type __rotate_right(_Tp __t, _Tp __n = 1) { const unsigned __bits = static_cast(sizeof(_Tp) * __CHAR_BIT__ - 1); __n &= __bits; return static_cast<_Tp>((__t << (__bits - __n)) | (static_cast::type>(__t) >> __n)); } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ALGORITHM libcxx/include/istream0000644000175000017500000014065612266757730016276 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- istream ----------------------------------===// // // The 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_ISTREAM #define _LIBCPP_ISTREAM /* istream synopsis 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; // 27.7.1.1.1 Constructor/destructor: explicit basic_istream(basic_streambuf* sb); basic_istream(basic_istream&& rhs); virtual ~basic_istream(); // 27.7.1.1.2 Assign/swap: basic_istream& operator=(basic_istream&& rhs); void swap(basic_istream& rhs); // 27.7.1.1.3 Prefix/suffix: class sentry; // 27.7.1.2 Formatted input: basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); basic_istream& operator>>(basic_ios& (*pf)(basic_ios&)); basic_istream& operator>>(ios_base& (*pf)(ios_base&)); basic_istream& operator>>(basic_streambuf* sb); basic_istream& operator>>(bool& n); basic_istream& operator>>(short& n); basic_istream& operator>>(unsigned short& n); basic_istream& operator>>(int& n); basic_istream& operator>>(unsigned int& n); basic_istream& operator>>(long& n); basic_istream& operator>>(unsigned long& n); basic_istream& operator>>(long long& n); basic_istream& operator>>(unsigned long long& n); basic_istream& operator>>(float& f); basic_istream& operator>>(double& f); basic_istream& operator>>(long double& f); basic_istream& operator>>(void*& p); // 27.7.1.3 Unformatted input: streamsize gcount() const; int_type get(); basic_istream& get(char_type& c); basic_istream& get(char_type* s, streamsize n); basic_istream& get(char_type* s, streamsize n, char_type delim); basic_istream& get(basic_streambuf& sb); basic_istream& get(basic_streambuf& sb, char_type delim); basic_istream& getline(char_type* s, streamsize n); basic_istream& getline(char_type* s, streamsize n, char_type delim); basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()); int_type peek(); basic_istream& read (char_type* s, streamsize n); streamsize readsome(char_type* s, streamsize n); basic_istream& putback(char_type c); basic_istream& unget(); int sync(); pos_type tellg(); basic_istream& seekg(pos_type); basic_istream& seekg(off_type, ios_base::seekdir); }; // 27.7.1.2.3 character extraction templates: template basic_istream& operator>>(basic_istream&, charT&); template basic_istream& operator>>(basic_istream&, unsigned char&); template basic_istream& operator>>(basic_istream&, signed char&); template basic_istream& operator>>(basic_istream&, charT*); template basic_istream& operator>>(basic_istream&, unsigned char*); template basic_istream& operator>>(basic_istream&, signed char*); template void swap(basic_istream& x, basic_istream& y); typedef basic_istream istream; typedef basic_istream wistream; 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; // constructor/destructor explicit basic_iostream(basic_streambuf* sb); basic_iostream(basic_iostream&& rhs); virtual ~basic_iostream(); // assign/swap basic_iostream& operator=(basic_iostream&& rhs); void swap(basic_iostream& rhs); }; template void swap(basic_iostream& x, basic_iostream& y); typedef basic_iostream iostream; typedef basic_iostream wiostream; template basic_istream& ws(basic_istream& is); template basic_istream& operator>>(basic_istream&& is, T& x); } // std */ #include <__config> #include #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template class _LIBCPP_TYPE_VIS_ONLY basic_istream : virtual public basic_ios<_CharT, _Traits> { streamsize __gc_; 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; // 27.7.1.1.1 Constructor/destructor: explicit basic_istream(basic_streambuf* __sb); virtual ~basic_istream(); protected: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_istream(basic_istream&& __rhs); #endif // 27.7.1.1.2 Assign/swap: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_istream& operator=(basic_istream&& __rhs); #endif void swap(basic_istream& __rhs); public: // 27.7.1.1.3 Prefix/suffix: class _LIBCPP_TYPE_VIS_ONLY sentry; // 27.7.1.2 Formatted input: basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)); basic_istream& operator>>(basic_ios& (*__pf)(basic_ios&)); basic_istream& operator>>(ios_base& (*__pf)(ios_base&)); basic_istream& operator>>(basic_streambuf* __sb); basic_istream& operator>>(bool& __n); basic_istream& operator>>(short& __n); basic_istream& operator>>(unsigned short& __n); basic_istream& operator>>(int& __n); basic_istream& operator>>(unsigned int& __n); basic_istream& operator>>(long& __n); basic_istream& operator>>(unsigned long& __n); basic_istream& operator>>(long long& __n); basic_istream& operator>>(unsigned long long& __n); basic_istream& operator>>(float& __f); basic_istream& operator>>(double& __f); basic_istream& operator>>(long double& __f); basic_istream& operator>>(void*& __p); // 27.7.1.3 Unformatted input: _LIBCPP_INLINE_VISIBILITY streamsize gcount() const {return __gc_;} int_type get(); basic_istream& get(char_type& __c); basic_istream& get(char_type* __s, streamsize __n); basic_istream& get(char_type* __s, streamsize __n, char_type __dlm); basic_istream& get(basic_streambuf& __sb); basic_istream& get(basic_streambuf& __sb, char_type __dlm); basic_istream& getline(char_type* __s, streamsize __n); basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm); basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); int_type peek(); basic_istream& read (char_type* __s, streamsize __n); streamsize readsome(char_type* __s, streamsize __n); basic_istream& putback(char_type __c); basic_istream& unget(); int sync(); pos_type tellg(); basic_istream& seekg(pos_type __pos); basic_istream& seekg(off_type __off, ios_base::seekdir __dir); }; template class _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry { bool __ok_; sentry(const sentry&); // = delete; sentry& operator=(const sentry&); // = delete; public: explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); // ~sentry() = default; _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const {return __ok_;} }; template basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws) : __ok_(false) { if (__is.good()) { if (__is.tie()) __is.tie()->flush(); if (!__noskipws && (__is.flags() & ios_base::skipws)) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); _Ip __i(__is); _Ip __eof; for (; __i != __eof; ++__i) if (!__ct.is(__ct.space, *__i)) break; if (__i == __eof) __is.setstate(ios_base::failbit | ios_base::eofbit); } __ok_ = __is.good(); } else __is.setstate(ios_base::failbit); } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf* __sb) : __gc_(0) { this->init(__sb); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) : __gc_(__rhs.__gc_) { __rhs.__gc_ = 0; this->move(__rhs); } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) { swap(__rhs); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template basic_istream<_CharT, _Traits>::~basic_istream() { } template inline _LIBCPP_INLINE_VISIBILITY void basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs) { _VSTD::swap(__gc_, __rhs.__gc_); basic_ios::swap(__rhs); } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(long long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(float& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(double& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(long double& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(bool& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(void*& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(short& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; long __temp; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); if (__temp < numeric_limits::min()) { __err |= ios_base::failbit; __n = numeric_limits::min(); } else if (__temp > numeric_limits::max()) { __err |= ios_base::failbit; __n = numeric_limits::max(); } else __n = static_cast(__temp); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(int& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; long __temp; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); if (__temp < numeric_limits::min()) { __err |= ios_base::failbit; __n = numeric_limits::min(); } else if (__temp > numeric_limits::max()) { __err |= ios_base::failbit; __n = numeric_limits::max(); } else __n = static_cast(__temp); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&)) { return __pf(*this); } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_ios& (*__pf)(basic_ios&)) { __pf(*this); return *this; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&)) { __pf(*this); return *this; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { streamsize __n = __is.width(); if (__n <= 0) __n = numeric_limits::max() / sizeof(_CharT) - 1; streamsize __c = 0; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); ios_base::iostate __err = ios_base::goodbit; while (__c < __n-1) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } _CharT __ch = _Traits::to_char_type(__i); if (__ct.is(__ct.space, __ch)) break; *__s++ = __ch; ++__c; __is.rdbuf()->sbumpc(); } *__s = _CharT(); __is.width(0); if (__c == 0) __err |= ios_base::failbit; __is.setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, unsigned char* __s) { return __is >> (char*)__s; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, signed char* __s) { return __is >> (char*)__s; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__i, _Traits::eof())) __is.setstate(ios_base::eofbit | ios_base::failbit); else __c = _Traits::to_char_type(__i); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, unsigned char& __c) { return __is >> (char&)__c; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, signed char& __c) { return __is >> (char&)__c; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_streambuf* __sb) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this, true); if (__s) { if (__sb) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS ios_base::iostate __err = ios_base::goodbit; while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } if (traits_type::eq_int_type( __sb->sputc(traits_type::to_char_type(__i)), traits_type::eof())) break; ++__gc_; this->rdbuf()->sbumpc(); } if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { if (__gc_ == 0) this->__set_failbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS } else this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::get() { __gc_ = 0; int_type __r = traits_type::eof(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this, true); if (__s) { __r = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__r, traits_type::eof())) this->setstate(ios_base::failbit | ios_base::eofbit); else __gc_ = 1; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type& __c) { int_type __ch = get(); if (__ch != traits_type::eof()) __c = traits_type::to_char_type(__ch); return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { if (__n > 0) { ios_base::iostate __err = ios_base::goodbit; while (__gc_ < __n-1) { int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } char_type __ch = traits_type::to_char_type(__i); if (traits_type::eq(__ch, __dlm)) break; *__s++ = __ch; ++__gc_; this->rdbuf()->sbumpc(); } *__s = char_type(); if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); } else this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n) { return get(__s, __n, this->widen('\n')); } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(basic_streambuf& __sb, char_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { ios_base::iostate __err = ios_base::goodbit; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } char_type __ch = traits_type::to_char_type(__i); if (traits_type::eq(__ch, __dlm)) break; if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof())) break; ++__gc_; this->rdbuf()->sbumpc(); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } #endif // _LIBCPP_NO_EXCEPTIONS if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(basic_streambuf& __sb) { return get(__sb, this->widen('\n')); } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { ios_base::iostate __err = ios_base::goodbit; while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } char_type __ch = traits_type::to_char_type(__i); if (traits_type::eq(__ch, __dlm)) { this->rdbuf()->sbumpc(); ++__gc_; break; } if (__gc_ >= __n-1) { __err |= ios_base::failbit; break; } *__s++ = __ch; this->rdbuf()->sbumpc(); ++__gc_; } if (__n > 0) *__s = char_type(); if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n) { return getline(__s, __n, this->widen('\n')); } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { ios_base::iostate __err = ios_base::goodbit; if (__n == numeric_limits::max()) { while (true) { typename traits_type::int_type __i = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } ++__gc_; if (traits_type::eq_int_type(__i, __dlm)) break; } } else { while (__gc_ < __n) { typename traits_type::int_type __i = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } ++__gc_; if (traits_type::eq_int_type(__i, __dlm)) break; } } this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::peek() { __gc_ = 0; int_type __r = traits_type::eof(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { __r = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__r, traits_type::eof())) this->setstate(ios_base::eofbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { __gc_ = this->rdbuf()->sgetn(__s, __n); if (__gc_ != __n) this->setstate(ios_base::failbit | ios_base::eofbit); } else this->setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n) { __gc_ = 0; streamsize __c = this->rdbuf()->in_avail(); switch (__c) { case -1: this->setstate(ios_base::eofbit); break; case 0: break; default: read(__s, _VSTD::min(__c, __n)); break; } return __gc_; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_type __c) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof()) this->setstate(ios_base::badbit); } else this->setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof()) this->setstate(ios_base::badbit); } else this->setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template int basic_istream<_CharT, _Traits>::sync() { int __r = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { if (this->rdbuf() == 0) return -1; if (this->rdbuf()->pubsync() == -1) { this->setstate(ios_base::badbit); return -1; } } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>::tellg() { pos_type __r(-1); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type __pos) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _Traits>& __is) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { const ctype<_CharT>& __ct = use_facet >(__is.getloc()); while (true) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __is.setstate(ios_base::eofbit); break; } if (!__ct.is(__ct.space, _Traits::to_char_type(__i))) break; __is.rdbuf()->sbumpc(); } } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) { __is >> __x; return __is; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template class _LIBCPP_TYPE_VIS_ONLY basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { public: // types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // constructor/destructor explicit basic_iostream(basic_streambuf* __sb); virtual ~basic_iostream(); protected: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_iostream(basic_iostream&& __rhs); #endif // assign/swap #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_iostream& operator=(basic_iostream&& __rhs); #endif void swap(basic_iostream& __rhs); public: }; template inline _LIBCPP_INLINE_VISIBILITY basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf* __sb) : basic_istream<_CharT, _Traits>(__sb) { } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)) { } template inline _LIBCPP_INLINE_VISIBILITY basic_iostream<_CharT, _Traits>& basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) { swap(__rhs); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template basic_iostream<_CharT, _Traits>::~basic_iostream() { } template inline _LIBCPP_INLINE_VISIBILITY void basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs) { basic_istream::swap(__rhs); } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { __str.clear(); streamsize __n = __is.width(); if (__n <= 0) __n = __str.max_size(); if (__n <= 0) __n = numeric_limits::max(); streamsize __c = 0; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); ios_base::iostate __err = ios_base::goodbit; while (__c < __n) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } _CharT __ch = _Traits::to_char_type(__i); if (__ct.is(__ct.space, __ch)) break; __str.push_back(__ch); ++__c; __is.rdbuf()->sbumpc(); } __is.width(0); if (__c == 0) __err |= ios_base::failbit; __is.setstate(__err); } else __is.setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { __str.clear(); ios_base::iostate __err = ios_base::goodbit; streamsize __extr = 0; while (true) { typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } ++__extr; _CharT __ch = _Traits::to_char_type(__i); if (_Traits::eq(__ch, __dlm)) break; __str.push_back(__ch); if (__str.size() == __str.max_size()) { __err |= ios_base::failbit; break; } } if (__extr == 0) __err |= ios_base::failbit; __is.setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str) { return getline(__is, __str, __is.widen('\n')); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) { return getline(__is, __str, __dlm); } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str) { return getline(__is, __str, __is.widen('\n')); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { basic_string<_CharT, _Traits> __str; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); streamsize __c = 0; ios_base::iostate __err = ios_base::goodbit; _CharT __zero = __ct.widen('0'); _CharT __one = __ct.widen('1'); while (__c < _Size) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } _CharT __ch = _Traits::to_char_type(__i); if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one)) break; __str.push_back(__ch); ++__c; __is.rdbuf()->sbumpc(); } __x = bitset<_Size>(__str); if (__c == 0) __err |= ios_base::failbit; __is.setstate(__err); } else __is.setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ISTREAM libcxx/include/complex.h0000644000175000017500000000130112266757730016506 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- complex.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_COMPLEX_H #define _LIBCPP_COMPLEX_H /* complex.h synopsis #include */ #ifdef __cplusplus #include #else // __cplusplus #include_next #endif // __cplusplus #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #endif // _LIBCPP_COMPLEX_H libcxx/include/climits0000644000175000017500000000157612266757730016273 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- climits ----------------------------------===// // // The 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_CLIMITS #define _LIBCPP_CLIMITS /* climits synopsis Macros: CHAR_BIT SCHAR_MIN SCHAR_MAX UCHAR_MAX CHAR_MIN CHAR_MAX MB_LEN_MAX SHRT_MIN SHRT_MAX USHRT_MAX INT_MIN INT_MAX UINT_MAX LONG_MIN LONG_MAX ULONG_MAX LLONG_MIN // C99 LLONG_MAX // C99 ULLONG_MAX // C99 */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #endif // _LIBCPP_CLIMITS libcxx/include/cstdint0000644000175000017500000000534112266757731016272 0ustar sylvestresylvestre// -*- C++ -*- //===--------------------------- cstdint ----------------------------------===// // // The 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_CSTDINT #define _LIBCPP_CSTDINT /* cstdint synopsis Macros: INT8_MIN INT16_MIN INT32_MIN INT64_MIN INT8_MAX INT16_MAX INT32_MAX INT64_MAX UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX INT_LEAST8_MIN INT_LEAST16_MIN INT_LEAST32_MIN INT_LEAST64_MIN INT_LEAST8_MAX INT_LEAST16_MAX INT_LEAST32_MAX INT_LEAST64_MAX UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX INT_FAST8_MIN INT_FAST16_MIN INT_FAST32_MIN INT_FAST64_MIN INT_FAST8_MAX INT_FAST16_MAX INT_FAST32_MAX INT_FAST64_MAX UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX INTPTR_MIN INTPTR_MAX UINTPTR_MAX INTMAX_MIN INTMAX_MAX UINTMAX_MAX PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX SIZE_MAX WCHAR_MIN WCHAR_MAX WINT_MIN WINT_MAX INT8_C(value) INT16_C(value) INT32_C(value) INT64_C(value) UINT8_C(value) UINT16_C(value) UINT32_C(value) UINT64_C(value) INTMAX_C(value) UINTMAX_C(value) namespace std { Types: int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t uint64_t int_least8_t int_least16_t int_least32_t int_least64_t uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t intptr_t uintptr_t intmax_t uintmax_t } // std */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD using::int8_t; using::int16_t; using::int32_t; using::int64_t; using::uint8_t; using::uint16_t; using::uint32_t; using::uint64_t; using::int_least8_t; using::int_least16_t; using::int_least32_t; using::int_least64_t; using::uint_least8_t; using::uint_least16_t; using::uint_least32_t; using::uint_least64_t; using::int_fast8_t; using::int_fast16_t; using::int_fast32_t; using::int_fast64_t; using::uint_fast8_t; using::uint_fast16_t; using::uint_fast32_t; using::uint_fast64_t; using::intptr_t; using::uintptr_t; using::intmax_t; using::uintmax_t; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CSTDINT libcxx/include/cctype0000644000175000017500000001107112266757730016105 0ustar sylvestresylvestre// -*- C++ -*- //===---------------------------- cctype ----------------------------------===// // // The 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_CCTYPE #define _LIBCPP_CCTYPE /* cctype synopsis namespace std { int isalnum(int c); int isalpha(int c); int isblank(int c); // C99 int iscntrl(int c); int isdigit(int c); int isgraph(int c); int islower(int c); int isprint(int c); int ispunct(int c); int isspace(int c); int isupper(int c); int isxdigit(int c); int tolower(int c); int toupper(int c); } // std */ #include <__config> #include #if defined(_LIBCPP_MSVCRT) #include "support/win32/support.h" #endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #ifdef isalnum inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalnum(int __c) {return isalnum(__c);} #undef isalnum inline _LIBCPP_INLINE_VISIBILITY int isalnum(int __c) {return __libcpp_isalnum(__c);} #else // isalnum using ::isalnum; #endif // isalnum #ifdef isalpha inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalpha(int __c) {return isalpha(__c);} #undef isalpha inline _LIBCPP_INLINE_VISIBILITY int isalpha(int __c) {return __libcpp_isalpha(__c);} #else // isalpha using ::isalpha; #endif // isalpha #ifdef isblank inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isblank(int __c) {return isblank(__c);} #undef isblank inline _LIBCPP_INLINE_VISIBILITY int isblank(int __c) {return __libcpp_isblank(__c);} #else // isblank using ::isblank; #endif // isblank #ifdef iscntrl inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iscntrl(int __c) {return iscntrl(__c);} #undef iscntrl inline _LIBCPP_INLINE_VISIBILITY int iscntrl(int __c) {return __libcpp_iscntrl(__c);} #else // iscntrl using ::iscntrl; #endif // iscntrl #ifdef isdigit inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isdigit(int __c) {return isdigit(__c);} #undef isdigit inline _LIBCPP_INLINE_VISIBILITY int isdigit(int __c) {return __libcpp_isdigit(__c);} #else // isdigit using ::isdigit; #endif // isdigit #ifdef isgraph inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isgraph(int __c) {return isgraph(__c);} #undef isgraph inline _LIBCPP_INLINE_VISIBILITY int isgraph(int __c) {return __libcpp_isgraph(__c);} #else // isgraph using ::isgraph; #endif // isgraph #ifdef islower inline _LIBCPP_INLINE_VISIBILITY int __libcpp_islower(int __c) {return islower(__c);} #undef islower inline _LIBCPP_INLINE_VISIBILITY int islower(int __c) {return __libcpp_islower(__c);} #else // islower using ::islower; #endif // islower #ifdef isprint inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isprint(int __c) {return isprint(__c);} #undef isprint inline _LIBCPP_INLINE_VISIBILITY int isprint(int __c) {return __libcpp_isprint(__c);} #else // isprint using ::isprint; #endif // isprint #ifdef ispunct inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ispunct(int __c) {return ispunct(__c);} #undef ispunct inline _LIBCPP_INLINE_VISIBILITY int ispunct(int __c) {return __libcpp_ispunct(__c);} #else // ispunct using ::ispunct; #endif // ispunct #ifdef isspace inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isspace(int __c) {return isspace(__c);} #undef isspace inline _LIBCPP_INLINE_VISIBILITY int isspace(int __c) {return __libcpp_isspace(__c);} #else // isspace using ::isspace; #endif // isspace #ifdef isupper inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isupper(int __c) {return isupper(__c);} #undef isupper inline _LIBCPP_INLINE_VISIBILITY int isupper(int __c) {return __libcpp_isupper(__c);} #else // isupper using ::isupper; #endif // isupper #ifdef isxdigit inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isxdigit(int __c) {return isxdigit(__c);} #undef isxdigit inline _LIBCPP_INLINE_VISIBILITY int isxdigit(int __c) {return __libcpp_isxdigit(__c);} #else // isxdigit using ::isxdigit; #endif // isxdigit #ifdef tolower inline _LIBCPP_INLINE_VISIBILITY int __libcpp_tolower(int __c) {return tolower(__c);} #undef tolower inline _LIBCPP_INLINE_VISIBILITY int tolower(int __c) {return __libcpp_tolower(__c);} #else // tolower using ::tolower; #endif // tolower #ifdef toupper inline _LIBCPP_INLINE_VISIBILITY int __libcpp_toupper(int __c) {return toupper(__c);} #undef toupper inline _LIBCPP_INLINE_VISIBILITY int toupper(int __c) {return __libcpp_toupper(__c);} #else // toupper using ::toupper; #endif // toupper _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CCTYPE libcxx/include/memory0000644000175000017500000051726212266757730016143 0ustar sylvestresylvestre// -*- C++ -*- //===-------------------------- memory ------------------------------------===// // // The 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_MEMORY #define _LIBCPP_MEMORY /* memory synopsis namespace std { struct allocator_arg_t { }; constexpr allocator_arg_t allocator_arg = allocator_arg_t(); template struct uses_allocator; template struct pointer_traits { typedef Ptr pointer; typedef
element_type; typedef
difference_type; template using rebind =
; static pointer pointer_to(
); }; template struct pointer_traits { typedef T* pointer; typedef T element_type; typedef ptrdiff_t difference_type; template using rebind = U*; static pointer pointer_to(
) noexcept; }; 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; typedef Alloc::difference_type | pointer_traits::difference_type difference_type; typedef Alloc::size_type | make_unsigned::type size_type; typedef Alloc::propagate_on_container_copy_assignment | false_type propagate_on_container_copy_assignment; typedef Alloc::propagate_on_container_move_assignment | false_type propagate_on_container_move_assignment; typedef Alloc::propagate_on_container_swap | false_type propagate_on_container_swap; template using rebind_alloc = Alloc::rebind::other | Alloc; template using rebind_traits = allocator_traits>; static pointer allocate(allocator_type& a, size_type n); static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; template static void construct(allocator_type& a, T* p, Args&&... args); template static void destroy(allocator_type& a, T* p); static size_type max_size(const allocator_type& a); // noexcept in C++14 static allocator_type select_on_container_copy_construction(const allocator_type& a); }; template <> class allocator { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind {typedef allocator<_Up> other;}; }; 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; template struct rebind {typedef allocator other;}; allocator() noexcept; allocator(const allocator&) noexcept; template allocator(const allocator&) noexcept; ~allocator(); pointer address(reference x) const noexcept; const_pointer address(const_reference x) const noexcept; pointer allocate(size_type, allocator::const_pointer hint = 0); void deallocate(pointer p, size_type n) noexcept; size_type max_size() const noexcept; template void construct(U* p, Args&&... args); template void destroy(U* p); }; template bool operator==(const allocator&, const allocator&) noexcept; template bool operator!=(const allocator&, const allocator&) noexcept; template class raw_storage_iterator : public iterator // purposefully not C++03 { public: explicit raw_storage_iterator(OutputIterator x); raw_storage_iterator& operator*(); raw_storage_iterator& operator=(const T& element); raw_storage_iterator& operator++(); raw_storage_iterator operator++(int); }; template pair get_temporary_buffer(ptrdiff_t n) noexcept; template void return_temporary_buffer(T* p) noexcept; template T* addressof(T& r) noexcept; template ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); template ForwardIterator uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); template void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); template ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x); template struct auto_ptr_ref {}; template class auto_ptr { public: typedef X element_type; explicit auto_ptr(X* p =0) throw(); auto_ptr(auto_ptr&) throw(); template auto_ptr(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr&) throw(); template auto_ptr& operator=(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr_ref r) throw(); ~auto_ptr() throw(); typename add_lvalue_reference::type operator*() const throw(); X* operator->() const throw(); X* get() const throw(); X* release() throw(); void reset(X* p =0) throw(); auto_ptr(auto_ptr_ref) throw(); template operator auto_ptr_ref() throw(); template operator auto_ptr() throw(); }; template struct default_delete { constexpr default_delete() noexcept = default; template default_delete(const default_delete&) noexcept; void operator()(T*) const noexcept; }; template struct default_delete { constexpr default_delete() noexcept = default; void operator()(T*) const noexcept; template void operator()(U*) const = delete; }; template > class unique_ptr { public: typedef see below pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; explicit unique_ptr(pointer p) noexcept; unique_ptr(pointer p, see below d1) noexcept; unique_ptr(pointer p, see below d2) noexcept; unique_ptr(unique_ptr&& u) noexcept; unique_ptr(nullptr_t) noexcept : unique_ptr() { } template unique_ptr(unique_ptr&& u) noexcept; template unique_ptr(auto_ptr&& u) noexcept; // destructor ~unique_ptr(); // assignment unique_ptr& operator=(unique_ptr&& u) noexcept; template unique_ptr& operator=(unique_ptr&& u) noexcept; unique_ptr& operator=(nullptr_t) noexcept; // observers typename add_lvalue_reference::type operator*() const; pointer operator->() const noexcept; pointer get() const noexcept; deleter_type& get_deleter() noexcept; const deleter_type& get_deleter() const noexcept; explicit operator bool() const noexcept; // modifiers pointer release() noexcept; void reset(pointer p = pointer()) noexcept; void swap(unique_ptr& u) noexcept; }; template class unique_ptr { public: typedef implementation-defined pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; explicit unique_ptr(pointer p) noexcept; unique_ptr(pointer p, see below d) noexcept; unique_ptr(pointer p, see below d) noexcept; unique_ptr(unique_ptr&& u) noexcept; unique_ptr(nullptr_t) noexcept : unique_ptr() { } // destructor ~unique_ptr(); // assignment unique_ptr& operator=(unique_ptr&& u) noexcept; unique_ptr& operator=(nullptr_t) noexcept; // observers T& operator[](size_t i) const; pointer get() const noexcept; deleter_type& get_deleter() noexcept; const deleter_type& get_deleter() const noexcept; explicit operator bool() const noexcept; // modifiers pointer release() noexcept; void reset(pointer p = pointer()) noexcept; void reset(nullptr_t) noexcept; template void reset(U) = delete; void swap(unique_ptr& u) noexcept; }; template void swap(unique_ptr& x, unique_ptr& y) noexcept; 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); 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, 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); template bool operator<(nullptr_t, const unique_ptr& y); template bool operator<=(const unique_ptr& x, nullptr_t); template bool operator<=(nullptr_t, const unique_ptr& y); template bool operator>(const unique_ptr& x, nullptr_t); template bool operator>(nullptr_t, const unique_ptr& y); template bool operator>=(const unique_ptr& x, nullptr_t); template bool operator>=(nullptr_t, const unique_ptr& y); class bad_weak_ptr : public std::exception { bad_weak_ptr() noexcept; }; template unique_ptr make_unique(Args&&... args); // C++14 template unique_ptr make_unique(size_t n); // C++14 template unspecified make_unique(Args&&...) = delete; // C++14, T == U[N] template class shared_ptr { public: typedef T element_type; // constructors: constexpr shared_ptr() noexcept; template explicit shared_ptr(Y* p); template shared_ptr(Y* p, D d); template shared_ptr(Y* p, D d, A a); template shared_ptr(nullptr_t p, D d); template shared_ptr(nullptr_t p, D d, A a); template shared_ptr(const shared_ptr& r, T *p) noexcept; shared_ptr(const shared_ptr& r) noexcept; template shared_ptr(const shared_ptr& r) noexcept; shared_ptr(shared_ptr&& r) noexcept; template shared_ptr(shared_ptr&& r) noexcept; template explicit shared_ptr(const weak_ptr& r); template shared_ptr(auto_ptr&& r); template shared_ptr(unique_ptr&& r); shared_ptr(nullptr_t) : shared_ptr() { } // destructor: ~shared_ptr(); // assignment: shared_ptr& operator=(const shared_ptr& r) noexcept; template shared_ptr& operator=(const shared_ptr& r) noexcept; shared_ptr& operator=(shared_ptr&& r) noexcept; template shared_ptr& operator=(shared_ptr&& r); template shared_ptr& operator=(auto_ptr&& r); template shared_ptr& operator=(unique_ptr&& r); // modifiers: void swap(shared_ptr& r) noexcept; void reset() noexcept; template void reset(Y* p); template void reset(Y* p, D d); template void reset(Y* p, D d, A a); // observers: T* get() const noexcept; T& operator*() const noexcept; T* operator->() const noexcept; long use_count() const noexcept; bool unique() const noexcept; explicit operator bool() const noexcept; template bool owner_before(shared_ptr const& b) const; template bool owner_before(weak_ptr const& b) const; }; // shared_ptr comparisons: template bool operator==(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator!=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator<(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator>(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator<=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator>=(shared_ptr const& a, shared_ptr const& b) 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; template bool operator>=(const shared_ptr& x, nullptr_t) noexcept; template bool operator>=(nullptr_t, const shared_ptr& y) noexcept; // shared_ptr specialized algorithms: template void swap(shared_ptr& a, shared_ptr& b) noexcept; // shared_ptr casts: template shared_ptr static_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr dynamic_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr const_pointer_cast(shared_ptr const& r) noexcept; // shared_ptr I/O: template basic_ostream& operator<< (basic_ostream& os, shared_ptr const& p); // shared_ptr get_deleter: template D* get_deleter(shared_ptr const& p) noexcept; template shared_ptr make_shared(Args&&... args); template shared_ptr allocate_shared(const A& a, Args&&... args); template class weak_ptr { public: typedef T element_type; // constructors constexpr weak_ptr() noexcept; template weak_ptr(shared_ptr const& r) noexcept; weak_ptr(weak_ptr const& r) noexcept; template weak_ptr(weak_ptr const& r) noexcept; // destructor ~weak_ptr(); // assignment weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(shared_ptr const& r) noexcept; // modifiers void swap(weak_ptr& r) noexcept; void reset() noexcept; // observers long use_count() const noexcept; bool expired() const noexcept; shared_ptr lock() const noexcept; template bool owner_before(shared_ptr const& b) const; template bool owner_before(weak_ptr const& b) const; }; // weak_ptr specialized algorithms: template void swap(weak_ptr& a, weak_ptr& b) noexcept; // class owner_less: 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; }; template class enable_shared_from_this { protected: constexpr enable_shared_from_this() noexcept; enable_shared_from_this(enable_shared_from_this const&) noexcept; enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; ~enable_shared_from_this(); public: shared_ptr shared_from_this(); shared_ptr shared_from_this() const; }; template bool atomic_is_lock_free(const shared_ptr* p); template shared_ptr atomic_load(const shared_ptr* p); template shared_ptr atomic_load_explicit(const shared_ptr* p, memory_order mo); template void atomic_store(shared_ptr* p, shared_ptr r); template void atomic_store_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template shared_ptr atomic_exchange(shared_ptr* p, shared_ptr r); template shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template bool atomic_compare_exchange_weak(shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_strong( shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_weak_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); template bool atomic_compare_exchange_strong_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); // Hash support template struct hash; template struct hash >; template struct hash >; // Pointer safety enum class pointer_safety { relaxed, preferred, strict }; void declare_reachable(void *p); template T *undeclare_reachable(T *p); void declare_no_pointers(char *p, size_t n); void undeclare_no_pointers(char *p, size_t n); pointer_safety get_pointer_safety() noexcept; void* align(size_t alignment, size_t size, void*& ptr, size_t& space); } // std */ #include <__config> #include #include #include #include #include #include #include #include #include <__functional_base> #include #include #include #if defined(_LIBCPP_NO_EXCEPTIONS) #include #endif #if __has_feature(cxx_atomic) # include #endif #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD // addressof moved to <__functional_base> template class allocator; template <> class _LIBCPP_TYPE_VIS_ONLY allocator { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind {typedef allocator<_Up> other;}; }; template <> class _LIBCPP_TYPE_VIS_ONLY allocator { public: typedef const void* pointer; typedef const void* const_pointer; typedef const void value_type; template struct rebind {typedef allocator<_Up> other;}; }; // pointer_traits template struct __has_element_type { private: struct __two {char __lx; char __lxx;}; template static __two __test(...); template static char __test(typename _Up::element_type* = 0); public: static const bool value = sizeof(__test<_Tp>(0)) == 1; }; template ::value> struct __pointer_traits_element_type; template struct __pointer_traits_element_type<_Ptr, true> { typedef typename _Ptr::element_type type; }; #ifndef _LIBCPP_HAS_NO_VARIADICS template

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 } libcxx/test/algorithms/alg.sorting/alg.sort/is.sorted/0000755000175000017500000000000012266757725024276 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp0000644000175000017500000001216112266757725031156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp0000644000175000017500000001106612266757725027746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp0000644000175000017500000001346212266757725032201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp0000644000175000017500000001234212266757725030762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.sort/partial.sort/0000755000175000017500000000000012266757725025006 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp0000644000175000017500000000306412266757725031165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp0000644000175000017500000000437412266757725032210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/0000755000175000017500000000000012266757725025757 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp0000644000175000017500000000460012266757725033165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp0000644000175000017500000000510212266757725034201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/0000755000175000017500000000000012266757725024125 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.binary.search/lower.bound/0000755000175000017500000000000012266757725026363 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp0000644000175000017500000000320212266757725033366 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp0000644000175000017500000000303412266757725032353 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/binary.search/0000755000175000017500000000000012266757725026655 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp0000644000175000017500000000337712266757725034167 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp0000644000175000017500000000316012266757725033137 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725030435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.sorting/alg.binary.search/equal.range/0000755000175000017500000000000012266757725026327 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp0000644000175000017500000000340412266757725032264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp0000644000175000017500000000371712266757725033311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/upper.bound/0000755000175000017500000000000012266757725026366 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp0000644000175000017500000000327412266757725033405 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp0000644000175000017500000000303412266757725032361 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/0000755000175000017500000000000012266757725024352 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.set.operations/set.intersection/0000755000175000017500000000000012266757725027652 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpplibcxx/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cp0000644000175000017500000003214612266757725035550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp0000644000175000017500000003174112266757725034712 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725030662 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/algorithms/alg.sorting/alg.set.operations/set.difference/0000755000175000017500000000000012266757725027236 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp0000644000175000017500000003225712266757725034703 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp0000644000175000017500000003205212266757725033656 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/includes/0000755000175000017500000000000012266757725026160 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp0000644000175000017500000000723512266757725031446 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp0000644000175000017500000000770112266757725032462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/set.union/0000755000175000017500000000000012266757725026274 5ustar sylvestresylvestrelibcxx/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp0000644000175000017500000003212412266757725032770 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp0000644000175000017500000003171712266757725031761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/0000755000175000017500000000000012266757725031251 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpplibcxx/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_differe0000644000175000017500000003207612266757725035557 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpplibcxx/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_differe0000644000175000017500000003243112266757725035552 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/algorithms/algorithms.general/0000755000175000017500000000000012266757725022171 5ustar sylvestresylvestrelibcxx/test/algorithms/algorithms.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/0000755000175000017500000000000012266757726016250 5ustar sylvestresylvestrelibcxx/test/iterators/version.pass.cpp0000644000175000017500000000073312266757726021411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/iterators/iterator.requirements/0000755000175000017500000000000012266757726022623 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/bidirectional.iterators/0000755000175000017500000000000012266757726027446 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726033756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.requirements/input.iterators/0000755000175000017500000000000012266757726025775 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726032305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.requirements/random.access.iterators/0000755000175000017500000000000012266757726027356 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726033666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726027133 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.requirements/output.iterators/0000755000175000017500000000000012266757726026176 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726032506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.requirements/forward.iterators/0000755000175000017500000000000012266757726026302 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726032612 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.requirements/iterator.iterators/0000755000175000017500000000000012266757726026467 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726032777 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.requirements/iterator.requirements.general/0000755000175000017500000000000012266757726030612 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726035122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.synopsis/0000755000175000017500000000000012266757726021767 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.synopsis/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026277 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/stream.iterators/0000755000175000017500000000000012266757726021556 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/ostreambuf.iterator/0000755000175000017500000000000012266757726025555 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp0000644000175000017500000000350612266757726030376 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/0000755000175000017500000000000012266757726031466 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp0000644000175000017500000000212412266757726035122 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp0000644000175000017500000000126612266757726034370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp0000644000175000017500000000156112266757726034227 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp0000644000175000017500000000166012266757726034730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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"); } } libcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/0000755000175000017500000000000012266757726031627 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp0000644000175000017500000000143012266757726035266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp0000644000175000017500000000140612266757726034753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/iterators/stream.iterators/istream.iterator/0000755000175000017500000000000012266757726025052 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/istream.iterator/types.pass.cpp0000644000175000017500000000327312266757726027674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // ... #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), ""); 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), ""); } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/0000755000175000017500000000000012266757726031307 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp0000644000175000017500000000134412266757726034426 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp0000644000175000017500000000105712266757726034407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); #include #include int main() { std::istream_iterator i; assert(i == std::istream_iterator()); } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp0000644000175000017500000000162512266757726033736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/0000755000175000017500000000000012266757726031146 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp0000644000175000017500000000135612266757726035655 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp0000644000175000017500000000127612266757726035457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp0000644000175000017500000000271112266757726033727 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp0000644000175000017500000000137112266757726033753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp0000644000175000017500000000133712266757726035072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/istreambuf.iterator/0000755000175000017500000000000012266757726025547 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/0000755000175000017500000000000012266757726033001 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp0000644000175000017500000000204612266757726035635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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'); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp0000644000175000017500000000432512266757726030370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; // ... #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), ""); 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), ""); } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/0000755000175000017500000000000012266757726032430 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp0000644000175000017500000000414212266757726035211 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/0000755000175000017500000000000012266757726032727 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp0000644000175000017500000000406212266757726035511 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/0000755000175000017500000000000012266757726032501 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpplibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.c0000644000175000017500000000261412266757726035605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp0000644000175000017500000000217012266757726035616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp0000644000175000017500000000173312266757726035337 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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'); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp0000644000175000017500000000133112266757726035574 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); #include #include #include int main() { { std::istreambuf_iterator i; assert(i == std::istreambuf_iterator()); } { std::istreambuf_iterator i; assert(i == std::istreambuf_iterator()); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/0000755000175000017500000000000012266757726032374 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpplibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.c0000644000175000017500000000414212266757726035475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/0000755000175000017500000000000012266757726033442 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpplibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increme0000644000175000017500000000177712266757726036070 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpplibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_incremen0000644000175000017500000000203612266757726036034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpplibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.c0000644000175000017500000000126112266757726035705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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! } libcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/0000755000175000017500000000000012266757726032364 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpplibcxx/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass0000644000175000017500000000162412266757726035526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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'); } } libcxx/test/iterators/stream.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/stream.iterators/ostream.iterator/0000755000175000017500000000000012266757726025060 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp0000644000175000017500000000314312266757726027676 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/0000755000175000017500000000000012266757726032075 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp0000644000175000017500000000113612266757726035221 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpplibcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass0000644000175000017500000000143612266757726035611 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } } libcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp0000644000175000017500000000121612266757726034520 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/0000755000175000017500000000000012266757726031162 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp0000644000175000017500000000214512266757726034444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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, "); } } libcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp0000644000175000017500000000136212266757726034621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp0000644000175000017500000000120712266757726035102 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/iterator.range/0000755000175000017500000000000012266757726024502 5ustar sylvestresylvestrelibcxx/test/iterators/stream.iterators/iterator.range/begin_const.pass.cpp0000644000175000017500000000122212266757726030442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/iterator.range/end_const.pass.cpp0000644000175000017500000000122212266757726030124 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/iterators/stream.iterators/iterator.range/end_array.pass.cpp0000644000175000017500000000114612266757726030121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp0000644000175000017500000000124112266757726031315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/iterator.range/begin_array.pass.cpp0000644000175000017500000000112512266757726030434 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp0000644000175000017500000000117712266757726031007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/iterators/iterator.primitives/0000755000175000017500000000000012266757726022273 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.primitives/iterator.operations/0000755000175000017500000000000012266757726026306 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.primitives/iterator.operations/advance.pass.cpp0000644000175000017500000000275312266757726031367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/iterator.primitives/iterator.operations/next.pass.cpp0000644000175000017500000000253712266757726030744 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/iterator.primitives/iterator.operations/distance.pass.cpp0000644000175000017500000000232112266757726031547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/iterator.primitives/iterator.operations/prev.pass.cpp0000644000175000017500000000230212266757726030730 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/iterators/iterator.primitives/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.primitives/std.iterator.tags/0000755000175000017500000000000012266757726025652 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp0000644000175000017500000000117312266757726033230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp0000644000175000017500000000150112266757726034674 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp0000644000175000017500000000144412266757726033536 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp0000644000175000017500000000117512266757726033433 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp0000644000175000017500000000151512266757726034672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/iterators/iterator.primitives/iterator.basic/0000755000175000017500000000000012266757726025204 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp0000644000175000017500000000561212266757726030512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/iterators/iterator.primitives/iterator.traits/0000755000175000017500000000000012266757726025431 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp0000644000175000017500000000260312266757726030734 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp0000644000175000017500000000225312266757726030564 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp0000644000175000017500000000230312266757726031766 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp0000644000175000017500000000106212266757726030237 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 { }; int main() { typedef std::iterator_traits It; } libcxx/test/iterators/predef.iterators/0000755000175000017500000000000012266757726021530 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/reverse.iterators/0000755000175000017500000000000012266757726025216 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/0000755000175000017500000000000012266757726030521 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp0000644000175000017500000000355012266757726033341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726031526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/0000755000175000017500000000000012266757726030433 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/0000755000175000017500000000000012266757726034162 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arro0000644000175000017500000000311612266757726035547 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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 class weird_iterator { It it_; public: typedef It value_type; typedef std::bidirectional_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; typedef It* pointer; typedef It& reference; weird_iterator() {} explicit weird_iterator(It it) : it_(it) {} ~weird_iterator() {it_ = It();} reference operator*() {return it_;} pointer operator->() {return &it_;} weird_iterator& operator--() {return *this;} }; template void test(It i, typename std::iterator_traits::value_type x) { std::reverse_iterator r(i); assert(r->get() == x.get()); } int main() { test(weird_iterator(A()), A()); A a; test(&a+1, A()); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/0000755000175000017500000000000012266757726033623 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pas0000644000175000017500000000245412266757726035314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726034743 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/0000755000175000017500000000000012266757726034020 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pas0000644000175000017500000000234112266757726035504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/0000755000175000017500000000000012266757726034515 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/diffe0000644000175000017500000000174412266757726035523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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'); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/0000755000175000017500000000000012266757726034212 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/differe0000644000175000017500000000173312266757726035545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/0000755000175000017500000000000012266757726033635 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/differen0000644000175000017500000000167012266757726035346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/0000755000175000017500000000000012266757726033562 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_i0000644000175000017500000000142512266757726035472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_i0000644000175000017500000000206512266757726035473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/0000755000175000017500000000000012266757726033613 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass0000644000175000017500000000162412266757726035274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pas0000644000175000017500000000163212266757726035307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/0000755000175000017500000000000012266757726033657 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pas0000644000175000017500000000245412266757726035350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/0000755000175000017500000000000012266757726034435 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_st0000644000175000017500000000276612266757726035517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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 class weird_iterator { It it_; public: typedef It value_type; typedef std::bidirectional_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; typedef It* pointer; typedef It& reference; weird_iterator() {} explicit weird_iterator(It it) : it_(it) {} ~weird_iterator() {it_ = It();} reference operator*() {return it_;} weird_iterator& operator--() {return *this;} }; template void test(It i, typename std::iterator_traits::value_type x) { std::reverse_iterator r(i); assert(*r == x); } int main() { test(weird_iterator(A()), A()); A a; test(&a+1, A()); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/0000755000175000017500000000000012266757726034316 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.p0000644000175000017500000000237212266757726035462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/0000755000175000017500000000000012266757726034122 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pa0000644000175000017500000000234112266757726035423 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/0000755000175000017500000000000012266757726034115 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pa0000644000175000017500000000234112266757726035416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/0000755000175000017500000000000012266757726033540 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/differenc0000644000175000017500000000165212266757726035414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/0000755000175000017500000000000012266757726033542 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/differenc0000644000175000017500000000166012266757726035415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/0000755000175000017500000000000012266757726034025 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pas0000644000175000017500000000234112266757726035511 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/0000755000175000017500000000000012266757726034011 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pas0000644000175000017500000000137112266757726035463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fai0000644000175000017500000000113512266757726035435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_0000644000175000017500000000137512266757726035554 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_0000644000175000017500000000175212266757726035553 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.0000644000175000017500000000126212266757726035437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/0000755000175000017500000000000012266757726034014 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_e0000644000175000017500000000056412266757726035540 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/0000755000175000017500000000000012266757726033637 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/differen0000644000175000017500000000167612266757726035356 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/0000755000175000017500000000000012266757726033617 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass0000644000175000017500000000163212266757726035277 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pas0000644000175000017500000000164012266757726035312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/0000755000175000017500000000000012266757726032355 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpplibcxx/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pas0000644000175000017500000000056412266757726035721 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/insert.iterators/0000755000175000017500000000000012266757726025047 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/0000755000175000017500000000000012266757726031014 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/libcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_ast0000755000175000017500000000000012266757726035366 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_ast0000644000175000017500000000125712266757726035375 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/0000755000175000017500000000000012266757726033546 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass0000644000175000017500000000134712266757726035422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/0000755000175000017500000000000012266757726034673 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv0000644000175000017500000000177312266757726035247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv0000644000175000017500000000167612266757726035257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726035324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/0000755000175000017500000000000012266757726034724 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/p0000644000175000017500000000126112266757726035106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/p0000644000175000017500000000133512266757726035110 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/0000755000175000017500000000000012266757726035122 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/c0000644000175000017500000000113312266757726035265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 template void test(C c) { std::back_insert_iterator i(c); } int main() { test(std::vector()); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpplibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/c0000644000175000017500000000111612266757726035266 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726031357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/0000755000175000017500000000000012266757726031332 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp0000644000175000017500000000342712266757726034155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 >(); } libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/0000755000175000017500000000000012266757726031244 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++0000755000175000017500000000000012266757726035325 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++0000644000175000017500000000126112266757726035327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++0000644000175000017500000000133512266757726035331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726035554 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_a0000755000175000017500000000000012266757726035477 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_a0000644000175000017500000000125712266757726035506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/0000755000175000017500000000000012266757726035353 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/0000644000175000017500000000171112266757726035355 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/0000644000175000017500000000161412266757726035357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons0000755000175000017500000000000012266757726035523 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons0000644000175000017500000000113212266757726035522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 template void test(C c) { std::front_insert_iterator i(c); } int main() { test(std::list()); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons0000644000175000017500000000111312266757726035521 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/0000755000175000017500000000000012266757726034226 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pa0000644000175000017500000000135012266757726035526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/0000755000175000017500000000000012266757726031102 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp0000644000175000017500000000333412266757726033722 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 >(); } libcxx/test/iterators/predef.iterators/insert.iterators/insert.iterator/0000755000175000017500000000000012266757726030203 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp0000644000175000017500000000340212266757726033017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 >(); } libcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/0000755000175000017500000000000012266757726030115 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/0000755000175000017500000000000012266757726034204 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pa0000644000175000017500000000124412266757726035506 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/0000755000175000017500000000000012266757726033324 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.c0000644000175000017500000000114012266757726035410 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 template void test(C c) { std::insert_iterator i(c, c.begin()); } int main() { test(std::vector()); } libcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726034425 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/0000755000175000017500000000000012266757726033075 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pas0000644000175000017500000000307312266757726035422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pas0000644000175000017500000000513412266757726035430 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 } libcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/0000755000175000017500000000000012266757726033126 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cp0000644000175000017500000000124612266757726035210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpplibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.c0000644000175000017500000000132212266757726035222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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()); } libcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/0000755000175000017500000000000012266757726031750 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp0000644000175000017500000000135212266757726034401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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()); } libcxx/test/iterators/predef.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026040 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/move.iterators/0000755000175000017500000000000012266757726024511 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/0000755000175000017500000000000012266757726027221 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/0000755000175000017500000000000012266757726031701 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.p0000644000175000017500000000163612266757726035223 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/0000755000175000017500000000000012266757726033112 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cp0000644000175000017500000000167512266757726035377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_it0000644000175000017500000000203612266757726035475 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.c0000644000175000017500000000202712266757726035357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/0000755000175000017500000000000012266757726032654 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_ty0000644000175000017500000000264312266757726035412 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/0000755000175000017500000000000012266757726032500 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp0000644000175000017500000000175712266757726034751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp0000644000175000017500000000176512266757726035147 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/0000755000175000017500000000000012266757726032516 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.c0000644000175000017500000000243212266757726035277 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/0000755000175000017500000000000012266757726032462 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp0000644000175000017500000000155312266757726034725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp0000644000175000017500000000156112266757726035123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726033531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/0000755000175000017500000000000012266757726032673 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.0000644000175000017500000000135612266757726035273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp0000644000175000017500000000145012266757726035307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp0000644000175000017500000000111512266757726035252 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.0000644000175000017500000000213712266757726035324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.0000644000175000017500000000132412266757726035265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/0000755000175000017500000000000012266757726031677 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.p0000644000175000017500000000164412266757726035220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/0000755000175000017500000000000012266757726032503 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp0000644000175000017500000000224612266757726035275 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp0000644000175000017500000000276612266757726035272 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cp0000644000175000017500000000276612266757726035270 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp0000644000175000017500000000224612266757726035270 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cp0000644000175000017500000000224612266757726035255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cp0000644000175000017500000000224612266757726035262 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/0000755000175000017500000000000012266757726031776 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.0000644000175000017500000000165412266757726035140 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/0000755000175000017500000000000012266757726032321 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.c0000644000175000017500000000115312266757726035262 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/0000755000175000017500000000000012266757726031774 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.0000644000175000017500000000166212266757726035135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/0000755000175000017500000000000012266757726032512 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhe0000644000175000017500000000056412266757726035446 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/0000755000175000017500000000000012266757726031643 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail0000644000175000017500000000140612266757726035360 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpplibcxx/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass0000644000175000017500000000224712266757726035417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/iterators/predef.iterators/move.iterators/move.iterator/0000755000175000017500000000000012266757726027307 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp0000644000175000017500000000344012266757726032125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726031021 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/predef.iterators/move.iterators/move.iter.requirements/0000755000175000017500000000000012266757726031143 5ustar sylvestresylvestrelibcxx/test/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726035453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterators.general/0000755000175000017500000000000012266757726021700 5ustar sylvestresylvestrelibcxx/test/iterators/iterators.general/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/iterators/iterator.range/0000755000175000017500000000000012266757726021174 5ustar sylvestresylvestrelibcxx/test/iterators/iterator.range/begin-end.pass.cpp0000644000175000017500000001050212266757726024473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #include <__config> #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 } 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 ); } #else int main(){} #endif libcxx/test/utilities/0000755000175000017500000000000012266757726016247 5ustar sylvestresylvestrelibcxx/test/utilities/date.time/0000755000175000017500000000000012266757725020120 5ustar sylvestresylvestrelibcxx/test/utilities/date.time/tested_elsewhere.pass.cpp0000644000175000017500000000256712266757725025136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; 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), ""); } libcxx/test/utilities/meta/0000755000175000017500000000000012266757725017174 5ustar sylvestresylvestrelibcxx/test/utilities/meta/version.pass.cpp0000644000175000017500000000074112266757725022334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/meta/meta.rqmts/0000755000175000017500000000000012266757725021267 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725025577 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/meta/meta.unary.prop.query/0000755000175000017500000000000012266757725023402 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.unary.prop.query/extent.pass.cpp0000644000175000017500000000302512266757725026362 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp0000644000175000017500000000241012266757725027512 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary.prop.query/rank.pass.cpp0000644000175000017500000000207512266757725026012 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/0000755000175000017500000000000012266757725021250 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.trans/meta.trans.other/0000755000175000017500000000000012266757725024444 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp0000644000175000017500000000141212266757725030017 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp0000644000175000017500000000505612266757725030125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 typedef bool (&PF1)(); typedef short (*PF2)(long); struct S { operator PF2() const; double operator()(char, int&); void calc(long) const; char data_; }; typedef void (S::*PMS)(long) const; typedef char S::*PMD; struct wat { wat& operator*() { return *this; } void foo(); }; template void test_result_of_imp() { static_assert((std::is_same::type, U>::value), ""); #if _LIBCPP_STD_VER > 11 static_assert((std::is_same, U>::value), ""); #endif } int main() { test_result_of_imp (); test_result_of_imp (); test_result_of_imp (); test_result_of_imp, int), void> (); test_result_of_imp (); test_result_of_imp (); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test_result_of_imp (); #endif test_result_of_imp (); #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES using type1 = std::result_of::type; #endif #if _LIBCPP_STD_VER > 11 using type2 = std::result_of_t; #endif static_assert((std::is_same::type, short>::value), "Error!"); static_assert((std::is_same::type, double>::value), "Error!"); static_assert((std::is_same::type, bool>::value), "Error!"); static_assert((std::is_same, int)>::type, void>::value), "Error!"); static_assert((std::is_same::type, void>::value), "Error!"); static_assert((std::is_same::type, void>::value), "Error!"); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES static_assert((std::is_same::type, char&&>::value), "Error!"); #endif static_assert((std::is_same::type, const char&>::value), "Error!"); #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES using type = std::result_of::type; #endif } libcxx/test/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp0000644000175000017500000000243412266757725031341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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) } libcxx/test/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp0000644000175000017500000000072512266757725027772 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp0000644000175000017500000001372012266757725031247 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, ""); } { 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 == 16, ""); 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 == 16, ""); static_assert(sizeof(T1) == 32, ""); } { 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, ""); } } libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp0000644000175000017500000000517212266757725030453 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp0000644000175000017500000000160312266757725027202 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp0000644000175000017500000000600712266757725030733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp0000644000175000017500000000103012266757725030042 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp0000644000175000017500000000147012266757725030422 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.trans/meta.trans.cv/0000755000175000017500000000000012266757725023733 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp0000644000175000017500000000212612266757725026625 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp0000644000175000017500000000224412266757725030035 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp0000644000175000017500000000215312266757725027343 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp0000644000175000017500000000207312266757725027373 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp0000644000175000017500000000225212266757725030601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp0000644000175000017500000000217512266757725030114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725025560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/meta/meta.trans/meta.trans.arr/0000755000175000017500000000000012266757725024107 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp0000644000175000017500000000243012266757725030443 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp0000644000175000017500000000251712266757725031464 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/utilities/meta/meta.trans/meta.trans.ref/0000755000175000017500000000000012266757725024077 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp0000644000175000017500000000204112266757725030501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp0000644000175000017500000000232112266757725030510 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp0000644000175000017500000000270512266757725027705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.trans/meta.trans.sign/0000755000175000017500000000000012266757725024263 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp0000644000175000017500000000341512266757725030550 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 }; 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 (); test_make_unsigned::type> (); } libcxx/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp0000644000175000017500000000320712266757725030204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 }; 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, const int >(); test_make_signed< BigEnum, std::conditional::type >(); } libcxx/test/utilities/meta/meta.trans/meta.trans.ptr/0000755000175000017500000000000012266757725024130 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp0000644000175000017500000000253112266757725030637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp0000644000175000017500000000170312266757725030072 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/0000755000175000017500000000000012266757725021257 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.unary/meta.unary.cat/0000755000175000017500000000000012266757725024110 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp0000644000175000017500000000312412266757725026677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp0000644000175000017500000000352112266757725027367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp0000644000175000017500000000311612266757725032117 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp0000644000175000017500000000276712266757725027275 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 libcxx/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp0000644000175000017500000000311012266757725030570 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp0000644000175000017500000000274112266757725026715 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp0000644000175000017500000000261512266757725027717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp0000644000175000017500000000246612266757725027715 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp0000644000175000017500000000333512266757725032501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp0000644000175000017500000000274112266757725026672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 _; double __; }; int main() { test_class(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp0000644000175000017500000000304212266757725027240 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp0000644000175000017500000000265412266757725026531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp0000644000175000017500000000307412266757725027412 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_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_function() { test_function_imp(); test_function_imp(); test_function_imp(); test_function_imp(); } int main() { test_function(); test_function(); test_function(); test_function(); } libcxx/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp0000644000175000017500000000270412266757725026530 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/0000755000175000017500000000000012266757725024321 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp0000644000175000017500000000255112266757725027741 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp0000644000175000017500000000312612266757725032401 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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&); }; 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(); #if __has_feature(cxx_access_control_sfinae) test_is_not_copy_constructible(); #endif } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp0000644000175000017500000000300012266757725033435 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp0000644000175000017500000000327312266757725034503 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp0000644000175000017500000000204112266757725030301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, ""); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp0000644000175000017500000000357112266757725034637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp0000644000175000017500000000311112266757725032367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp0000644000175000017500000000262512266757725030306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp0000644000175000017500000000306512266757725033054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp0000644000175000017500000000410412266757725033050 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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(); #if __has_feature(cxx_access_control_sfinae) test_is_not_default_constructible(); #endif } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp0000644000175000017500000000332712266757725033132 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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&); }; int main() { test_is_nothrow_constructible (); test_is_nothrow_constructible (); test_is_nothrow_constructible (); test_is_nothrow_constructible (); test_is_not_nothrow_constructible (); test_is_not_nothrow_constructible (); test_is_not_nothrow_constructible (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp0000644000175000017500000000412312266757725032736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_has_not_nothrow_destructor() { 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 ~Abstract() = 0; }; struct A { ~A(); }; int main() { test_has_not_nothrow_destructor(); test_has_not_nothrow_destructor(); test_has_not_nothrow_destructor(); #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 } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp0000644000175000017500000000237712266757725033414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp0000644000175000017500000000216712266757725032363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); }; 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp0000644000175000017500000000244712266757725031632 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); test_is_not_move_assignable (); #endif test_is_not_move_assignable (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp0000644000175000017500000000357312266757725031166 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; }; class Abstract { virtual ~Abstract() = 0; }; struct A { ~A(); }; typedef void (Function) (); 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_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); #if __has_feature(cxx_access_control_sfinae) test_is_not_destructible(); #endif test_is_not_destructible(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp0000644000175000017500000000212212266757725033005 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; }; #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, ""); #endif // _LIBCPP_HAS_NO_CONSTEXPR } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp0000644000175000017500000000265312266757725031635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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&); }; 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp0000644000175000017500000000270412266757725027626 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp0000644000175000017500000000365412266757725032601 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp0000644000175000017500000000233112266757725027246 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp0000644000175000017500000000213712266757725032677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); }; 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp0000644000175000017500000000246212266757725031666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp0000644000175000017500000000176112266757725027620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, ""); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp0000644000175000017500000000332012266757725031343 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); }; 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp0000644000175000017500000000314412266757725034155 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp0000644000175000017500000000246112266757725033412 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp0000644000175000017500000000357412266757725031043 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp0000644000175000017500000000310012266757725033720 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp0000644000175000017500000000416112266757725035152 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp0000644000175000017500000000371012266757725033256 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_has_not_trivial_destructor() { 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 ~Abstract() = 0; }; struct A { ~A(); }; int main() { test_has_not_trivial_destructor(); test_has_not_trivial_destructor(); test_has_not_trivial_destructor(); test_has_not_trivial_destructor(); 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp0000644000175000017500000000314512266757725030273 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp0000644000175000017500000000263312266757725033726 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp0000644000175000017500000000226312266757725030142 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp0000644000175000017500000000162112266757725031162 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp0000644000175000017500000000314512266757725034162 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp0000644000175000017500000000253712266757725030604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; struct C { template D operator,(U&&); }; struct E { C operator=(int); }; int main() { test_is_assignable (); test_is_assignable (); test_is_assignable (); test_is_assignable (); test_is_assignable (); test_is_assignable (); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 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 (); } libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp0000644000175000017500000000354412266757725034500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.unary/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725025567 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/0000755000175000017500000000000012266757725024277 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp0000644000175000017500000000225412266757725027071 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp0000644000175000017500000000265112266757725027561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp0000644000175000017500000000224612266757725032311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp0000644000175000017500000000224012266757725030762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp0000644000175000017500000000207112266757725027100 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp0000644000175000017500000000174512266757725030111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp0000644000175000017500000000161612266757725030100 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp0000644000175000017500000000246512266757725032673 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp0000644000175000017500000000207112266757725027055 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 _; double __; }; int main() { test_class(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp0000644000175000017500000000217212266757725027432 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp0000644000175000017500000000200412266757725026705 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp0000644000175000017500000000222412266757725027575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp0000644000175000017500000000203412266757725026713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.rel/0000755000175000017500000000000012266757725020703 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.rel/is_same.pass.cpp0000644000175000017500000000272712266757725024004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.rel/is_convertible.pass.cpp0000644000175000017500000001724112266757725025370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/meta/meta.rel/is_base_of.pass.cpp0000644000175000017500000000234612266757725024452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/meta/meta.type.synop/0000755000175000017500000000000012266757725022251 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026561 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/meta/meta.hel/0000755000175000017500000000000012266757725020671 5ustar sylvestresylvestrelibcxx/test/utilities/meta/meta.hel/integral_constant.pass.cpp0000644000175000017500000000263612266757725026067 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; std::true_type t1; std::true_type t2 = t1; } libcxx/test/utilities/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725022556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/function.objects/0000755000175000017500000000000012266757725021523 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.require/0000755000175000017500000000000012266757725024131 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.require/unary_function.pass.cpp0000644000175000017500000000120012266757725030636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/function.objects/func.require/binary_function.pass.cpp0000644000175000017500000000133612266757725030776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/function.objects/version.pass.cpp0000644000175000017500000000073712266757725024670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/function.objects/comparisons/0000755000175000017500000000000012266757725024060 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp0000644000175000017500000000200012266757725027332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp0000644000175000017500000000215412266757725027670 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/comparisons/less.pass.cpp0000644000175000017500000000212112266757725026473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp0000644000175000017500000000211412266757725030220 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp0000644000175000017500000000213712266757725027165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp0000644000175000017500000000217112266757725030352 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/comparisons/transparent.pass.cpp0000644000175000017500000000472012266757725030075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/function.objects/negators/0000755000175000017500000000000012266757725023345 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/negators/binary_negate.pass.cpp0000644000175000017500000000136412266757725027631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::value), ""); assert(!f(36, 36)); assert( f(36, 0)); assert( f(0, 36)); assert( f(0, 0)); } libcxx/test/utilities/function.objects/negators/unary_negate.pass.cpp0000644000175000017500000000126612266757725027504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::value), ""); assert(f(36)); assert(!f(0)); } libcxx/test/utilities/function.objects/negators/not2.pass.cpp0000644000175000017500000000115512266757725025702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/function.objects/negators/not1.pass.cpp0000644000175000017500000000103512266757725025676 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/function.objects/func.memfn/0000755000175000017500000000000012266757725023557 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp0000644000175000017500000000251512266757725031615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } 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'); } } 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'); } } int main() { test0(std::mem_fn(&A::test0)); test1(std::mem_fn(&A::test1)); test2(std::mem_fn(&A::test2)); } libcxx/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp0000644000175000017500000000261412266757725033514 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } 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'); } } 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'); } } int main() { test0(std::mem_fn(&A::test0)); test1(std::mem_fn(&A::test1)); test2(std::mem_fn(&A::test2)); } libcxx/test/utilities/function.objects/func.memfn/member_function.pass.cpp0000644000175000017500000000222412266757725030404 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } template void test1(F f) { { A a; assert(f(a, 1) == 'b'); A* ap = &a; assert(f(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'); } } int main() { test0(std::mem_fn(&A::test0)); test1(std::mem_fn(&A::test1)); test2(std::mem_fn(&A::test2)); } libcxx/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp0000644000175000017500000000254212266757725032306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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'); } } 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'); } } 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'); } } int main() { test0(std::mem_fn(&A::test0)); test1(std::mem_fn(&A::test1)); test2(std::mem_fn(&A::test2)); } libcxx/test/utilities/function.objects/func.memfn/member_data.fail.cpp0000644000175000017500000000142612266757725027440 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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_)); } libcxx/test/utilities/function.objects/func.memfn/member_data.pass.cpp0000644000175000017500000000140612266757725027471 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } int main() { test(std::mem_fn(&A::data_)); } libcxx/test/utilities/function.objects/bind/0000755000175000017500000000000012266757725022437 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/bind/func.bind/0000755000175000017500000000000012266757725024305 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/0000755000175000017500000000000012266757725027066 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp0000644000175000017500000001314012266757725033407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp0000644000175000017500000001363212266757725033407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } int main() { test_void_1(); test_int_1(); test_void_2(); } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp0000644000175000017500000000237712266757725033303 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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;} struct A_int_0 { void operator()() {++count;} void operator()() const {count += 2;} }; int main() { test(std::bind(f)); test(std::bind(&f)); test(std::bind(A_int_0())); test_const(std::bind(A_int_0())); test(std::bind(f)); test(std::bind(&f)); test(std::bind(A_int_0())); test_const(std::bind(A_int_0())); } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp0000644000175000017500000000203412266757725032020 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp0000644000175000017500000000232012266757725033120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp0000644000175000017500000000165112266757725031514 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725030615 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.place/0000755000175000017500000000000012266757725027236 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp0000644000175000017500000000147612266757725033364 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 template void test(const T& t) { T t2; T t3 = t; } 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); } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/0000755000175000017500000000000012266757725027422 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp0000644000175000017500000000176012266757725034054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp0000644000175000017500000000142312266757725034761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/function.objects/bind/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725026747 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/function.objects/func.wrap/0000755000175000017500000000000012266757725023426 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/0000755000175000017500000000000012266757725026263 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/0000755000175000017500000000000012266757725031662 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pas0000644000175000017500000000114212266757725035233 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/0000755000175000017500000000000012266757725031713 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp0000644000175000017500000000164712266757725034634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pas0000644000175000017500000000225412266757725035156 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass0000644000175000017500000000173012266757725035170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp0000644000175000017500000001464312266757725034667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp0000644000175000017500000000442112266757725031101 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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 unary_function // iff sizeof...(ArgTypes) == 1 and // // ArgTypes contains T1 // : public binary_function // iff sizeof...(ArgTypes) == 2 and // // ArgTypes contains T1 and T2 // { // public: // typedef R result_type; // ... // }; #include #include int main() { static_assert((!std::is_base_of, std::function >::value), ""); static_assert((!std::is_base_of, std::function >::value), ""); static_assert(( std::is_same< std::function::result_type, int>::value), ""); static_assert(( std::is_base_of, std::function >::value), ""); static_assert((!std::is_base_of, std::function >::value), ""); static_assert(( std::is_same< std::function::result_type, double>::value), ""); static_assert((!std::is_base_of, std::function >::value), ""); static_assert(( std::is_base_of, std::function >::value), ""); static_assert(( std::is_same< std::function::result_type, double>::value), ""); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/0000755000175000017500000000000012266757725031662 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp0000644000175000017500000000610412266757725034306 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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); } 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(new_called == 0); { std::function f1 = A(1); std::function f2 = A(2); assert(A::count == 2); assert(new_called == 2); assert(f1.target()->id() == 1); assert(f2.target()->id() == 2); swap(f1, f2); assert(A::count == 2); assert(new_called == 2); assert(f1.target()->id() == 2); assert(f2.target()->id() == 1); } assert(A::count == 0); assert(new_called == 0); { std::function f1 = A(1); std::function f2 = g; assert(A::count == 1); assert(new_called == 1); assert(f1.target()->id() == 1); assert(*f2.target() == g); swap(f1, f2); assert(A::count == 1); assert(new_called == 1); assert(*f1.target() == g); assert(f2.target()->id() == 1); } assert(A::count == 0); assert(new_called == 0); { std::function f1 = g; std::function f2 = A(1); assert(A::count == 1); assert(new_called == 1); assert(*f1.target() == g); assert(f2.target()->id() == 1); swap(f1, f2); assert(A::count == 1); assert(new_called == 1); assert(f1.target()->id() == 1); assert(*f2.target() == g); } assert(A::count == 0); assert(new_called == 0); { std::function f1 = g; std::function f2 = h; assert(A::count == 0); assert(new_called == 0); assert(*f1.target() == g); assert(*f2.target() == h); swap(f1, f2); assert(A::count == 0); assert(new_called == 0); assert(*f1.target() == h); assert(*f2.target() == g); } assert(A::count == 0); assert(new_called == 0); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/0000755000175000017500000000000012266757725032054 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp0000644000175000017500000000357212266757725035022 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass0000644000175000017500000000215312266757725035274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/0000755000175000017500000000000012266757725031676 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pas0000644000175000017500000000123012266757725035251 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "test_allocator.h" int main() { std::function f(std::allocator_arg, test_allocator(), nullptr); assert(!f); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.0000644000175000017500000000313112266757725035264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } 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(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); f = nullptr; assert(A::count == 0); assert(new_called == 0); assert(f.target() == 0); } { std::function f = g; assert(new_called == 0); assert(f.target()); assert(f.target() == 0); f = nullptr; assert(new_called == 0); assert(f.target() == 0); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass0000644000175000017500000000122612266757725035173 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp0000644000175000017500000000375412266757725034717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "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 g(int) {return 0;} class Foo { public: void bar(int k) { } }; int main() { { std::function f(std::allocator_arg, test_allocator(), A()); assert(A::count == 1); assert(f.target()); assert(f.target() == 0); } assert(A::count == 0); { std::function f(std::allocator_arg, test_allocator(), g); assert(f.target()); assert(f.target() == 0); } { std::function f(std::allocator_arg, test_allocator(), (int (*)(int))0); assert(!f); assert(f.target() == 0); assert(f.target() == 0); } { std::function f(std::allocator_arg, test_allocator(), &A::foo); assert(f); assert(f.target() != 0); } { Foo f; std::function fun = std::bind(&Foo::bar, &f, std::placeholders::_1); fun(10); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pa0000644000175000017500000000445212266757725035224 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #include #include "test_allocator.h" 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); } 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(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); std::function f2(std::allocator_arg, test_allocator(), f); assert(A::count == 2); assert(new_called == 2); assert(f2.target()); assert(f2.target() == 0); } assert(A::count == 0); assert(new_called == 0); { std::function f = g; assert(new_called == 0); assert(f.target()); assert(f.target() == 0); std::function f2(std::allocator_arg, test_allocator(), f); assert(new_called == 0); assert(f2.target()); assert(f2.target() == 0); } assert(new_called == 0); { std::function f; assert(new_called == 0); assert(f.target() == 0); assert(f.target() == 0); std::function f2(std::allocator_arg, test_allocator(), f); assert(new_called == 0); assert(f2.target() == 0); assert(f2.target() == 0); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cp0000644000175000017500000000104312266757725035210 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp0000644000175000017500000000360312266757725033536 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } 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(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); } assert(A::count == 0); assert(new_called == 0); { std::function f = g; assert(new_called == 0); assert(f.target()); assert(f.target() == 0); } assert(new_called == 0); { std::function f = (int (*)(int))0; assert(!f); assert(new_called == 0); assert(f.target() == 0); assert(f.target() == 0); } { std::function f = &A::foo; assert(f); assert(new_called == 0); assert(f.target() != 0); } } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp0000644000175000017500000000405712266757725035106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } 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(new_called == 0); { std::function f; f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); } assert(A::count == 0); assert(new_called == 0); { std::function f; f = g; assert(new_called == 0); assert(f.target()); assert(f.target() == 0); } assert(new_called == 0); { std::function f; f = (int (*)(int))0; assert(!f); assert(new_called == 0); assert(f.target() == 0); assert(f.target() == 0); } { std::function f; f = &A::foo; assert(f); assert(new_called == 0); assert(f.target() != 0); } } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp0000644000175000017500000000120412266757725034436 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "test_allocator.h" int main() { std::function f(std::allocator_arg, test_allocator()); assert(!f); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp0000644000175000017500000000103212266757725034767 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp0000644000175000017500000000516612266757725034331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 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); } 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(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); std::function f2 = f; assert(A::count == 2); assert(new_called == 2); assert(f2.target()); assert(f2.target() == 0); } assert(A::count == 0); assert(new_called == 0); { std::function f = g; assert(new_called == 0); assert(f.target()); assert(f.target() == 0); std::function f2 = f; assert(new_called == 0); assert(f2.target()); assert(f2.target() == 0); } assert(new_called == 0); { std::function f; assert(new_called == 0); assert(f.target() == 0); assert(f.target() == 0); std::function f2 = f; assert(new_called == 0); assert(f2.target() == 0); assert(f2.target() == 0); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES assert(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); std::function f2 = std::move(f); assert(A::count == 1); assert(new_called == 1); assert(f2.target()); assert(f2.target() == 0); assert(f.target() == 0); assert(f.target() == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.p0000644000175000017500000000325412266757725035244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 "test_allocator.h" 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); } 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(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); std::function f2(std::allocator_arg, test_allocator(), std::move(f)); assert(A::count == 1); assert(new_called == 1); assert(f2.target()); assert(f2.target() == 0); assert(f.target() == 0); assert(f.target() == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.0000644000175000017500000000524112266757725035164 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } 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(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); std::function f2; f2 = f; assert(A::count == 2); assert(new_called == 2); assert(f2.target()); assert(f2.target() == 0); } assert(A::count == 0); assert(new_called == 0); { std::function f = g; assert(new_called == 0); assert(f.target()); assert(f.target() == 0); std::function f2; f2 = f; assert(new_called == 0); assert(f2.target()); assert(f2.target() == 0); } assert(new_called == 0); { std::function f; assert(new_called == 0); assert(f.target() == 0); assert(f.target() == 0); std::function f2; f2 = f; assert(new_called == 0); assert(f2.target() == 0); assert(f2.target() == 0); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES assert(new_called == 0); { std::function f = A(); assert(A::count == 1); assert(new_called == 1); assert(f.target()); assert(f.target() == 0); std::function f2; f2 = std::move(f); assert(A::count == 1); assert(new_called == 1); assert(f2.target()); assert(f2.target() == 0); assert(f.target() == 0); assert(f.target() == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/0000755000175000017500000000000012266757725032617 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.p0000644000175000017500000000224312266757725035165 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/0000755000175000017500000000000012266757725031676 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp0000644000175000017500000000572612266757725034333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } 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(new_called == 0); { std::function f1 = A(1); std::function f2 = A(2); assert(A::count == 2); assert(new_called == 2); assert(f1.target()->id() == 1); assert(f2.target()->id() == 2); f1.swap(f2); assert(A::count == 2); assert(new_called == 2); assert(f1.target()->id() == 2); assert(f2.target()->id() == 1); } assert(A::count == 0); assert(new_called == 0); { std::function f1 = A(1); std::function f2 = g; assert(A::count == 1); assert(new_called == 1); assert(f1.target()->id() == 1); assert(*f2.target() == g); f1.swap(f2); assert(A::count == 1); assert(new_called == 1); assert(*f1.target() == g); assert(f2.target()->id() == 1); } assert(A::count == 0); assert(new_called == 0); { std::function f1 = g; std::function f2 = A(1); assert(A::count == 1); assert(new_called == 1); assert(*f1.target() == g); assert(f2.target()->id() == 1); f1.swap(f2); assert(A::count == 1); assert(new_called == 1); assert(f1.target()->id() == 1); assert(*f2.target() == g); } assert(A::count == 0); assert(new_called == 0); { std::function f1 = g; std::function f2 = h; assert(A::count == 0); assert(new_called == 0); assert(*f1.target() == g); assert(*f2.target() == h); f1.swap(f2); assert(A::count == 0); assert(new_called == 0); assert(*f1.target() == h); assert(*f2.target() == g); } assert(A::count == 0); assert(new_called == 0); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pa0000644000175000017500000000220312266757725035120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027736 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/0000755000175000017500000000000012266757725026712 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp0000644000175000017500000000123712266757725034014 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/0000755000175000017500000000000012266757725033323 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpplibcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_funct0000644000175000017500000000076612266757725035204 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; } libcxx/test/utilities/function.objects/func.def/0000755000175000017500000000000012266757725023213 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp0000644000175000017500000000056412266757725027523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/function.objects/bitwise.operations/0000755000175000017500000000000012266757725025353 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp0000644000175000017500000000330012266757725030276 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp0000644000175000017500000000264212266757725030466 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp0000644000175000017500000000324212266757725030473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 f2 = 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 } libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp0000644000175000017500000000326112266757725030426 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/bitwise.operations/transparent.pass.cpp0000644000175000017500000000355212266757725031372 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/function.objects/unord.hash/0000755000175000017500000000000012266757725023574 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/unord.hash/integral.pass.cpp0000644000175000017500000000242112266757725027051 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { static_assert((std::is_base_of, std::hash >::value), ""); std::hash 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(); } libcxx/test/utilities/function.objects/unord.hash/enum.fail.cpp0000644000175000017500000000107012266757725026154 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 ); } libcxx/test/utilities/function.objects/unord.hash/pointer.pass.cpp0000644000175000017500000000165612266757725026735 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { static_assert((std::is_base_of, std::hash >::value), ""); std::hash h; typedef typename std::remove_pointer::type type; type i; type j; assert(h(&i) != h(&j)); } int main() { test(); } libcxx/test/utilities/function.objects/unord.hash/floating.pass.cpp0000644000175000017500000000273512266757725027057 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { static_assert((std::is_base_of, std::hash >::value), ""); std::hash 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(); } libcxx/test/utilities/function.objects/unord.hash/enum.pass.cpp0000644000175000017500000000321712266757725026214 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #include <__config> #if _LIBCPP_STD_VER > 11 #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() { static_assert((std::is_base_of, std::hash >::value), ""); typedef typename std::underlying_type::type under_type; std::hash 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 libcxx/test/utilities/function.objects/logical.operations/0000755000175000017500000000000012266757725025317 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp0000644000175000017500000000230612266757725031103 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp0000644000175000017500000000235412266757725031230 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp0000644000175000017500000000175012266757725031265 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/logical.operations/transparent.pass.cpp0000644000175000017500000000317712266757725031341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/function.objects/refwrap/0000755000175000017500000000000012266757725023171 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/refwrap/weak_result.pass.cpp0000644000175000017500000000534012266757725027171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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, ""); } libcxx/test/utilities/function.objects/refwrap/refwrap.assign/0000755000175000017500000000000012266757725026122 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp0000644000175000017500000000206712266757725032116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/unary.pass.cpp0000644000175000017500000000574212266757725026010 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/function.objects/refwrap/refwrap.const/0000755000175000017500000000000012266757725025764 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp0000644000175000017500000000102612266757725031411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp0000644000175000017500000000144612266757725031452 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp0000644000175000017500000000154612266757725031444 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/0000755000175000017500000000000012266757725026300 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp0000644000175000017500000000113512266757725030745 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp0000644000175000017500000000116112266757725031107 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp0000644000175000017500000000117212266757725030713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp0000644000175000017500000000124312266757725030746 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 int main() { int i = 0; std::reference_wrapper r1 = std::ref(i); std::reference_wrapper r2 = std::ref(r1); assert(&r2.get() == &i); } libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp0000644000175000017500000000127712266757725031120 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/binary.pass.cpp0000644000175000017500000000633712266757725026137 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/function.objects/refwrap/refwrap.access/0000755000175000017500000000000012266757725026077 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp0000644000175000017500000000145512266757725031742 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/function.objects/refwrap/type.pass.cpp0000644000175000017500000000316112266757725025624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/0000755000175000017500000000000012266757725026131 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp0000644000175000017500000000212412266757725031041 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp0000644000175000017500000000242512266757725032340 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp0000644000175000017500000000236512266757725032174 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp0000644000175000017500000001454512266757725031106 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/function.objects/arithmetic.operations/0000755000175000017500000000000012266757725026036 5ustar sylvestresylvestrelibcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp0000644000175000017500000000172012266757725030472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp0000644000175000017500000000177512266757725031710 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp0000644000175000017500000000171212266757725030753 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp0000644000175000017500000000176312266757725031145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp0000644000175000017500000000173312266757725031203 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp0000644000175000017500000000172112266757725030643 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_base_of, F>::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 } libcxx/test/utilities/function.objects/arithmetic.operations/transparent.pass.cpp0000644000175000017500000000463012266757725032053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/type.index/0000755000175000017500000000000012266757725020335 5ustar sylvestresylvestrelibcxx/test/utilities/type.index/version.pass.cpp0000644000175000017500000000073512266757725023500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/type.index/type.index.overview/0000755000175000017500000000000012266757725024271 5ustar sylvestresylvestrelibcxx/test/utilities/type.index/type.index.overview/copy_ctor.pass.cpp0000644000175000017500000000110012266757725027733 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/type.index/type.index.overview/copy_assign.pass.cpp0000644000175000017500000000117112266757725030260 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/type.index/type.index.hash/0000755000175000017500000000000012266757725023346 5ustar sylvestresylvestrelibcxx/test/utilities/type.index/type.index.hash/hash.pass.cpp0000644000175000017500000000130312266757725025737 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { std::type_index t1 = typeid(int); assert(std::hash()(t1) == t1.hash_code()); } libcxx/test/utilities/type.index/type.index.members/0000755000175000017500000000000012266757725024055 5ustar sylvestresylvestrelibcxx/test/utilities/type.index/type.index.members/ctor.pass.cpp0000644000175000017500000000101612266757725026473 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 int main() { std::type_index t1 = typeid(int); } libcxx/test/utilities/type.index/type.index.members/lt.pass.cpp0000644000175000017500000000217012266757725026145 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } } libcxx/test/utilities/type.index/type.index.members/hash_code.pass.cpp0000644000175000017500000000114012266757725027437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/utilities/type.index/type.index.members/name.pass.cpp0000644000175000017500000000116512266757725026451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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()); } libcxx/test/utilities/type.index/type.index.members/eq.pass.cpp0000644000175000017500000000130412266757725026131 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/type.index/type.index.synopsis/0000755000175000017500000000000012266757725024312 5ustar sylvestresylvestrelibcxx/test/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp0000644000175000017500000000134112266757725031135 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { static_assert((std::is_base_of, std::hash >::value), ""); } libcxx/test/utilities/memory/0000755000175000017500000000000012266757726017557 5ustar sylvestresylvestrelibcxx/test/utilities/memory/storage.iterator/0000755000175000017500000000000012266757726023053 5ustar sylvestresylvestrelibcxx/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp0000644000175000017500000000211112266757726030600 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/utilities/memory/c.malloc/0000755000175000017500000000000012266757726021247 5ustar sylvestresylvestrelibcxx/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp0000644000175000017500000000065512266757726025560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/memory/version.pass.cpp0000644000175000017500000000072712266757726022723 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { } libcxx/test/utilities/memory/ptr.align/0000755000175000017500000000000012266757726021455 5ustar sylvestresylvestrelibcxx/test/utilities/memory/ptr.align/align.pass.cpp0000644000175000017500000000336012266757726024222 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() { int i = 0; 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); } libcxx/test/utilities/memory/util.smartptr/0000755000175000017500000000000012266757726022407 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.weakptr/0000755000175000017500000000000012266757726026713 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp0000644000175000017500000000140312266757726033004 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026717 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/0000755000175000017500000000000012266757726026161 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp0000644000175000017500000000145612266757726033036 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp0000644000175000017500000000143712266757726032775 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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)); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.enab/0000755000175000017500000000000012266757726026143 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp0000644000175000017500000000243412266757726034445 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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() { { 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 } } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/0000755000175000017500000000000012266757726026165 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/0000755000175000017500000000000012266757726033035 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pas0000644000175000017500000000411712266757726035725 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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; 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)); } } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/0000755000175000017500000000000012266757726032701 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhe0000644000175000017500000000056412266757726035635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp0000644000175000017500000000116112266757726031001 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/0000755000175000017500000000000012266757726032674 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp0000644000175000017500000000213112266757726035314 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/0000755000175000017500000000000012266757726032525 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cp0000644000175000017500000000176012266757726035462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_we0000644000175000017500000000162612266757726035624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp0000644000175000017500000000243712266757726035134 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_sh0000644000175000017500000000163012266757726035616 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.f0000644000175000017500000000124612266757726035537 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/0000755000175000017500000000000012266757726033070 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pa0000644000175000017500000000425712266757726035526 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); #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::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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass0000644000175000017500000000363612266757726035604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); #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() { { 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.0000644000175000017500000000103712266757726035463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.0000644000175000017500000000424712266757726035523 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/0000755000175000017500000000000012266757726032521 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp0000644000175000017500000000206412266757726035146 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp0000644000175000017500000000147412266757726035322 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/0000755000175000017500000000000012266757726033226 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.p0000644000175000017500000000236312266757726035517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pas0000644000175000017500000000233612266757726035553 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y0000644000175000017500000000231612266757726035576 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/0000755000175000017500000000000012266757726026504 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/0000755000175000017500000000000012266757726033457 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter0000644000175000017500000000351212266757726035666 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/0000755000175000017500000000000012266757726033357 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_point0000644000175000017500000000233412266757726035637 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.c0000644000175000017500000000502312266757726035442 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_point0000644000175000017500000000362712266757726035645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.0000644000175000017500000000221412266757726035446 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_point0000644000175000017500000000455512266757726035646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h0000644000175000017500000000246212266757726031344 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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;} }; 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 libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/0000755000175000017500000000000012266757726033726 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_d0000644000175000017500000000230012266757726035627 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t0000644000175000017500000000247412266757726035703 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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() { { 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); } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_pt0000644000175000017500000000235012266757726035622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t0000644000175000017500000000104012266757726035667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_d0000644000175000017500000000252212266757726035635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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; 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); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_pt0000644000175000017500000000342012266757726035661 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #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::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); } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_pt0000644000175000017500000000532412266757726035626 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_t0000644000175000017500000000210012266757726035645 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 #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); } } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_d0000644000175000017500000000214412266757726035635 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.p0000644000175000017500000000167012266757726035573 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t0000644000175000017500000000225412266757726035677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #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); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.0000644000175000017500000000404312266757726035565 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); #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); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.0000644000175000017500000000300112266757726035535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t0000644000175000017500000000212012266757726035667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_d0000644000175000017500000000215112266757726035633 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.p0000644000175000017500000000101712266757726035532 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_pt0000644000175000017500000000441112266757726035622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t0000644000175000017500000000212312266757726035672 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_pt0000644000175000017500000000266312266757726035631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_pt0000644000175000017500000000356112266757726035627 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/0000755000175000017500000000000012266757726034064 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr0000644000175000017500000000512412266757726035646 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_p0000644000175000017500000000575312266757726035606 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_p0000644000175000017500000000515312266757726035640 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); 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); assert(pA.get() == 0); assert(pB.get() == ptrA); } assert(B::count == 0); assert(A::count == 0); } assert(B::count == 0); assert(A::count == 0); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_p0000644000175000017500000000564312266757726035604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_p0000644000175000017500000000561612266757726035604 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_p0000644000175000017500000000572512266757726035605 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp0000644000175000017500000000116512266757726031324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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), ""); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/0000755000175000017500000000000012266757726033357 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp0000644000175000017500000000146412266757726035454 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp0000644000175000017500000000156212266757726035441 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr0000644000175000017500000000425012266757726035642 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/0000755000175000017500000000000012266757726034043 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate0000644000175000017500000000242612266757726035556 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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" 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); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_sha0000644000175000017500000000312112266757726035533 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #include int new_count = 0; void* operator new(std::size_t s) throw(std::bad_alloc) { ++new_count; return std::malloc(s); } void operator delete(void* p) throw() { std::free(p); } 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 nc = new_count; { int i = 67; char c = 'e'; std::shared_ptr p = std::make_shared(i, c); assert(new_count == nc+1); assert(A::count == 1); assert(p->get_int() == 67); assert(p->get_char() == 'e'); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES nc = new_count; { char c = 'e'; std::shared_ptr p = std::make_shared(67, c); assert(new_count == nc+1); assert(A::count == 1); assert(p->get_int() == 67); assert(p->get_char() == 'e'); } #endif assert(A::count == 0); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/0000755000175000017500000000000012266757726033532 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_po0000644000175000017500000000232112266757726035575 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_poi0000644000175000017500000000323212266757726035613 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_poin0000644000175000017500000000236012266757726035631 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/0000755000175000017500000000000012266757726033532 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.0000644000175000017500000000507612266757726035462 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/0000755000175000017500000000000012266757726033207 5ustar sylvestresylvestrelibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp0000644000175000017500000000136512266757726035274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/0000755000175000017500000000000012266757726033537 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_els0000644000175000017500000000056412266757726035622 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/0000755000175000017500000000000012266757726033363 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.0000644000175000017500000000131112266757726035457 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass0000644000175000017500000000116412266757726035563 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_befor0000644000175000017500000000163712266757726035624 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference0000644000175000017500000000106612266757726035560 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_befor0000644000175000017500000000146212266757726035620 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pas0000644000175000017500000000114212266757726035517 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/0000755000175000017500000000000012266757726027757 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_stron0000644000175000017500000000360412266757726035756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp0000644000175000017500000000170212266757726034546 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp0000644000175000017500000000157512266757726033713 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_stron0000644000175000017500000000264512266757726035762 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp0000644000175000017500000000123612266757726035412 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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 } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp0000644000175000017500000000170112266757726035603 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.0000644000175000017500000000263512266757726035621 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass0000644000175000017500000000175712266757726035700 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp0000644000175000017500000000161312266757726034121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_0000644000175000017500000000356212266757726035702 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpplibcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cp0000644000175000017500000000171112266757726035641 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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_lib=x86_64-apple-darwin11 // XFAIL: with_system_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 } libcxx/test/utilities/memory/temporary.buffer/0000755000175000017500000000000012266757726023051 5ustar sylvestresylvestrelibcxx/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp0000644000175000017500000000136012266757726030075 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/memory/allocator.tag/0000755000175000017500000000000012266757726022311 5ustar sylvestresylvestrelibcxx/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp0000644000175000017500000000106212266757726026572 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/allocator.traits/0000755000175000017500000000000012266757726023044 5ustar sylvestresylvestrelibcxx/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp0000644000175000017500000000537412266757726027357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/0000755000175000017500000000000012266757726027762 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibcxx/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpplibcxx/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_cons0000644000175000017500000000303412266757726035776 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp0000644000175000017500000000303212266757726033250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp0000644000175000017500000000150412266757726033217 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp0000644000175000017500000000162212266757726033531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp0000644000175000017500000000614312266757726033463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp0000644000175000017500000000255512266757726034250 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp0000644000175000017500000000324012266757726033123 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/allocator.traits/value_type.pass.cpp0000644000175000017500000000131212266757726026667 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/0000755000175000017500000000000012266757726027474 5ustar sylvestresylvestrelibcxx/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp0000644000175000017500000000255612266757726033170 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp0000644000175000017500000000256212266757726034305 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp0000644000175000017500000000237412266757726033654 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpplibcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_ass0000644000175000017500000000212212266757726036030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp0000644000175000017500000000501412266757726033562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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 } libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp0000644000175000017500000000164612266757726032634 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpplibcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_ass0000644000175000017500000000212212266757726036034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpplibcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pas0000644000175000017500000000203312266757726035751 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp0000644000175000017500000000247612266757726035065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp0000644000175000017500000000240512266757726034034 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.traits/allocator_type.pass.cpp0000644000175000017500000000130112266757726027531 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.uses/0000755000175000017500000000000012266757726022515 5ustar sylvestresylvestrelibcxx/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726027025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/allocator.uses/allocator.uses.trait/0000755000175000017500000000000012266757726026575 5ustar sylvestresylvestrelibcxx/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp0000644000175000017500000000165512266757726033274 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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), ""); } libcxx/test/utilities/memory/allocator.uses/allocator.uses.construction/0000755000175000017500000000000012266757726030204 5ustar sylvestresylvestrelibcxx/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp0000644000175000017500000000056412266757726035215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/default.allocator/0000755000175000017500000000000012266757726023162 5ustar sylvestresylvestrelibcxx/test/utilities/memory/default.allocator/allocator.globals/0000755000175000017500000000000012266757726026564 5ustar sylvestresylvestrelibcxx/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp0000644000175000017500000000140112266757726030636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/memory/default.allocator/allocator.members/0000755000175000017500000000000012266757726026573 5ustar sylvestresylvestrelibcxx/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp0000644000175000017500000000147012266757726031673 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } libcxx/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp0000644000175000017500000000126012266757726032062 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } libcxx/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp0000644000175000017500000000254612266757726032037 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #include int new_called = 0; void* operator new(std::size_t s) throw(std::bad_alloc) { ++new_called; assert(s == 3 * sizeof(int)); return std::malloc(s); } void operator delete(void* p) throw() { --new_called; std::free(p); } 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(new_called == 0); assert(A_constructed == 0); A* ap = a.allocate(3); assert(new_called == 1); assert(A_constructed == 0); a.deallocate(ap, 3); assert(new_called == 0); assert(A_constructed == 0); A* ap2 = a.allocate(3, (const void*)5); assert(new_called == 1); assert(A_constructed == 0); a.deallocate(ap2, 3); assert(new_called == 0); assert(A_constructed == 0); } libcxx/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp0000644000175000017500000000657412266757726032304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 #include int new_called = 0; void* operator new(std::size_t s) throw(std::bad_alloc) { ++new_called; assert(s == 3 * sizeof(int)); return std::malloc(s); } void operator delete(void* p) throw() { --new_called; std::free(p); } 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(new_called == 0); assert(A_constructed == 0); A* ap = a.allocate(3); assert(new_called == 1); assert(A_constructed == 0); a.construct(ap); assert(new_called == 1); assert(A_constructed == 1); a.destroy(ap); assert(new_called == 1); assert(A_constructed == 0); a.construct(ap, A()); assert(new_called == 1); assert(A_constructed == 1); a.destroy(ap); assert(new_called == 1); assert(A_constructed == 0); a.construct(ap, 5); assert(new_called == 1); assert(A_constructed == 1); a.destroy(ap); assert(new_called == 1); assert(A_constructed == 0); a.construct(ap, 5, (int*)0); assert(new_called == 1); assert(A_constructed == 1); a.destroy(ap); assert(new_called == 1); assert(A_constructed == 0); a.deallocate(ap, 3); assert(new_called == 0); assert(A_constructed == 0); } { std::allocator a; assert(new_called == 0); assert(move_only_constructed == 0); move_only* ap = a.allocate(3); assert(new_called == 1); assert(move_only_constructed == 0); a.construct(ap); assert(new_called == 1); assert(move_only_constructed == 1); a.destroy(ap); assert(new_called == 1); assert(move_only_constructed == 0); a.construct(ap, move_only()); assert(new_called == 1); assert(move_only_constructed == 1); a.destroy(ap); assert(new_called == 1); assert(move_only_constructed == 0); a.deallocate(ap, 3); assert(new_called == 0); assert(move_only_constructed == 0); } } libcxx/test/utilities/memory/default.allocator/allocator_void.pass.cpp0000644000175000017500000000233412266757726027636 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler 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; } libcxx/test/utilities/memory/default.allocator/allocator_types.pass.cpp0000644000175000017500000000367712266757726030054 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; // // 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), ""); std::allocator a; std::allocator a2 = a; a2 = a; std::allocator a3 = a2; } libcxx/test/utilities/memory/unique.ptr/0000755000175000017500000000000012266757726021671 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/0000755000175000017500000000000012266757726025263 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/0000755000175000017500000000000012266757726032635 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.c0000644000175000017500000000113312266757726035364 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp0000644000175000017500000000265112266757726035264 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pas0000644000175000017500000000110512266757726035472 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cp0000644000175000017500000000164012266757726035332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); 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(); p.reset(new A); assert(A::count == 1); } assert(A::count == 0); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cp0000644000175000017500000000230612266757726035333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/0000755000175000017500000000000012266757726031604 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp0000644000175000017500000000143012266757726034225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass0000644000175000017500000000231012266757726035340 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp0000644000175000017500000000143612266757726034761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp0000644000175000017500000000130312266757726034326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail0000644000175000017500000000226512266757726035321 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail0000644000175000017500000000225112266757726035311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail0000644000175000017500000000126312266757726035315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 struct A { }; struct Deleter { void operator()(void*) {} }; int main() { std::unique_ptr s; std::unique_ptr s2; s2 = std::move(s); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp0000644000175000017500000000131712266757726034334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass0000644000175000017500000000242212266757726035345 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail0000644000175000017500000000203612266757726035311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp0000644000175000017500000000335312266757726034370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp0000644000175000017500000000175612266757726034344 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail0000644000175000017500000000227212266757726035315 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass0000644000175000017500000000205612266757726035346 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail0000644000175000017500000000230612266757726035316 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail0000644000175000017500000000205212266757726035312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp0000644000175000017500000000200512266757726034331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/0000755000175000017500000000000012266757726031623 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass0000644000175000017500000000222612266757726035367 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass0000644000175000017500000000247412266757726035377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp0000644000175000017500000000226412266757726035121 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass0000644000175000017500000000245712266757726035373 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp0000644000175000017500000000301412266757726035114 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() {} libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp0000644000175000017500000000116512266757726035066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp0000644000175000017500000000106012266757726035025 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp0000644000175000017500000000165112266757726034777 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.c0000644000175000017500000000247212266757726035451 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp0000644000175000017500000000150512266757726034351 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.p0000644000175000017500000000221212266757726035331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail0000644000175000017500000000312012266757726035333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.f0000644000175000017500000000204712266757726035325 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.p0000644000175000017500000000155112266757726035340 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass0000644000175000017500000000312612266757726035371 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp0000644000175000017500000000163512266757726035066 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail0000644000175000017500000000200012266757726035323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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; } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail0000644000175000017500000000561212266757726035334 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail0000644000175000017500000000242512266757726035333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail0000644000175000017500000000124412266757726035333 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 struct A { }; struct Deleter { void operator()(void*) {} }; int main() { std::unique_ptr s; std::unique_ptr s2(std::move(s)); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp0000644000175000017500000000127212266757726035030 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp0000644000175000017500000000107312266757726035065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.p0000644000175000017500000000214012266757726035327 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp0000644000175000017500000000152112266757726034350 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass0000644000175000017500000000312512266757726035365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail0000644000175000017500000000202212266757726035323 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail0000644000175000017500000000561112266757726035341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.p0000644000175000017500000000476712266757726035347 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp0000644000175000017500000000130512266757726035061 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.p0000644000175000017500000000231712266757726035340 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp0000644000175000017500000000115212266757726035026 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp0000644000175000017500000000255112266757726035065 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() {} libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp0000644000175000017500000000674612266757726034420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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;} }; 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail0000644000175000017500000000244612266757726035337 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp0000644000175000017500000000176112266757726034357 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail0000644000175000017500000000222012266757726035331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp0000644000175000017500000000613312266757726034407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail0000644000175000017500000000222112266757726035324 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail0000644000175000017500000000311212266757726035326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail0000644000175000017500000000312112266757726035326 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass0000644000175000017500000000222512266757726035363 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail0000644000175000017500000000216412266757726035335 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail0000644000175000017500000000311312266757726035332 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.p0000644000175000017500000000226612266757726035341 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp0000644000175000017500000000266212266757726035125 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass0000644000175000017500000000246012266757726035370 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../../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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail0000644000175000017500000000221312266757726035330 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp0000644000175000017500000000177512266757726034365 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp0000644000175000017500000000137512266757726031463 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/0000755000175000017500000000000012266757726032666 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp0000644000175000017500000000167112266757726035420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.0000644000175000017500000000132112266757726035520 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.0000644000175000017500000000105612266757726035466 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pa0000644000175000017500000000100212266757726035450 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp0000644000175000017500000000102212266757726035111 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pa0000644000175000017500000000136712266757726035502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/0000755000175000017500000000000012266757726031624 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp0000644000175000017500000000156312266757726034254 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726026201 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/0000755000175000017500000000000012266757726025422 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp0000644000175000017500000000374412266757726030055 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp0000644000175000017500000000372612266757726027510 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp0000644000175000017500000000516212266757726027661 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp0000644000175000017500000000447012266757726031437 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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)); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/0000755000175000017500000000000012266757726024747 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/0000755000175000017500000000000012266757726031036 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp0000644000175000017500000000117712266757726035171 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp0000644000175000017500000000135512266757726034137 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp0000644000175000017500000000110512266757726034610 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/0000755000175000017500000000000012266757726031441 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.c0000644000175000017500000000056412266757726035411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp0000644000175000017500000000056412266757726031257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// int main() { } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/0000755000175000017500000000000012266757726030755 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp0000644000175000017500000000163112266757726035136 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp0000644000175000017500000000110512266757726033331 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp0000644000175000017500000000124412266757726034053 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp0000644000175000017500000000107612266757726034536 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/0000755000175000017500000000000012266757726025245 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp0000644000175000017500000000076512266757726032377 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp0000644000175000017500000000100312266757726032356 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp0000644000175000017500000000162712266757726032507 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp0000644000175000017500000000075512266757726032375 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp0000644000175000017500000000205312266757726032336 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 } libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp0000644000175000017500000000074412266757726032372 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/deleter.h0000644000175000017500000001053312266757726023470 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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 libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/0000755000175000017500000000000012266757726025465 5ustar sylvestresylvestrelibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp0000644000175000017500000000130312266757726030207 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp0000644000175000017500000000156512266757726031146 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp0000644000175000017500000000235312266757726031765 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/0000755000175000017500000000000012266757726032227 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cp0000644000175000017500000000230612266757726035342 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cp0000644000175000017500000000304012266757726035337 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() {} ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cp0000644000175000017500000000120112266757726035301 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cp0000644000175000017500000000106212266757726035253 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp0000644000175000017500000000165512266757726035407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cp0000644000175000017500000000221512266757726035311 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp0000644000175000017500000000151412266757726034755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter040000644000175000017500000000223512266757726035504 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fa0000644000175000017500000000312412266757726035416 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter040000644000175000017500000000207012266757726035501 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cp0000644000175000017500000000164212266757726035310 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fa0000644000175000017500000000243612266757726035417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fa0000644000175000017500000000244412266757726035413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fa0000644000175000017500000000243512266757726035413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fa0000644000175000017500000000223112266757726035407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cp0000644000175000017500000000127512266757726035257 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 { Deleter() {} public: Deleter(Deleter&) {} Deleter& operator=(Deleter&) {} void operator()(void*) const {} }; int main() { std::unique_ptr p; } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cp0000644000175000017500000000110712266757726035307 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fa0000644000175000017500000000245112266757726035417 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter020000644000175000017500000000216112266757726035500 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp0000644000175000017500000000153012266757726034754 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fa0000644000175000017500000000313212266757726035415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fa0000644000175000017500000000221612266757726035407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fa0000644000175000017500000000245012266757726035413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fa0000644000175000017500000000244312266757726035420 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter010000644000175000017500000000163312266757726035502 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter050000644000175000017500000000203712266757726035505 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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()); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cp0000644000175000017500000000132212266757726035304 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cp0000644000175000017500000000115512266757726035255 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cp0000644000175000017500000000262412266757726035312 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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() {} libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp0000644000175000017500000000365612266757726035021 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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;} }; 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp0000644000175000017500000000177312266757726034766 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fa0000644000175000017500000000313112266757726035411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fa0000644000175000017500000000222412266757726035414 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp0000644000175000017500000000303312266757726035007 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fa0000644000175000017500000000222512266757726035407 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fa0000644000175000017500000000223212266757726035413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fa0000644000175000017500000000311612266757726035411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fa0000644000175000017500000000312512266757726035411 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fa0000644000175000017500000000311712266757726035415 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter030000644000175000017500000000231112266757726035476 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fa0000644000175000017500000000221712266757726035413 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp0000644000175000017500000000200712266757726034756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp0000644000175000017500000000227212266757726031761 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp0000644000175000017500000000225612266757726031760 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp0000644000175000017500000000132612266757726030215 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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[3]); std::unique_ptr s2; s2 = s; } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/0000755000175000017500000000000012266757726033241 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.0000644000175000017500000000231212266757726035356 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass0000644000175000017500000000114012266757726035545 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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; } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cp0000644000175000017500000000256012266757726035507 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.0000644000175000017500000000165512266757726035421 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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(); 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(); p.reset(new A[5]); assert(A::count == 5); } assert(A::count == 0); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp0000644000175000017500000000204212266757726031750 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp0000644000175000017500000000144312266757726031650 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp0000644000175000017500000000140612266757726031660 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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), ""); } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp0000644000175000017500000000230212266757726031756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp0000644000175000017500000000360012266757726030244 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp0000644000175000017500000000175612266757726030225 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp0000644000175000017500000000207012266757726031757 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/0000755000175000017500000000000012266757726033272 5ustar sylvestresylvestre././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_boo0000644000175000017500000000132612266757726035677 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.0000644000175000017500000000100412266757726035535 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.c0000644000175000017500000000167312266757726035521 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp0000644000175000017500000000102712266757726035522 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fai0000644000175000017500000000106012266757726035600 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpplibcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.0000644000175000017500000000137312266757726035562 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp0000644000175000017500000000227712266757726031764 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp0000644000175000017500000000143012266757726031116 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp0000644000175000017500000000231312266757726031756 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 "../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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp0000644000175000017500000000206212266757726031755 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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 // 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); } libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp0000644000175000017500000000200512266757726030212 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The 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); } libcxx/test/utilities/memory/pointer.traits/0000755000175000017500000000000012266757726022544 5ustar sylvestresylvestrelibcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp0000644000175000017500000000132112266757726026374 0ustar sylvestresylvestre//===----------------------------------------------------------------------===// // // The LLVM 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(