diff options
Diffstat (limited to 'libcxx/test/input.output')
363 files changed, 19370 insertions, 0 deletions
diff --git a/libcxx/test/input.output/file.streams/c.files/cinttypes.pass.cpp b/libcxx/test/input.output/file.streams/c.files/cinttypes.pass.cpp new file mode 100644 index 00000000000..23f1dbe9998 --- /dev/null +++ b/libcxx/test/input.output/file.streams/c.files/cinttypes.pass.cpp @@ -0,0 +1,929 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test <cinttypes> + +#include <cinttypes> +#include <type_traits> + +#ifndef INT8_MIN +#error INT8_MIN not defined +#endif + +#ifndef INT16_MIN +#error INT16_MIN not defined +#endif + +#ifndef INT32_MIN +#error INT32_MIN not defined +#endif + +#ifndef INT64_MIN +#error INT64_MIN not defined +#endif + +#ifndef INT8_MAX +#error INT8_MAX not defined +#endif + +#ifndef INT16_MAX +#error INT16_MAX not defined +#endif + +#ifndef INT32_MAX +#error INT32_MAX not defined +#endif + +#ifndef INT64_MAX +#error INT64_MAX not defined +#endif + +#ifndef UINT8_MAX +#error UINT8_MAX not defined +#endif + +#ifndef UINT16_MAX +#error UINT16_MAX not defined +#endif + +#ifndef UINT32_MAX +#error UINT32_MAX not defined +#endif + +#ifndef UINT64_MAX +#error UINT64_MAX not defined +#endif + +#ifndef INT_LEAST8_MIN +#error INT_LEAST8_MIN not defined +#endif + +#ifndef INT_LEAST16_MIN +#error INT_LEAST16_MIN not defined +#endif + +#ifndef INT_LEAST32_MIN +#error INT_LEAST32_MIN not defined +#endif + +#ifndef INT_LEAST64_MIN +#error INT_LEAST64_MIN not defined +#endif + +#ifndef INT_LEAST8_MAX +#error INT_LEAST8_MAX not defined +#endif + +#ifndef INT_LEAST16_MAX +#error INT_LEAST16_MAX not defined +#endif + +#ifndef INT_LEAST32_MAX +#error INT_LEAST32_MAX not defined +#endif + +#ifndef INT_LEAST64_MAX +#error INT_LEAST64_MAX not defined +#endif + +#ifndef UINT_LEAST8_MAX +#error UINT_LEAST8_MAX not defined +#endif + +#ifndef UINT_LEAST16_MAX +#error UINT_LEAST16_MAX not defined +#endif + +#ifndef UINT_LEAST32_MAX +#error UINT_LEAST32_MAX not defined +#endif + +#ifndef UINT_LEAST64_MAX +#error UINT_LEAST64_MAX not defined +#endif + +#ifndef INT_FAST8_MIN +#error INT_FAST8_MIN not defined +#endif + +#ifndef INT_FAST16_MIN +#error INT_FAST16_MIN not defined +#endif + +#ifndef INT_FAST32_MIN +#error INT_FAST32_MIN not defined +#endif + +#ifndef INT_FAST64_MIN +#error INT_FAST64_MIN not defined +#endif + +#ifndef INT_FAST8_MAX +#error INT_FAST8_MAX not defined +#endif + +#ifndef INT_FAST16_MAX +#error INT_FAST16_MAX not defined +#endif + +#ifndef INT_FAST32_MAX +#error INT_FAST32_MAX not defined +#endif + +#ifndef INT_FAST64_MAX +#error INT_FAST64_MAX not defined +#endif + +#ifndef UINT_FAST8_MAX +#error UINT_FAST8_MAX not defined +#endif + +#ifndef UINT_FAST16_MAX +#error UINT_FAST16_MAX not defined +#endif + +#ifndef UINT_FAST32_MAX +#error UINT_FAST32_MAX not defined +#endif + +#ifndef UINT_FAST64_MAX +#error UINT_FAST64_MAX not defined +#endif + +#ifndef INTPTR_MIN +#error INTPTR_MIN not defined +#endif + +#ifndef INTPTR_MAX +#error INTPTR_MAX not defined +#endif + +#ifndef UINTPTR_MAX +#error UINTPTR_MAX not defined +#endif + +#ifndef INTMAX_MIN +#error INTMAX_MIN not defined +#endif + +#ifndef INTMAX_MAX +#error INTMAX_MAX not defined +#endif + +#ifndef UINTMAX_MAX +#error UINTMAX_MAX not defined +#endif + +#ifndef PTRDIFF_MIN +#error PTRDIFF_MIN not defined +#endif + +#ifndef PTRDIFF_MAX +#error PTRDIFF_MAX not defined +#endif + +#ifndef SIG_ATOMIC_MIN +#error SIG_ATOMIC_MIN not defined +#endif + +#ifndef SIG_ATOMIC_MAX +#error SIG_ATOMIC_MAX not defined +#endif + +#ifndef SIZE_MAX +#error SIZE_MAX not defined +#endif + +#ifndef WCHAR_MIN +#error WCHAR_MIN not defined +#endif + +#ifndef WCHAR_MAX +#error WCHAR_MAX not defined +#endif + +#ifndef WINT_MIN +#error WINT_MIN not defined +#endif + +#ifndef WINT_MAX +#error WINT_MAX not defined +#endif + +#ifndef INT8_C +#error INT8_C not defined +#endif + +#ifndef INT16_C +#error INT16_C not defined +#endif + +#ifndef INT32_C +#error INT32_C not defined +#endif + +#ifndef INT64_C +#error INT64_C not defined +#endif + +#ifndef UINT8_C +#error UINT8_C not defined +#endif + +#ifndef UINT16_C +#error UINT16_C not defined +#endif + +#ifndef UINT32_C +#error UINT32_C not defined +#endif + +#ifndef UINT64_C +#error UINT64_C not defined +#endif + +#ifndef INTMAX_C +#error INTMAX_C not defined +#endif + +#ifndef UINTMAX_C +#error UINTMAX_C not defined +#endif + +#ifndef PRId8 +#error PRId8 not defined +#endif + +#ifndef PRId16 +#error PRId16 not defined +#endif + +#ifndef PRId32 +#error PRId32 not defined +#endif + +#ifndef PRId64 +#error PRId64 not defined +#endif + +#ifndef PRIdLEAST8 +#error PRIdLEAST8 not defined +#endif + +#ifndef PRIdLEAST16 +#error PRIdLEAST16 not defined +#endif + +#ifndef PRIdLEAST32 +#error PRIdLEAST32 not defined +#endif + +#ifndef PRIdLEAST64 +#error PRIdLEAST64 not defined +#endif + +#ifndef PRIdFAST8 +#error PRIdFAST8 not defined +#endif + +#ifndef PRIdFAST16 +#error PRIdFAST16 not defined +#endif + +#ifndef PRIdFAST32 +#error PRIdFAST32 not defined +#endif + +#ifndef PRIdFAST64 +#error PRIdFAST64 not defined +#endif + +#ifndef PRIdMAX +#error PRIdMAX not defined +#endif + +#ifndef PRIdPTR +#error PRIdPTR not defined +#endif + +#ifndef PRIi8 +#error PRIi8 not defined +#endif + +#ifndef PRIi16 +#error PRIi16 not defined +#endif + +#ifndef PRIi32 +#error PRIi32 not defined +#endif + +#ifndef PRIi64 +#error PRIi64 not defined +#endif + +#ifndef PRIiLEAST8 +#error PRIiLEAST8 not defined +#endif + +#ifndef PRIiLEAST16 +#error PRIiLEAST16 not defined +#endif + +#ifndef PRIiLEAST32 +#error PRIiLEAST32 not defined +#endif + +#ifndef PRIiLEAST64 +#error PRIiLEAST64 not defined +#endif + +#ifndef PRIiFAST8 +#error PRIiFAST8 not defined +#endif + +#ifndef PRIiFAST16 +#error PRIiFAST16 not defined +#endif + +#ifndef PRIiFAST32 +#error PRIiFAST32 not defined +#endif + +#ifndef PRIiFAST64 +#error PRIiFAST64 not defined +#endif + +#ifndef PRIiMAX +#error PRIiMAX not defined +#endif + +#ifndef PRIiPTR +#error PRIiPTR not defined +#endif + +#ifndef PRIo8 +#error PRIo8 not defined +#endif + +#ifndef PRIo16 +#error PRIo16 not defined +#endif + +#ifndef PRIo32 +#error PRIo32 not defined +#endif + +#ifndef PRIo64 +#error PRIo64 not defined +#endif + +#ifndef PRIoLEAST8 +#error PRIoLEAST8 not defined +#endif + +#ifndef PRIoLEAST16 +#error PRIoLEAST16 not defined +#endif + +#ifndef PRIoLEAST32 +#error PRIoLEAST32 not defined +#endif + +#ifndef PRIoLEAST64 +#error PRIoLEAST64 not defined +#endif + +#ifndef PRIoFAST8 +#error PRIoFAST8 not defined +#endif + +#ifndef PRIoFAST16 +#error PRIoFAST16 not defined +#endif + +#ifndef PRIoFAST32 +#error PRIoFAST32 not defined +#endif + +#ifndef PRIoFAST64 +#error PRIoFAST64 not defined +#endif + +#ifndef PRIoMAX +#error PRIoMAX not defined +#endif + +#ifndef PRIoPTR +#error PRIoPTR not defined +#endif + +#ifndef PRIu8 +#error PRIu8 not defined +#endif + +#ifndef PRIu16 +#error PRIu16 not defined +#endif + +#ifndef PRIu32 +#error PRIu32 not defined +#endif + +#ifndef PRIu64 +#error PRIu64 not defined +#endif + +#ifndef PRIuLEAST8 +#error PRIuLEAST8 not defined +#endif + +#ifndef PRIuLEAST16 +#error PRIuLEAST16 not defined +#endif + +#ifndef PRIuLEAST32 +#error PRIuLEAST32 not defined +#endif + +#ifndef PRIuLEAST64 +#error PRIuLEAST64 not defined +#endif + +#ifndef PRIuFAST8 +#error PRIuFAST8 not defined +#endif + +#ifndef PRIuFAST16 +#error PRIuFAST16 not defined +#endif + +#ifndef PRIuFAST32 +#error PRIuFAST32 not defined +#endif + +#ifndef PRIuFAST64 +#error PRIuFAST64 not defined +#endif + +#ifndef PRIuMAX +#error PRIuMAX not defined +#endif + +#ifndef PRIuPTR +#error PRIuPTR not defined +#endif + +#ifndef PRIx8 +#error PRIx8 not defined +#endif + +#ifndef PRIx16 +#error PRIx16 not defined +#endif + +#ifndef PRIx32 +#error PRIx32 not defined +#endif + +#ifndef PRIx64 +#error PRIx64 not defined +#endif + +#ifndef PRIxLEAST8 +#error PRIxLEAST8 not defined +#endif + +#ifndef PRIxLEAST16 +#error PRIxLEAST16 not defined +#endif + +#ifndef PRIxLEAST32 +#error PRIxLEAST32 not defined +#endif + +#ifndef PRIxLEAST64 +#error PRIxLEAST64 not defined +#endif + +#ifndef PRIxFAST8 +#error PRIxFAST8 not defined +#endif + +#ifndef PRIxFAST16 +#error PRIxFAST16 not defined +#endif + +#ifndef PRIxFAST32 +#error PRIxFAST32 not defined +#endif + +#ifndef PRIxFAST64 +#error PRIxFAST64 not defined +#endif + +#ifndef PRIxMAX +#error PRIxMAX not defined +#endif + +#ifndef PRIxPTR +#error PRIxPTR not defined +#endif + +#ifndef PRIX8 +#error PRIX8 not defined +#endif + +#ifndef PRIX16 +#error PRIX16 not defined +#endif + +#ifndef PRIX32 +#error PRIX32 not defined +#endif + +#ifndef PRIX64 +#error PRIX64 not defined +#endif + +#ifndef PRIXLEAST8 +#error PRIXLEAST8 not defined +#endif + +#ifndef PRIXLEAST16 +#error PRIXLEAST16 not defined +#endif + +#ifndef PRIXLEAST32 +#error PRIXLEAST32 not defined +#endif + +#ifndef PRIXLEAST64 +#error PRIXLEAST64 not defined +#endif + +#ifndef PRIXFAST8 +#error PRIXFAST8 not defined +#endif + +#ifndef PRIXFAST16 +#error PRIXFAST16 not defined +#endif + +#ifndef PRIXFAST32 +#error PRIXFAST32 not defined +#endif + +#ifndef PRIXFAST64 +#error PRIXFAST64 not defined +#endif + +#ifndef PRIXMAX +#error PRIXMAX not defined +#endif + +#ifndef PRIXPTR +#error PRIXPTR not defined +#endif + +#ifndef SCNd8 +#error SCNd8 not defined +#endif + +#ifndef SCNd16 +#error SCNd16 not defined +#endif + +#ifndef SCNd32 +#error SCNd32 not defined +#endif + +#ifndef SCNd64 +#error SCNd64 not defined +#endif + +#ifndef SCNdLEAST8 +#error SCNdLEAST8 not defined +#endif + +#ifndef SCNdLEAST16 +#error SCNdLEAST16 not defined +#endif + +#ifndef SCNdLEAST32 +#error SCNdLEAST32 not defined +#endif + +#ifndef SCNdLEAST64 +#error SCNdLEAST64 not defined +#endif + +#ifndef SCNdFAST8 +#error SCNdFAST8 not defined +#endif + +#ifndef SCNdFAST16 +#error SCNdFAST16 not defined +#endif + +#ifndef SCNdFAST32 +#error SCNdFAST32 not defined +#endif + +#ifndef SCNdFAST64 +#error SCNdFAST64 not defined +#endif + +#ifndef SCNdMAX +#error SCNdMAX not defined +#endif + +#ifndef SCNdPTR +#error SCNdPTR not defined +#endif + +#ifndef SCNi8 +#error SCNi8 not defined +#endif + +#ifndef SCNi16 +#error SCNi16 not defined +#endif + +#ifndef SCNi32 +#error SCNi32 not defined +#endif + +#ifndef SCNi64 +#error SCNi64 not defined +#endif + +#ifndef SCNiLEAST8 +#error SCNiLEAST8 not defined +#endif + +#ifndef SCNiLEAST16 +#error SCNiLEAST16 not defined +#endif + +#ifndef SCNiLEAST32 +#error SCNiLEAST32 not defined +#endif + +#ifndef SCNiLEAST64 +#error SCNiLEAST64 not defined +#endif + +#ifndef SCNiFAST8 +#error SCNiFAST8 not defined +#endif + +#ifndef SCNiFAST16 +#error SCNiFAST16 not defined +#endif + +#ifndef SCNiFAST32 +#error SCNiFAST32 not defined +#endif + +#ifndef SCNiFAST64 +#error SCNiFAST64 not defined +#endif + +#ifndef SCNiMAX +#error SCNiMAX not defined +#endif + +#ifndef SCNiPTR +#error SCNiPTR not defined +#endif + +#ifndef SCNo8 +#error SCNo8 not defined +#endif + +#ifndef SCNo16 +#error SCNo16 not defined +#endif + +#ifndef SCNo32 +#error SCNo32 not defined +#endif + +#ifndef SCNo64 +#error SCNo64 not defined +#endif + +#ifndef SCNoLEAST8 +#error SCNoLEAST8 not defined +#endif + +#ifndef SCNoLEAST16 +#error SCNoLEAST16 not defined +#endif + +#ifndef SCNoLEAST32 +#error SCNoLEAST32 not defined +#endif + +#ifndef SCNoLEAST64 +#error SCNoLEAST64 not defined +#endif + +#ifndef SCNoFAST8 +#error SCNoFAST8 not defined +#endif + +#ifndef SCNoFAST16 +#error SCNoFAST16 not defined +#endif + +#ifndef SCNoFAST32 +#error SCNoFAST32 not defined +#endif + +#ifndef SCNoFAST64 +#error SCNoFAST64 not defined +#endif + +#ifndef SCNoMAX +#error SCNoMAX not defined +#endif + +#ifndef SCNoPTR +#error SCNoPTR not defined +#endif + +#ifndef SCNu8 +#error SCNu8 not defined +#endif + +#ifndef SCNu16 +#error SCNu16 not defined +#endif + +#ifndef SCNu32 +#error SCNu32 not defined +#endif + +#ifndef SCNu64 +#error SCNu64 not defined +#endif + +#ifndef SCNuLEAST8 +#error SCNuLEAST8 not defined +#endif + +#ifndef SCNuLEAST16 +#error SCNuLEAST16 not defined +#endif + +#ifndef SCNuLEAST32 +#error SCNuLEAST32 not defined +#endif + +#ifndef SCNuLEAST64 +#error SCNuLEAST64 not defined +#endif + +#ifndef SCNuFAST8 +#error SCNuFAST8 not defined +#endif + +#ifndef SCNuFAST16 +#error SCNuFAST16 not defined +#endif + +#ifndef SCNuFAST32 +#error SCNuFAST32 not defined +#endif + +#ifndef SCNuFAST64 +#error SCNuFAST64 not defined +#endif + +#ifndef SCNuMAX +#error SCNuMAX not defined +#endif + +#ifndef SCNuPTR +#error SCNuPTR not defined +#endif + +#ifndef SCNx8 +#error SCNx8 not defined +#endif + +#ifndef SCNx16 +#error SCNx16 not defined +#endif + +#ifndef SCNx32 +#error SCNx32 not defined +#endif + +#ifndef SCNx64 +#error SCNx64 not defined +#endif + +#ifndef SCNxLEAST8 +#error SCNxLEAST8 not defined +#endif + +#ifndef SCNxLEAST16 +#error SCNxLEAST16 not defined +#endif + +#ifndef SCNxLEAST32 +#error SCNxLEAST32 not defined +#endif + +#ifndef SCNxLEAST64 +#error SCNxLEAST64 not defined +#endif + +#ifndef SCNxFAST8 +#error SCNxFAST8 not defined +#endif + +#ifndef SCNxFAST16 +#error SCNxFAST16 not defined +#endif + +#ifndef SCNxFAST32 +#error SCNxFAST32 not defined +#endif + +#ifndef SCNxFAST64 +#error SCNxFAST64 not defined +#endif + +#ifndef SCNxMAX +#error SCNxMAX not defined +#endif + +#ifndef SCNxPTR +#error SCNxPTR not defined +#endif + +int main() +{ + { + std::int8_t i1 = 0; + std::int16_t i2 = 0; + std::int32_t i3 = 0; + std::int64_t i4 = 0; + } + { + std::uint8_t i1 = 0; + std::uint16_t i2 = 0; + std::uint32_t i3 = 0; + std::uint64_t i4 = 0; + } + { + std::int_least8_t i1 = 0; + std::int_least16_t i2 = 0; + std::int_least32_t i3 = 0; + std::int_least64_t i4 = 0; + } + { + std::uint_least8_t i1 = 0; + std::uint_least16_t i2 = 0; + std::uint_least32_t i3 = 0; + std::uint_least64_t i4 = 0; + } + { + std::int_fast8_t i1 = 0; + std::int_fast16_t i2 = 0; + std::int_fast32_t i3 = 0; + std::int_fast64_t i4 = 0; + } + { + std::uint_fast8_t i1 = 0; + std::uint_fast16_t i2 = 0; + std::uint_fast32_t i3 = 0; + std::uint_fast64_t i4 = 0; + } + { + std::intptr_t i1 = 0; + std::uintptr_t i2 = 0; + std::intmax_t i3 = 0; + std::uintmax_t i4 = 0; + } + { + std::imaxdiv_t i1 = {0}; + } + std::intmax_t i = 0; + static_assert((std::is_same<decltype(std::imaxabs(i)), std::intmax_t>::value), ""); + static_assert((std::is_same<decltype(std::imaxdiv(i, i)), std::imaxdiv_t>::value), ""); + static_assert((std::is_same<decltype(std::strtoimax("", (char**)0, 0)), std::intmax_t>::value), ""); + static_assert((std::is_same<decltype(std::strtoumax("", (char**)0, 0)), std::uintmax_t>::value), ""); + static_assert((std::is_same<decltype(std::wcstoimax(L"", (wchar_t**)0, 0)), std::intmax_t>::value), ""); + static_assert((std::is_same<decltype(std::wcstoumax(L"", (wchar_t**)0, 0)), std::uintmax_t>::value), ""); +} diff --git a/libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp b/libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp new file mode 100644 index 00000000000..4b909097f95 --- /dev/null +++ b/libcxx/test/input.output/file.streams/c.files/cstdio.pass.cpp @@ -0,0 +1,134 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test <cstdio> + +#include <cstdio> +#include <type_traits> + +#ifndef BUFSIZ +#error BUFSIZ not defined +#endif + +#ifndef EOF +#error EOF not defined +#endif + +#ifndef FILENAME_MAX +#error FILENAME_MAX not defined +#endif + +#ifndef FOPEN_MAX +#error FOPEN_MAX not defined +#endif + +#ifndef L_tmpnam +#error L_tmpnam not defined +#endif + +#ifndef NULL +#error NULL not defined +#endif + +#ifndef SEEK_CUR +#error SEEK_CUR not defined +#endif + +#ifndef SEEK_END +#error SEEK_END not defined +#endif + +#ifndef SEEK_SET +#error SEEK_SET not defined +#endif + +#ifndef TMP_MAX +#error TMP_MAX not defined +#endif + +#ifndef _IOFBF +#error _IOFBF not defined +#endif + +#ifndef _IOLBF +#error _IOLBF not defined +#endif + +#ifndef _IONBF +#error _IONBF not defined +#endif + +#ifndef stderr +#error stderr not defined +#endif + +#ifndef stdin +#error stdin not defined +#endif + +#ifndef stdout +#error stdout not defined +#endif + +#include <cstdarg> + +int main() +{ + std::FILE* fp = 0; + std::fpos_t fpos = {0}; + std::size_t s = 0; + char* cp = 0; + std::va_list va; + static_assert((std::is_same<decltype(std::remove("")), int>::value), ""); + static_assert((std::is_same<decltype(std::rename("","")), int>::value), ""); + static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), ""); + static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), ""); + static_assert((std::is_same<decltype(std::fclose(fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), ""); + static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), ""); + static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), ""); + static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::fprintf(fp,"")), int>::value), ""); + static_assert((std::is_same<decltype(std::fscanf(fp,"")), int>::value), ""); + static_assert((std::is_same<decltype(std::printf("")), int>::value), ""); + static_assert((std::is_same<decltype(std::scanf("")), int>::value), ""); + static_assert((std::is_same<decltype(std::snprintf(cp,0,"")), int>::value), ""); + static_assert((std::is_same<decltype(std::sprintf(cp,"")), int>::value), ""); + static_assert((std::is_same<decltype(std::sscanf("","")), int>::value), ""); + static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vfscanf(fp,"",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vprintf("",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vscanf("",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vsnprintf(cp,0,"",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vsprintf(cp,"",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vsscanf("","",va)), int>::value), ""); + static_assert((std::is_same<decltype(std::fgetc(fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::fgets(cp,0,fp)), char*>::value), ""); + static_assert((std::is_same<decltype(std::fputc(0,fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::getc(fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::getchar()), int>::value), ""); + static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), ""); + static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::putchar(0)), int>::value), ""); + static_assert((std::is_same<decltype(std::puts("")), int>::value), ""); + static_assert((std::is_same<decltype(std::ungetc(0,fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::fread((void*)0,0,0,fp)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::fwrite((const void*)0,0,0,fp)), std::size_t>::value), ""); + static_assert((std::is_same<decltype(std::fgetpos(fp, &fpos)), int>::value), ""); + static_assert((std::is_same<decltype(std::fseek(fp, 0,0)), int>::value), ""); + static_assert((std::is_same<decltype(std::fsetpos(fp, &fpos)), int>::value), ""); + static_assert((std::is_same<decltype(std::ftell(fp)), long>::value), ""); + static_assert((std::is_same<decltype(std::rewind(fp)), void>::value), ""); + static_assert((std::is_same<decltype(std::clearerr(fp)), void>::value), ""); + static_assert((std::is_same<decltype(std::feof(fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::ferror(fp)), int>::value), ""); + static_assert((std::is_same<decltype(std::perror("")), void>::value), ""); +} diff --git a/libcxx/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp b/libcxx/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp new file mode 100644 index 00000000000..eeba0060dde --- /dev/null +++ b/libcxx/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cstdio> + +#include <cstdio> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp b/libcxx/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp new file mode 100644 index 00000000000..d7018b83477 --- /dev/null +++ b/libcxx/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cinttypes> + +#include <cinttypes> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..248c5cd4f4a --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_filebuf + +// void swap(basic_filebuf& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::filebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); + { + std::wfilebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp new file mode 100644 index 00000000000..24e1f74ac7a --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_filebuf + +// basic_filebuf& operator=(basic_filebuf&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::filebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); + { + std::wfilebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); +#endif +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..cbb9dfd1869 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_filebuf + +// template <class charT, class traits> +// void +// swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::filebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); + { + std::wfilebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp new file mode 100644 index 00000000000..61f4399e739 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_filebuf + +// basic_filebuf(); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::filebuf f; + assert(!f.is_open()); + } + { + std::wfilebuf f; + assert(!f.is_open()); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp new file mode 100644 index 00000000000..d04ed73d86d --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_filebuf + +// basic_filebuf(basic_filebuf&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::filebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); + { + std::wfilebuf f; + assert(f.open("test.dat", 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'); + } + remove("test.dat"); +#endif +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp new file mode 100644 index 00000000000..151521d25e4 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// basic_filebuf<charT,traits>* open(const char* s, ios_base::openmode mode); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::filebuf f; + assert(f.open("test.dat", std::ios_base::out) != 0); + assert(f.is_open()); + assert(f.sputn("123", 3) == 3); + } + { + std::filebuf f; + assert(f.open("test.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sbumpc() == '1'); + assert(f.sbumpc() == '2'); + assert(f.sbumpc() == '3'); + } + remove("test.dat"); + { + std::wfilebuf f; + assert(f.open("test.dat", std::ios_base::out) != 0); + assert(f.is_open()); + assert(f.sputn(L"123", 3) == 3); + } + { + std::wfilebuf f; + assert(f.open("test.dat", 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("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp new file mode 100644 index 00000000000..c01942ba94e --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// int_type overflow(int_type c = traits::eof()); + +// This test is not entirely portable + +#include <fstream> +#include <cassert> + +template <class CharT> +struct test_buf + : public std::basic_filebuf<CharT> +{ + typedef std::basic_filebuf<CharT> base; + typedef typename base::char_type char_type; + typedef typename base::int_type int_type; + typedef typename base::traits_type traits_type; + + char_type* pbase() const {return base::pbase();} + char_type* pptr() const {return base::pptr();} + char_type* epptr() const {return base::epptr();} + void gbump(int n) {base::gbump(n);} + + virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);} +}; + +int main() +{ + { + test_buf<char> f; + assert(f.open("overflow.dat", std::ios_base::out) != 0); + assert(f.is_open()); + assert(f.pbase() == 0); + assert(f.pptr() == 0); + assert(f.epptr() == 0); + assert(f.overflow('a') == 'a'); + assert(f.pbase() != 0); + assert(f.pptr() == f.pbase()); + assert(f.epptr() - f.pbase() == 4095); + } + { + test_buf<char> f; + assert(f.open("overflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sgetc() == 'a'); + } + std::remove("overflow.dat"); + { + test_buf<char> f; + f.pubsetbuf(0, 0); + assert(f.open("overflow.dat", std::ios_base::out) != 0); + assert(f.is_open()); + assert(f.pbase() == 0); + assert(f.pptr() == 0); + assert(f.epptr() == 0); + assert(f.overflow('a') == 'a'); + assert(f.pbase() == 0); + assert(f.pptr() == 0); + assert(f.epptr() == 0); + } + { + test_buf<char> f; + assert(f.open("overflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sgetc() == 'a'); + } + std::remove("overflow.dat"); + { + test_buf<wchar_t> f; + assert(f.open("overflow.dat", std::ios_base::out) != 0); + assert(f.is_open()); + assert(f.pbase() == 0); + assert(f.pptr() == 0); + assert(f.epptr() == 0); + assert(f.overflow(L'a') == L'a'); + assert(f.pbase() != 0); + assert(f.pptr() == f.pbase()); + assert(f.epptr() - f.pbase() == 4095); + } + { + test_buf<wchar_t> f; + assert(f.open("overflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sgetc() == L'a'); + } + std::remove("overflow.dat"); + { + test_buf<wchar_t> f; + f.pubsetbuf(0, 0); + assert(f.open("overflow.dat", std::ios_base::out) != 0); + assert(f.is_open()); + assert(f.pbase() == 0); + assert(f.pptr() == 0); + assert(f.epptr() == 0); + assert(f.overflow(L'a') == L'a'); + assert(f.pbase() == 0); + assert(f.pptr() == 0); + assert(f.epptr() == 0); + } + { + test_buf<wchar_t> f; + assert(f.open("overflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sgetc() == L'a'); + } + std::remove("overflow.dat"); + { + test_buf<wchar_t> f; + f.pubimbue(std::locale("en_US.UTF-8")); + assert(f.open("overflow.dat", std::ios_base::out) != 0); + assert(f.sputc(0x4E51) == 0x4E51); + assert(f.sputc(0x4E52) == 0x4E52); + assert(f.sputc(0x4E53) == 0x4E53); + } + { + test_buf<char> f; + assert(f.open("overflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sbumpc() == 0xE4); + assert(f.sbumpc() == 0xB9); + assert(f.sbumpc() == 0x91); + assert(f.sbumpc() == 0xE4); + assert(f.sbumpc() == 0xB9); + assert(f.sbumpc() == 0x92); + assert(f.sbumpc() == 0xE4); + assert(f.sbumpc() == 0xB9); + assert(f.sbumpc() == 0x93); + assert(f.sbumpc() == -1); + } + std::remove("overflow.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp new file mode 100644 index 00000000000..4b0a16537d3 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// int_type pbackfail(int_type c = traits::eof()); + +// This test is not entirely portable + +#include <fstream> +#include <cassert> + +template <class CharT> +struct test_buf + : public std::basic_filebuf<CharT> +{ + typedef std::basic_filebuf<CharT> base; + typedef typename base::char_type char_type; + typedef typename base::int_type int_type; + typedef typename base::traits_type traits_type; + + char_type* eback() const {return base::eback();} + char_type* gptr() const {return base::gptr();} + char_type* egptr() const {return base::egptr();} + void gbump(int n) {base::gbump(n);} + + virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);} +}; + +int main() +{ + { + test_buf<char> f; + assert(f.open("underflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sbumpc() == '1'); + assert(f.sgetc() == '2'); + assert(f.pbackfail('a') == -1); + } + { + test_buf<char> f; + assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) != 0); + assert(f.is_open()); + assert(f.sbumpc() == '1'); + assert(f.sgetc() == '2'); + assert(f.pbackfail('a') == 'a'); + assert(f.sbumpc() == 'a'); + assert(f.sgetc() == '2'); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp new file mode 100644 index 00000000000..27584caf4d4 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// pos_type seekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out); + +// This test is not entirely portable + +#include <fstream> +#include <cassert> + +template <class CharT> +struct test_buf + : public std::basic_filebuf<CharT> +{ + typedef std::basic_filebuf<CharT> base; + typedef typename base::char_type char_type; + typedef typename base::int_type int_type; + typedef typename base::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"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat new file mode 100644 index 00000000000..e2e107ac61a --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat @@ -0,0 +1 @@ +123456789
\ No newline at end of file diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp new file mode 100644 index 00000000000..c704d45228f --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp @@ -0,0 +1,119 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// int_type underflow(); + +// This test is not entirely portable + +#include <fstream> +#include <cassert> + +template <class CharT> +struct test_buf + : public std::basic_filebuf<CharT> +{ + typedef std::basic_filebuf<CharT> base; + typedef typename base::char_type char_type; + typedef typename base::int_type int_type; + + char_type* eback() const {return base::eback();} + char_type* gptr() const {return base::gptr();} + char_type* egptr() const {return base::egptr();} + void gbump(int n) {base::gbump(n);} + + virtual int_type underflow() {return base::underflow();} +}; + +int main() +{ + { + test_buf<char> f; + assert(f.open("underflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.eback() == 0); + assert(f.gptr() == 0); + assert(f.egptr() == 0); + assert(f.underflow() == '1'); + assert(f.eback() != 0); + assert(f.eback() == f.gptr()); + assert(*f.gptr() == '1'); + assert(f.egptr() - f.eback() == 9); + } + { + test_buf<char> f; + assert(f.open("underflow.dat", std::ios_base::in) != 0); + assert(f.pubsetbuf(0, 0)); + assert(f.is_open()); + assert(f.eback() == 0); + assert(f.gptr() == 0); + assert(f.egptr() == 0); + assert(f.underflow() == '1'); + assert(f.eback() != 0); + assert(f.eback() == f.gptr()); + assert(*f.gptr() == '1'); + assert(f.egptr() - f.eback() == 8); + f.gbump(8); + assert(f.sgetc() == '9'); + assert(f.eback()[0] == '5'); + assert(f.eback()[1] == '6'); + assert(f.eback()[2] == '7'); + assert(f.eback()[3] == '8'); + assert(f.gptr() - f.eback() == 4); + assert(*f.gptr() == '9'); + assert(f.egptr() - f.gptr() == 1); + } + { + test_buf<wchar_t> f; + assert(f.open("underflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.eback() == 0); + assert(f.gptr() == 0); + assert(f.egptr() == 0); + assert(f.underflow() == L'1'); + assert(f.eback() != 0); + assert(f.eback() == f.gptr()); + assert(*f.gptr() == L'1'); + assert(f.egptr() - f.eback() == 9); + } + { + test_buf<wchar_t> f; + assert(f.pubsetbuf(0, 0)); + assert(f.open("underflow.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.eback() == 0); + assert(f.gptr() == 0); + assert(f.egptr() == 0); + assert(f.underflow() == L'1'); + assert(f.eback() != 0); + assert(f.eback() == f.gptr()); + assert(*f.gptr() == L'1'); + assert(f.egptr() - f.eback() == 8); + f.gbump(8); + assert(f.sgetc() == L'9'); + assert(f.eback()[0] == L'5'); + assert(f.eback()[1] == L'6'); + assert(f.eback()[2] == L'7'); + assert(f.eback()[3] == L'8'); + assert(f.gptr() - f.eback() == 4); + assert(*f.gptr() == L'9'); + assert(f.egptr() - f.gptr() == 1); + } + { + test_buf<wchar_t> f; + f.pubimbue(std::locale("en_US.UTF-8")); + assert(f.open("underflow_utf8.dat", std::ios_base::in) != 0); + assert(f.is_open()); + assert(f.sbumpc() == 0x4E51); + assert(f.sbumpc() == 0x4E52); + assert(f.sbumpc() == 0x4E53); + assert(f.sbumpc() == -1); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat new file mode 100644 index 00000000000..ee7063e1207 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat @@ -0,0 +1 @@ +δΉδΉδΉ
\ No newline at end of file diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp new file mode 100644 index 00000000000..8c412c91700 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_filebuf +// : public basic_streambuf<charT, traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <fstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_filebuf<char> >::value), ""); + static_assert((std::is_same<std::basic_filebuf<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_filebuf<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_filebuf<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_filebuf<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_filebuf<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..9c247ba3ad8 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// void swap(basic_fstream& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + std::fstream fs2("test2.dat", 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("test1.dat"); + std::remove("test2.dat"); + { + std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + std::wfstream fs2("test2.dat", 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("test1.dat"); + std::remove("test2.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp new file mode 100644 index 00000000000..82253914f69 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// basic_fstream& operator=(basic_fstream&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::fstream fso("test.dat", 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("test.dat"); + { + std::wfstream fso("test.dat", 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("test.dat"); +#endif +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..178092e1c13 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// template <class charT, class traits> +// void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + std::fstream fs2("test2.dat", 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("test1.dat"); + std::remove("test2.dat"); + { + std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + std::wfstream fs2("test2.dat", 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("test1.dat"); + std::remove("test2.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp new file mode 100644 index 00000000000..7e9e478e415 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// basic_fstream(); + +#include <fstream> +#include <type_traits> + +int main() +{ + { + std::fstream fs; + } + { + std::wfstream fs; + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp new file mode 100644 index 00000000000..0690bb49448 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// basic_fstream(basic_fstream&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::fstream fso("test.dat", 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("test.dat"); + { + std::wfstream fso("test.dat", 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("test.dat"); +#endif +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp new file mode 100644 index 00000000000..fb884d08f04 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in | ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs("test.dat", 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("test.dat"); + { + std::wfstream fs("test.dat", 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("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp new file mode 100644 index 00000000000..ad7cf4703d6 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs(std::string("test.dat"), + 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("test.dat"); + { + std::wfstream fs(std::string("test.dat"), + 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("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp new file mode 100644 index 00000000000..e18daf5669a --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// void close(); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs; + assert(!fs.is_open()); + fs.open("test.dat", std::ios_base::out); + assert(fs.is_open()); + fs.close(); + assert(!fs.is_open()); + } + remove("test.dat"); + { + std::wfstream fs; + assert(!fs.is_open()); + fs.open("test.dat", std::ios_base::out); + assert(fs.is_open()); + fs.close(); + assert(!fs.is_open()); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp new file mode 100644 index 00000000000..4ce6933a086 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs; + assert(!fs.is_open()); + fs.open("test.dat", 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("test.dat"); + { + std::wfstream fs; + assert(!fs.is_open()); + fs.open("test.dat", 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("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp new file mode 100644 index 00000000000..d0596c2cc24 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs; + assert(!fs.is_open()); + fs.open(std::string("test.dat"), 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("test.dat"); + { + std::wfstream fs; + assert(!fs.is_open()); + fs.open(std::string("test.dat"), 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("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp new file mode 100644 index 00000000000..5cc55af6bdc --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// basic_filebuf<charT,traits>* rdbuf() const; + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::fstream fs; + assert(fs.rdbuf()); + } + { + std::wfstream fs; + assert(fs.rdbuf()); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream/types.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream/types.pass.cpp new file mode 100644 index 00000000000..3184f563523 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/fstream/types.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream +// : public basic_iostream<charT,traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <fstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_fstream<char> >::value), ""); + static_assert((std::is_same<std::basic_fstream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_fstream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_fstream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_fstream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_fstream<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..0dd5479dd74 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// void swap(basic_ifstream& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs1("test.dat"); + std::ifstream fs2("test2.dat"); + fs1.swap(fs2); + double x = 0; + fs1 >> x; + assert(x == 4.5); + fs2 >> x; + assert(x == 3.25); + } + { + std::wifstream fs1("test.dat"); + std::wifstream fs2("test2.dat"); + fs1.swap(fs2); + double x = 0; + fs1 >> x; + assert(x == 4.5); + fs2 >> x; + assert(x == 3.25); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp new file mode 100644 index 00000000000..a8b371c31d9 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// basic_ifstream& operator=(basic_ifstream&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..f2e08bbc027 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// template <class charT, class traits> +// void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs1("test.dat"); + std::ifstream fs2("test2.dat"); + swap(fs1, fs2); + double x = 0; + fs1 >> x; + assert(x == 4.5); + fs2 >> x; + assert(x == 3.25); + } + { + std::wifstream fs1("test.dat"); + std::wifstream fs2("test2.dat"); + swap(fs1, fs2); + double x = 0; + fs1 >> x; + assert(x == 4.5); + fs2 >> x; + assert(x == 3.25); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/test.dat b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/test.dat new file mode 100644 index 00000000000..64064d34a8e --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/test.dat @@ -0,0 +1 @@ +3.25
\ No newline at end of file diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat new file mode 100644 index 00000000000..958d30d86d0 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat @@ -0,0 +1 @@ +4.5
\ No newline at end of file diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp new file mode 100644 index 00000000000..6b5fc3b1edf --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// basic_ifstream(); + +#include <fstream> +#include <type_traits> + +int main() +{ + { + std::ifstream fs; + } + { + std::wifstream fs; + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp new file mode 100644 index 00000000000..d75def033b0 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// basic_ifstream(basic_ifstream&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp new file mode 100644 index 00000000000..57fc3ca5cbe --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + { + std::ifstream fs("test.dat", std::ios_base::out); + double x = 0; + fs >> x; + assert(x == 3.25); + } + { + std::wifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + { + std::wifstream fs("test.dat", std::ios_base::out); + double x = 0; + fs >> x; + assert(x == 3.25); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp new file mode 100644 index 00000000000..01620501ec4 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs(std::string("test.dat")); + double x = 0; + fs >> x; + assert(x == 3.25); + } + { + std::ifstream fs(std::string("test.dat"), std::ios_base::out); + double x = 0; + fs >> x; + assert(x == 3.25); + } + { + std::wifstream fs(std::string("test.dat")); + double x = 0; + fs >> x; + assert(x == 3.25); + } + { + std::wifstream fs(std::string("test.dat"), std::ios_base::out); + double x = 0; + fs >> x; + assert(x == 3.25); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/test.dat b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/test.dat new file mode 100644 index 00000000000..64064d34a8e --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.cons/test.dat @@ -0,0 +1 @@ +3.25
\ No newline at end of file diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp new file mode 100644 index 00000000000..4d1777e77a0 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// void close(); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs; + assert(!fs.is_open()); + fs.open("test.dat"); + assert(fs.is_open()); + fs.close(); + assert(!fs.is_open()); + } + { + std::wifstream fs; + assert(!fs.is_open()); + fs.open("test.dat"); + assert(fs.is_open()); + fs.close(); + assert(!fs.is_open()); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp new file mode 100644 index 00000000000..8f103503a1b --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// void open(const char* s, ios_base::openmode mode = ios_base::in); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs; + assert(!fs.is_open()); + char c = 'a'; + fs >> c; + assert(fs.fail()); + assert(c == 'a'); + fs.open("test.dat"); + assert(fs.is_open()); + fs >> c; + assert(c == 'r'); + } + { + std::wifstream fs; + assert(!fs.is_open()); + wchar_t c = L'a'; + fs >> c; + assert(fs.fail()); + assert(c == L'a'); + fs.open("test.dat"); + assert(fs.is_open()); + fs >> c; + assert(c == L'r'); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp new file mode 100644 index 00000000000..a7604ba4d18 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// void open(const string& s, ios_base::openmode mode = ios_base::in); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs; + assert(!fs.is_open()); + char c = 'a'; + fs >> c; + assert(fs.fail()); + assert(c == 'a'); + fs.open(std::string("test.dat")); + assert(fs.is_open()); + fs >> c; + assert(c == 'r'); + } + { + std::wifstream fs; + assert(!fs.is_open()); + wchar_t c = L'a'; + fs >> c; + assert(fs.fail()); + assert(c == L'a'); + fs.open(std::string("test.dat")); + assert(fs.is_open()); + fs >> c; + assert(c == L'r'); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp new file mode 100644 index 00000000000..d32efa17dc5 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream + +// basic_filebuf<charT,traits>* rdbuf() const; + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ifstream fs("test.dat"); + std::filebuf* fb = fs.rdbuf(); + assert(fb->sgetc() == 'r'); + } + { + std::wifstream fs("test.dat"); + std::wfilebuf* fb = fs.rdbuf(); + assert(fb->sgetc() == L'r'); + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream.members/test.dat b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/test.dat new file mode 100644 index 00000000000..1d2f01491f7 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream.members/test.dat @@ -0,0 +1 @@ +r
\ No newline at end of file diff --git a/libcxx/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp new file mode 100644 index 00000000000..6a431ba3cf3 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ifstream +// : public basic_istream<charT,traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <fstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_istream<char>, std::basic_ifstream<char> >::value), ""); + static_assert((std::is_same<std::basic_ifstream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_ifstream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_ifstream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_ifstream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_ifstream<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..fad2675e9d8 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// void swap(basic_ofstream& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs1("test1.dat"); + std::ofstream fs2("test2.dat"); + fs1 << 3.25; + fs2 << 4.5; + fs1.swap(fs2); + fs1 << ' ' << 3.25; + fs2 << ' ' << 4.5; + } + { + std::ifstream fs("test1.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + fs >> x; + assert(x == 4.5); + } + remove("test1.dat"); + { + std::ifstream fs("test2.dat"); + double x = 0; + fs >> x; + assert(x == 4.5); + fs >> x; + assert(x == 3.25); + } + remove("test2.dat"); + { + std::wofstream fs1("test1.dat"); + std::wofstream fs2("test2.dat"); + fs1 << 3.25; + fs2 << 4.5; + fs1.swap(fs2); + fs1 << ' ' << 3.25; + fs2 << ' ' << 4.5; + } + { + std::wifstream fs("test1.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + fs >> x; + assert(x == 4.5); + } + remove("test1.dat"); + { + std::wifstream fs("test2.dat"); + double x = 0; + fs >> x; + assert(x == 4.5); + fs >> x; + assert(x == 3.25); + } + remove("test2.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp new file mode 100644 index 00000000000..7ee8150b9ac --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// basic_ofstream& operator=(basic_ofstream&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::ofstream fso("test.dat"); + std::ofstream fs; + fs = move(fso); + fs << 3.25; + } + { + std::ifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); + { + std::wofstream fso("test.dat"); + std::wofstream fs; + fs = move(fso); + fs << 3.25; + } + { + std::wifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); +#endif +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..f256da9fed6 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// template <class charT, class traits> +// void swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs1("test1.dat"); + std::ofstream fs2("test2.dat"); + fs1 << 3.25; + fs2 << 4.5; + swap(fs1, fs2); + fs1 << ' ' << 3.25; + fs2 << ' ' << 4.5; + } + { + std::ifstream fs("test1.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + fs >> x; + assert(x == 4.5); + } + remove("test1.dat"); + { + std::ifstream fs("test2.dat"); + double x = 0; + fs >> x; + assert(x == 4.5); + fs >> x; + assert(x == 3.25); + } + remove("test2.dat"); + { + std::wofstream fs1("test1.dat"); + std::wofstream fs2("test2.dat"); + fs1 << 3.25; + fs2 << 4.5; + swap(fs1, fs2); + fs1 << ' ' << 3.25; + fs2 << ' ' << 4.5; + } + { + std::wifstream fs("test1.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + fs >> x; + assert(x == 4.5); + } + remove("test1.dat"); + { + std::wifstream fs("test2.dat"); + double x = 0; + fs >> x; + assert(x == 4.5); + fs >> x; + assert(x == 3.25); + } + remove("test2.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp new file mode 100644 index 00000000000..f66c9c010a1 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// basic_ofstream(); + +#include <fstream> +#include <type_traits> + +int main() +{ + { + std::ofstream fs; + } + { + std::wofstream fs; + } +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp new file mode 100644 index 00000000000..5bd5a2ad0e2 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// basic_ofstream(basic_ofstream&& rhs); + +#include <fstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + std::ofstream fso("test.dat"); + std::ofstream fs = move(fso); + fs << 3.25; + } + { + std::ifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); + { + std::wofstream fso("test.dat"); + std::wofstream fs = move(fso); + fs << 3.25; + } + { + std::wifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); +#endif +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp new file mode 100644 index 00000000000..ecbe065f332 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs("test.dat"); + fs << 3.25; + } + { + std::ifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); + { + std::wofstream fs("test.dat"); + fs << 3.25; + } + { + std::wifstream fs("test.dat"); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp new file mode 100644 index 00000000000..a6a5a6008f1 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs(std::string("test.dat")); + fs << 3.25; + } + { + std::ifstream fs(std::string("test.dat")); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); + { + std::wofstream fs(std::string("test.dat")); + fs << 3.25; + } + { + std::wifstream fs(std::string("test.dat")); + double x = 0; + fs >> x; + assert(x == 3.25); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp new file mode 100644 index 00000000000..439b6958ae0 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// void close(); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs; + assert(!fs.is_open()); + fs.open("test.dat"); + assert(fs.is_open()); + fs.close(); + assert(!fs.is_open()); + } + remove("test.dat"); + { + std::wofstream fs; + assert(!fs.is_open()); + fs.open("test.dat"); + assert(fs.is_open()); + fs.close(); + assert(!fs.is_open()); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp new file mode 100644 index 00000000000..ec4b444ec19 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// void open(const char* s, ios_base::openmode mode = ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs; + assert(!fs.is_open()); + char c = 'a'; + fs << c; + assert(fs.fail()); + fs.open("test.dat"); + assert(fs.is_open()); + fs << c; + } + { + std::ifstream fs("test.dat"); + char c = 0; + fs >> c; + assert(c == 'a'); + } + remove("test.dat"); + { + std::wofstream fs; + assert(!fs.is_open()); + wchar_t c = L'a'; + fs << c; + assert(fs.fail()); + fs.open("test.dat"); + assert(fs.is_open()); + fs << c; + } + { + std::wifstream fs("test.dat"); + wchar_t c = 0; + fs >> c; + assert(c == L'a'); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp new file mode 100644 index 00000000000..c1e2150c0b8 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// void open(const string& s, ios_base::openmode mode = ios_base::out); + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs; + assert(!fs.is_open()); + char c = 'a'; + fs << c; + assert(fs.fail()); + fs.open(std::string("test.dat")); + assert(fs.is_open()); + fs << c; + } + { + std::ifstream fs("test.dat"); + char c = 0; + fs >> c; + assert(c == 'a'); + } + remove("test.dat"); + { + std::wofstream fs; + assert(!fs.is_open()); + wchar_t c = L'a'; + fs << c; + assert(fs.fail()); + fs.open(std::string("test.dat")); + assert(fs.is_open()); + fs << c; + } + { + std::wifstream fs("test.dat"); + wchar_t c = 0; + fs >> c; + assert(c == L'a'); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp new file mode 100644 index 00000000000..0b955602b4d --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream + +// basic_filebuf<charT,traits>* rdbuf() const; + +#include <fstream> +#include <cassert> + +int main() +{ + { + std::ofstream fs("test.dat"); + std::filebuf* fb = fs.rdbuf(); + assert(fb->sputc('r') == 'r'); + } + remove("test.dat"); + { + std::wofstream fs("test.dat"); + std::wfilebuf* fb = fs.rdbuf(); + assert(fb->sputc(L'r') == L'r'); + } + remove("test.dat"); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp new file mode 100644 index 00000000000..32b46430f99 --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ofstream +// : public basic_ostream<charT,traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <fstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ofstream<char> >::value), ""); + static_assert((std::is_same<std::basic_ofstream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_ofstream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_ofstream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_ofstream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_ofstream<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/file.streams/fstreams/version.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/version.pass.cpp new file mode 100644 index 00000000000..ed34b5aa59b --- /dev/null +++ b/libcxx/test/input.output/file.streams/fstreams/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +#include <fstream> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/file.streams/nothing_to_do.pass.cpp b/libcxx/test/input.output/file.streams/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/file.streams/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/input.output.general/nothing_to_do.pass.cpp b/libcxx/test/input.output/input.output.general/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/input.output.general/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/ext.manip/get_money.pass.cpp b/libcxx/test/input.output/iostream.format/ext.manip/get_money.pass.cpp new file mode 100644 index 00000000000..80dc0eda1e6 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/ext.manip/get_money.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// template <class moneyT> T7 get_money(moneyT& mon, bool intl = false); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } +}; + +int main() +{ + { + testbuf<char> sb(" -$1,234,567.89"); + std::istream is(&sb); + is.imbue(std::locale("en_US")); + long double x = 0; + is >> std::get_money(x, false); + assert(x == -123456789); + } + { + testbuf<char> sb(" -USD 1,234,567.89"); + std::istream is(&sb); + is.imbue(std::locale("en_US")); + long double x = 0; + is >> std::get_money(x, true); + assert(x == -123456789); + } + { + testbuf<wchar_t> sb(L" -$1,234,567.89"); + std::wistream is(&sb); + is.imbue(std::locale("en_US")); + long double x = 0; + is >> std::get_money(x, false); + assert(x == -123456789); + } + { + testbuf<wchar_t> sb(L" -USD 1,234,567.89"); + std::wistream is(&sb); + is.imbue(std::locale("en_US")); + long double x = 0; + is >> std::get_money(x, true); + assert(x == -123456789); + } +} diff --git a/libcxx/test/input.output/iostream.format/ext.manip/get_time.pass.cpp b/libcxx/test/input.output/iostream.format/ext.manip/get_time.pass.cpp new file mode 100644 index 00000000000..8a52bf399a1 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/ext.manip/get_time.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// template <class charT> T9 get_time(struct tm* tmb, const charT* fmt); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } +}; + +int main() +{ + { + testbuf<char> sb(" Sat Dec 31 23:55:59 2061"); + std::istream is(&sb); + is.imbue(std::locale("en_US")); + 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<wchar_t> sb(L" Sat Dec 31 23:55:59 2061"); + std::wistream is(&sb); + is.imbue(std::locale("en_US")); + 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()); + } +} diff --git a/libcxx/test/input.output/iostream.format/ext.manip/put_money.pass.cpp b/libcxx/test/input.output/iostream.format/ext.manip/put_money.pass.cpp new file mode 100644 index 00000000000..ade9fb72436 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/ext.manip/put_money.pass.cpp @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false); + +#include <iomanip> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + os.imbue(std::locale("en_US")); + showbase(os); + long double x = -123456789; + os << std::put_money(x, false); + assert(sb.str() == "-$1,234,567.89"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.imbue(std::locale("en_US")); + showbase(os); + long double x = -123456789; + os << std::put_money(x, true); + assert(sb.str() == "-USD 1,234,567.89"); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.imbue(std::locale("en_US")); + showbase(os); + long double x = -123456789; + os << std::put_money(x, false); + assert(sb.str() == L"-$1,234,567.89"); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.imbue(std::locale("en_US")); + showbase(os); + long double x = -123456789; + os << std::put_money(x, true); + assert(sb.str() == L"-USD 1,234,567.89"); + } +} diff --git a/libcxx/test/input.output/iostream.format/ext.manip/put_time.pass.cpp b/libcxx/test/input.output/iostream.format/ext.manip/put_time.pass.cpp new file mode 100644 index 00000000000..304b516bef4 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/ext.manip/put_time.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt); + +#include <iomanip> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + os.imbue(std::locale("en_US")); + 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<wchar_t> sb; + std::wostream os(&sb); + os.imbue(std::locale("en_US")); + 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"); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..076d3990204 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// void swap(basic_iostream& rhs); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_iostream + : public std::basic_iostream<CharT> +{ + typedef std::basic_iostream<CharT> base; + test_iostream(testbuf<CharT>* sb) : base(sb) {} + + void swap(test_iostream& s) {base::swap(s);} +}; + +int main() +{ + { + testbuf<char> sb1; + testbuf<char> sb2; + test_iostream<char> is1(&sb1); + test_iostream<char> is2(&sb2); + is1.swap(is2); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_iostream<wchar_t> is1(&sb1); + test_iostream<wchar_t> is2(&sb2); + is1.swap(is2); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp new file mode 100644 index 00000000000..1b3fda77101 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// basic_iostream& operator=(basic_iostream&& rhs); + +#include <istream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_iostream + : public std::basic_iostream<CharT> +{ + typedef std::basic_iostream<CharT> base; + test_iostream(testbuf<CharT>* sb) : base(sb) {} + + test_iostream& operator=(test_iostream&& s) + {base::operator=(std::move(s)); return *this;} +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb1; + testbuf<char> sb2; + test_iostream<char> is1(&sb1); + test_iostream<char> is2(&sb2); + is2 = (std::move(is1)); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_iostream<wchar_t> is1(&sb1); + test_iostream<wchar_t> is2(&sb2); + is2 = (std::move(is1)); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp new file mode 100644 index 00000000000..7c1549a502a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// basic_iostream(basic_iostream&& rhs); + +#include <istream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_iostream + : public std::basic_iostream<CharT> +{ + typedef std::basic_iostream<CharT> base; + test_iostream(testbuf<CharT>* sb) : base(sb) {} + + test_iostream(test_iostream&& s) + : base(std::move(s)) {} +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb; + test_iostream<char> is1(&sb); + test_iostream<char> is(std::move(is1)); + assert(is1.rdbuf() == &sb); + assert(is1.gcount() == 0); + assert(is.gcount() == 0); + assert(is.rdbuf() == 0); + assert(is.tie() == 0); + assert(is.fill() == ' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb; + test_iostream<wchar_t> is1(&sb); + test_iostream<wchar_t> is(std::move(is1)); + assert(is1.gcount() == 0); + assert(is.gcount() == 0); + assert(is1.rdbuf() == &sb); + assert(is.rdbuf() == 0); + assert(is.tie() == 0); + assert(is.fill() == L' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp new file mode 100644 index 00000000000..7d087b3e4d4 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// explicit basic_iostream(basic_streambuf<charT,traits>* sb); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::basic_iostream<char> is(&sb); + assert(is.rdbuf() == &sb); + assert(is.tie() == 0); + assert(is.fill() == ' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + assert(is.gcount() == 0); + } + { + testbuf<wchar_t> sb; + std::basic_iostream<wchar_t> is(&sb); + assert(is.rdbuf() == &sb); + assert(is.tie() == 0); + assert(is.fill() == L' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + assert(is.gcount() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp new file mode 100644 index 00000000000..e41cf766523 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream : +// public basic_istream<charT,traits>, +// public basic_ostream<charT,traits> +// { +// public: +// // types: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <istream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_istream<char>, std::basic_iostream<char> >::value), ""); + static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_iostream<char> >::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp new file mode 100644 index 00000000000..f1a234f5ced --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(bool& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + bool n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + bool n = true; + is >> n; + assert(n == false); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 1 "); + std::istream is(&sb); + bool n = 0; + is >> n; + assert(n == true); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" 1 "); + std::wistream is(&sb); + bool n = 0; + is >> n; + assert(n == true); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp new file mode 100644 index 00000000000..56414e90375 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(double& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + double n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + double n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + double n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" -123.5 "); + std::wistream is(&sb); + double n = 10; + is >> n; + assert(n == -123.5); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp new file mode 100644 index 00000000000..9e4cc27cd9c --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(float& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + float n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + float n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + float n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" -123.5 "); + std::wistream is(&sb); + float n = 10; + is >> n; + assert(n == -123.5); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp new file mode 100644 index 00000000000..49ade2309c8 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(int& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + int n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + int n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + int n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" -1234567890123456 "); + std::wistream is(&sb); + int n = 10; + is >> n; + assert(n == std::numeric_limits<int>::min()); + assert(!is.eof()); + assert( is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp new file mode 100644 index 00000000000..03b86f99a32 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(long& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + long n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" -123 "); + std::wistream is(&sb); + long n = 10; + is >> n; + assert(n == -123); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp new file mode 100644 index 00000000000..60ba96f9efd --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(long double& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + long double n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + long double n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + long double n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" -123.5 "); + std::wistream is(&sb); + long double n = 10; + is >> n; + assert(n == -123.5); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp new file mode 100644 index 00000000000..ae0ea8df61a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(long long& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + long long n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + long long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + long long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" -123 "); + std::wistream is(&sb); + long long n = 10; + is >> n; + assert(n == -123); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp new file mode 100644 index 00000000000..0c10e271d39 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(void*& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + void* n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + void* n = (void*)1; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 1 "); + std::istream is(&sb); + void* n = 0; + is >> n; + assert(n == (void*)1); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" 1 "); + std::wistream is(&sb); + void* n = 0; + is >> n; + assert(n == (void*)1); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp new file mode 100644 index 00000000000..482b09ffd20 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(short& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + short n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + short n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + short n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" -1234567890 "); + std::wistream is(&sb); + short n = 10; + is >> n; + assert(n == std::numeric_limits<short>::min()); + assert(!is.eof()); + assert( is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp new file mode 100644 index 00000000000..9fa8e8d205d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(unsigned int& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + unsigned int n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + unsigned int n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + unsigned int n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" 123 "); + std::wistream is(&sb); + unsigned int n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp new file mode 100644 index 00000000000..08e2b70fe9a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(unsigned long& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + unsigned long n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + unsigned long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + unsigned long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" 123 "); + std::wistream is(&sb); + unsigned long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp new file mode 100644 index 00000000000..7504b62711e --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(unsigned long long& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + unsigned long long n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + unsigned long long n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + unsigned long long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" 123 "); + std::wistream is(&sb); + unsigned long long n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp new file mode 100644 index 00000000000..a095e531c3d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// operator>>(unsigned short& val); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + std::istream is((std::streambuf*)0); + unsigned short n = 0; + is >> n; + assert(is.fail()); + } + { + testbuf<char> sb("0"); + std::istream is(&sb); + unsigned short n = 10; + is >> n; + assert(n == 0); + assert( is.eof()); + assert(!is.fail()); + } + { + testbuf<char> sb(" 123 "); + std::istream is(&sb); + unsigned short n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } + { + testbuf<wchar_t> sb(L" 123 "); + std::wistream is(&sb); + unsigned short n = 10; + is >> n; + assert(n == 123); + assert(!is.eof()); + assert(!is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/basic_ios.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/basic_ios.pass.cpp new file mode 100644 index 00000000000..62121edfba3 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/basic_ios.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// basic_istream<charT,traits>& operator>>(basic_ios<charT,traits>& +// (*pf)(basic_ios<charT,traits>&)); + +#include <istream> +#include <cassert> + +int f_called = 0; + +template <class CharT> +std::basic_ios<CharT>& +f(std::basic_ios<CharT>& is) +{ + ++f_called; + return is; +} + +int main() +{ + { + std::istream is((std::streambuf*)0); + is >> f; + assert(f_called == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/chart.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/chart.pass.cpp new file mode 100644 index 00000000000..74cd9cc6480 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/chart.pass.cpp @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template<class charT, class traits> +// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT& c); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" "); + std::istream is(&sb); + char c = 'z'; + is >> c; + assert( is.eof()); + assert( is.fail()); + assert(c == 'z'); + } + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + char c; + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'a'); + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'b'); + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'c'); + } + { + testbuf<wchar_t> sb(L" abc"); + std::wistream is(&sb); + wchar_t c; + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == L'a'); + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == L'b'); + is >> c; + assert( is.eof()); + assert(!is.fail()); + assert(c == L'c'); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/ios_base.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/ios_base.pass.cpp new file mode 100644 index 00000000000..37fd2c379c5 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/ios_base.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// basic_istream<charT,traits>& operator>>(ios_base& (*pf)(ios_base&)); + +#include <istream> +#include <cassert> + +int f_called = 0; + +std::ios_base& +f(std::ios_base& is) +{ + ++f_called; + return is; +} + +int main() +{ + { + std::istream is((std::streambuf*)0); + is >> f; + assert(f_called == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/istream.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/istream.pass.cpp new file mode 100644 index 00000000000..bbaccb59f10 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/istream.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>& +// (*pf)(basic_istream<charT,traits>&)); + +#include <istream> +#include <cassert> + +int f_called = 0; + +template <class CharT> +std::basic_istream<CharT>& +f(std::basic_istream<CharT>& is) +{ + ++f_called; + return is; +} + +int main() +{ + { + std::istream is((std::streambuf*)0); + is >> f; + assert(f_called == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char.pass.cpp new file mode 100644 index 00000000000..6f7050ddd08 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template<class traits> +// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char& c); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" "); + std::istream is(&sb); + signed char c = 'z'; + is >> c; + assert( is.eof()); + assert( is.fail()); + assert(c == 'z'); + } + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + signed char c; + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'a'); + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'b'); + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'c'); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char_pointer.pass.cpp new file mode 100644 index 00000000000..8a100f2613a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char_pointer.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template<class traits> +// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char* s); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + signed char s[20]; + is >> s; + assert(!is.eof()); + assert(!is.fail()); + assert(std::string((char*)s) == "abcdefghijk"); + } + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + is.width(4); + signed char s[20]; + is >> s; + assert(!is.eof()); + assert(!is.fail()); + assert(std::string((char*)s) == "abc"); + assert(is.width() == 0); + } + { + testbuf<char> sb(" abcdefghijk"); + std::istream is(&sb); + signed char s[20]; + is >> s; + assert( is.eof()); + assert(!is.fail()); + assert(std::string((char*)s) == "abcdefghijk"); + assert(is.width() == 0); + } + { + testbuf<char> sb(" abcdefghijk"); + std::istream is(&sb); + signed char s[20]; + is.width(1); + is >> s; + assert(!is.eof()); + assert( is.fail()); + assert(std::string((char*)s) == ""); + assert(is.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/streambuf.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/streambuf.pass.cpp new file mode 100644 index 00000000000..65b7a3e8116 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/streambuf.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// basic_istream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb); + +#include <istream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + testbuf(const std::basic_string<CharT>& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb("testing..."); + std::istream is(&sb); + testbuf<char> sb2; + is >> &sb2; + assert(sb2.str() == "testing..."); + assert(is.gcount() == 10); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char.pass.cpp new file mode 100644 index 00000000000..ce1792d9605 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template<class traits> +// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char& c); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" "); + std::istream is(&sb); + unsigned char c = 'z'; + is >> c; + assert( is.eof()); + assert( is.fail()); + assert(c == 'z'); + } + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + unsigned char c; + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'a'); + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'b'); + is >> c; + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'c'); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char_pointer.pass.cpp new file mode 100644 index 00000000000..5df4e8dfebb --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char_pointer.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template<class traits> +// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char* s); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + unsigned char s[20]; + is >> s; + assert(!is.eof()); + assert(!is.fail()); + assert(std::string((char*)s) == "abcdefghijk"); + } + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + is.width(4); + unsigned char s[20]; + is >> s; + assert(!is.eof()); + assert(!is.fail()); + assert(std::string((char*)s) == "abc"); + assert(is.width() == 0); + } + { + testbuf<char> sb(" abcdefghijk"); + std::istream is(&sb); + unsigned char s[20]; + is >> s; + assert( is.eof()); + assert(!is.fail()); + assert(std::string((char*)s) == "abcdefghijk"); + assert(is.width() == 0); + } + { + testbuf<char> sb(" abcdefghijk"); + std::istream is(&sb); + unsigned char s[20]; + is.width(1); + is >> s; + assert(!is.eof()); + assert( is.fail()); + assert(std::string((char*)s) == ""); + assert(is.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/wchar_t_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/wchar_t_pointer.pass.cpp new file mode 100644 index 00000000000..3b5dca6641c --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/wchar_t_pointer.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template<class charT, class traits> +// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT* s); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" abcdefghijk "); + std::istream is(&sb); + char s[20]; + is >> s; + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == "abcdefghijk"); + } + { + testbuf<wchar_t> sb(L" abcdefghijk "); + std::wistream is(&sb); + is.width(4); + wchar_t s[20]; + is >> s; + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L"abc"); + assert(is.width() == 0); + } + { + testbuf<wchar_t> sb(L" abcdefghijk"); + std::wistream is(&sb); + wchar_t s[20]; + is >> s; + assert( is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L"abcdefghijk"); + assert(is.width() == 0); + } + { + testbuf<char> sb(" abcdefghijk"); + std::istream is(&sb); + char s[20]; + is.width(1); + is >> s; + assert(!is.eof()); + assert( is.fail()); + assert(std::string(s) == ""); + assert(is.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp new file mode 100644 index 00000000000..0820470ca47 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits> +// basic_istream<charT,traits>& +// ws(basic_istream<charT,traits>& is); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" 123"); + std::istream is(&sb); + ws(is); + assert(is.good()); + assert(is.peek() == '1'); + } + { + testbuf<wchar_t> sb(L" 123"); + std::wistream is(&sb); + ws(is); + assert(is.good()); + assert(is.peek() == L'1'); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp new file mode 100644 index 00000000000..13a62abe42a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits, class T> +// basic_istream<charT, traits>& +// operator>>(basic_istream<charT, traits>&& is, T& x); + +#include <istream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb(" 123"); + int i = 0; + std::istream(&sb) >> i; + assert(i == 123); + } + { + testbuf<wchar_t> sb(L" 123"); + int i = 0; + std::wistream(&sb) >> i; + assert(i == 123); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp new file mode 100644 index 00000000000..b33813a920f --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp @@ -0,0 +1,100 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// int_type get(); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" "); + std::istream is(&sb); + char c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == ' '); + assert(is.gcount() == 1); + } + { + testbuf<char> sb(" abc"); + std::istream is(&sb); + char c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == ' '); + assert(is.gcount() == 1); + c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'a'); + assert(is.gcount() == 1); + c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'b'); + assert(is.gcount() == 1); + c = is.get(); + assert( is.eof()); + assert(!is.fail()); + assert(c == 'c'); + assert(is.gcount() == 1); + } + { + testbuf<wchar_t> sb(L" abc"); + std::wistream is(&sb); + wchar_t c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == L' '); + assert(is.gcount() == 1); + c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == L'a'); + assert(is.gcount() == 1); + c = is.get(); + assert(!is.eof()); + assert(!is.fail()); + assert(c == L'b'); + assert(is.gcount() == 1); + c = is.get(); + assert( is.eof()); + assert(!is.fail()); + assert(c == L'c'); + assert(is.gcount() == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp new file mode 100644 index 00000000000..b90708c3675 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp @@ -0,0 +1,103 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& get(char_type& c); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" "); + std::istream is(&sb); + char c; + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == ' '); + assert(is.gcount() == 1); + } + { + testbuf<char> sb(" abc"); + std::istream is(&sb); + char c; + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == ' '); + assert(is.gcount() == 1); + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'a'); + assert(is.gcount() == 1); + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == 'b'); + assert(is.gcount() == 1); + is.get(c); + assert( is.eof()); + assert(!is.fail()); + assert(c == 'c'); + assert(is.gcount() == 1); + } + { + testbuf<wchar_t> sb(L" abc"); + std::wistream is(&sb); + wchar_t c; + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == L' '); + assert(is.gcount() == 1); + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == L'a'); + assert(is.gcount() == 1); + is.get(c); + assert(!is.eof()); + assert(!is.fail()); + assert(c == L'b'); + assert(is.gcount() == 1); + is.get(c); + assert( is.eof()); + assert(!is.fail()); + assert(c == L'c'); + assert(is.gcount() == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp new file mode 100644 index 00000000000..a9751afa57d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp @@ -0,0 +1,99 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& get(char_type* s, streamsize n); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" \n \n "); + std::istream is(&sb); + char s[5]; + is.get(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 2); + is.get(s, 5); + assert(!is.eof()); + assert( is.fail()); + assert(std::string(s) == ""); + assert(is.gcount() == 0); + is.clear(); + assert(is.get() == '\n'); + is.get(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 4); + assert(is.get() == '\n'); + is.get(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 1); + } + { + testbuf<wchar_t> sb(L" \n \n "); + std::wistream is(&sb); + wchar_t s[5]; + is.get(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 2); + is.get(s, 5); + assert(!is.eof()); + assert( is.fail()); + assert(std::wstring(s) == L""); + assert(is.gcount() == 0); + is.clear(); + assert(is.get() == L'\n'); + is.get(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 4); + assert(is.get() == L'\n'); + is.get(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp new file mode 100644 index 00000000000..f02c7205d08 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp @@ -0,0 +1,99 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& get(char_type* s, streamsize n, char_type delim); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" * * "); + std::istream is(&sb); + char s[5]; + is.get(s, 5, '*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 2); + is.get(s, 5, '*'); + assert(!is.eof()); + assert( is.fail()); + assert(std::string(s) == ""); + assert(is.gcount() == 0); + is.clear(); + assert(is.get() == '*'); + is.get(s, 5, '*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 4); + assert(is.get() == '*'); + is.get(s, 5, '*'); + assert( is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 1); + } + { + testbuf<wchar_t> sb(L" * * "); + std::wistream is(&sb); + wchar_t s[5]; + is.get(s, 5, L'*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 2); + is.get(s, 5, L'*'); + assert(!is.eof()); + assert( is.fail()); + assert(std::wstring(s) == L""); + assert(is.gcount() == 0); + is.clear(); + assert(is.get() == L'*'); + is.get(s, 5, L'*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 4); + assert(is.get() == L'*'); + is.get(s, 5, L'*'); + assert( is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp new file mode 100644 index 00000000000..88345a5fd3c --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb); + +#include <istream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + testbuf(const std::basic_string<CharT>& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb("testing\n..."); + std::istream is(&sb); + testbuf<char> sb2; + is.get(sb2); + assert(sb2.str() == "testing"); + assert(is.good()); + assert(is.gcount() == 7); + assert(is.get() == '\n'); + is.get(sb2); + assert(sb2.str() == "testing..."); + assert(is.eof()); + assert(!is.fail()); + assert(is.gcount() == 3); + } + { + testbuf<wchar_t> sb(L"testing\n..."); + std::wistream is(&sb); + testbuf<wchar_t> sb2; + is.get(sb2); + assert(sb2.str() == L"testing"); + assert(is.good()); + assert(is.gcount() == 7); + assert(is.get() == L'\n'); + is.get(sb2); + assert(sb2.str() == L"testing..."); + assert(is.eof()); + assert(!is.fail()); + assert(is.gcount() == 3); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp new file mode 100644 index 00000000000..c1fd3330785 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb, +// char_type delim); + +#include <istream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + testbuf(const std::basic_string<CharT>& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb("testing*..."); + std::istream is(&sb); + testbuf<char> sb2; + is.get(sb2, '*'); + assert(sb2.str() == "testing"); + assert(is.good()); + assert(is.gcount() == 7); + assert(is.get() == '*'); + is.get(sb2, '*'); + assert(sb2.str() == "testing..."); + assert(is.eof()); + assert(!is.fail()); + assert(is.gcount() == 3); + } + { + testbuf<wchar_t> sb(L"testing*..."); + std::wistream is(&sb); + testbuf<wchar_t> sb2; + is.get(sb2, L'*'); + assert(sb2.str() == L"testing"); + assert(is.good()); + assert(is.gcount() == 7); + assert(is.get() == L'*'); + is.get(sb2, L'*'); + assert(sb2.str() == L"testing..."); + assert(is.eof()); + assert(!is.fail()); + assert(is.gcount() == 3); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp new file mode 100644 index 00000000000..2d834911eac --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& getline(char_type* s, streamsize n); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" \n \n "); + std::istream is(&sb); + char s[5]; + is.getline(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 3); + is.getline(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 5); + is.getline(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 1); + } + { + testbuf<wchar_t> sb(L" \n \n "); + std::wistream is(&sb); + wchar_t s[5]; + is.getline(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 3); + is.getline(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 5); + is.getline(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp new file mode 100644 index 00000000000..800b31cf609 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& getline(char_type* s, streamsize n, char_type delim); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" * * "); + std::istream is(&sb); + char s[5]; + is.getline(s, 5, '*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 3); + is.getline(s, 5, '*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 5); + is.getline(s, 5, '*'); + assert( is.eof()); + assert(!is.fail()); + assert(std::string(s) == " "); + assert(is.gcount() == 1); + } + { + testbuf<wchar_t> sb(L" * * "); + std::wistream is(&sb); + wchar_t s[5]; + is.getline(s, 5, L'*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 3); + is.getline(s, 5, L'*'); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 5); + is.getline(s, 5, L'*'); + assert( is.eof()); + assert(!is.fail()); + assert(std::wstring(s) == L" "); + assert(is.gcount() == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp new file mode 100644 index 00000000000..6a31b6ae2a9 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& +// ignore(streamsize n = 1, int_type delim = traits::eof()); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" 1\n2345\n6"); + std::istream is(&sb); + is.ignore(); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 1); + is.ignore(5, '\n'); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 2); + is.ignore(15); + assert( is.eof()); + assert(!is.fail()); + assert(is.gcount() == 6); + } + { + testbuf<wchar_t> sb(L" 1\n2345\n6"); + std::wistream is(&sb); + is.ignore(); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 1); + is.ignore(5, '\n'); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 2); + is.ignore(15); + assert( is.eof()); + assert(!is.fail()); + assert(is.gcount() == 6); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp new file mode 100644 index 00000000000..7051a76205f --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// int_type peek(); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" 1\n2345\n6"); + std::istream is(&sb); + assert(is.peek() == ' '); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 0); + is.get(); + assert(is.peek() == '1'); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 0); + } + { + testbuf<wchar_t> sb(L" 1\n2345\n6"); + std::wistream is(&sb); + assert(is.peek() == L' '); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 0); + is.get(); + assert(is.peek() == L'1'); + assert(!is.eof()); + assert(!is.fail()); + assert(is.gcount() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp new file mode 100644 index 00000000000..ec527c6e9d5 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& putback(char_type c); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" 123456789"); + std::istream is(&sb); + is.get(); + is.get(); + is.get(); + is.putback('a'); + assert(is.bad()); + assert(is.gcount() == 0); + is.clear(); + is.putback('2'); + assert(is.good()); + assert(is.gcount() == 0); + is.putback('1'); + assert(is.good()); + assert(is.gcount() == 0); + is.putback(' '); + assert(is.good()); + assert(is.gcount() == 0); + is.putback(' '); + assert(is.bad()); + assert(is.gcount() == 0); + } + { + testbuf<wchar_t> sb(L" 123456789"); + std::wistream is(&sb); + is.get(); + is.get(); + is.get(); + is.putback(L'a'); + assert(is.bad()); + assert(is.gcount() == 0); + is.clear(); + is.putback(L'2'); + assert(is.good()); + assert(is.gcount() == 0); + is.putback(L'1'); + assert(is.good()); + assert(is.gcount() == 0); + is.putback(L' '); + assert(is.good()); + assert(is.gcount() == 0); + is.putback(L' '); + assert(is.bad()); + assert(is.gcount() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp new file mode 100644 index 00000000000..f9487f68e8a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& read(char_type* s, streamsize n); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" 123456789"); + std::istream is(&sb); + char s[5]; + is.read(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s, 5) == " 1234"); + assert(is.gcount() == 5); + is.read(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(std::string(s, 5) == "56789"); + assert(is.gcount() == 5); + is.read(s, 5); + assert( is.eof()); + assert( is.fail()); + assert(is.gcount() == 0); + } + { + testbuf<wchar_t> sb(L" 123456789"); + std::wistream is(&sb); + wchar_t s[5]; + is.read(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s, 5) == L" 1234"); + assert(is.gcount() == 5); + is.read(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(std::wstring(s, 5) == L"56789"); + assert(is.gcount() == 5); + is.read(s, 5); + assert( is.eof()); + assert( is.fail()); + assert(is.gcount() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp new file mode 100644 index 00000000000..3f55befcd88 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// streamsize readsome(char_type* s, streamsize n); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" 1234567890"); + std::istream is(&sb); + char s[5]; + assert(is.readsome(s, 5) == 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s, 5) == " 1234"); + assert(is.gcount() == 5); + is.readsome(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::string(s, 5) == "56789"); + assert(is.gcount() == 5); + is.readsome(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(is.gcount() == 1); + assert(std::string(s, 1) == "0"); + } + { + testbuf<wchar_t> sb(L" 1234567890"); + std::wistream is(&sb); + wchar_t s[5]; + assert(is.readsome(s, 5) == 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s, 5) == L" 1234"); + assert(is.gcount() == 5); + is.readsome(s, 5); + assert(!is.eof()); + assert(!is.fail()); + assert(std::wstring(s, 5) == L"56789"); + assert(is.gcount() == 5); + is.readsome(s, 5); + assert( is.eof()); + assert(!is.fail()); + assert(is.gcount() == 1); + assert(std::wstring(s, 1) == L"0"); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp new file mode 100644 index 00000000000..e99f1abc9f1 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& seekg(pos_type pos); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +protected: + typename base::pos_type seekpos(typename base::pos_type sp, + std::ios_base::openmode which) + { + assert(which == std::ios_base::in); + return sp; + } +}; + +int main() +{ + { + testbuf<char> sb(" 123456789"); + std::istream is(&sb); + is.seekg(5); + assert(is.good()); + is.seekg(-1); + assert(is.fail()); + } + { + testbuf<wchar_t> sb(L" 123456789"); + std::wistream is(&sb); + is.seekg(5); + assert(is.good()); + is.seekg(-1); + assert(is.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp new file mode 100644 index 00000000000..b185d5aec94 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& seekg(off_type off, ios_base::seekdir dir); + +#include <istream> +#include <cassert> + +int seekoff_called = 0; + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +protected: + typename base::pos_type seekoff(typename base::off_type off, + std::ios_base::seekdir way, + std::ios_base::openmode which) + { + assert(which == std::ios_base::in); + ++seekoff_called; + return off; + } +}; + +int main() +{ + { + testbuf<char> sb(" 123456789"); + std::istream is(&sb); + is.seekg(5, std::ios_base::cur); + assert(is.good()); + assert(seekoff_called == 1); + } + { + testbuf<wchar_t> sb(L" 123456789"); + std::wistream is(&sb); + is.seekg(5, std::ios_base::cur); + assert(is.good()); + assert(seekoff_called == 2); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp new file mode 100644 index 00000000000..9e19c0f84c3 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// int sync(); + +#include <istream> +#include <cassert> + +int sync_called = 0; + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} + +protected: + int sync() + { + ++sync_called; + return 5; + } +}; + +int main() +{ + { + testbuf<char> sb(" 123456789"); + std::istream is(&sb); + assert(is.sync() == 0); + assert(sync_called = 1); + } + { + testbuf<wchar_t> sb(L" 123456789"); + std::wistream is(&sb); + assert(is.sync() == 0); + assert(sync_called = 2); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp new file mode 100644 index 00000000000..4424a9539f1 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// pos_type tellg(); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +protected: + typename base::pos_type seekoff(typename base::off_type off, + std::ios_base::seekdir way, + std::ios_base::openmode which) + { + assert(off == 0); + assert(way == std::ios_base::cur); + assert(which == std::ios_base::in); + return 5; + } +}; + +int main() +{ + { + testbuf<char> sb(" 123456789"); + std::istream is(&sb); + assert(is.tellg() == 5); + } + { + testbuf<wchar_t> sb(L" 123456789"); + std::wistream is(&sb); + assert(is.tellg() == 5); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp new file mode 100644 index 00000000000..2d0eb1f7df5 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// basic_istream<charT,traits>& unget(); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +}; + +int main() +{ + { + testbuf<char> sb(" 123456789"); + std::istream is(&sb); + is.get(); + is.get(); + is.get(); + is.unget(); + assert(is.good()); + assert(is.gcount() == 0); + is.unget(); + assert(is.good()); + assert(is.gcount() == 0); + is.unget(); + assert(is.good()); + assert(is.gcount() == 0); + is.unget(); + assert(is.bad()); + assert(is.gcount() == 0); + } + { + testbuf<wchar_t> sb(L" 123456789"); + std::wistream is(&sb); + is.get(); + is.get(); + is.get(); + is.unget(); + assert(is.good()); + assert(is.gcount() == 0); + is.unget(); + assert(is.good()); + assert(is.gcount() == 0); + is.unget(); + assert(is.good()); + assert(is.gcount() == 0); + is.unget(); + assert(is.bad()); + assert(is.gcount() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..2961ecb8904 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// void swap(basic_istream& rhs); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_istream + : public std::basic_istream<CharT> +{ + typedef std::basic_istream<CharT> base; + test_istream(testbuf<CharT>* sb) : base(sb) {} + + void swap(test_istream& s) {base::swap(s);} +}; + +int main() +{ + { + testbuf<char> sb1; + testbuf<char> sb2; + test_istream<char> is1(&sb1); + test_istream<char> is2(&sb2); + is1.swap(is2); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_istream<wchar_t> is1(&sb1); + test_istream<wchar_t> is2(&sb2); + is1.swap(is2); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp new file mode 100644 index 00000000000..41748f3511e --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// basic_istream& operator=(basic_istream&& rhs); + +#include <istream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_istream + : public std::basic_istream<CharT> +{ + typedef std::basic_istream<CharT> base; + test_istream(testbuf<CharT>* sb) : base(sb) {} + + test_istream& operator=(test_istream&& s) + {base::operator=(std::move(s)); return *this;} +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb1; + testbuf<char> sb2; + test_istream<char> is1(&sb1); + test_istream<char> is2(&sb2); + is2 = (std::move(is1)); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_istream<wchar_t> is1(&sb1); + test_istream<wchar_t> is2(&sb2); + is2 = (std::move(is1)); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp new file mode 100644 index 00000000000..f49deed862e --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// basic_istream(basic_istream&& rhs); + +#include <istream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_istream + : public std::basic_istream<CharT> +{ + typedef std::basic_istream<CharT> base; + test_istream(testbuf<CharT>* sb) : base(sb) {} + + test_istream(test_istream&& s) + : base(std::move(s)) {} +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb; + test_istream<char> is1(&sb); + test_istream<char> is(std::move(is1)); + assert(is1.rdbuf() == &sb); + assert(is1.gcount() == 0); + assert(is.gcount() == 0); + assert(is.rdbuf() == 0); + assert(is.tie() == 0); + assert(is.fill() == ' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb; + test_istream<wchar_t> is1(&sb); + test_istream<wchar_t> is(std::move(is1)); + assert(is1.gcount() == 0); + assert(is.gcount() == 0); + assert(is1.rdbuf() == &sb); + assert(is.rdbuf() == 0); + assert(is.tie() == 0); + assert(is.fill() == L' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp new file mode 100644 index 00000000000..0b0dc8dc8e2 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream; + +// explicit basic_istream(basic_streambuf<charT,traits>* sb); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::basic_istream<char> is(&sb); + assert(is.rdbuf() == &sb); + assert(is.tie() == 0); + assert(is.fill() == ' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + assert(is.gcount() == 0); + } + { + testbuf<wchar_t> sb; + std::basic_istream<wchar_t> is(&sb); + assert(is.rdbuf() == &sb); + assert(is.tie() == 0); + assert(is.fill() == L' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + assert(is.gcount() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream/istream::sentry/ctor.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream/istream::sentry/ctor.pass.cpp new file mode 100644 index 00000000000..dcd760fd5ff --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream/istream::sentry/ctor.pass.cpp @@ -0,0 +1,128 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream::sentry; + +// explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false); + +#include <istream> +#include <cassert> + +int sync_called = 0; + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_string<CharT> string_type; + typedef std::basic_streambuf<CharT> base; +private: + string_type str_; +public: + + testbuf() {} + testbuf(const string_type& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()) + str_.size()); + } + + CharT* eback() const {return base::eback();} + CharT* gptr() const {return base::gptr();} + CharT* egptr() const {return base::egptr();} +protected: + + int virtual sync() + { + ++sync_called; + return 1; + } +}; + +int main() +{ + { + std::istream is((testbuf<char>*)0); + std::istream::sentry sen(is, true); + assert(!(bool)sen); + assert(!is.good()); + assert(is.gcount() == 0); + assert(sync_called == 0); + } + { + std::wistream is((testbuf<wchar_t>*)0); + std::wistream::sentry sen(is, true); + assert(!(bool)sen); + assert(!is.good()); + assert(is.gcount() == 0); + assert(sync_called == 0); + } + { + testbuf<char> sb(" 123"); + std::istream is(&sb); + std::istream::sentry sen(is, true); + assert((bool)sen); + assert(is.good()); + assert(is.gcount() == 0); + assert(sync_called == 0); + assert(sb.gptr() == sb.eback()); + } + { + testbuf<wchar_t> sb(L" 123"); + std::wistream is(&sb); + std::wistream::sentry sen(is, true); + assert((bool)sen); + assert(is.good()); + assert(is.gcount() == 0); + assert(sync_called == 0); + assert(sb.gptr() == sb.eback()); + } + { + testbuf<char> sb(" 123"); + std::istream is(&sb); + std::istream::sentry sen(is); + assert((bool)sen); + assert(is.good()); + assert(sync_called == 0); + assert(sb.gptr() == sb.eback() + 3); + } + { + testbuf<wchar_t> sb(L" 123"); + std::wistream is(&sb); + std::wistream::sentry sen(is); + assert((bool)sen); + assert(is.good()); + assert(sync_called == 0); + assert(sb.gptr() == sb.eback() + 3); + } + { + testbuf<char> sb(" "); + std::istream is(&sb); + std::istream::sentry sen(is); + assert(!(bool)sen); + assert(is.fail()); + assert(is.eof()); + assert(sync_called == 0); + assert(sb.gptr() == sb.eback() + 6); + } + { + testbuf<char> sb(" "); + std::istream is(&sb); + std::istream::sentry sen(is, true); + assert((bool)sen); + assert(is.good()); + assert(sync_called == 0); + assert(sb.gptr() == sb.eback()); + } +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/istream/types.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/istream/types.pass.cpp new file mode 100644 index 00000000000..d9d471e2d2d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/istream/types.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_istream +// : virtual public basic_ios<charT,traits> +// { +// public: +// // types (inherited from basic_ios (27.5.4)): +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <istream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_ios<char>, std::basic_istream<char> >::value), ""); + static_assert((std::is_same<std::basic_istream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_istream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_istream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_istream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_istream<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/iostream.format/input.streams/version.pass.cpp b/libcxx/test/input.output/iostream.format/input.streams/version.pass.cpp new file mode 100644 index 00000000000..9ad9c6693b2 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/input.streams/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <istream> + +#include <istream> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostream.format/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..691fddd7ac1 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// void swap(basic_ostream& rhs); + +#include <ostream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_ostream + : public std::basic_ostream<CharT> +{ + typedef std::basic_ostream<CharT> base; + test_ostream(testbuf<CharT>* sb) : base(sb) {} + + void swap(test_ostream& s) {base::swap(s);} +}; + +int main() +{ + { + testbuf<char> sb1; + testbuf<char> sb2; + test_ostream<char> os1(&sb1); + test_ostream<char> os2(&sb2); + os1.swap(os2); + assert(os1.rdbuf() == &sb1); + assert(os1.tie() == 0); + assert(os1.fill() == ' '); + assert(os1.rdstate() == os1.goodbit); + assert(os1.exceptions() == os1.goodbit); + assert(os1.flags() == (os1.skipws | os1.dec)); + assert(os1.precision() == 6); + assert(os1.getloc().name() == "C"); + assert(os2.rdbuf() == &sb2); + assert(os2.tie() == 0); + assert(os2.fill() == ' '); + assert(os2.rdstate() == os2.goodbit); + assert(os2.exceptions() == os2.goodbit); + assert(os2.flags() == (os2.skipws | os2.dec)); + assert(os2.precision() == 6); + assert(os2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_ostream<wchar_t> os1(&sb1); + test_ostream<wchar_t> os2(&sb2); + os1.swap(os2); + assert(os1.rdbuf() == &sb1); + assert(os1.tie() == 0); + assert(os1.fill() == ' '); + assert(os1.rdstate() == os1.goodbit); + assert(os1.exceptions() == os1.goodbit); + assert(os1.flags() == (os1.skipws | os1.dec)); + assert(os1.precision() == 6); + assert(os1.getloc().name() == "C"); + assert(os2.rdbuf() == &sb2); + assert(os2.tie() == 0); + assert(os2.fill() == ' '); + assert(os2.rdstate() == os2.goodbit); + assert(os2.exceptions() == os2.goodbit); + assert(os2.flags() == (os2.skipws | os2.dec)); + assert(os2.precision() == 6); + assert(os2.getloc().name() == "C"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp new file mode 100644 index 00000000000..0b78da46b3e --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream& operator=(basic_ostream&& rhs); + +#include <ostream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_ostream + : public std::basic_ostream<CharT> +{ + typedef std::basic_ostream<CharT> base; + test_ostream(testbuf<CharT>* sb) : base(sb) {} + + test_ostream& operator=(test_ostream&& s) + {base::operator=(std::move(s)); return *this;} +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb1; + testbuf<char> sb2; + test_ostream<char> os1(&sb1); + test_ostream<char> os2(&sb2); + os2 = (std::move(os1)); + assert(os1.rdbuf() == &sb1); + assert(os1.tie() == 0); + assert(os1.fill() == ' '); + assert(os1.rdstate() == os1.goodbit); + assert(os1.exceptions() == os1.goodbit); + assert(os1.flags() == (os1.skipws | os1.dec)); + assert(os1.precision() == 6); + assert(os1.getloc().name() == "C"); + assert(os2.rdbuf() == &sb2); + assert(os2.tie() == 0); + assert(os2.fill() == ' '); + assert(os2.rdstate() == os2.goodbit); + assert(os2.exceptions() == os2.goodbit); + assert(os2.flags() == (os2.skipws | os2.dec)); + assert(os2.precision() == 6); + assert(os2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_ostream<wchar_t> os1(&sb1); + test_ostream<wchar_t> os2(&sb2); + os2 = (std::move(os1)); + assert(os1.rdbuf() == &sb1); + assert(os1.tie() == 0); + assert(os1.fill() == ' '); + assert(os1.rdstate() == os1.goodbit); + assert(os1.exceptions() == os1.goodbit); + assert(os1.flags() == (os1.skipws | os1.dec)); + assert(os1.precision() == 6); + assert(os1.getloc().name() == "C"); + assert(os2.rdbuf() == &sb2); + assert(os2.tie() == 0); + assert(os2.fill() == ' '); + assert(os2.rdstate() == os2.goodbit); + assert(os2.exceptions() == os2.goodbit); + assert(os2.flags() == (os2.skipws | os2.dec)); + assert(os2.precision() == 6); + assert(os2.getloc().name() == "C"); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp new file mode 100644 index 00000000000..d7444a0e3bd --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream(basic_ostream&& rhs); + +#include <ostream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_ostream + : public std::basic_ostream<CharT> +{ + typedef std::basic_ostream<CharT> base; + test_ostream(testbuf<CharT>* sb) : base(sb) {} + + test_ostream(test_ostream&& s) + : base(std::move(s)) {} +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb; + test_ostream<char> os1(&sb); + test_ostream<char> os(std::move(os1)); + assert(os1.rdbuf() == &sb); + assert(os.rdbuf() == 0); + assert(os.tie() == 0); + assert(os.fill() == ' '); + assert(os.rdstate() == os.goodbit); + assert(os.exceptions() == os.goodbit); + assert(os.flags() == (os.skipws | os.dec)); + assert(os.precision() == 6); + assert(os.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb; + test_ostream<wchar_t> os1(&sb); + test_ostream<wchar_t> os(std::move(os1)); + assert(os1.rdbuf() == &sb); + assert(os.rdbuf() == 0); + assert(os.tie() == 0); + assert(os.fill() == L' '); + assert(os.rdstate() == os.goodbit); + assert(os.exceptions() == os.goodbit); + assert(os.flags() == (os.skipws | os.dec)); + assert(os.precision() == 6); + assert(os.getloc().name() == "C"); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp new file mode 100644 index 00000000000..74a31af19d7 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// explicit basic_ostream(basic_streambuf<charT,traits>* sb); + +#include <ostream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::basic_ostream<char> os(&sb); + assert(os.rdbuf() == &sb); + assert(os.tie() == 0); + assert(os.fill() == ' '); + assert(os.rdstate() == os.goodbit); + assert(os.exceptions() == os.goodbit); + assert(os.flags() == (os.skipws | os.dec)); + assert(os.precision() == 6); + assert(os.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb; + std::basic_ostream<wchar_t> os(&sb); + assert(os.rdbuf() == &sb); + assert(os.tie() == 0); + assert(os.fill() == L' '); + assert(os.rdstate() == os.goodbit); + assert(os.exceptions() == os.goodbit); + assert(os.flags() == (os.skipws | os.dec)); + assert(os.precision() == 6); + assert(os.getloc().name() == "C"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp new file mode 100644 index 00000000000..e7e750405fe --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(bool val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + bool b = false; + os << b; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + bool b = false; + os << b; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + bool b = true; + os << b; + assert(sb.str() == "1"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + boolalpha(os); + bool b = true; + os << b; + assert(sb.str() == "true"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + boolalpha(os); + bool b = false; + os << b; + assert(sb.str() == "false"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp new file mode 100644 index 00000000000..c7882bcabcb --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(double val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + double n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + double n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + double n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + double n = -10.5; + os << n; + assert(sb.str() == "-10.5"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp new file mode 100644 index 00000000000..1b05f86e114 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(float val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + float n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + float n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + float n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + float n = -10.5; + os << n; + assert(sb.str() == "-10.5"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp new file mode 100644 index 00000000000..3464977d90f --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(int val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + int n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + int n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + int n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + int n = -10; + os << n; + assert(sb.str() == "fffffff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp new file mode 100644 index 00000000000..be4f643e59a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(long val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + long n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + long n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + long n = 0xfffffff6; + os << n; + assert(sb.str() == "fffffff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp new file mode 100644 index 00000000000..6d882900f3a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(long double val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + long double n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + long double n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + long double n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + long double n = -10.5; + os << n; + assert(sb.str() == "-10.5"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp new file mode 100644 index 00000000000..47b6e4bf0e8 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(long long val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + long long n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + long long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + long long n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + long long n = -10; + os << n; + assert(sb.str() == "fffffffffffffff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp new file mode 100644 index 00000000000..9282fbb85d2 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(const void* val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + const void* n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + const void* n = 0; + os << n; + assert(sb.str() == "0x0"); + assert(os.good()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + const void* n = &sb; + os << n; + assert(os.good()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp new file mode 100644 index 00000000000..36ed10d9175 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(short val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + short n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + short n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + short n = -10; + os << n; + assert(sb.str() == "-10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + short n = -10; + os << n; + assert(sb.str() == "fff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp new file mode 100644 index 00000000000..59078716dc8 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(unsigned int val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + unsigned int n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned int n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned int n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + unsigned int n = 0xFFF6; + os << n; + assert(sb.str() == "fff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp new file mode 100644 index 00000000000..9ee9f583f29 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(unsigned long val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + unsigned long n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned long n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + unsigned long n = 0xfffffff6; + os << n; + assert(sb.str() == "fffffff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp new file mode 100644 index 00000000000..41ea650c8cd --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(unsigned long long val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + unsigned long long n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned long long n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned long long n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + unsigned long long n = -10; + os << n; + assert(sb.str() == "fffffffffffffff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp new file mode 100644 index 00000000000..9f96e53ee77 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// operator<<(unsigned short val); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + unsigned short n = 0; + os << n; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned short n = 0; + os << n; + assert(sb.str() == "0"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned short n = 10; + os << n; + assert(sb.str() == "10"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + hex(os); + unsigned short n = 0xFFF6; + os << n; + assert(sb.str() == "fff6"); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp new file mode 100644 index 00000000000..f6aa56f17dc --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class charT, class traits> +// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, charT c); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::wostream os((std::wstreambuf*)0); + wchar_t c = L'a'; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + wchar_t c = L'a'; + os << c; + assert(sb.str() == L"a"); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + wchar_t c = L'a'; + os << c; + assert(sb.str() == L" a"); + assert(os.width() == 0); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + left(os); + wchar_t c = L'a'; + os << c; + assert(sb.str() == L"a "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp new file mode 100644 index 00000000000..935ea397829 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class charT, class traits> +// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const charT* s); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::wostream os((std::wstreambuf*)0); + const wchar_t* c = L"123"; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + const wchar_t* c = L"123"; + os << c; + assert(sb.str() == L"123"); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + const wchar_t* c = L"123"; + os << c; + assert(sb.str() == L" 123"); + assert(os.width() == 0); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + left(os); + const wchar_t* c = L"123"; + os << c; + assert(sb.str() == L"123 "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp new file mode 100644 index 00000000000..26acb157151 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class char, class traits> +// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, char c); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + char c = 'a'; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + char c = 'a'; + os << c; + assert(sb.str() == "a"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + char c = 'a'; + os << c; + assert(sb.str() == " a"); + assert(os.width() == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + left(os); + char c = 'a'; + os << c; + assert(sb.str() == "a "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp new file mode 100644 index 00000000000..60a201cfcc5 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class traits> +// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const char* s); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + const char* c = "123"; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + const char* c = "123"; + os << c; + assert(sb.str() == "123"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + const char* c = "123"; + os << c; + assert(sb.str() == " 123"); + assert(os.width() == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + left(os); + const char* c = "123"; + os << c; + assert(sb.str() == "123 "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp new file mode 100644 index 00000000000..5c4974ec287 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class charT, class traits> +// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, char c); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::wostream os((std::wstreambuf*)0); + char c = 'a'; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + char c = 'a'; + os << c; + assert(sb.str() == L"a"); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + char c = 'a'; + os << c; + assert(sb.str() == L" a"); + assert(os.width() == 0); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + left(os); + char c = 'a'; + os << c; + assert(sb.str() == L"a "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp new file mode 100644 index 00000000000..246ff933ae3 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class charT, class traits> +// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const char* s); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::wostream os((std::wstreambuf*)0); + const char* c = "123"; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + const char* c = "123"; + os << c; + assert(sb.str() == L"123"); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + const char* c = "123"; + os << c; + assert(sb.str() == L" 123"); + assert(os.width() == 0); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os.width(5); + left(os); + const char* c = "123"; + os << c; + assert(sb.str() == L"123 "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp new file mode 100644 index 00000000000..d777aa9f5e2 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class char, class traits> +// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, signed char c); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + signed char c = 'a'; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + signed char c = 'a'; + os << c; + assert(sb.str() == "a"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + signed char c = 'a'; + os << c; + assert(sb.str() == " a"); + assert(os.width() == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + left(os); + signed char c = 'a'; + os << c; + assert(sb.str() == "a "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp new file mode 100644 index 00000000000..f432f05ff65 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class traits> +// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const signed char* s); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + const signed char* c = (const signed char*)"123"; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + const signed char* c = (const signed char*)"123"; + os << c; + assert(sb.str() == "123"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + const signed char* c = (const signed char*)"123"; + os << c; + assert(sb.str() == " 123"); + assert(os.width() == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + left(os); + const signed char* c = (const signed char*)"123"; + os << c; + assert(sb.str() == "123 "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp new file mode 100644 index 00000000000..be56928d7b2 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class char, class traits> +// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, unsigned char c); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + unsigned char c = 'a'; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + unsigned char c = 'a'; + os << c; + assert(sb.str() == "a"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + unsigned char c = 'a'; + os << c; + assert(sb.str() == " a"); + assert(os.width() == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + left(os); + unsigned char c = 'a'; + os << c; + assert(sb.str() == "a "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp new file mode 100644 index 00000000000..e8c5337c94e --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template<class traits> +// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const unsigned char* s); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + const unsigned char* c = (const unsigned char*)"123"; + os << c; + assert(os.bad()); + assert(os.fail()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + const unsigned char* c = (const unsigned char*)"123"; + os << c; + assert(sb.str() == "123"); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + const unsigned char* c = (const unsigned char*)"123"; + os << c; + assert(sb.str() == " 123"); + assert(os.width() == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os.width(5); + left(os); + const unsigned char* c = (const unsigned char*)"123"; + os << c; + assert(sb.str() == "123 "); + assert(os.width() == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp new file mode 100644 index 00000000000..0d91b52de48 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>& +// (*pf)(basic_ios<charT,traits>&)); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +template <class CharT> +std::basic_ios<CharT>& +f(std::basic_ios<CharT>& os) +{ + std::uppercase(os); + return os; +} + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + assert(!(os.flags() & std::ios_base::uppercase)); + os << f; + assert( (os.flags() & std::ios_base::uppercase)); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp new file mode 100644 index 00000000000..9bdc2a78930 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&)); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + assert(!(os.flags() & std::ios_base::uppercase)); + os << std::uppercase; + assert( (os.flags() & std::ios_base::uppercase)); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp new file mode 100644 index 00000000000..c86bc0cbbbb --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream<charT,traits>& operator<< +// (basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&)) + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +template <class CharT> +std::basic_ostream<CharT>& +f(std::basic_ostream<CharT>& os) +{ + os << "testing..."; + return os; +} + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + os << f; + assert(sb.str() == "testing..."); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp new file mode 100644 index 00000000000..b9acd192626 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + testbuf(const std::basic_string<CharT>& str) + : str_(str) + { + base::setg(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + testbuf<char> sb2("testing..."); + assert(sb.str() == ""); + os << &sb2; + assert(sb.str() == "testing..."); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp new file mode 100644 index 00000000000..e532339eb45 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template <class charT, class traits> +// basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os); + +#include <ostream> +#include <cassert> + +int sync_called = 0; + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } + + virtual int + sync() + { + ++sync_called; + return 0; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + endl(os); + assert(sb.str() == "\n"); + assert(sync_called == 1); + assert(os.good()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + endl(os); + assert(sb.str() == L"\n"); + assert(sync_called == 2); + assert(os.good()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp new file mode 100644 index 00000000000..98308a0860a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template <class charT, class traits> +// basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + ends(os); + assert(sb.str().size() == 1); + assert(sb.str().back() == 0); + assert(os.good()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + ends(os); + assert(sb.str().size() == 1); + assert(sb.str().back() == 0); + assert(os.good()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp new file mode 100644 index 00000000000..2a14f8ebf77 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template <class charT, class traits> +// basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os); + +#include <ostream> +#include <cassert> + +int sync_called = 0; + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ +public: + testbuf() + { + } + +protected: + + virtual int + sync() + { + ++sync_called; + return 0; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + flush(os); + assert(sync_called == 1); + assert(os.good()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + flush(os); + assert(sync_called == 2); + assert(os.good()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp new file mode 100644 index 00000000000..85c589c86a4 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// template <class charT, class traits, class T> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>&& os, const T& x); + +#include <ostream> +#include <cassert> + +#ifdef _LIBCPP_MOVE + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +#endif + +int main() +{ +#ifdef _LIBCPP_MOVE + { + testbuf<char> sb; + std::ostream(&sb) << "testing..."; + assert(sb.str() == "testing..."); + } + { + testbuf<wchar_t> sb; + std::wostream(&sb) << L"123"; + assert(sb.str() == L"123"); + } +#endif +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp new file mode 100644 index 00000000000..e45db835138 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream<charT,traits>& seekp(pos_type pos); + +#include <ostream> +#include <cassert> + +int seekpos_called = 0; + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + testbuf() {} + +protected: + + typename base::pos_type + seekpos(typename base::pos_type sp, std::ios_base::openmode which) + { + ++seekpos_called; + assert(which == std::ios_base::out); + return sp; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + assert(&os.seekp(5) == &os); + assert(seekpos_called == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + assert(&os.seekp(10) == &os); + assert(seekpos_called == 1); + assert(os.good()); + assert(&os.seekp(-1) == &os); + assert(seekpos_called == 2); + assert(os.fail()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp new file mode 100644 index 00000000000..f3e4d016af6 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir); + +#include <ostream> +#include <cassert> + +int seekoff_called = 0; + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + testbuf() {} + +protected: + + typename base::pos_type + seekoff(typename base::off_type off, std::ios_base::seekdir way, + std::ios_base::openmode which) + { + ++seekoff_called; + assert(way == std::ios_base::beg); + assert(which == std::ios_base::out); + return off; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + assert(&os.seekp(5, std::ios_base::beg) == &os); + assert(seekoff_called == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + assert(&os.seekp(10, std::ios_base::beg) == &os); + assert(seekoff_called == 1); + assert(os.good()); + assert(&os.seekp(-1, std::ios_base::beg) == &os); + assert(seekoff_called == 2); + assert(os.good()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp new file mode 100644 index 00000000000..bd3561100cc --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// pos_type tellp(); + +#include <ostream> +#include <cassert> + +int seekoff_called = 0; + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + testbuf() {} + +protected: + + typename base::pos_type + seekoff(typename base::off_type off, std::ios_base::seekdir way, std::ios_base::openmode which) + { + assert(off == 0); + assert(way == std::ios_base::cur); + assert(which == std::ios_base::out); + ++seekoff_called; + return 10; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + assert(os.tellp() == -1); + } + { + testbuf<char> sb; + std::ostream os(&sb); + assert(os.tellp() == 10); + assert(seekoff_called == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp new file mode 100644 index 00000000000..dcbdc4f0c29 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream& flush(); + +#include <ostream> +#include <cassert> + +int sync_called = 0; + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ +public: + testbuf() + { + } + +protected: + + virtual int + sync() + { + if (sync_called++ == 1) + return -1; + return 0; + } +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + os.flush(); + assert(os.good()); + assert(sync_called == 1); + os.flush(); + assert(os.bad()); + assert(sync_called == 2); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp new file mode 100644 index 00000000000..fc31d1828c9 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream<charT,traits>& put(char_type c); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::wostream os((std::wstreambuf*)0); + wchar_t c = L'a'; + os.put(c); + assert(os.bad()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + wchar_t c = L'a'; + os.put(c); + assert(sb.str() == L"a"); + assert(os.good()); + } + { + testbuf<char> sb; + std::ostream os(&sb); + char c = 'a'; + os.put(c); + assert(sb.str() == "a"); + assert(os.good()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp new file mode 100644 index 00000000000..9c399ad6e0d --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream; + +// basic_ostream& write(const char_type* s, streamsize n); + +#include <ostream> +#include <cassert> + +template <class CharT> +class testbuf + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + std::basic_string<CharT> str_; +public: + testbuf() + { + } + + std::basic_string<CharT> str() const + {return std::basic_string<CharT>(base::pbase(), base::pptr());} + +protected: + + virtual typename base::int_type + overflow(typename base::int_type __c = base::traits_type::eof()) + { + if (__c != base::traits_type::eof()) + { + int n = str_.size(); + str_.push_back(__c); + str_.resize(str_.capacity()); + base::setp(const_cast<CharT*>(str_.data()), + const_cast<CharT*>(str_.data() + str_.size())); + base::pbump(n+1); + } + return __c; + } +}; + +int main() +{ + { + std::wostream os((std::wstreambuf*)0); + const wchar_t s[] = L"123456790"; + os.write(s, sizeof(s)/sizeof(s[0])-1); + assert(os.bad()); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + const wchar_t s[] = L"123456790"; + os.write(s, sizeof(s)/sizeof(s[0])-1); + assert(os.good()); + assert(sb.str() == s); + } + { + testbuf<char> sb; + std::ostream os(&sb); + const char s[] = "123456790"; + os.write(s, sizeof(s)/sizeof(s[0])-1); + assert(sb.str() == s); + assert(os.good()); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp new file mode 100644 index 00000000000..db05eb633ed --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream +// : virtual public basic_ios<charT,traits> +// { +// public: +// // types (inherited from basic_ios (27.5.4)): +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <ostream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_ios<char>, std::basic_ostream<char> >::value), ""); + static_assert((std::is_same<std::basic_ostream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_ostream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_ostream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_ostream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_ostream<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream::sentry/construct.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream::sentry/construct.pass.cpp new file mode 100644 index 00000000000..a949f620d07 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream::sentry/construct.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream::sentry; + +// explicit sentry(basic_ostream<charT,traits>& os); + +#include <ostream> +#include <cassert> + +int sync_called = 0; + +template <class CharT> +struct testbuf1 + : public std::basic_streambuf<CharT> +{ + testbuf1() {} + +protected: + + int virtual sync() + { + ++sync_called; + return 1; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + std::ostream::sentry s(os); + assert(!bool(s)); + } + { + testbuf1<char> sb; + std::ostream os(&sb); + std::ostream::sentry s(os); + assert(bool(s)); + } + { + testbuf1<char> sb; + std::ostream os(&sb); + testbuf1<char> sb2; + std::ostream os2(&sb2); + os.tie(&os2); + assert(sync_called == 0); + std::ostream::sentry s(os); + assert(bool(s)); + assert(sync_called == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/ostream::sentry/destruct.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/ostream::sentry/destruct.pass.cpp new file mode 100644 index 00000000000..a5f9bb36003 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/ostream::sentry/destruct.pass.cpp @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ostream::sentry; + +// ~sentry(); + +#include <ostream> +#include <cassert> + +int sync_called = 0; + +template <class CharT> +struct testbuf1 + : public std::basic_streambuf<CharT> +{ + testbuf1() {} + +protected: + + int virtual sync() + { + ++sync_called; + return 1; + } +}; + +int main() +{ + { + std::ostream os((std::streambuf*)0); + std::ostream::sentry s(os); + assert(!bool(s)); + } + assert(sync_called == 0); + { + testbuf1<char> sb; + std::ostream os(&sb); + std::ostream::sentry s(os); + assert(bool(s)); + } + assert(sync_called == 0); + { + testbuf1<char> sb; + std::ostream os(&sb); + std::ostream::sentry s(os); + assert(bool(s)); + unitbuf(os); + } + assert(sync_called == 1); + { + testbuf1<char> sb; + std::ostream os(&sb); + try + { + std::ostream::sentry s(os); + assert(bool(s)); + unitbuf(os); + throw 1; + } + catch (...) + { + } + assert(sync_called == 1); + } +} diff --git a/libcxx/test/input.output/iostream.format/output.streams/version.pass.cpp b/libcxx/test/input.output/iostream.format/output.streams/version.pass.cpp new file mode 100644 index 00000000000..c43ff79ae45 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/output.streams/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ostream> + +#include <ostream> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp b/libcxx/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp new file mode 100644 index 00000000000..7a83cd8358a --- /dev/null +++ b/libcxx/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// T1 resetiosflags(ios_base::fmtflags mask); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::istream is(&sb); + assert(is.flags() & std::ios_base::skipws); + is >> std::resetiosflags(std::ios_base::skipws); + assert(!(is.flags() & std::ios_base::skipws)); + } + { + testbuf<char> sb; + std::ostream os(&sb); + assert(os.flags() & std::ios_base::skipws); + os << std::resetiosflags(std::ios_base::skipws); + assert(!(os.flags() & std::ios_base::skipws)); + } + { + testbuf<wchar_t> sb; + std::wistream is(&sb); + assert(is.flags() & std::ios_base::skipws); + is >> std::resetiosflags(std::ios_base::skipws); + assert(!(is.flags() & std::ios_base::skipws)); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + assert(os.flags() & std::ios_base::skipws); + os << std::resetiosflags(std::ios_base::skipws); + assert(!(os.flags() & std::ios_base::skipws)); + } +} diff --git a/libcxx/test/input.output/iostream.format/std.manip/setbase.pass.cpp b/libcxx/test/input.output/iostream.format/std.manip/setbase.pass.cpp new file mode 100644 index 00000000000..995bfdd127b --- /dev/null +++ b/libcxx/test/input.output/iostream.format/std.manip/setbase.pass.cpp @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// T3 setbase(int base); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::istream is(&sb); + is >> std::setbase(8); + assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct); + is >> std::setbase(10); + assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec); + is >> std::setbase(16); + assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex); + is >> std::setbase(15); + assert((is.flags() & std::ios_base::basefield) == 0); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os << std::setbase(8); + assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct); + os << std::setbase(10); + assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec); + os << std::setbase(16); + assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex); + os << std::setbase(15); + assert((os.flags() & std::ios_base::basefield) == 0); + } + { + testbuf<wchar_t> sb; + std::wistream is(&sb); + is >> std::setbase(8); + assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct); + is >> std::setbase(10); + assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec); + is >> std::setbase(16); + assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex); + is >> std::setbase(15); + assert((is.flags() & std::ios_base::basefield) == 0); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os << std::setbase(8); + assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct); + os << std::setbase(10); + assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec); + os << std::setbase(16); + assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex); + os << std::setbase(15); + assert((os.flags() & std::ios_base::basefield) == 0); + } +} diff --git a/libcxx/test/input.output/iostream.format/std.manip/setfill.pass.cpp b/libcxx/test/input.output/iostream.format/std.manip/setfill.pass.cpp new file mode 100644 index 00000000000..654bd8b797f --- /dev/null +++ b/libcxx/test/input.output/iostream.format/std.manip/setfill.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// template<charT> T4 setfill(charT c); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::ostream os(&sb); + os << std::setfill('*'); + assert(os.fill() == '*'); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os << std::setfill(L'*'); + assert(os.fill() == L'*'); + } +} diff --git a/libcxx/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp b/libcxx/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp new file mode 100644 index 00000000000..027e187ec53 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// T2 setiosflags (ios_base::fmtflags mask); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::istream is(&sb); + assert(!(is.flags() & std::ios_base::oct)); + is >> std::setiosflags(std::ios_base::oct); + assert(is.flags() & std::ios_base::oct); + } + { + testbuf<char> sb; + std::ostream os(&sb); + assert(!(os.flags() & std::ios_base::oct)); + os << std::setiosflags(std::ios_base::oct); + assert(os.flags() & std::ios_base::oct); + } + { + testbuf<wchar_t> sb; + std::wistream is(&sb); + assert(!(is.flags() & std::ios_base::oct)); + is >> std::setiosflags(std::ios_base::oct); + assert(is.flags() & std::ios_base::oct); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + assert(!(os.flags() & std::ios_base::oct)); + os << std::setiosflags(std::ios_base::oct); + assert(os.flags() & std::ios_base::oct); + } +} diff --git a/libcxx/test/input.output/iostream.format/std.manip/setprecision.pass.cpp b/libcxx/test/input.output/iostream.format/std.manip/setprecision.pass.cpp new file mode 100644 index 00000000000..626c1620844 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/std.manip/setprecision.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// T5 setprecision(int n); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::istream is(&sb); + is >> std::setprecision(10); + assert(is.precision() == 10); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os << std::setprecision(10); + assert(os.precision() == 10); + } + { + testbuf<wchar_t> sb; + std::wistream is(&sb); + is >> std::setprecision(10); + assert(is.precision() == 10); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os << std::setprecision(10); + assert(os.precision() == 10); + } +} diff --git a/libcxx/test/input.output/iostream.format/std.manip/setw.pass.cpp b/libcxx/test/input.output/iostream.format/std.manip/setw.pass.cpp new file mode 100644 index 00000000000..85df1a4937b --- /dev/null +++ b/libcxx/test/input.output/iostream.format/std.manip/setw.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +// T6 setw(int n); + +#include <iomanip> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::istream is(&sb); + is >> std::setw(10); + assert(is.width() == 10); + } + { + testbuf<char> sb; + std::ostream os(&sb); + os << std::setw(10); + assert(os.width() == 10); + } + { + testbuf<wchar_t> sb; + std::wistream is(&sb); + is >> std::setw(10); + assert(is.width() == 10); + } + { + testbuf<wchar_t> sb; + std::wostream os(&sb); + os << std::setw(10); + assert(os.width() == 10); + } +} diff --git a/libcxx/test/input.output/iostream.format/std.manip/version.pass.cpp b/libcxx/test/input.output/iostream.format/std.manip/version.pass.cpp new file mode 100644 index 00000000000..233c6e6a8e3 --- /dev/null +++ b/libcxx/test/input.output/iostream.format/std.manip/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iomanip> + +#include <iomanip> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.forward/iosfwd.pass.cpp b/libcxx/test/input.output/iostream.forward/iosfwd.pass.cpp new file mode 100644 index 00000000000..ede5ca93b43 --- /dev/null +++ b/libcxx/test/input.output/iostream.forward/iosfwd.pass.cpp @@ -0,0 +1,142 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iosfwd> + +#include <iosfwd> +#include <cwchar> // for mbstate_t + +int main() +{ + { + std::char_traits<char>* t1 = 0; + std::char_traits<wchar_t>* t2 = 0; + std::char_traits<unsigned short>* t3 = 0; + } + { + std::basic_ios<char>* t1 = 0; + std::basic_ios<wchar_t>* t2 = 0; + std::basic_ios<unsigned short>* t3 = 0; + } + { + std::basic_streambuf<char>* t1 = 0; + std::basic_streambuf<wchar_t>* t2 = 0; + std::basic_streambuf<unsigned short>* t3 = 0; + } + { + std::basic_istream<char>* t1 = 0; + std::basic_istream<wchar_t>* t2 = 0; + std::basic_istream<unsigned short>* t3 = 0; + } + { + std::basic_ostream<char>* t1 = 0; + std::basic_ostream<wchar_t>* t2 = 0; + std::basic_ostream<unsigned short>* t3 = 0; + } + { + std::basic_iostream<char>* t1 = 0; + std::basic_iostream<wchar_t>* t2 = 0; + std::basic_iostream<unsigned short>* t3 = 0; + } + { + std::basic_stringbuf<char>* t1 = 0; + std::basic_stringbuf<wchar_t>* t2 = 0; + std::basic_stringbuf<unsigned short>* t3 = 0; + } + { + std::basic_istringstream<char>* t1 = 0; + std::basic_istringstream<wchar_t>* t2 = 0; + std::basic_istringstream<unsigned short>* t3 = 0; + } + { + std::basic_ostringstream<char>* t1 = 0; + std::basic_ostringstream<wchar_t>* t2 = 0; + std::basic_ostringstream<unsigned short>* t3 = 0; + } + { + std::basic_stringstream<char>* t1 = 0; + std::basic_stringstream<wchar_t>* t2 = 0; + std::basic_stringstream<unsigned short>* t3 = 0; + } + { + std::basic_filebuf<char>* t1 = 0; + std::basic_filebuf<wchar_t>* t2 = 0; + std::basic_filebuf<unsigned short>* t3 = 0; + } + { + std::basic_ifstream<char>* t1 = 0; + std::basic_ifstream<wchar_t>* t2 = 0; + std::basic_ifstream<unsigned short>* t3 = 0; + } + { + std::basic_ofstream<char>* t1 = 0; + std::basic_ofstream<wchar_t>* t2 = 0; + std::basic_ofstream<unsigned short>* t3 = 0; + } + { + std::basic_fstream<char>* t1 = 0; + std::basic_fstream<wchar_t>* t2 = 0; + std::basic_fstream<unsigned short>* t3 = 0; + } + { + std::istreambuf_iterator<char>* t1 = 0; + std::istreambuf_iterator<wchar_t>* t2 = 0; + std::istreambuf_iterator<unsigned short>* t3 = 0; + } + { + std::ostreambuf_iterator<char>* t1 = 0; + std::ostreambuf_iterator<wchar_t>* t2 = 0; + std::ostreambuf_iterator<unsigned short>* t3 = 0; + } + { + std::ios* t1 = 0; + std::wios* t2 = 0; + } + { + std::streambuf* t1 = 0; + std::istream* t2 = 0; + std::ostream* t3 = 0; + std::iostream* t4 = 0; + } + { + std::stringbuf* t1 = 0; + std::istringstream* t2 = 0; + std::ostringstream* t3 = 0; + std::stringstream* t4 = 0; + } + { + std::filebuf* t1 = 0; + std::ifstream* t2 = 0; + std::ofstream* t3 = 0; + std::fstream* t4 = 0; + } + { + std::wstreambuf* t1 = 0; + std::wistream* t2 = 0; + std::wostream* t3 = 0; + std::wiostream* t4 = 0; + } + { + std::wstringbuf* t1 = 0; + std::wistringstream* t2 = 0; + std::wostringstream* t3 = 0; + std::wstringstream* t4 = 0; + } + { + std::wfilebuf* t1 = 0; + std::wifstream* t2 = 0; + std::wofstream* t3 = 0; + std::wfstream* t4 = 0; + } + { + std::fpos<std::mbstate_t>* t1 = 0; + std::streampos* t2 = 0; + std::wstreampos* t3 = 0; + } +} diff --git a/libcxx/test/input.output/iostream.forward/version.pass.cpp b/libcxx/test/input.output/iostream.forward/version.pass.cpp new file mode 100644 index 00000000000..ece6eb50fd9 --- /dev/null +++ b/libcxx/test/input.output/iostream.forward/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iosfwd> + +#include <iosfwd> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp new file mode 100644 index 00000000000..65925e27a94 --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream cerr; + +#include <iostream> +#include <cassert> + +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 +} diff --git a/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp new file mode 100644 index 00000000000..5a5806c5cbe --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream cin; + +#include <iostream> +#include <cassert> + +int main() +{ +#if 0 + std::cout << "Hello World!\n"; + int i; + std::cout << "Enter a number: "; + std::cin >> i; + std::cout << "The number is : " << i << '\n'; +#else + assert(std::cin.tie() == &std::cout); +#endif +} diff --git a/libcxx/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp new file mode 100644 index 00000000000..7369323a95c --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream clog; + +#include <iostream> + +int main() +{ +#if 0 + std::clog << "Hello World!\n"; +#else + (void)std::clog; +#endif +} diff --git a/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp new file mode 100644 index 00000000000..b93be297edd --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream cout; + +#include <iostream> + +int main() +{ +#if 0 + std::cout << "Hello World!\n"; + int i; + std::cout << "Enter a number: "; + std::cin >> i; + std::cout << "The number is : " << i << '\n'; +#else + (void)std::cout; +#endif +} diff --git a/libcxx/test/input.output/iostream.objects/version.pass.cpp b/libcxx/test/input.output/iostream.objects/version.pass.cpp new file mode 100644 index 00000000000..32138f8fd8c --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +#include <iostream> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp new file mode 100644 index 00000000000..ff5009cb196 --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream wcerr; + +#include <iostream> +#include <cassert> + +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 +} diff --git a/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp new file mode 100644 index 00000000000..fce5bc91bc4 --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream wcin; + +#include <iostream> +#include <cassert> + +int main() +{ +#if 0 + std::wcout << L"Hello World!\n"; + int i; + std::wcout << L"Enter a number: "; + std::wcin >> i; + std::wcout << L"The number is : " << i << L'\n'; +#else + assert(std::wcin.tie() == &std::wcout); +#endif +} diff --git a/libcxx/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp new file mode 100644 index 00000000000..b1405f5d09a --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream wclog; + +#include <iostream> + +int main() +{ +#if 0 + std::wclog << L"Hello World!\n"; +#else + (void)std::wclog; +#endif +} diff --git a/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp new file mode 100644 index 00000000000..aa6d3842958 --- /dev/null +++ b/libcxx/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <iostream> + +// istream wcout; + +#include <iostream> + +int main() +{ +#if 0 + std::wcout << L"Hello World!\n"; +#else + (void)std::wcout; +#endif +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp new file mode 100644 index 00000000000..ccb1af43a8a --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// void state(stateT s); + +#include <ios> +#include <cassert> + +int main() +{ + std::fpos<int> f; + f.state(3); + assert(f.state() == 3); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp new file mode 100644 index 00000000000..c720b087704 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// Addition + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(5); + std::streamoff o(6); + P q = p + o; + assert(q == P(11)); + p += o; + assert(p == q); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp new file mode 100644 index 00000000000..8a23ff2b187 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// fpos(int) + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(5); + assert(p == P(5)); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp new file mode 100644 index 00000000000..baefb93cc9c --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// Subraction with fpos + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(11); + P q(6); + std::streamoff o = p - q; + assert(o == 5); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp new file mode 100644 index 00000000000..c45576993cd --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// == and != + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(5); + P q(6); + assert(p == p); + assert(p != q); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp new file mode 100644 index 00000000000..9ae80734e9a --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// converts to and from streamoff + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(std::streamoff(7)); + std::streamoff offset(p); + assert(offset == 7); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp new file mode 100644 index 00000000000..f662b72c17f --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// streamsize and streamoff interconvert + +#include <ios> +#include <cassert> + +int main() +{ + std::streamoff o(5); + std::streamsize sz(o); + assert(sz == 5); + std::streamoff o2(sz); + assert(o == o2); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp new file mode 100644 index 00000000000..7bc9ea8559e --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// Subraction with offset + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(11); + std::streamoff o(6); + P q = p - o; + assert(q == P(5)); + p -= o; + assert(p == q); +} diff --git a/libcxx/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp new file mode 100644 index 00000000000..685f4a674fd --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags flags() const; + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.flags() == (test::skipws | test::dec)); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp new file mode 100644 index 00000000000..d1e4915b3fe --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags flags(fmtflags fmtfl); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + test::fmtflags f = t.flags(test::hex | test::right); + assert(f == (test::skipws | test::dec)); + assert(t.flags() == (test::hex | test::right)); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp new file mode 100644 index 00000000000..13c421530f6 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize precision() const; + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.precision() == 6); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp new file mode 100644 index 00000000000..a68ca121e96 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize precision(streamsize prec); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.precision() == 6); + std::streamsize p = t.precision(10); + assert(p == 6); + assert(t.precision() == 10); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp new file mode 100644 index 00000000000..5584c8b85e1 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags setf(fmtflags fmtfl) + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + test::fmtflags f = t.setf(test::hex | test::right); + assert(f == (test::skipws | test::dec)); + assert(t.flags() == (test::skipws | test::dec | test::hex | test::right)); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp new file mode 100644 index 00000000000..2ec8737f488 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags setf(fmtflags fmtfl, fmtflags mask); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + test::fmtflags f = t.setf(test::hex | test::right, test::dec | test::right); + assert(f == (test::skipws | test::dec)); + assert(t.flags() == (test::skipws | test::right)); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp new file mode 100644 index 00000000000..a45d557dce6 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// void unsetf(fmtflags mask); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + t.unsetf(test::dec | test::right); + assert(t.flags() == test::skipws); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp new file mode 100644 index 00000000000..b5785306426 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize width() const; + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.width() == 0); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp new file mode 100644 index 00000000000..c8a4488e416 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize width(streamsize wide); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.width() == 0); + std::streamsize w = t.width(4); + assert(w == 0); + assert(t.width() == 4); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp new file mode 100644 index 00000000000..33a37cdd873 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// void register_callback(event_callback fn, int index); + +#include <ios> +#include <string> +#include <locale> +#include <cassert> + +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() == "en_US"); + 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("en_US")); + assert(f1_called == 3); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp new file mode 100644 index 00000000000..6c52995924f --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ~ios_base() + +#include <ios> +#include <string> +#include <locale> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +bool f1_called = false; +bool f2_called = false; +bool f3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert( f2_called); + assert( f3_called); + assert(stream.getloc().name() == "C"); + assert(index == 4); + f1_called = true; + } +} + +void f2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert(!f2_called); + assert( f3_called); + assert(stream.getloc().name() == "C"); + assert(index == 5); + f2_called = true; + } +} + +void f3(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert(!f2_called); + assert(!f3_called); + assert(stream.getloc().name() == "C"); + assert(index == 6); + f3_called = true; + } +} + +int main() +{ + { + test t; + std::ios_base& b = t; + b.register_callback(f1, 4); + b.register_callback(f2, 5); + b.register_callback(f3, 6); + } + assert(f1_called); + assert(f2_called); + assert(f3_called); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp new file mode 100644 index 00000000000..bd4d737b676 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// locale getloc() const; + +#include <ios> +#include <string> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.getloc().name() == std::string("C")); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp new file mode 100644 index 00000000000..01cc795c3aa --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// locale imbue(const locale& loc); + +#include <ios> +#include <string> +#include <locale> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +bool f1_called = false; +bool f2_called = false; +bool f3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(!f1_called); + assert( f2_called); + assert( f3_called); + assert(stream.getloc().name() == "en_US"); + 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() == "en_US"); + 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() == "en_US"); + 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("en_US")); + assert(l.name() == std::string("C")); + assert(b.getloc().name() == std::string("en_US")); + assert(f1_called); + assert(f2_called); + assert(f3_called); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp new file mode 100644 index 00000000000..e700c5aeba1 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// long& iword(int idx); + +#include <ios> +#include <string> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + std::ios_base& b = t; + for (int i = 0; i < 10000; ++i) + { + assert(b.iword(i) == 0); + b.iword(i) = i; + assert(b.iword(i) == i); + for (int j = 0; j <= i; ++j) + assert(b.iword(j) == j); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp new file mode 100644 index 00000000000..a96e6e19b2a --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// void*& pword(int idx); + +#include <ios> +#include <string> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + std::ios_base& b = t; + for (int i = 0; i < 10000; ++i) + { + assert(b.pword(i) == 0); + b.pword(i) = (void*)i; + assert(b.pword(i) == (void*)i); + for (int j = 0; j <= i; ++j) + assert(b.pword(j) == (void*)j); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp new file mode 100644 index 00000000000..3f803b246b5 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static int xalloc(); + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::xalloc() == 0); + assert(std::ios_base::xalloc() == 1); + assert(std::ios_base::xalloc() == 2); + assert(std::ios_base::xalloc() == 3); + assert(std::ios_base::xalloc() == 4); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp new file mode 100644 index 00000000000..71334fef399 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// bool sync_with_stdio(bool sync = true); + +#include <ios> +#include <cassert> + +int main() +{ + assert( std::ios_base::sync_with_stdio(false)); + assert(!std::ios_base::sync_with_stdio(false)); + assert(!std::ios_base::sync_with_stdio(true)); + assert( std::ios_base::sync_with_stdio(true)); + assert( std::ios_base::sync_with_stdio()); + assert( std::ios_base::sync_with_stdio(false)); + assert(!std::ios_base::sync_with_stdio()); + assert( std::ios_base::sync_with_stdio()); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::Init/tested_elsewhere.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::Init/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::Init/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_char_pointer_error_code.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_char_pointer_error_code.pass.cpp new file mode 100644 index 00000000000..1d4b3cbe096 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_char_pointer_error_code.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base::failure + +// explicit failure(const char* msg, const error_code& ec = io_errc::stream); + +#include <ios> +#include <string> +#include <cassert> + +int main() +{ + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg.c_str(), make_error_code(std::errc::is_a_directory)); + assert(se.code() == std::make_error_code(std::errc::is_a_directory)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find("Is a directory") != std::string::npos); + } + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg.c_str()); + assert(se.code() == std::make_error_code(std::io_errc::stream)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find(std::iostream_category().message(static_cast<int> + (std::io_errc::stream))) != std::string::npos); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_string_error_code.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_string_error_code.pass.cpp new file mode 100644 index 00000000000..7c6051f80b4 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_string_error_code.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base::failure + +// explicit failure(const string& msg, const error_code& ec = io_errc::stream); + +#include <ios> +#include <string> +#include <cassert> + +int main() +{ + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory)); + assert(se.code() == std::make_error_code(std::errc::is_a_directory)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find("Is a directory") != std::string::npos); + } + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg); + assert(se.code() == std::make_error_code(std::io_errc::stream)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find(std::iostream_category().message(static_cast<int> + (std::io_errc::stream))) != std::string::npos); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::fmtflags/fmtflags.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::fmtflags/fmtflags.pass.cpp new file mode 100644 index 00000000000..bf91c445cd9 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::fmtflags/fmtflags.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const fmtflags boolalpha; +// static const fmtflags dec; +// static const fmtflags fixed; +// static const fmtflags hex; +// static const fmtflags internal; +// static const fmtflags left; +// static const fmtflags oct; +// static const fmtflags right; +// static const fmtflags scientific; +// static const fmtflags showbase; +// static const fmtflags showpoint; +// static const fmtflags showpos; +// static const fmtflags skipws; +// static const fmtflags unitbuf; +// static const fmtflags uppercase; +// static const fmtflags adjustfield = left | right | internal; +// static const fmtflags basefield = dec | oct | hex; +// static const fmtflags floatfield = scientific | fixed; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::boolalpha); + assert(std::ios_base::dec); + assert(std::ios_base::fixed); + assert(std::ios_base::hex); + assert(std::ios_base::internal); + assert(std::ios_base::left); + assert(std::ios_base::oct); + assert(std::ios_base::right); + assert(std::ios_base::scientific); + assert(std::ios_base::showbase); + assert(std::ios_base::showpoint); + assert(std::ios_base::showpos); + assert(std::ios_base::skipws); + assert(std::ios_base::unitbuf); + assert(std::ios_base::uppercase); + + assert + ( + ( std::ios_base::boolalpha + & std::ios_base::dec + & std::ios_base::fixed + & std::ios_base::hex + & std::ios_base::internal + & std::ios_base::left + & std::ios_base::oct + & std::ios_base::right + & std::ios_base::scientific + & std::ios_base::showbase + & std::ios_base::showpoint + & std::ios_base::showpos + & std::ios_base::skipws + & std::ios_base::unitbuf + & std::ios_base::uppercase) == 0 + ); + + assert(std::ios_base::adjustfield == (std::ios_base::left + | std::ios_base::right + | std::ios_base::internal)); + assert(std::ios_base::basefield == (std::ios_base::dec + | std::ios_base::oct + | std::ios_base::hex)); + assert(std::ios_base::floatfield == (std::ios_base::scientific + | std::ios_base::fixed)); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::iostate/iostate.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::iostate/iostate.pass.cpp new file mode 100644 index 00000000000..4c73561b422 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::iostate/iostate.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const iostate badbit; +// static const iostate eofbit; +// static const iostate failbit; +// static const iostate goodbit = 0; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::badbit); + assert(std::ios_base::eofbit); + assert(std::ios_base::failbit); + + assert + ( + ( std::ios_base::badbit + & std::ios_base::eofbit + & std::ios_base::failbit) == 0 + ); + + assert(std::ios_base::goodbit == 0); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::openmode/openmode.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::openmode/openmode.pass.cpp new file mode 100644 index 00000000000..9a592717b37 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::openmode/openmode.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const openmode app; +// static const openmode ate; +// static const openmode binary; +// static const openmode in; +// static const openmode out; +// static const openmode trunc; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::app); + assert(std::ios_base::ate); + assert(std::ios_base::binary); + assert(std::ios_base::in); + assert(std::ios_base::out); + assert(std::ios_base::trunc); + + assert + ( + ( std::ios_base::app + & std::ios_base::ate + & std::ios_base::binary + & std::ios_base::in + & std::ios_base::out + & std::ios_base::trunc) == 0 + ); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::seekdir/seekdir.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::seekdir/seekdir.pass.cpp new file mode 100644 index 00000000000..5aeee65b136 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/ios::seekdir/seekdir.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const seekdir beg; +// static const seekdir cur; +// static const seekdir end; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::beg != std::ios_base::cur); + assert(std::ios_base::beg != std::ios_base::end); + assert(std::ios_base::cur != std::ios_base::end); +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..bcb85cf099e --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +#include <ios> + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp new file mode 100644 index 00000000000..771f115dfe8 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// explicit basic_ios(basic_streambuf<charT,traits>* sb); + +#include <ios> +#include <streambuf> +#include <cassert> + +int main() +{ + { + std::streambuf* sb = 0; + std::basic_ios<char> ios(sb); + assert(ios.rdbuf() == sb); + assert(ios.tie() == 0); + assert(ios.rdstate() == std::ios::badbit); + assert(ios.exceptions() == std::ios::goodbit); + assert(ios.flags() == (std::ios::skipws | std::ios::dec)); + assert(ios.width() == 0); + assert(ios.precision() == 6); + assert(ios.fill() == ' '); + assert(ios.getloc() == std::locale()); + } + { + std::streambuf* sb = (std::streambuf*)1; + std::basic_ios<char> ios(sb); + assert(ios.rdbuf() == sb); + assert(ios.tie() == 0); + assert(ios.rdstate() == std::ios::goodbit); + assert(ios.exceptions() == std::ios::goodbit); + assert(ios.flags() == (std::ios::skipws | std::ios::dec)); + assert(ios.width() == 0); + assert(ios.precision() == 6); + assert(ios.fill() == ' '); + assert(ios.getloc() == std::locale()); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp new file mode 100644 index 00000000000..dc1484d0040 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp @@ -0,0 +1,185 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_ios& copyfmt(const basic_ios& rhs); + +#include <ios> +#include <streambuf> +#include <cassert> + +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() == "en_US"); + 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() == "en_US"); + 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() == "fr_FR"); + 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() == "fr_FR"); + 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() == "fr_FR"); + 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("en_US")); + 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("fr_FR")); + 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() == "fr_FR"); + assert(ios1.exceptions() == std::ios::eofbit); + assert(f1_called); + assert(f2_called); + assert(g1_called); + assert(g2_called); + assert(g3_called); + assert(ios1.iword(0) == 4); + assert(ios1.iword(1) == 5); + assert(ios1.iword(2) == 6); + assert(ios1.iword(3) == 7); + assert(ios1.iword(4) == 8); + assert(ios1.iword(5) == 9); + assert(ios1.pword(0) == &d1); + assert(ios1.pword(1) == &d2); + assert(ios1.tie() == (std::ostream*)2); + assert(ios1.fill() == '2'); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp new file mode 100644 index 00000000000..57ec94e3349 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char_type fill() const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::ios ios(0); + assert(ios.fill() == ' '); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp new file mode 100644 index 00000000000..8b09684d042 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char_type fill(char_type fillch); + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(ios.fill() == ' '); + char c = ios.fill('*'); + assert(c == ' '); + assert(ios.fill() == '*'); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp new file mode 100644 index 00000000000..dd1d416aff9 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp @@ -0,0 +1,99 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// locale imbue(const locale& loc); + +#include <ios> +#include <streambuf> +#include <cassert> + +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() == "en_US"); + 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() == "en_US"); + 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() == "en_US"); + 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("en_US")); + assert(l.name() == std::string("C")); + assert(ios.getloc().name() == std::string("en_US")); + 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("en_US")); + assert(l.name() == std::string("C")); + assert(ios.getloc().name() == std::string("en_US")); + assert(sb.getloc().name() == std::string("en_US")); + assert(f1_called); + assert(f2_called); + assert(f3_called); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp new file mode 100644 index 00000000000..a50f2d997cd --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp @@ -0,0 +1,136 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void move(basic_ios&& rhs); + +#include <ios> +#include <streambuf> +#include <cassert> + +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("fr_FR")); + 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() == "fr_FR"); + assert(ios1.exceptions() == std::ios::eofbit); + assert(!f1_called); + assert(!f2_called); + assert(!g1_called); + assert(!g2_called); + assert(!g3_called); + assert(ios1.iword(0) == 4); + assert(ios1.iword(1) == 5); + assert(ios1.iword(2) == 6); + assert(ios1.iword(3) == 7); + assert(ios1.iword(4) == 8); + assert(ios1.iword(5) == 9); + assert(ios1.pword(0) == &d1); + assert(ios1.pword(1) == &d2); + assert(ios1.tie() == (std::ostream*)2); + assert(ios1.fill() == '2'); + ios1.imbue(std::locale("C")); + assert(!f1_called); + assert(!f2_called); + assert(g1_called); + assert(g2_called); + assert(g3_called); + + assert(ios2.rdbuf() == &sb2); + assert(ios2.tie() == 0); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp new file mode 100644 index 00000000000..db23adb33e9 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char narrow(char_type c, char dfault) const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::ios ios(0); + assert(ios.narrow('c', '*') == 'c'); + assert(ios.narrow('\xFE', '*') == '*'); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp new file mode 100644 index 00000000000..1cf250ad1c1 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_streambuf<charT,traits>* rdbuf() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +int main() +{ + { + const std::ios ios(0); + assert(ios.rdbuf() == 0); + } + { + std::streambuf* sb = (std::streambuf*)1; + const std::ios ios(sb); + assert(ios.rdbuf() == sb); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp new file mode 100644 index 00000000000..3dde3e55a77 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb); + +#include <ios> +#include <streambuf> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(ios.rdbuf() == 0); + assert(!ios.good()); + std::streambuf* sb = (std::streambuf*)1; + std::streambuf* sb2 = ios.rdbuf(sb); + assert(sb2 == 0); + assert(ios.rdbuf() == sb); + assert(ios.good()); + sb2 = ios.rdbuf(0); + assert(sb2 == (std::streambuf*)1); + assert(ios.rdbuf() == 0); + assert(ios.bad()); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp new file mode 100644 index 00000000000..2ce7a92a62f --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void set_rdbuf(basic_streambuf<charT, traits>* sb); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf + : public std::streambuf +{ +}; + +struct testios + : public std::ios +{ + testios(std::streambuf* p) : std::ios(p) {} + void set_rdbuf(std::streambuf* x) {std::ios::set_rdbuf(x);} +}; + +int main() +{ + testbuf sb1; + testbuf sb2; + testios ios(&sb1); + try + { + ios.setstate(std::ios::badbit); + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + ios.set_rdbuf(&sb2); + assert(ios.rdbuf() == &sb2); + try + { + ios.setstate(std::ios::badbit); + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + ios.set_rdbuf(0); + assert(ios.rdbuf() == 0); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp new file mode 100644 index 00000000000..bd49d5f49d6 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp @@ -0,0 +1,163 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void move(basic_ios&& rhs); + +#include <ios> +#include <streambuf> +#include <cassert> + +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("en_US")); + 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("fr_FR")); + 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() == "fr_FR"); + 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() == "en_US"); + assert(ios2.exceptions() == std::ios::failbit); + assert(ios2.iword(0) == 1); + assert(ios2.iword(1) == 2); + assert(ios2.iword(2) == 3); + assert(ios2.pword(0) == &c1); + assert(ios2.pword(1) == &c2); + assert(ios2.pword(2) == &c3); + assert(ios2.tie() == (std::ostream*)1); + assert(ios2.fill() == '1'); + ios2.imbue(std::locale("C")); + assert(f1_called); + assert(f2_called); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp new file mode 100644 index 00000000000..ef400ec5609 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_ostream<charT,traits>* tie() const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::basic_ios<char> ios(0); + assert(ios.tie() == 0); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp new file mode 100644 index 00000000000..7b3c043aec2 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr); + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + std::ostream* os = (std::ostream*)1; + std::ostream* r = ios.tie(os); + assert(r == 0); + assert(ios.tie() == os); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp new file mode 100644 index 00000000000..18e2cb50b50 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char_type widen(char c) const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::ios ios(0); + assert(ios.widen('c') == 'c'); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp new file mode 100644 index 00000000000..340b06b7583 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool bad() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(ios.bad()); + ios.setstate(std::ios::eofbit); + assert(ios.bad()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(!ios.bad()); + ios.setstate(std::ios::eofbit); + assert(!ios.bad()); + ios.setstate(std::ios::failbit); + assert(!ios.bad()); + ios.setstate(std::ios::badbit); + assert(ios.bad()); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp new file mode 100644 index 00000000000..837f94998bf --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// operator unspecified-bool-type() const; + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(static_cast<bool>(ios) == !ios.fail()); + ios.setstate(std::ios::failbit); + assert(static_cast<bool>(ios) == !ios.fail()); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp new file mode 100644 index 00000000000..8d46f9117f9 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void clear(iostate state = goodbit); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + ios.clear(); + assert(ios.rdstate() == std::ios::badbit); + try + { + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + try + { + ios.clear(); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == std::ios::badbit); + } + try + { + ios.clear(std::ios::eofbit); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit)); + } + } + { + testbuf sb; + std::ios ios(&sb); + ios.clear(); + assert(ios.rdstate() == std::ios::goodbit); + ios.exceptions(std::ios::badbit); + ios.clear(); + assert(ios.rdstate() == std::ios::goodbit); + ios.clear(std::ios::eofbit); + assert(ios.rdstate() == std::ios::eofbit); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp new file mode 100644 index 00000000000..3319e084f32 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool eof() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(!ios.eof()); + ios.setstate(std::ios::eofbit); + assert(ios.eof()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(!ios.eof()); + ios.setstate(std::ios::eofbit); + assert(ios.eof()); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp new file mode 100644 index 00000000000..0050e0cc507 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// iostate exceptions() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + const std::ios ios(0); + assert(ios.exceptions() == std::ios::goodbit); + } + { + testbuf sb; + const std::ios ios(&sb); + assert(ios.exceptions() == std::ios::goodbit); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp new file mode 100644 index 00000000000..9a7904f23f4 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// iostate exceptions() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(ios.exceptions() == std::ios::goodbit); + ios.exceptions(std::ios::eofbit); + assert(ios.exceptions() == std::ios::eofbit); + try + { + ios.exceptions(std::ios::badbit); + assert(false); + } + catch (std::ios::failure&) + { + } + assert(ios.exceptions() == std::ios::badbit); + } + { + testbuf sb; + std::ios ios(&sb); + assert(ios.exceptions() == std::ios::goodbit); + ios.exceptions(std::ios::eofbit); + assert(ios.exceptions() == std::ios::eofbit); + ios.exceptions(std::ios::badbit); + assert(ios.exceptions() == std::ios::badbit); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp new file mode 100644 index 00000000000..b47e7288786 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool fail() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(ios.fail()); + ios.setstate(std::ios::eofbit); + assert(ios.fail()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(!ios.fail()); + ios.setstate(std::ios::eofbit); + assert(!ios.fail()); + ios.setstate(std::ios::badbit); + assert(ios.fail()); + ios.setstate(std::ios::failbit); + assert(ios.fail()); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp new file mode 100644 index 00000000000..a01d449b466 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool good() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(!ios.good()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(ios.good()); + ios.setstate(std::ios::eofbit); + assert(!ios.good()); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp new file mode 100644 index 00000000000..0bf3ccc720a --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool operator!() const; + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(!ios == ios.fail()); + ios.setstate(std::ios::failbit); + assert(!ios == ios.fail()); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp new file mode 100644 index 00000000000..3be58714581 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// iostate rdstate() const; + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(ios.rdstate() == std::ios::badbit); + ios.setstate(std::ios::failbit); + assert(ios.rdstate() == (std::ios::failbit | std::ios::badbit)); +} diff --git a/libcxx/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp new file mode 100644 index 00000000000..4b045424633 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void setstate(iostate state); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + ios.setstate(std::ios::goodbit); + assert(ios.rdstate() == std::ios::badbit); + try + { + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + try + { + ios.setstate(std::ios::goodbit); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == std::ios::badbit); + } + try + { + ios.setstate(std::ios::eofbit); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit)); + } + } + { + testbuf sb; + std::ios ios(&sb); + ios.setstate(std::ios::goodbit); + assert(ios.rdstate() == std::ios::goodbit); + ios.setstate(std::ios::eofbit); + assert(ios.rdstate() == std::ios::eofbit); + ios.setstate(std::ios::failbit); + assert(ios.rdstate() == (std::ios::eofbit | std::ios::failbit)); + } +} diff --git a/libcxx/test/input.output/iostreams.base/ios/types.pass.cpp b/libcxx/test/input.output/iostreams.base/ios/types.pass.cpp new file mode 100644 index 00000000000..0b9aeacb7c7 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/ios/types.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ios : public ios_base +// { +// public: +// typedef charT char_type; +// typedef typename traits::int_type int_type; +// typedef typename traits::pos_type pos_type; +// typedef typename traits::off_type off_type; +// typedef traits traits_type; + +#include <ios> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::ios_base, std::basic_ios<char> >::value), ""); + static_assert((std::is_same<std::basic_ios<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_ios<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_ios<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_ios<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_ios<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp new file mode 100644 index 00000000000..67eabb6a3d7 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& internal(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::internal(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::internal); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp new file mode 100644 index 00000000000..3bf05c808ba --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& left(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::left(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::left); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp new file mode 100644 index 00000000000..25ca737c29c --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& right(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::right(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::right); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp new file mode 100644 index 00000000000..74e114beb76 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& dec(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::dec(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::dec); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp new file mode 100644 index 00000000000..c1ca0d6c441 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& hex(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::hex(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::hex); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp new file mode 100644 index 00000000000..6c020e7a02c --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& oct(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::oct(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::oct); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp new file mode 100644 index 00000000000..bfed3f4cc20 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// const error_category& iostream_category(); + +#include <ios> +#include <cassert> +#include <string> + +int main() +{ + const std::error_category& e_cat1 = std::iostream_category(); + std::string m1 = e_cat1.name(); + assert(m1 == "iostream"); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp new file mode 100644 index 00000000000..f404cb10896 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// error_code make_error_code(io_errc e); + +#include <ios> +#include <cassert> + +int main() +{ + { + std::error_code ec = make_error_code(std::io_errc::stream); + assert(ec.value() == static_cast<int>(std::io_errc::stream)); + assert(ec.category() == std::iostream_category()); + } +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp new file mode 100644 index 00000000000..0024984a346 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// error_condition make_error_condition(io_errc e); + +#include <ios> +#include <cassert> + +int main() +{ + { + const std::error_condition ec1 = std::make_error_condition(std::io_errc::stream); + assert(ec1.value() == static_cast<int>(std::io_errc::stream)); + assert(ec1.category() == std::iostream_category()); + } +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp new file mode 100644 index 00000000000..3b8b967491c --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& defaultfloat(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::defaultfloat(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::fixed)); + assert(!(ios.flags() & std::ios::scientific)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp new file mode 100644 index 00000000000..2b704e4bfe7 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& fixed(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::fixed(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::fixed); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp new file mode 100644 index 00000000000..c849e86ef0a --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& hexfloat(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::hexfloat(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::fixed); + assert(ios.flags() & std::ios::scientific); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp new file mode 100644 index 00000000000..e20e993bf86 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& scientific(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::scientific(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::scientific); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp new file mode 100644 index 00000000000..08734cf7867 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& boolalpha(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::boolalpha(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::boolalpha); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp new file mode 100644 index 00000000000..4f31343b302 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noboolalpha(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::boolalpha(ios); + std::ios_base& r = std::noboolalpha(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::boolalpha)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp new file mode 100644 index 00000000000..fe47b6c48d3 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noshowbase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::showbase(ios); + std::ios_base& r = std::noshowbase(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::showbase)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp new file mode 100644 index 00000000000..71cdc500800 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noshowpoint(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::showpoint(ios); + std::ios_base& r = std::noshowpoint(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::showpoint)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp new file mode 100644 index 00000000000..902506e1106 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noshowpos(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::showpos(ios); + std::ios_base& r = std::noshowpos(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::showpos)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp new file mode 100644 index 00000000000..2e2c3a691e8 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noskipws(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::skipws(ios); + std::ios_base& r = std::noskipws(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::skipws)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp new file mode 100644 index 00000000000..ddfaee549b2 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& nounitbuf(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::unitbuf(ios); + std::ios_base& r = std::nounitbuf(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::unitbuf)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp new file mode 100644 index 00000000000..864dcc4b879 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& nouppercase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::uppercase(ios); + std::ios_base& r = std::nouppercase(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::uppercase)); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp new file mode 100644 index 00000000000..84fe15b9de2 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& showbase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::showbase(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::showbase); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp new file mode 100644 index 00000000000..ce6ef8cdeb5 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& showpoint(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::showpoint(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::showpoint); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp new file mode 100644 index 00000000000..74665afee69 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& showpos(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::showpos(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::showpos); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp new file mode 100644 index 00000000000..71c47f4ee32 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& skipws(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::skipws(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::skipws); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp new file mode 100644 index 00000000000..a931cc42956 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& unitbuf(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::unitbuf(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::unitbuf); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp new file mode 100644 index 00000000000..653bd1c64ad --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& uppercase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::uppercase(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::uppercase); +} diff --git a/libcxx/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp b/libcxx/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp new file mode 100644 index 00000000000..85c1f5ec1dc --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// typedef OFF_T streamoff; + +#include <ios> +#include <type_traits> + +int main() +{ + static_assert(std::is_integral<std::streamoff>::value, ""); + static_assert(std::is_signed<std::streamoff>::value, ""); +} diff --git a/libcxx/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp b/libcxx/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp new file mode 100644 index 00000000000..0c31b168646 --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// typedef SZ_T streamsize; + +#include <ios> +#include <type_traits> + +int main() +{ + static_assert(std::is_integral<std::streamsize>::value, ""); + static_assert(std::is_signed<std::streamsize>::value, ""); +} diff --git a/libcxx/test/input.output/iostreams.base/version.pass.cpp b/libcxx/test/input.output/iostreams.base/version.pass.cpp new file mode 100644 index 00000000000..62bcfa8101e --- /dev/null +++ b/libcxx/test/input.output/iostreams.base/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +#include <ios> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp b/libcxx/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp b/libcxx/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/nothing_to_do.pass.cpp b/libcxx/test/input.output/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp new file mode 100644 index 00000000000..b7736cb8889 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// basic_streambuf(const basic_streambuf& rhs); // protected + +#include <streambuf> +#include <cassert> + +std::streambuf get(); + +int main() +{ + std::streambuf sb = get(); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp new file mode 100644 index 00000000000..3f9f7d5184d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp @@ -0,0 +1,82 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// basic_streambuf(const basic_streambuf& rhs); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + test() {} + + test(const test& t) + : std::basic_streambuf<CharT>(t) + { + assert(this->eback() == t.eback()); + assert(this->gptr() == t.gptr()); + assert(this->egptr() == t.egptr()); + assert(this->pbase() == t.pbase()); + assert(this->pptr() == t.pptr()); + assert(this->epptr() == t.epptr()); + assert(this->getloc() == t.getloc()); + } + + void setg(CharT* gbeg, CharT* gnext, CharT* gend) + { + base::setg(gbeg, gnext, gend); + } + void setp(CharT* pbeg, CharT* pend) + { + base::setp(pbeg, pend); + } +}; + +int main() +{ + { + test<char> t; + test<char> t2 = t; + } + { + test<wchar_t> t; + test<wchar_t> t2 = t; + } + { + char g1, g2, g3, p1, p3; + test<char> t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test<char> t2 = t; + } + { + wchar_t g1, g2, g3, p1, p3; + test<wchar_t> t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test<wchar_t> t2 = t; + } + std::locale::global(std::locale("en_US")); + { + test<char> t; + test<char> t2 = t; + } + { + test<wchar_t> t; + test<wchar_t> t2 = t; + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp new file mode 100644 index 00000000000..3ae29ffff12 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// basic_streambuf(); // is protected + +#include <streambuf> + +int main() +{ + std::basic_streambuf<char> sb; +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp new file mode 100644 index 00000000000..975b1a3e816 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// basic_streambuf(); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() + { + assert(this->eback() == 0); + assert(this->gptr() == 0); + assert(this->egptr() == 0); + assert(this->pbase() == 0); + assert(this->pptr() == 0); + assert(this->epptr() == 0); + } +}; + +int main() +{ + { + test<char> t; + assert(t.getloc().name() == "C"); + } + { + test<wchar_t> t; + assert(t.getloc().name() == "C"); + } + std::locale::global(std::locale("en_US")); + { + test<char> t; + assert(t.getloc().name() == "en_US"); + } + { + test<wchar_t> t; + assert(t.getloc().name() == "en_US"); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp new file mode 100644 index 00000000000..4fc6ff00c1e --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// pos_type pubseekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubseekoff(0, std::ios_base::beg) == -1); + assert(t.pubseekoff(0, std::ios_base::beg, std::ios_base::app) == -1); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp new file mode 100644 index 00000000000..a50594ed67e --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// pos_type pubseekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out; + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubseekpos(0, std::ios_base::app) == -1); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp new file mode 100644 index 00000000000..f558f5f4a83 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// basic_streambuf* pubsetbuf(char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubsetbuf(0, 0) == &t); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp new file mode 100644 index 00000000000..166a57a3b86 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int pubsync(); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubsync() == 0); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp new file mode 100644 index 00000000000..68ff5e58b77 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// locale pubimbue(const locale& loc); +// locale getloc() const; + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} + + void imbue(const std::locale&) + { + assert(this->getloc().name() == "en_US"); + } +}; + +int main() +{ + { + test<char> t; + assert(t.getloc().name() == "C"); + } + std::locale::global(std::locale("en_US")); + { + test<char> t; + assert(t.getloc().name() == "en_US"); + assert(t.pubimbue(std::locale("fr_FR")).name() == "en_US"); + assert(t.getloc().name() == "fr_FR"); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp new file mode 100644 index 00000000000..d47603056d4 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize in_avail(); + +#include <streambuf> +#include <cassert> + +int showmanyc_called = 0; + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + + test() {} + + void setg(CharT* gbeg, CharT* gnext, CharT* gend) + { + base::setg(gbeg, gnext, gend); + } +protected: + std::streamsize showmanyc() + { + ++showmanyc_called; + return 5; + } +}; + +int main() +{ + { + test<char> t; + assert(t.in_avail() == 5); + assert(showmanyc_called == 1); + char in[5]; + t.setg(in, in+2, in+5); + assert(t.in_avail() == 3); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp new file mode 100644 index 00000000000..179d72f7dd3 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sbumpc(); + +#include <streambuf> +#include <cassert> + +int uflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type uflow() + { + ++uflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(uflow_called == 0); + assert(t.sbumpc() == 'a'); + assert(uflow_called == 1); + char in[] = "ABC"; + t.setg(in, in, in+sizeof(in)); + assert(t.sbumpc() == 'A'); + assert(uflow_called == 1); + assert(t.sbumpc() == 'B'); + assert(uflow_called == 1); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp new file mode 100644 index 00000000000..44fd1bc01c8 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sgetc(); + +#include <streambuf> +#include <cassert> + +int underflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type underflow() + { + ++underflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(underflow_called == 0); + assert(t.sgetc() == 'a'); + assert(underflow_called == 1); + char in[] = "ABC"; + t.setg(in, in, in+sizeof(in)); + assert(t.sgetc() == 'A'); + assert(underflow_called == 1); + assert(t.sgetc() == 'A'); + assert(underflow_called == 1); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp new file mode 100644 index 00000000000..47daa3a040f --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize sgetn(char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +int xsgetn_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + test() {} + +protected: + std::streamsize xsgetn(char_type* s, std::streamsize n) + { + ++xsgetn_called; + return 10; + } +}; + +int main() +{ + test t; + assert(xsgetn_called == 0); + assert(t.sgetn(0, 0) == 10); + assert(xsgetn_called == 1); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp new file mode 100644 index 00000000000..e4121b5f9c5 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type snextc(); + +#include <streambuf> +#include <cassert> + +int uflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type uflow() + { + ++uflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(uflow_called == 0); + assert(t.snextc() == -1); + assert(uflow_called == 1); + char in[] = "ABC"; + t.setg(in, in, in+sizeof(in)); + assert(t.snextc() == 'B'); + assert(uflow_called == 1); + assert(t.snextc() == 'C'); + assert(uflow_called == 1); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp new file mode 100644 index 00000000000..0b113fd89af --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sputbackc(char_type c); + +#include <streambuf> +#include <cassert> + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type pbackfail(int_type c = traits_type::eof()) + { + ++pbackfail_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(pbackfail_called == 0); + assert(t.sputbackc('A') == 'a'); + assert(pbackfail_called == 1); + char in[] = "ABC"; + t.setg(in, in+1, in+sizeof(in)); + assert(t.sputbackc('A') == 'A'); + assert(pbackfail_called == 1); + assert(t.sputbackc('A') == 'a'); + assert(pbackfail_called == 2); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp new file mode 100644 index 00000000000..9d69a9eb7fa --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sungetc(); + +#include <streambuf> +#include <cassert> + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type pbackfail(int_type c = traits_type::eof()) + { + ++pbackfail_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(pbackfail_called == 0); + assert(t.sungetc() == 'a'); + assert(pbackfail_called == 1); + char in[] = "ABC"; + t.setg(in, in+1, in+sizeof(in)); + assert(t.sungetc() == 'A'); + assert(pbackfail_called == 1); + assert(t.sungetc() == 'a'); + assert(pbackfail_called == 2); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp new file mode 100644 index 00000000000..c46042c85f0 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sputc(char_type c); + +#include <streambuf> +#include <cassert> + +int overflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + void setp(char* pbeg, char* pend) + { + base::setp(pbeg, pend); + } + +protected: + int_type overflow(int_type c = traits_type::eof()) + { + ++overflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(overflow_called == 0); + assert(t.sputc('A') == 'a'); + assert(overflow_called == 1); + char out[3] = {0}; + t.setp(out, out+sizeof(out)); + assert(t.sputc('A') == 'A'); + assert(overflow_called == 1); + assert(out[0] == 'A'); + assert(t.sputc('B') == 'B'); + assert(overflow_called == 1); + assert(out[0] == 'A'); + assert(out[1] == 'B'); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp new file mode 100644 index 00000000000..42096719660 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize sputn(const char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +int xsputn_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + test() {} + +protected: + std::streamsize xsputn(const char_type* s, std::streamsize n) + { + ++xsputn_called; + return 5; + } +}; + +int main() +{ + test t; + assert(xsputn_called == 0); + assert(t.sputn(0, 0) == 5); + assert(xsputn_called == 1); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp new file mode 100644 index 00000000000..87c04e4e707 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// basic_streambuf& operator=(const basic_streambuf& rhs); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + test() {} + + test& operator=(const test& t) + { + base::operator=(t); + assert(this->eback() == t.eback()); + assert(this->gptr() == t.gptr()); + assert(this->egptr() == t.egptr()); + assert(this->pbase() == t.pbase()); + assert(this->pptr() == t.pptr()); + assert(this->epptr() == t.epptr()); + assert(this->getloc() == t.getloc()); + return *this; + } + + void setg(CharT* gbeg, CharT* gnext, CharT* gend) + { + base::setg(gbeg, gnext, gend); + } + void setp(CharT* pbeg, CharT* pend) + { + base::setp(pbeg, pend); + } +}; + +int main() +{ + { + test<char> t; + test<char> t2; + t2 = t; + } + { + test<wchar_t> t; + test<wchar_t> t2; + t2 = t; + } + { + char g1, g2, g3, p1, p3; + test<char> t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test<char> t2; + t2 = t; + } + { + wchar_t g1, g2, g3, p1, p3; + test<wchar_t> t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test<wchar_t> t2; + t2 = t; + } + std::locale::global(std::locale("en_US")); + { + test<char> t; + test<char> t2; + t2 = t; + } + { + test<wchar_t> t; + test<wchar_t> t2; + t2 = t; + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp new file mode 100644 index 00000000000..5cfd9f044ad --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp @@ -0,0 +1,99 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// void swap(basic_streambuf& rhs); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + test() {} + + void swap(test& t) + { + test old_this(*this); + test old_that(t); + base::swap(t); + assert(this->eback() == old_that.eback()); + assert(this->gptr() == old_that.gptr()); + assert(this->egptr() == old_that.egptr()); + assert(this->pbase() == old_that.pbase()); + assert(this->pptr() == old_that.pptr()); + assert(this->epptr() == old_that.epptr()); + assert(this->getloc() == old_that.getloc()); + + assert(t.eback() == old_this.eback()); + assert(t.gptr() == old_this.gptr()); + assert(t.egptr() == old_this.egptr()); + assert(t.pbase() == old_this.pbase()); + assert(t.pptr() == old_this.pptr()); + assert(t.epptr() == old_this.epptr()); + assert(t.getloc() == old_this.getloc()); + return *this; + } + + void setg(CharT* gbeg, CharT* gnext, CharT* gend) + { + base::setg(gbeg, gnext, gend); + } + void setp(CharT* pbeg, CharT* pend) + { + base::setp(pbeg, pend); + } +}; + +int main() +{ + { + test<char> t; + test<char> t2; + swap(t2, t); + } + { + test<wchar_t> t; + test<wchar_t> t2; + swap(t2, t); + } + { + char g1, g2, g3, p1, p3; + test<char> t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test<char> t2; + swap(t2, t); + } + { + wchar_t g1, g2, g3, p1, p3; + test<wchar_t> t; + t.setg(&g1, &g2, &g3); + t.setp(&p1, &p3); + test<wchar_t> t2; + swap(t2, t); + } + std::locale::global(std::locale("en_US")); + { + test<char> t; + test<char> t2; + swap(t2, t); + } + { + test<wchar_t> t; + test<wchar_t> t2; + swap(t2, t); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp new file mode 100644 index 00000000000..021a1372487 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// void gbump(int n); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + + test() {} + + void setg(CharT* gbeg, CharT* gnext, CharT* gend) + { + base::setg(gbeg, gnext, gend); + } + + void gbump(int n) + { + CharT* gbeg = base::eback(); + CharT* gnext = base::gptr(); + CharT* gend = base::egptr(); + base::gbump(n); + assert(base::eback() == gbeg); + assert(base::gptr() == gnext+n); + assert(base::egptr() == gend); + } +}; + +int main() +{ + { + test<char> t; + char in[] = "ABCDE"; + t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); + t.gbump(2); + } + { + test<wchar_t> t; + wchar_t in[] = L"ABCDE"; + t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); + t.gbump(3); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp new file mode 100644 index 00000000000..8ca539c50fc --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// void setg(char_type* gbeg, char_type* gnext, char_type* gend); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + + test() {} + + void setg(CharT* gbeg, CharT* gnext, CharT* gend) + { + base::setg(gbeg, gnext, gend); + assert(base::eback() == gbeg); + assert(base::gptr() == gnext); + assert(base::egptr() == gend); + } +}; + +int main() +{ + { + test<char> t; + char in[] = "ABC"; + t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); + } + { + test<wchar_t> t; + wchar_t in[] = L"ABC"; + t.setg(in, in+1, in+sizeof(in)/sizeof(in[0])); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp new file mode 100644 index 00000000000..7a062d090a9 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// void pbump(int n); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + + test() {} + + void setp(CharT* pbeg, CharT* pend) + { + base::setp(pbeg, pend); + } + + void pbump(int n) + { + CharT* pbeg = base::pbase(); + CharT* pnext = base::pptr(); + CharT* pend = base::epptr(); + base::pbump(n); + assert(base::pbase() == pbeg); + assert(base::pptr() == pnext+n); + assert(base::epptr() == pend); + } +}; + +int main() +{ + { + test<char> t; + char in[] = "ABCDE"; + t.setp(in, in+sizeof(in)/sizeof(in[0])); + t.pbump(2); + t.pbump(1); + } + { + test<wchar_t> t; + wchar_t in[] = L"ABCDE"; + t.setp(in, in+sizeof(in)/sizeof(in[0])); + t.pbump(3); + t.pbump(1); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp new file mode 100644 index 00000000000..b727c5ac0fe --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// void setp(char_type* pbeg, char_type* pend); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + + test() {} + + void setp(CharT* pbeg, CharT* pend) + { + base::setp(pbeg, pend); + assert(base::pbase() == pbeg); + assert(base::pptr() == pbeg); + assert(base::epptr() == pend); + } +}; + +int main() +{ + { + test<char> t; + char in[] = "ABC"; + t.setp(in, in+sizeof(in)/sizeof(in[0])); + } + { + test<wchar_t> t; + wchar_t in[] = L"ABC"; + t.setp(in, in+sizeof(in)/sizeof(in[0])); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp new file mode 100644 index 00000000000..c9b328ed941 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize showmanyc(); + +#include <streambuf> +#include <cassert> + +int showmanyc_called = 0; + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + test<char> t; + assert(t.in_avail() == 0); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp new file mode 100644 index 00000000000..74d08f82aed --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type uflow(); + +#include <streambuf> +#include <cassert> + +int underflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + test() {} + +}; + +int main() +{ + test t; + assert(t.sgetc() == -1); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp new file mode 100644 index 00000000000..b39fbf32ea8 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type underflow(); + +#include <streambuf> +#include <cassert> + +struct test + : public std::basic_streambuf<char> +{ + test() {} +}; + +int main() +{ + test t; + assert(t.sgetc() == -1); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp new file mode 100644 index 00000000000..799443b431c --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize xsgetn(char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } +}; + +int main() +{ + test t; + char input[7] = "123456"; + t.setg(input, input, input+7); + char output[sizeof(input)] = {0}; + assert(t.sgetn(output, 10) == 7); + assert(strcmp(input, output) == 0); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp new file mode 100644 index 00000000000..4609ff950e9 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type pbackfail(int_type c = traits::eof()); + +#include <streambuf> +#include <cassert> + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + test() {} +}; + +int main() +{ + test t; + assert(t.sputbackc('A') == -1); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp new file mode 100644 index 00000000000..96183ef6e8d --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type overflow(int_type c = traits::eof()); + +#include <streambuf> +#include <cassert> + +struct test + : public std::basic_streambuf<char> +{ + test() {} +}; + +int main() +{ + test t; + assert(t.sputc('A') == -1); +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp new file mode 100644 index 00000000000..95d522e5613 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize xsputn(const char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setp(char* pbeg, char* pend) + { + base::setp(pbeg, pend); + } +}; + +int main() +{ + { + test t; + char in[] = "123456"; + assert(t.sputn(in, sizeof(in)) == 0); + char out[sizeof(in)] = {0}; + t.setp(out, out+sizeof(out)); + assert(t.sputn(in, sizeof(in)) == sizeof(in)); + assert(strcmp(in, out) == 0); + } +} diff --git a/libcxx/test/input.output/stream.buffers/streambuf/types.pass.cpp b/libcxx/test/input.output/stream.buffers/streambuf/types.pass.cpp new file mode 100644 index 00000000000..664caebd773 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/streambuf/types.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf +// { +// public: +// // types: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <streambuf> +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::streambuf::char_type, char>::value), ""); + static_assert((std::is_same<std::streambuf::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::streambuf::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::streambuf::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::streambuf::off_type, std::char_traits<char>::off_type>::value), ""); + + static_assert((std::is_same<std::wstreambuf::char_type, wchar_t>::value), ""); + static_assert((std::is_same<std::wstreambuf::traits_type, std::char_traits<wchar_t> >::value), ""); + static_assert((std::is_same<std::wstreambuf::int_type, std::char_traits<wchar_t>::int_type>::value), ""); + static_assert((std::is_same<std::wstreambuf::pos_type, std::char_traits<wchar_t>::pos_type>::value), ""); + static_assert((std::is_same<std::wstreambuf::off_type, std::char_traits<wchar_t>::off_type>::value), ""); +} diff --git a/libcxx/test/input.output/stream.buffers/version.pass.cpp b/libcxx/test/input.output/stream.buffers/version.pass.cpp new file mode 100644 index 00000000000..8d9de9f9e14 --- /dev/null +++ b/libcxx/test/input.output/stream.buffers/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +#include <streambuf> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..75237e76cf1 --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream + +// void swap(basic_istringstream& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream ss0(" 123 456"); + std::istringstream ss(" 789 321"); + ss.swap(ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss0 >> i; + assert(i == 789); + ss0 >> i; + assert(i == 321); + } + { + std::wistringstream ss0(L" 123 456"); + std::wistringstream ss(L" 789 321"); + ss.swap(ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss0 >> i; + assert(i == 789); + ss0 >> i; + assert(i == 321); + } +} diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp new file mode 100644 index 00000000000..8ac3fda2cf5 --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream + +// basic_istringstream& operator=(basic_istringstream&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..696dd5b7dc0 --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream + +// template <class charT, class traits, class Allocator> +// void +// swap(basic_istringstream<charT, traits, Allocator>& x, +// basic_istringstream<charT, traits, Allocator>& y); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream ss0(" 123 456"); + std::istringstream ss(" 789 321"); + swap(ss, ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss0 >> i; + assert(i == 789); + ss0 >> i; + assert(i == 321); + } + { + std::wistringstream ss0(L" 123 456"); + std::wistringstream ss(L" 789 321"); + swap(ss, ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss0 >> i; + assert(i == 789); + ss0 >> i; + assert(i == 321); + } +} diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp new file mode 100644 index 00000000000..83933f7c1ef --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream + +// explicit basic_istringstream(ios_base::openmode which = ios_base::in); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream ss; + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == ""); + } + { + std::istringstream ss(std::ios_base::in); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == ""); + } + { + std::wistringstream ss; + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L""); + } + { + std::wistringstream ss(std::ios_base::in); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L""); + } +} diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp new file mode 100644 index 00000000000..83d66bb91f4 --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream + +// basic_istringstream(basic_istringstream&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp new file mode 100644 index 00000000000..5ff47e64244 --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream + +// explicit basic_istringstream(const basic_string<charT,traits,allocator>& str, +// ios_base::openmode which = ios_base::in); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream ss(" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + } + { + std::istringstream ss(" 123 456", std::ios_base::out); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + } + { + std::wistringstream ss(L" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + } + { + std::wistringstream ss(L" 123 456", std::ios_base::out); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + } +} diff --git a/libcxx/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp new file mode 100644 index 00000000000..08b01d3a4db --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream + +// void str(const basic_string<charT,traits,Allocator>& s); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream ss(" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss.str(" 789"); + ss.clear(); + assert(ss.good()); + assert(ss.str() == " 789"); + ss >> i; + assert(i == 789); + } + { + std::wistringstream ss(L" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss.str(L" 789"); + ss.clear(); + assert(ss.good()); + assert(ss.str() == L" 789"); + ss >> i; + assert(i == 789); + } +} diff --git a/libcxx/test/input.output/string.streams/istringstream/types.pass.cpp b/libcxx/test/input.output/string.streams/istringstream/types.pass.cpp new file mode 100644 index 00000000000..8d88da97fe5 --- /dev/null +++ b/libcxx/test/input.output/string.streams/istringstream/types.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_istringstream +// : public basic_istream<charT, traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; +// typedef Allocator allocator_type; + +#include <sstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_istream<char>, std::basic_istringstream<char> >::value), ""); + static_assert((std::is_same<std::basic_istringstream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_istringstream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_istringstream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_istringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_istringstream<char>::off_type, std::char_traits<char>::off_type>::value), ""); + static_assert((std::is_same<std::basic_istringstream<char>::allocator_type, std::allocator<char> >::value), ""); +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..c2ab4f5846b --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream + +// void swap(basic_ostringstream& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream ss0(" 123 456"); + std::ostringstream ss; + ss.swap(ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == "234 5676"); + ss0 << i << ' ' << 567;; + assert(ss0.str() == "234 567"); + } + { + std::wostringstream ss0(L" 123 456"); + std::wostringstream ss; + ss.swap(ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == L"234 5676"); + ss0 << i << ' ' << 567;; + assert(ss0.str() == L"234 567"); + } +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp new file mode 100644 index 00000000000..664473da054 --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream + +// basic_ostringstream& operator=(basic_ostringstream&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..c9780630bc6 --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream + +// void swap(basic_ostringstream& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream ss0(" 123 456"); + std::ostringstream ss; + swap(ss, ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == "234 5676"); + ss0 << i << ' ' << 567;; + assert(ss0.str() == "234 567"); + } + { + std::wostringstream ss0(L" 123 456"); + std::wostringstream ss; + swap(ss, ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == L"234 5676"); + ss0 << i << ' ' << 567;; + assert(ss0.str() == L"234 567"); + } +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp new file mode 100644 index 00000000000..96140bc457c --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream + +// explicit basic_ostringstream(ios_base::openmode which = ios_base::in); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream ss; + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == ""); + } + { + std::ostringstream ss(std::ios_base::out); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == ""); + } + { + std::wostringstream ss; + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L""); + } + { + std::wostringstream ss(std::ios_base::out); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L""); + } +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp new file mode 100644 index 00000000000..799ea36bfdf --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream + +// basic_ostringstream(basic_ostringstream&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp new file mode 100644 index 00000000000..6707ae85719 --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream + +// explicit basic_ostringstream(const basic_string<charT,traits,allocator>& str, +// ios_base::openmode which = ios_base::in); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream ss(" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == "234 5676"); + } + { + std::ostringstream ss(" 123 456", std::ios_base::in); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == "234 5676"); + } + { + std::wostringstream ss(L" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == L"234 5676"); + } + { + std::wostringstream ss(L" 123 456", std::ios_base::in); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 234; + ss << i << ' ' << 567;; + assert(ss.str() == L"234 5676"); + } +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp new file mode 100644 index 00000000000..0025da961e1 --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream + +// void str(const basic_string<charT,traits,Allocator>& s); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream ss(" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456"); + int i = 0; + ss << i; + assert(ss.str() == "0123 456"); + ss << 456; + assert(ss.str() == "0456 456"); + ss.str(" 789"); + assert(ss.str() == " 789"); + ss << "abc"; + assert(ss.str() == "abc9"); + } + { + std::wostringstream ss(L" 123 456"); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456"); + int i = 0; + ss << i; + assert(ss.str() == L"0123 456"); + ss << 456; + assert(ss.str() == L"0456 456"); + ss.str(L" 789"); + assert(ss.str() == L" 789"); + ss << L"abc"; + assert(ss.str() == L"abc9"); + } +} diff --git a/libcxx/test/input.output/string.streams/ostringstream/types.pass.cpp b/libcxx/test/input.output/string.streams/ostringstream/types.pass.cpp new file mode 100644 index 00000000000..24fe1ff3812 --- /dev/null +++ b/libcxx/test/input.output/string.streams/ostringstream/types.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_ostringstream +// : public basic_ostream<charT, traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; +// typedef Allocator allocator_type; + +#include <sstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ostringstream<char> >::value), ""); + static_assert((std::is_same<std::basic_ostringstream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_ostringstream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_ostringstream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_ostringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_ostringstream<char>::off_type, std::char_traits<char>::off_type>::value), ""); + static_assert((std::is_same<std::basic_ostringstream<char>::allocator_type, std::allocator<char> >::value), ""); +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..0562ceae87b --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// void swap(basic_stringbuf& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf buf1("testing"); + std::stringbuf buf; + buf.swap(buf1); + assert(buf.str() == "testing"); + assert(buf1.str() == ""); + } + { + std::stringbuf buf1("testing", std::ios_base::in); + std::stringbuf buf; + buf.swap(buf1); + assert(buf.str() == "testing"); + assert(buf1.str() == ""); + } + { + std::stringbuf buf1("testing", std::ios_base::out); + std::stringbuf buf; + buf.swap(buf1); + assert(buf.str() == "testing"); + assert(buf1.str() == ""); + } + { + std::wstringbuf buf1(L"testing"); + std::wstringbuf buf; + buf.swap(buf1); + assert(buf.str() == L"testing"); + assert(buf1.str() == L""); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::in); + std::wstringbuf buf; + buf.swap(buf1); + assert(buf.str() == L"testing"); + assert(buf1.str() == L""); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::out); + std::wstringbuf buf; + buf.swap(buf1); + assert(buf.str() == L"testing"); + assert(buf1.str() == L""); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp new file mode 100644 index 00000000000..84a978f46e3 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// basic_stringbuf& operator=(basic_stringbuf&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf buf1("testing"); + std::stringbuf buf; + buf = move(buf1); + assert(buf.str() == "testing"); + } + { + std::stringbuf buf1("testing", std::ios_base::in); + std::stringbuf buf; + buf = move(buf1); + assert(buf.str() == "testing"); + } + { + std::stringbuf buf1("testing", std::ios_base::out); + std::stringbuf buf; + buf = move(buf1); + assert(buf.str() == "testing"); + } + { + std::wstringbuf buf1(L"testing"); + std::wstringbuf buf; + buf = move(buf1); + assert(buf.str() == L"testing"); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::in); + std::wstringbuf buf; + buf = move(buf1); + assert(buf.str() == L"testing"); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::out); + std::wstringbuf buf; + buf = move(buf1); + assert(buf.str() == L"testing"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..451a8389154 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// template <class charT, class traits, class Allocator> +// void swap(basic_stringbuf<charT, traits, Allocator>& x, +// basic_stringbuf<charT, traits, Allocator>& y); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf buf1("testing"); + std::stringbuf buf; + swap(buf, buf1); + assert(buf.str() == "testing"); + assert(buf1.str() == ""); + } + { + std::stringbuf buf1("testing", std::ios_base::in); + std::stringbuf buf; + swap(buf, buf1); + assert(buf.str() == "testing"); + assert(buf1.str() == ""); + } + { + std::stringbuf buf1("testing", std::ios_base::out); + std::stringbuf buf; + swap(buf, buf1); + assert(buf.str() == "testing"); + assert(buf1.str() == ""); + } + { + std::wstringbuf buf1(L"testing"); + std::wstringbuf buf; + swap(buf, buf1); + assert(buf.str() == L"testing"); + assert(buf1.str() == L""); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::in); + std::wstringbuf buf; + swap(buf, buf1); + assert(buf.str() == L"testing"); + assert(buf1.str() == L""); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::out); + std::wstringbuf buf; + swap(buf, buf1); + assert(buf.str() == L"testing"); + assert(buf1.str() == L""); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp new file mode 100644 index 00000000000..f8231ba04ed --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf buf; + assert(buf.str() == ""); + } + { + std::wstringbuf buf; + assert(buf.str() == L""); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp new file mode 100644 index 00000000000..bec0464eff2 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// basic_stringbuf(basic_stringbuf&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf buf1("testing"); + std::stringbuf buf(move(buf1)); + assert(buf.str() == "testing"); + } + { + std::stringbuf buf1("testing", std::ios_base::in); + std::stringbuf buf(move(buf1)); + assert(buf.str() == "testing"); + } + { + std::stringbuf buf1("testing", std::ios_base::out); + std::stringbuf buf(move(buf1)); + assert(buf.str() == "testing"); + } + { + std::wstringbuf buf1(L"testing"); + std::wstringbuf buf(move(buf1)); + assert(buf.str() == L"testing"); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::in); + std::wstringbuf buf(move(buf1)); + assert(buf.str() == L"testing"); + } + { + std::wstringbuf buf1(L"testing", std::ios_base::out); + std::wstringbuf buf(move(buf1)); + assert(buf.str() == L"testing"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp new file mode 100644 index 00000000000..53c0081fc57 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// explicit basic_stringbuf(const basic_string<charT,traits,Allocator>& s, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf buf("testing"); + assert(buf.str() == "testing"); + } + { + std::stringbuf buf("testing", std::ios_base::in); + assert(buf.str() == "testing"); + } + { + std::stringbuf buf("testing", std::ios_base::out); + assert(buf.str() == "testing"); + } + { + std::wstringbuf buf(L"testing"); + assert(buf.str() == L"testing"); + } + { + std::wstringbuf buf(L"testing", std::ios_base::in); + assert(buf.str() == L"testing"); + } + { + std::wstringbuf buf(L"testing", std::ios_base::out); + assert(buf.str() == L"testing"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp new file mode 100644 index 00000000000..601e5bcac4f --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// void str(const basic_string<charT,traits,Allocator>& s); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf buf("testing"); + assert(buf.str() == "testing"); + buf.str("another test"); + assert(buf.str() == "another test"); + } + { + std::wstringbuf buf(L"testing"); + assert(buf.str() == L"testing"); + buf.str(L"another test"); + assert(buf.str() == L"another test"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp new file mode 100644 index 00000000000..048f05dc30c --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// int_type overflow(int_type c = traits::eof()); + +#include <sstream> +#include <cassert> + +int overflow_called = 0; + +template <class CharT> +struct testbuf + : public std::basic_stringbuf<CharT> +{ + typedef std::basic_stringbuf<CharT> base; + explicit testbuf(const std::basic_string<CharT>& str, + std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) + : base(str, which) {} + + typename base::int_type + overflow(typename base::int_type c = base::type_traits::eof()) + {++overflow_called; return base::overflow(c);} + + void pbump(int n) {base::pbump(n);} +}; + +int main() +{ + { + testbuf<char> sb("abc"); + assert(sb.sputc('1') == '1'); + assert(sb.str() == "1bc"); + assert(sb.sputc('2') == '2'); + assert(sb.str() == "12c"); + assert(sb.sputc('3') == '3'); + assert(sb.str() == "123"); + assert(sb.sputc('4') == '4'); + assert(sb.str() == "1234"); + assert(sb.sputc('5') == '5'); + assert(sb.str() == "12345"); + assert(sb.sputc('6') == '6'); + assert(sb.str() == "123456"); + assert(sb.sputc('7') == '7'); + assert(sb.str() == "1234567"); + assert(sb.sputc('8') == '8'); + assert(sb.str() == "12345678"); + assert(sb.sputc('9') == '9'); + assert(sb.str() == "123456789"); + assert(sb.sputc('0') == '0'); + assert(sb.str() == "1234567890"); + assert(sb.sputc('1') == '1'); + assert(sb.str() == "12345678901"); + } + { + testbuf<wchar_t> sb(L"abc"); + assert(sb.sputc(L'1') == L'1'); + assert(sb.str() == L"1bc"); + assert(sb.sputc(L'2') == L'2'); + assert(sb.str() == L"12c"); + assert(sb.sputc(L'3') == L'3'); + assert(sb.str() == L"123"); + assert(sb.sputc(L'4') == L'4'); + assert(sb.str() == L"1234"); + assert(sb.sputc(L'5') == L'5'); + assert(sb.str() == L"12345"); + assert(sb.sputc(L'6') == L'6'); + assert(sb.str() == L"123456"); + assert(sb.sputc(L'7') == L'7'); + assert(sb.str() == L"1234567"); + assert(sb.sputc(L'8') == L'8'); + assert(sb.str() == L"12345678"); + assert(sb.sputc(L'9') == L'9'); + assert(sb.str() == L"123456789"); + assert(sb.sputc(L'0') == L'0'); + assert(sb.str() == L"1234567890"); + assert(sb.sputc(L'1') == L'1'); + assert(sb.str() == L"12345678901"); + } + { + testbuf<char> sb("abc", std::ios_base::app | std::ios_base::out); + assert(sb.sputc('1') == '1'); + assert(sb.str() == "abc1"); + assert(sb.sputc('2') == '2'); + assert(sb.str() == "abc12"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp new file mode 100644 index 00000000000..0f85c0c65b1 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// int_type pbackfail(int_type c = traits::eof()); + +#include <sstream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_stringbuf<CharT> +{ + typedef std::basic_stringbuf<CharT> base; + explicit testbuf(const std::basic_string<CharT>& str, + std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) + : base(str, which) {} + + typename base::int_type + pbackfail(typename base::int_type c = base::type_traits::eof()) + {return base::pbackfail(c);} + + void pbump(int n) {base::pbump(n);} +}; + +int main() +{ + { + testbuf<char> sb("123", std::ios_base::in); + assert(sb.sgetc() == '1'); + assert(sb.snextc() == '2'); + assert(sb.snextc() == '3'); + assert(sb.sgetc() == '3'); + assert(sb.snextc() == std::char_traits<char>::eof()); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail('3') == std::char_traits<char>::eof()); + assert(sb.pbackfail('2') == '2'); + assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof()); + assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof()); + assert(sb.str() == "123"); + } + { + testbuf<char> sb("123"); + assert(sb.sgetc() == '1'); + assert(sb.snextc() == '2'); + assert(sb.snextc() == '3'); + assert(sb.sgetc() == '3'); + assert(sb.snextc() == std::char_traits<char>::eof()); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof()); + assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof()); + assert(sb.str() == "133"); + } + { + testbuf<wchar_t> sb(L"123", std::ios_base::in); + assert(sb.sgetc() == L'1'); + assert(sb.snextc() == L'2'); + assert(sb.snextc() == L'3'); + assert(sb.sgetc() == L'3'); + assert(sb.snextc() == std::char_traits<wchar_t>::eof()); + assert(sb.pbackfail(L'3') == L'3'); + assert(sb.pbackfail(L'3') == std::char_traits<wchar_t>::eof()); + assert(sb.pbackfail(L'2') == L'2'); + assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof()); + assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof()); + assert(sb.str() == L"123"); + } + { + testbuf<wchar_t> sb(L"123"); + assert(sb.sgetc() == L'1'); + assert(sb.snextc() == L'2'); + assert(sb.snextc() == L'3'); + assert(sb.sgetc() == L'3'); + assert(sb.snextc() == std::char_traits<wchar_t>::eof()); + assert(sb.pbackfail(L'3') == L'3'); + assert(sb.pbackfail(L'3') == L'3'); + assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof()); + assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof()); + assert(sb.str() == L"133"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp new file mode 100644 index 00000000000..43cc9e0de1e --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp @@ -0,0 +1,143 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// pos_type seekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf sb("0123456789", std::ios_base::in); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(sb.sgetc() == '6'); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(sb.sgetc() == '7'); + } + { + std::stringbuf sb("0123456789", std::ios_base::out); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + assert(sb.sputc('a') == 'a'); + assert(sb.str() == "012a456789"); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); + assert(sb.sputc('b') == 'b'); + assert(sb.str() == "012a456b89"); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); + assert(sb.sputc('c') == 'c'); + assert(sb.str() == "012a456c89"); + } + { + std::stringbuf sb("0123456789"); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(sb.sgetc() == '6'); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(sb.sgetc() == '7'); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + assert(sb.sputc('a') == 'a'); + assert(sb.str() == "012a456789"); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7); + assert(sb.sgetc() == '7'); + assert(sb.sputc('c') == 'c'); + assert(sb.str() == "012a456c89"); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + assert(sb.sputc('3') == '3'); + assert(sb.str() == "0123456c89"); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); + assert(sb.sputc('7') == '7'); + assert(sb.str() == "0123456789"); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); + assert(sb.sputc('c') == 'c'); + assert(sb.str() == "0123456c89"); + } + { + std::wstringbuf sb(L"0123456789", std::ios_base::in); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + assert(sb.sgetc() == L'3'); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(sb.sgetc() == L'6'); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(sb.sgetc() == L'7'); + } + { + std::wstringbuf sb(L"0123456789", std::ios_base::out); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + assert(sb.sputc(L'a') == L'a'); + assert(sb.str() == L"012a456789"); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); + assert(sb.sputc(L'b') == L'b'); + assert(sb.str() == L"012a456b89"); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); + assert(sb.sputc(L'c') == L'c'); + assert(sb.str() == L"012a456c89"); + } + { + std::wstringbuf sb(L"0123456789"); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + assert(sb.sgetc() == L'3'); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(sb.sgetc() == L'6'); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(sb.sgetc() == L'7'); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3); + assert(sb.sgetc() == L'3'); + assert(sb.sputc(L'a') == L'a'); + assert(sb.str() == L"012a456789"); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7); + assert(sb.sgetc() == L'7'); + assert(sb.sputc(L'c') == L'c'); + assert(sb.str() == L"012a456c89"); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + assert(sb.sputc(L'3') == L'3'); + assert(sb.str() == L"0123456c89"); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); + assert(sb.sputc(L'7') == L'7'); + assert(sb.str() == L"0123456789"); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); + assert(sb.sputc(L'c') == L'c'); + assert(sb.str() == L"0123456c89"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp new file mode 100644 index 00000000000..6e2d832a0c8 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf sb("0123456789", std::ios_base::in); + assert(sb.pubseekpos(3, std::ios_base::out) == -1); + assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekpos(3, std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + } + { + std::stringbuf sb("0123456789", std::ios_base::out); + assert(sb.pubseekpos(3, std::ios_base::in) == -1); + assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekpos(3, std::ios_base::out) == 3); + assert(sb.sputc('a') == 'a'); + assert(sb.str() == "012a456789"); + } + { + std::stringbuf sb("0123456789"); + assert(sb.pubseekpos(3, std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + assert(sb.sputc('a') == 'a'); + assert(sb.str() == "012a456789"); + assert(sb.pubseekpos(3, std::ios_base::out) == 3); + assert(sb.sputc('3') == '3'); + assert(sb.str() == "0123456789"); + } + { + std::wstringbuf sb(L"0123456789", std::ios_base::in); + assert(sb.pubseekpos(3, std::ios_base::out) == -1); + assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekpos(3, std::ios_base::in) == 3); + assert(sb.sgetc() == L'3'); + } + { + std::wstringbuf sb(L"0123456789", std::ios_base::out); + assert(sb.pubseekpos(3, std::ios_base::in) == -1); + assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekpos(3, std::ios_base::out) == 3); + assert(sb.sputc(L'a') == L'a'); + assert(sb.str() == L"012a456789"); + } + { + std::wstringbuf sb(L"0123456789"); + assert(sb.pubseekpos(3, std::ios_base::in) == 3); + assert(sb.sgetc() == L'3'); + assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3); + assert(sb.sgetc() == L'3'); + assert(sb.sputc(L'a') == L'a'); + assert(sb.str() == L"012a456789"); + assert(sb.pubseekpos(3, std::ios_base::out) == 3); + assert(sb.sputc(L'3') == L'3'); + assert(sb.str() == L"0123456789"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp new file mode 100644 index 00000000000..184e759305d --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// basic_streambuf<charT,traits>* setbuf(charT* s, streamsize n); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringbuf sb("0123456789"); + assert(sb.pubsetbuf(0, 0) == &sb); + assert(sb.str() == "0123456789"); + } + { + std::wstringbuf sb(L"0123456789"); + assert(sb.pubsetbuf(0, 0) == &sb); + assert(sb.str() == L"0123456789"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp new file mode 100644 index 00000000000..1f5b91e79c4 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf + +// int_type underflow(); + +#include <sstream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_stringbuf<CharT> +{ + typedef std::basic_stringbuf<CharT> base; + explicit testbuf(const std::basic_string<CharT>& str) + : base(str) {} + + typename base::int_type underflow() {return base::underflow();} + void pbump(int n) {base::pbump(n);} +}; + +int main() +{ + { + testbuf<char> sb("123"); + sb.pbump(3); + assert(sb.underflow() == '1'); + assert(sb.underflow() == '1'); + assert(sb.snextc() == '2'); + assert(sb.underflow() == '2'); + assert(sb.underflow() == '2'); + assert(sb.snextc() == '3'); + assert(sb.underflow() == '3'); + assert(sb.underflow() == '3'); + assert(sb.snextc() == std::char_traits<char>::eof()); + assert(sb.underflow() == std::char_traits<char>::eof()); + assert(sb.underflow() == std::char_traits<char>::eof()); + sb.sputc('4'); + assert(sb.underflow() == '4'); + assert(sb.underflow() == '4'); + } + { + testbuf<wchar_t> sb(L"123"); + sb.pbump(3); + assert(sb.underflow() == L'1'); + assert(sb.underflow() == L'1'); + assert(sb.snextc() == L'2'); + assert(sb.underflow() == L'2'); + assert(sb.underflow() == L'2'); + assert(sb.snextc() == L'3'); + assert(sb.underflow() == L'3'); + assert(sb.underflow() == L'3'); + assert(sb.snextc() == std::char_traits<wchar_t>::eof()); + assert(sb.underflow() == std::char_traits<wchar_t>::eof()); + assert(sb.underflow() == std::char_traits<wchar_t>::eof()); + sb.sputc(L'4'); + assert(sb.underflow() == L'4'); + assert(sb.underflow() == L'4'); + } +} diff --git a/libcxx/test/input.output/string.streams/stringbuf/types.pass.cpp b/libcxx/test/input.output/string.streams/stringbuf/types.pass.cpp new file mode 100644 index 00000000000..84930d65cc8 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringbuf/types.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringbuf +// : public basic_streambuf<charT, traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; +// typedef Allocator allocator_type; + +#include <sstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_stringbuf<char> >::value), ""); + static_assert((std::is_same<std::basic_stringbuf<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_stringbuf<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_stringbuf<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_stringbuf<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_stringbuf<char>::off_type, std::char_traits<char>::off_type>::value), ""); + static_assert((std::is_same<std::basic_stringbuf<char>::allocator_type, std::allocator<char> >::value), ""); +} diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/default.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/default.pass.cpp new file mode 100644 index 00000000000..e8c73250b21 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream.cons/default.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream + +// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringstream ss; + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == ""); + } + { + std::stringstream ss(std::ios_base::in); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == ""); + } + { + std::wstringstream ss; + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L""); + } + { + std::wstringstream ss(std::ios_base::in); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L""); + } +} diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/move.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/move.pass.cpp new file mode 100644 index 00000000000..da6821087e9 --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream.cons/move.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream + +// basic_stringstream(basic_stringstream&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/string.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/string.pass.cpp new file mode 100644 index 00000000000..e1e7f636fec --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream.cons/string.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream + +// explicit basic_stringstream(const basic_string<charT,traits,Allocator>& str, +// ios_base::openmode which = ios_base::out|ios_base::in); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringstream ss(" 123 456 "); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == "456 1236 "); + } + { + std::wstringstream ss(L" 123 456 "); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == L"456 1236 "); + } +} diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp new file mode 100644 index 00000000000..6517d20fe1b --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream + +// void swap(basic_stringstream& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringstream ss0(" 123 456 "); + std::stringstream ss; + ss.swap(ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == "456 1236 "); + ss0 << i << ' ' << 123; + assert(ss0.str() == "456 123"); + } + { + std::wstringstream ss0(L" 123 456 "); + std::wstringstream ss; + ss.swap(ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == L"456 1236 "); + ss0 << i << ' ' << 123; + assert(ss0.str() == L"456 123"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp new file mode 100644 index 00000000000..cffc43017ed --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream + +// basic_stringstream& operator=(basic_stringstream&& rhs); + +#include <sstream> +#include <cassert> + +int main() +{ +#ifdef _LIBCPP_MOVE + { + 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 +} diff --git a/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp new file mode 100644 index 00000000000..f5ee2923dfc --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream + +// template <class charT, class traits, class Allocator> +// void +// swap(basic_stringstream<charT, traits, Allocator>& x, +// basic_stringstream<charT, traits, Allocator>& y); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringstream ss0(" 123 456 "); + std::stringstream ss; + swap(ss, ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == "456 1236 "); + ss0 << i << ' ' << 123; + assert(ss0.str() == "456 123"); + } + { + std::wstringstream ss0(L" 123 456 "); + std::wstringstream ss; + swap(ss, ss0); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == L"456 1236 "); + ss0 << i << ' ' << 123; + assert(ss0.str() == L"456 123"); + } +} diff --git a/libcxx/test/input.output/string.streams/stringstream.members/str.pass.cpp b/libcxx/test/input.output/string.streams/stringstream.members/str.pass.cpp new file mode 100644 index 00000000000..1352d0fae0e --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream.members/str.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream + +// void str(const basic_string<charT,traits,Allocator>& str); + +#include <sstream> +#include <cassert> + +int main() +{ + { + std::stringstream ss(" 123 456 "); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == " 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == "456 1236 "); + ss.str("5466 89 "); + ss >> i; + assert(i == 5466); + ss >> i; + assert(i == 89); + ss << i << ' ' << 321; + assert(ss.str() == "89 3219 "); + } + { + std::wstringstream ss(L" 123 456 "); + assert(ss.rdbuf() != 0); + assert(ss.good()); + assert(ss.str() == L" 123 456 "); + int i = 0; + ss >> i; + assert(i == 123); + ss >> i; + assert(i == 456); + ss << i << ' ' << 123; + assert(ss.str() == L"456 1236 "); + ss.str(L"5466 89 "); + ss >> i; + assert(i == 5466); + ss >> i; + assert(i == 89); + ss << i << ' ' << 321; + assert(ss.str() == L"89 3219 "); + } +} diff --git a/libcxx/test/input.output/string.streams/stringstream/types.pass.cpp b/libcxx/test/input.output/string.streams/stringstream/types.pass.cpp new file mode 100644 index 00000000000..0b64c24cfaf --- /dev/null +++ b/libcxx/test/input.output/string.streams/stringstream/types.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > +// class basic_stringstream +// : public basic_iostream<charT, traits> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; +// typedef Allocator allocator_type; + +#include <sstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_stringstream<char> >::value), ""); + static_assert((std::is_same<std::basic_stringstream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_stringstream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_stringstream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_stringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_stringstream<char>::off_type, std::char_traits<char>::off_type>::value), ""); + static_assert((std::is_same<std::basic_stringstream<char>::allocator_type, std::allocator<char> >::value), ""); +} diff --git a/libcxx/test/input.output/string.streams/version.pass.cpp b/libcxx/test/input.output/string.streams/version.pass.cpp new file mode 100644 index 00000000000..05673944cce --- /dev/null +++ b/libcxx/test/input.output/string.streams/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <sstream> + +#include <sstream> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |