Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
929
test/std/input.output/file.streams/c.files/cinttypes.pass.cpp
Normal file
929
test/std/input.output/file.streams/c.files/cinttypes.pass.cpp
Normal file
@@ -0,0 +1,929 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test <cinttypes>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef INT8_MIN
|
||||
#error INT8_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT16_MIN
|
||||
#error INT16_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT32_MIN
|
||||
#error INT32_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT64_MIN
|
||||
#error INT64_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT8_MAX
|
||||
#error INT8_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT16_MAX
|
||||
#error INT16_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT32_MAX
|
||||
#error INT32_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT64_MAX
|
||||
#error INT64_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT8_MAX
|
||||
#error UINT8_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT16_MAX
|
||||
#error UINT16_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
#error UINT32_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT64_MAX
|
||||
#error UINT64_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST8_MIN
|
||||
#error INT_LEAST8_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST16_MIN
|
||||
#error INT_LEAST16_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST32_MIN
|
||||
#error INT_LEAST32_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST64_MIN
|
||||
#error INT_LEAST64_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST8_MAX
|
||||
#error INT_LEAST8_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST16_MAX
|
||||
#error INT_LEAST16_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST32_MAX
|
||||
#error INT_LEAST32_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_LEAST64_MAX
|
||||
#error INT_LEAST64_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_LEAST8_MAX
|
||||
#error UINT_LEAST8_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_LEAST16_MAX
|
||||
#error UINT_LEAST16_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_LEAST32_MAX
|
||||
#error UINT_LEAST32_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_LEAST64_MAX
|
||||
#error UINT_LEAST64_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST8_MIN
|
||||
#error INT_FAST8_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST16_MIN
|
||||
#error INT_FAST16_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST32_MIN
|
||||
#error INT_FAST32_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST64_MIN
|
||||
#error INT_FAST64_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST8_MAX
|
||||
#error INT_FAST8_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST16_MAX
|
||||
#error INT_FAST16_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST32_MAX
|
||||
#error INT_FAST32_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST64_MAX
|
||||
#error INT_FAST64_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_FAST8_MAX
|
||||
#error UINT_FAST8_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_FAST16_MAX
|
||||
#error UINT_FAST16_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_FAST32_MAX
|
||||
#error UINT_FAST32_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT_FAST64_MAX
|
||||
#error UINT_FAST64_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INTPTR_MIN
|
||||
#error INTPTR_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INTPTR_MAX
|
||||
#error INTPTR_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINTPTR_MAX
|
||||
#error UINTPTR_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INTMAX_MIN
|
||||
#error INTMAX_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef INTMAX_MAX
|
||||
#error INTMAX_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINTMAX_MAX
|
||||
#error UINTMAX_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef PTRDIFF_MIN
|
||||
#error PTRDIFF_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef PTRDIFF_MAX
|
||||
#error PTRDIFF_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef SIG_ATOMIC_MIN
|
||||
#error SIG_ATOMIC_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef SIG_ATOMIC_MAX
|
||||
#error SIG_ATOMIC_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#error SIZE_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef WCHAR_MIN
|
||||
#error WCHAR_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef WCHAR_MAX
|
||||
#error WCHAR_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef WINT_MIN
|
||||
#error WINT_MIN not defined
|
||||
#endif
|
||||
|
||||
#ifndef WINT_MAX
|
||||
#error WINT_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT8_C
|
||||
#error INT8_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT16_C
|
||||
#error INT16_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT32_C
|
||||
#error INT32_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef INT64_C
|
||||
#error INT64_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT8_C
|
||||
#error UINT8_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT16_C
|
||||
#error UINT16_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT32_C
|
||||
#error UINT32_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINT64_C
|
||||
#error UINT64_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef INTMAX_C
|
||||
#error INTMAX_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef UINTMAX_C
|
||||
#error UINTMAX_C not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRId8
|
||||
#error PRId8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRId16
|
||||
#error PRId16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRId32
|
||||
#error PRId32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRId64
|
||||
#error PRId64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST8
|
||||
#error PRIdLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST16
|
||||
#error PRIdLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST32
|
||||
#error PRIdLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdLEAST64
|
||||
#error PRIdLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdFAST8
|
||||
#error PRIdFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdFAST16
|
||||
#error PRIdFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdFAST32
|
||||
#error PRIdFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdFAST64
|
||||
#error PRIdFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdMAX
|
||||
#error PRIdMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIdPTR
|
||||
#error PRIdPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIi8
|
||||
#error PRIi8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIi16
|
||||
#error PRIi16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIi32
|
||||
#error PRIi32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIi64
|
||||
#error PRIi64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiLEAST8
|
||||
#error PRIiLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiLEAST16
|
||||
#error PRIiLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiLEAST32
|
||||
#error PRIiLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiLEAST64
|
||||
#error PRIiLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiFAST8
|
||||
#error PRIiFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiFAST16
|
||||
#error PRIiFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiFAST32
|
||||
#error PRIiFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiFAST64
|
||||
#error PRIiFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiMAX
|
||||
#error PRIiMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIiPTR
|
||||
#error PRIiPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIo8
|
||||
#error PRIo8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIo16
|
||||
#error PRIo16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIo32
|
||||
#error PRIo32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIo64
|
||||
#error PRIo64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoLEAST8
|
||||
#error PRIoLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoLEAST16
|
||||
#error PRIoLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoLEAST32
|
||||
#error PRIoLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoLEAST64
|
||||
#error PRIoLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoFAST8
|
||||
#error PRIoFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoFAST16
|
||||
#error PRIoFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoFAST32
|
||||
#error PRIoFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoFAST64
|
||||
#error PRIoFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoMAX
|
||||
#error PRIoMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIoPTR
|
||||
#error PRIoPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIu8
|
||||
#error PRIu8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIu16
|
||||
#error PRIu16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIu32
|
||||
#error PRIu32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIu64
|
||||
#error PRIu64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuLEAST8
|
||||
#error PRIuLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuLEAST16
|
||||
#error PRIuLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuLEAST32
|
||||
#error PRIuLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuLEAST64
|
||||
#error PRIuLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuFAST8
|
||||
#error PRIuFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuFAST16
|
||||
#error PRIuFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuFAST32
|
||||
#error PRIuFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuFAST64
|
||||
#error PRIuFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuMAX
|
||||
#error PRIuMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIuPTR
|
||||
#error PRIuPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIx8
|
||||
#error PRIx8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIx16
|
||||
#error PRIx16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIx32
|
||||
#error PRIx32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIx64
|
||||
#error PRIx64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxLEAST8
|
||||
#error PRIxLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxLEAST16
|
||||
#error PRIxLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxLEAST32
|
||||
#error PRIxLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxLEAST64
|
||||
#error PRIxLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxFAST8
|
||||
#error PRIxFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxFAST16
|
||||
#error PRIxFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxFAST32
|
||||
#error PRIxFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxFAST64
|
||||
#error PRIxFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxMAX
|
||||
#error PRIxMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIxPTR
|
||||
#error PRIxPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIX8
|
||||
#error PRIX8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIX16
|
||||
#error PRIX16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIX32
|
||||
#error PRIX32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIX64
|
||||
#error PRIX64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXLEAST8
|
||||
#error PRIXLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXLEAST16
|
||||
#error PRIXLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXLEAST32
|
||||
#error PRIXLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXLEAST64
|
||||
#error PRIXLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXFAST8
|
||||
#error PRIXFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXFAST16
|
||||
#error PRIXFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXFAST32
|
||||
#error PRIXFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXFAST64
|
||||
#error PRIXFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXMAX
|
||||
#error PRIXMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef PRIXPTR
|
||||
#error PRIXPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNd8
|
||||
#error SCNd8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNd16
|
||||
#error SCNd16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNd32
|
||||
#error SCNd32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNd64
|
||||
#error SCNd64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdLEAST8
|
||||
#error SCNdLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdLEAST16
|
||||
#error SCNdLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdLEAST32
|
||||
#error SCNdLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdLEAST64
|
||||
#error SCNdLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdFAST8
|
||||
#error SCNdFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdFAST16
|
||||
#error SCNdFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdFAST32
|
||||
#error SCNdFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdFAST64
|
||||
#error SCNdFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdMAX
|
||||
#error SCNdMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNdPTR
|
||||
#error SCNdPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNi8
|
||||
#error SCNi8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNi16
|
||||
#error SCNi16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNi32
|
||||
#error SCNi32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNi64
|
||||
#error SCNi64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiLEAST8
|
||||
#error SCNiLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiLEAST16
|
||||
#error SCNiLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiLEAST32
|
||||
#error SCNiLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiLEAST64
|
||||
#error SCNiLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiFAST8
|
||||
#error SCNiFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiFAST16
|
||||
#error SCNiFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiFAST32
|
||||
#error SCNiFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiFAST64
|
||||
#error SCNiFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiMAX
|
||||
#error SCNiMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNiPTR
|
||||
#error SCNiPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNo8
|
||||
#error SCNo8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNo16
|
||||
#error SCNo16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNo32
|
||||
#error SCNo32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNo64
|
||||
#error SCNo64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoLEAST8
|
||||
#error SCNoLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoLEAST16
|
||||
#error SCNoLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoLEAST32
|
||||
#error SCNoLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoLEAST64
|
||||
#error SCNoLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoFAST8
|
||||
#error SCNoFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoFAST16
|
||||
#error SCNoFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoFAST32
|
||||
#error SCNoFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoFAST64
|
||||
#error SCNoFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoMAX
|
||||
#error SCNoMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNoPTR
|
||||
#error SCNoPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNu8
|
||||
#error SCNu8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNu16
|
||||
#error SCNu16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNu32
|
||||
#error SCNu32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNu64
|
||||
#error SCNu64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuLEAST8
|
||||
#error SCNuLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuLEAST16
|
||||
#error SCNuLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuLEAST32
|
||||
#error SCNuLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuLEAST64
|
||||
#error SCNuLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuFAST8
|
||||
#error SCNuFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuFAST16
|
||||
#error SCNuFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuFAST32
|
||||
#error SCNuFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuFAST64
|
||||
#error SCNuFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuMAX
|
||||
#error SCNuMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNuPTR
|
||||
#error SCNuPTR not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNx8
|
||||
#error SCNx8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNx16
|
||||
#error SCNx16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNx32
|
||||
#error SCNx32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNx64
|
||||
#error SCNx64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxLEAST8
|
||||
#error SCNxLEAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxLEAST16
|
||||
#error SCNxLEAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxLEAST32
|
||||
#error SCNxLEAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxLEAST64
|
||||
#error SCNxLEAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxFAST8
|
||||
#error SCNxFAST8 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxFAST16
|
||||
#error SCNxFAST16 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxFAST32
|
||||
#error SCNxFAST32 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxFAST64
|
||||
#error SCNxFAST64 not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxMAX
|
||||
#error SCNxMAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef SCNxPTR
|
||||
#error SCNxPTR not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::int8_t i1 = 0;
|
||||
std::int16_t i2 = 0;
|
||||
std::int32_t i3 = 0;
|
||||
std::int64_t i4 = 0;
|
||||
}
|
||||
{
|
||||
std::uint8_t i1 = 0;
|
||||
std::uint16_t i2 = 0;
|
||||
std::uint32_t i3 = 0;
|
||||
std::uint64_t i4 = 0;
|
||||
}
|
||||
{
|
||||
std::int_least8_t i1 = 0;
|
||||
std::int_least16_t i2 = 0;
|
||||
std::int_least32_t i3 = 0;
|
||||
std::int_least64_t i4 = 0;
|
||||
}
|
||||
{
|
||||
std::uint_least8_t i1 = 0;
|
||||
std::uint_least16_t i2 = 0;
|
||||
std::uint_least32_t i3 = 0;
|
||||
std::uint_least64_t i4 = 0;
|
||||
}
|
||||
{
|
||||
std::int_fast8_t i1 = 0;
|
||||
std::int_fast16_t i2 = 0;
|
||||
std::int_fast32_t i3 = 0;
|
||||
std::int_fast64_t i4 = 0;
|
||||
}
|
||||
{
|
||||
std::uint_fast8_t i1 = 0;
|
||||
std::uint_fast16_t i2 = 0;
|
||||
std::uint_fast32_t i3 = 0;
|
||||
std::uint_fast64_t i4 = 0;
|
||||
}
|
||||
{
|
||||
std::intptr_t i1 = 0;
|
||||
std::uintptr_t i2 = 0;
|
||||
std::intmax_t i3 = 0;
|
||||
std::uintmax_t i4 = 0;
|
||||
}
|
||||
{
|
||||
std::imaxdiv_t i1 = {0};
|
||||
}
|
||||
std::intmax_t i = 0;
|
||||
static_assert((std::is_same<decltype(std::imaxabs(i)), std::intmax_t>::value), "");
|
||||
static_assert((std::is_same<decltype(std::imaxdiv(i, i)), std::imaxdiv_t>::value), "");
|
||||
static_assert((std::is_same<decltype(std::strtoimax("", (char**)0, 0)), std::intmax_t>::value), "");
|
||||
static_assert((std::is_same<decltype(std::strtoumax("", (char**)0, 0)), std::uintmax_t>::value), "");
|
||||
static_assert((std::is_same<decltype(std::wcstoimax(L"", (wchar_t**)0, 0)), std::intmax_t>::value), "");
|
||||
static_assert((std::is_same<decltype(std::wcstoumax(L"", (wchar_t**)0, 0)), std::uintmax_t>::value), "");
|
||||
}
|
139
test/std/input.output/file.streams/c.files/cstdio.pass.cpp
Normal file
139
test/std/input.output/file.streams/c.files/cstdio.pass.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test <cstdio>
|
||||
|
||||
#include <cstdio>
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef BUFSIZ
|
||||
#error BUFSIZ not defined
|
||||
#endif
|
||||
|
||||
#ifndef EOF
|
||||
#error EOF not defined
|
||||
#endif
|
||||
|
||||
#ifndef FILENAME_MAX
|
||||
#error FILENAME_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef FOPEN_MAX
|
||||
#error FOPEN_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef L_tmpnam
|
||||
#error L_tmpnam not defined
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#error NULL not defined
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_CUR
|
||||
#error SEEK_CUR not defined
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_END
|
||||
#error SEEK_END not defined
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#error SEEK_SET not defined
|
||||
#endif
|
||||
|
||||
#ifndef TMP_MAX
|
||||
#error TMP_MAX not defined
|
||||
#endif
|
||||
|
||||
#ifndef _IOFBF
|
||||
#error _IOFBF not defined
|
||||
#endif
|
||||
|
||||
#ifndef _IOLBF
|
||||
#error _IOLBF not defined
|
||||
#endif
|
||||
|
||||
#ifndef _IONBF
|
||||
#error _IONBF not defined
|
||||
#endif
|
||||
|
||||
#ifndef stderr
|
||||
#error stderr not defined
|
||||
#endif
|
||||
|
||||
#ifndef stdin
|
||||
#error stdin not defined
|
||||
#endif
|
||||
|
||||
#ifndef stdout
|
||||
#error stdout not defined
|
||||
#endif
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wformat-zero-length"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::FILE* fp = 0;
|
||||
std::fpos_t fpos = {0};
|
||||
std::size_t s = 0;
|
||||
char* cp = 0;
|
||||
std::va_list va;
|
||||
static_assert((std::is_same<decltype(std::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), "");
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
|
||||
#endif
|
||||
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), "");
|
||||
}
|
23
test/std/input.output/file.streams/c.files/gets.fail.cpp
Normal file
23
test/std/input.output/file.streams/c.files/gets.fail.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test <cstdio>
|
||||
|
||||
// gets
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
(void) std::gets((char *) NULL);
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <cstdio>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <cinttypes>
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_filebuf
|
||||
|
||||
// void swap(basic_filebuf& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::filebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn("123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == '2');
|
||||
std::filebuf f2;
|
||||
f2.swap(f);
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == '2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfilebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn(L"123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == L'2');
|
||||
std::wfilebuf f2;
|
||||
f2.swap(f);
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == L'2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_filebuf
|
||||
|
||||
// basic_filebuf& operator=(basic_filebuf&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::filebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn("123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == '2');
|
||||
std::filebuf f2;
|
||||
f2 = move(f);
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == '2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfilebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn(L"123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == L'2');
|
||||
std::wfilebuf f2;
|
||||
f2 = move(f);
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == L'2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_filebuf
|
||||
|
||||
// template <class charT, class traits>
|
||||
// void
|
||||
// swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::filebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn("123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == '2');
|
||||
std::filebuf f2;
|
||||
swap(f2, f);
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == '2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfilebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn(L"123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == L'2');
|
||||
std::wfilebuf f2;
|
||||
swap(f2, f);
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == L'2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_filebuf
|
||||
|
||||
// basic_filebuf();
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::filebuf f;
|
||||
assert(!f.is_open());
|
||||
}
|
||||
{
|
||||
std::wfilebuf f;
|
||||
assert(!f.is_open());
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_filebuf
|
||||
|
||||
// basic_filebuf(basic_filebuf&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::filebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn("123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == '2');
|
||||
std::filebuf f2(move(f));
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == '2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfilebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn(L"123", 3) == 3);
|
||||
f.pubseekoff(1, std::ios_base::beg);
|
||||
assert(f.sgetc() == L'2');
|
||||
std::wfilebuf f2(move(f));
|
||||
assert(!f.is_open());
|
||||
assert(f2.is_open());
|
||||
assert(f2.sgetc() == L'2');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// basic_filebuf<charT,traits>* open(const char* s, ios_base::openmode mode);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::filebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn("123", 3) == 3);
|
||||
}
|
||||
{
|
||||
std::filebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == '1');
|
||||
assert(f.sbumpc() == '2');
|
||||
assert(f.sbumpc() == '3');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfilebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sputn(L"123", 3) == 3);
|
||||
}
|
||||
{
|
||||
std::wfilebuf f;
|
||||
assert(f.open(temp.c_str(), std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == L'1');
|
||||
assert(f.sbumpc() == L'2');
|
||||
assert(f.sbumpc() == L'3');
|
||||
}
|
||||
remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,142 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// int_type overflow(int_type c = traits::eof());
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
struct test_buf
|
||||
: public std::basic_filebuf<CharT>
|
||||
{
|
||||
typedef std::basic_filebuf<CharT> base;
|
||||
typedef typename base::char_type char_type;
|
||||
typedef typename base::int_type int_type;
|
||||
typedef typename base::traits_type traits_type;
|
||||
|
||||
char_type* pbase() const {return base::pbase();}
|
||||
char_type* pptr() const {return base::pptr();}
|
||||
char_type* epptr() const {return base::epptr();}
|
||||
void gbump(int n) {base::gbump(n);}
|
||||
|
||||
virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow('a') == 'a');
|
||||
assert(f.pbase() != 0);
|
||||
assert(f.pptr() == f.pbase());
|
||||
assert(f.epptr() - f.pbase() == 4095);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == 'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<char> f;
|
||||
f.pubsetbuf(0, 0);
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow('a') == 'a');
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == 'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow(L'a') == L'a');
|
||||
assert(f.pbase() != 0);
|
||||
assert(f.pptr() == f.pbase());
|
||||
assert(f.epptr() - f.pbase() == 4095);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == L'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
f.pubsetbuf(0, 0);
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
assert(f.overflow(L'a') == L'a');
|
||||
assert(f.pbase() == 0);
|
||||
assert(f.pptr() == 0);
|
||||
assert(f.epptr() == 0);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sgetc() == L'a');
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
assert(f.open("overflow.dat", std::ios_base::out) != 0);
|
||||
assert(f.sputc(0x4E51) == 0x4E51);
|
||||
assert(f.sputc(0x4E52) == 0x4E52);
|
||||
assert(f.sputc(0x4E53) == 0x4E53);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("overflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == 0xE4);
|
||||
assert(f.sbumpc() == 0xB9);
|
||||
assert(f.sbumpc() == 0x91);
|
||||
assert(f.sbumpc() == 0xE4);
|
||||
assert(f.sbumpc() == 0xB9);
|
||||
assert(f.sbumpc() == 0x92);
|
||||
assert(f.sbumpc() == 0xE4);
|
||||
assert(f.sbumpc() == 0xB9);
|
||||
assert(f.sbumpc() == 0x93);
|
||||
assert(f.sbumpc() == -1);
|
||||
}
|
||||
std::remove("overflow.dat");
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// int_type pbackfail(int_type c = traits::eof());
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct test_buf
|
||||
: public std::basic_filebuf<CharT>
|
||||
{
|
||||
typedef std::basic_filebuf<CharT> base;
|
||||
typedef typename base::char_type char_type;
|
||||
typedef typename base::int_type int_type;
|
||||
typedef typename base::traits_type traits_type;
|
||||
|
||||
char_type* eback() const {return base::eback();}
|
||||
char_type* gptr() const {return base::gptr();}
|
||||
char_type* egptr() const {return base::egptr();}
|
||||
void gbump(int n) {base::gbump(n);}
|
||||
|
||||
virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == '1');
|
||||
assert(f.sgetc() == '2');
|
||||
assert(f.pbackfail('a') == -1);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == '1');
|
||||
assert(f.sgetc() == '2');
|
||||
assert(f.pbackfail('a') == 'a');
|
||||
assert(f.sbumpc() == 'a');
|
||||
assert(f.sgetc() == '2');
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// pos_type seekoff(off_type off, ios_base::seekdir way,
|
||||
// ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
// pos_type seekpos(pos_type sp,
|
||||
// ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
char buf[10];
|
||||
typedef std::filebuf::pos_type pos_type;
|
||||
std::filebuf f;
|
||||
f.pubsetbuf(buf, sizeof(buf));
|
||||
assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
f.sputn("abcdefghijklmnopqrstuvwxyz", 26);
|
||||
assert(buf[0] == 'v');
|
||||
pos_type p = f.pubseekoff(-15, std::ios_base::cur);
|
||||
assert(p == 11);
|
||||
assert(f.sgetc() == 'l');
|
||||
f.pubseekoff(0, std::ios_base::beg);
|
||||
assert(f.sgetc() == 'a');
|
||||
f.pubseekoff(-1, std::ios_base::end);
|
||||
assert(f.sgetc() == 'z');
|
||||
assert(f.pubseekpos(p) == p);
|
||||
assert(f.sgetc() == 'l');
|
||||
}
|
||||
std::remove("seekoff.dat");
|
||||
{
|
||||
wchar_t buf[10];
|
||||
typedef std::filebuf::pos_type pos_type;
|
||||
std::wfilebuf f;
|
||||
f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
|
||||
assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc) != 0);
|
||||
assert(f.is_open());
|
||||
f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
|
||||
assert(buf[0] == L'v');
|
||||
pos_type p = f.pubseekoff(-15, std::ios_base::cur);
|
||||
assert(p == 11);
|
||||
assert(f.sgetc() == L'l');
|
||||
f.pubseekoff(0, std::ios_base::beg);
|
||||
assert(f.sgetc() == L'a');
|
||||
f.pubseekoff(-1, std::ios_base::end);
|
||||
assert(f.sgetc() == L'z');
|
||||
assert(f.pubseekpos(p) == p);
|
||||
assert(f.sgetc() == L'l');
|
||||
}
|
||||
std::remove("seekoff.dat");
|
||||
}
|
@@ -0,0 +1 @@
|
||||
123456789
|
@@ -0,0 +1,121 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// int_type underflow();
|
||||
|
||||
// This test is not entirely portable
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
struct test_buf
|
||||
: public std::basic_filebuf<CharT>
|
||||
{
|
||||
typedef std::basic_filebuf<CharT> base;
|
||||
typedef typename base::char_type char_type;
|
||||
typedef typename base::int_type int_type;
|
||||
|
||||
char_type* eback() const {return base::eback();}
|
||||
char_type* gptr() const {return base::gptr();}
|
||||
char_type* egptr() const {return base::egptr();}
|
||||
void gbump(int n) {base::gbump(n);}
|
||||
|
||||
virtual int_type underflow() {return base::underflow();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == '1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == '1');
|
||||
assert(f.egptr() - f.eback() == 9);
|
||||
}
|
||||
{
|
||||
test_buf<char> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.pubsetbuf(0, 0));
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == '1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == '1');
|
||||
assert(f.egptr() - f.eback() == 8);
|
||||
f.gbump(8);
|
||||
assert(f.sgetc() == '9');
|
||||
assert(f.eback()[0] == '5');
|
||||
assert(f.eback()[1] == '6');
|
||||
assert(f.eback()[2] == '7');
|
||||
assert(f.eback()[3] == '8');
|
||||
assert(f.gptr() - f.eback() == 4);
|
||||
assert(*f.gptr() == '9');
|
||||
assert(f.egptr() - f.gptr() == 1);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == L'1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == L'1');
|
||||
assert(f.egptr() - f.eback() == 9);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
assert(f.pubsetbuf(0, 0));
|
||||
assert(f.open("underflow.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.eback() == 0);
|
||||
assert(f.gptr() == 0);
|
||||
assert(f.egptr() == 0);
|
||||
assert(f.underflow() == L'1');
|
||||
assert(f.eback() != 0);
|
||||
assert(f.eback() == f.gptr());
|
||||
assert(*f.gptr() == L'1');
|
||||
assert(f.egptr() - f.eback() == 8);
|
||||
f.gbump(8);
|
||||
assert(f.sgetc() == L'9');
|
||||
assert(f.eback()[0] == L'5');
|
||||
assert(f.eback()[1] == L'6');
|
||||
assert(f.eback()[2] == L'7');
|
||||
assert(f.eback()[3] == L'8');
|
||||
assert(f.gptr() - f.eback() == 4);
|
||||
assert(*f.gptr() == L'9');
|
||||
assert(f.egptr() - f.gptr() == 1);
|
||||
}
|
||||
{
|
||||
test_buf<wchar_t> f;
|
||||
f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
assert(f.open("underflow_utf8.dat", std::ios_base::in) != 0);
|
||||
assert(f.is_open());
|
||||
assert(f.sbumpc() == 0x4E51);
|
||||
assert(f.sbumpc() == 0x4E52);
|
||||
assert(f.sbumpc() == 0x4E53);
|
||||
assert(f.sbumpc() == -1);
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
乑乒乓
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_filebuf
|
||||
// : public basic_streambuf<charT, traits>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef typename traits_type::int_type int_type;
|
||||
// typedef typename traits_type::pos_type pos_type;
|
||||
// typedef typename traits_type::off_type off_type;
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_filebuf<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_filebuf<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_filebuf<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_filebuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_filebuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_filebuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// void swap(basic_fstream& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp1 = get_temp_file_name();
|
||||
std::string temp2 = get_temp_file_name();
|
||||
{
|
||||
std::fstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
fs1 << 1 << ' ' << 2;
|
||||
fs2 << 2 << ' ' << 1;
|
||||
fs1.seekg(0);
|
||||
fs1.swap(fs2);
|
||||
fs1.seekg(0);
|
||||
int i;
|
||||
fs1 >> i;
|
||||
assert(i == 2);
|
||||
fs1 >> i;
|
||||
assert(i == 1);
|
||||
i = 0;
|
||||
fs2 >> i;
|
||||
assert(i == 1);
|
||||
fs2 >> i;
|
||||
assert(i == 2);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
std::remove(temp2.c_str());
|
||||
{
|
||||
std::wfstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
fs1 << 1 << ' ' << 2;
|
||||
fs2 << 2 << ' ' << 1;
|
||||
fs1.seekg(0);
|
||||
fs1.swap(fs2);
|
||||
fs1.seekg(0);
|
||||
int i;
|
||||
fs1 >> i;
|
||||
assert(i == 2);
|
||||
fs1 >> i;
|
||||
assert(i == 1);
|
||||
i = 0;
|
||||
fs2 >> i;
|
||||
assert(i == 1);
|
||||
fs2 >> i;
|
||||
assert(i == 2);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
std::remove(temp2.c_str());
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// basic_fstream& operator=(basic_fstream&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::fstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::fstream fs;
|
||||
fs = move(fso);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::wfstream fs;
|
||||
fs = move(fso);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// template <class charT, class traits>
|
||||
// void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp1 = get_temp_file_name();
|
||||
std::string temp2 = get_temp_file_name();
|
||||
{
|
||||
std::fstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
fs1 << 1 << ' ' << 2;
|
||||
fs2 << 2 << ' ' << 1;
|
||||
fs1.seekg(0);
|
||||
swap(fs1, fs2);
|
||||
fs1.seekg(0);
|
||||
int i;
|
||||
fs1 >> i;
|
||||
assert(i == 2);
|
||||
fs1 >> i;
|
||||
assert(i == 1);
|
||||
i = 0;
|
||||
fs2 >> i;
|
||||
assert(i == 1);
|
||||
fs2 >> i;
|
||||
assert(i == 2);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
std::remove(temp2.c_str());
|
||||
{
|
||||
std::wfstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
fs1 << 1 << ' ' << 2;
|
||||
fs2 << 2 << ' ' << 1;
|
||||
fs1.seekg(0);
|
||||
swap(fs1, fs2);
|
||||
fs1.seekg(0);
|
||||
int i;
|
||||
fs1 >> i;
|
||||
assert(i == 2);
|
||||
fs1 >> i;
|
||||
assert(i == 1);
|
||||
i = 0;
|
||||
fs2 >> i;
|
||||
assert(i == 1);
|
||||
fs2 >> i;
|
||||
assert(i == 2);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
std::remove(temp2.c_str());
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// basic_fstream();
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::fstream fs;
|
||||
}
|
||||
{
|
||||
std::wfstream fs;
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// basic_fstream(basic_fstream&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::fstream fso(temp, std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::fstream fs = move(fso);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
std::wfstream fs = move(fso);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in | ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::fstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::fstream fs(temp,
|
||||
std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfstream fs(temp,
|
||||
std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// void close();
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::fstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp.c_str(), std::ios_base::out);
|
||||
assert(fs.is_open());
|
||||
fs.close();
|
||||
assert(!fs.is_open());
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp.c_str(), std::ios_base::out);
|
||||
assert(fs.is_open());
|
||||
fs.close();
|
||||
assert(!fs.is_open());
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::fstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
assert(fs.is_open());
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
assert(fs.is_open());
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::fstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp, std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
assert(fs.is_open());
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wfstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp, std::ios_base::in | std::ios_base::out
|
||||
| std::ios_base::trunc);
|
||||
assert(fs.is_open());
|
||||
double x = 0;
|
||||
fs << 3.25;
|
||||
fs.seekg(0);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
|
||||
// basic_filebuf<charT,traits>* rdbuf() const;
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::fstream fs;
|
||||
assert(fs.rdbuf());
|
||||
}
|
||||
{
|
||||
std::wfstream fs;
|
||||
assert(fs.rdbuf());
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_fstream
|
||||
// : public basic_iostream<charT,traits>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef typename traits_type::int_type int_type;
|
||||
// typedef typename traits_type::pos_type pos_type;
|
||||
// typedef typename traits_type::off_type off_type;
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_fstream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_fstream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_fstream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_fstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_fstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_fstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// void swap(basic_ifstream& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs1("test.dat");
|
||||
std::ifstream fs2("test2.dat");
|
||||
fs1.swap(fs2);
|
||||
double x = 0;
|
||||
fs1 >> x;
|
||||
assert(x == 4.5);
|
||||
fs2 >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fs1("test.dat");
|
||||
std::wifstream fs2("test2.dat");
|
||||
fs1.swap(fs2);
|
||||
double x = 0;
|
||||
fs1 >> x;
|
||||
assert(x == 4.5);
|
||||
fs2 >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// basic_ifstream& operator=(basic_ifstream&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::ifstream fso("test.dat");
|
||||
std::ifstream fs;
|
||||
fs = move(fso);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fso("test.dat");
|
||||
std::wifstream fs;
|
||||
fs = move(fso);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// template <class charT, class traits>
|
||||
// void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs1("test.dat");
|
||||
std::ifstream fs2("test2.dat");
|
||||
swap(fs1, fs2);
|
||||
double x = 0;
|
||||
fs1 >> x;
|
||||
assert(x == 4.5);
|
||||
fs2 >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fs1("test.dat");
|
||||
std::wifstream fs2("test2.dat");
|
||||
swap(fs1, fs2);
|
||||
double x = 0;
|
||||
fs1 >> x;
|
||||
assert(x == 4.5);
|
||||
fs2 >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
3.25
|
@@ -0,0 +1 @@
|
||||
4.5
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// basic_ifstream();
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs;
|
||||
}
|
||||
{
|
||||
std::wifstream fs;
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// basic_ifstream(basic_ifstream&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::ifstream fso("test.dat");
|
||||
std::ifstream fs = move(fso);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fso("test.dat");
|
||||
std::wifstream fs = move(fso);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs("test.dat");
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::ifstream fs("test.dat", std::ios_base::out);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fs("test.dat");
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fs("test.dat", std::ios_base::out);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs(std::string("test.dat"));
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::ifstream fs(std::string("test.dat"), std::ios_base::out);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fs(std::string("test.dat"));
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
{
|
||||
std::wifstream fs(std::string("test.dat"), std::ios_base::out);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
3.25
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// void close();
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open("test.dat");
|
||||
assert(fs.is_open());
|
||||
fs.close();
|
||||
assert(!fs.is_open());
|
||||
}
|
||||
{
|
||||
std::wifstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open("test.dat");
|
||||
assert(fs.is_open());
|
||||
fs.close();
|
||||
assert(!fs.is_open());
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// void open(const char* s, ios_base::openmode mode = ios_base::in);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs;
|
||||
assert(!fs.is_open());
|
||||
char c = 'a';
|
||||
fs >> c;
|
||||
assert(fs.fail());
|
||||
assert(c == 'a');
|
||||
fs.open("test.dat");
|
||||
assert(fs.is_open());
|
||||
fs >> c;
|
||||
assert(c == 'r');
|
||||
}
|
||||
{
|
||||
std::wifstream fs;
|
||||
assert(!fs.is_open());
|
||||
wchar_t c = L'a';
|
||||
fs >> c;
|
||||
assert(fs.fail());
|
||||
assert(c == L'a');
|
||||
fs.open("test.dat");
|
||||
assert(fs.is_open());
|
||||
fs >> c;
|
||||
assert(c == L'r');
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// void open(const string& s, ios_base::openmode mode = ios_base::in);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs;
|
||||
assert(!fs.is_open());
|
||||
char c = 'a';
|
||||
fs >> c;
|
||||
assert(fs.fail());
|
||||
assert(c == 'a');
|
||||
fs.open(std::string("test.dat"));
|
||||
assert(fs.is_open());
|
||||
fs >> c;
|
||||
assert(c == 'r');
|
||||
}
|
||||
{
|
||||
std::wifstream fs;
|
||||
assert(!fs.is_open());
|
||||
wchar_t c = L'a';
|
||||
fs >> c;
|
||||
assert(fs.fail());
|
||||
assert(c == L'a');
|
||||
fs.open(std::string("test.dat"));
|
||||
assert(fs.is_open());
|
||||
fs >> c;
|
||||
assert(c == L'r');
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
|
||||
// basic_filebuf<charT,traits>* rdbuf() const;
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ifstream fs("test.dat");
|
||||
std::filebuf* fb = fs.rdbuf();
|
||||
assert(fb->sgetc() == 'r');
|
||||
}
|
||||
{
|
||||
std::wifstream fs("test.dat");
|
||||
std::wfilebuf* fb = fs.rdbuf();
|
||||
assert(fb->sgetc() == L'r');
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
r
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ifstream
|
||||
// : public basic_istream<charT,traits>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef typename traits_type::int_type int_type;
|
||||
// typedef typename traits_type::pos_type pos_type;
|
||||
// typedef typename traits_type::off_type off_type;
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_istream<char>, std::basic_ifstream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ifstream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_ifstream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ifstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ifstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ifstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// void swap(basic_ofstream& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp1 = get_temp_file_name();
|
||||
std::string temp2 = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs1(temp1.c_str());
|
||||
std::ofstream fs2(temp2.c_str());
|
||||
fs1 << 3.25;
|
||||
fs2 << 4.5;
|
||||
fs1.swap(fs2);
|
||||
fs1 << ' ' << 3.25;
|
||||
fs2 << ' ' << 4.5;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp1.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
{
|
||||
std::ifstream fs(temp2.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp2.c_str());
|
||||
{
|
||||
std::wofstream fs1(temp1.c_str());
|
||||
std::wofstream fs2(temp2.c_str());
|
||||
fs1 << 3.25;
|
||||
fs2 << 4.5;
|
||||
fs1.swap(fs2);
|
||||
fs1 << ' ' << 3.25;
|
||||
fs2 << ' ' << 4.5;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp1.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
{
|
||||
std::wifstream fs(temp2.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp2.c_str());
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// basic_ofstream& operator=(basic_ofstream&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fso(temp.c_str());
|
||||
std::ofstream fs;
|
||||
fs = move(fso);
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fso(temp.c_str());
|
||||
std::wofstream fs;
|
||||
fs = move(fso);
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// template <class charT, class traits>
|
||||
// void swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp1 = get_temp_file_name();
|
||||
std::string temp2 = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs1(temp1.c_str());
|
||||
std::ofstream fs2(temp2.c_str());
|
||||
fs1 << 3.25;
|
||||
fs2 << 4.5;
|
||||
swap(fs1, fs2);
|
||||
fs1 << ' ' << 3.25;
|
||||
fs2 << ' ' << 4.5;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp1.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
{
|
||||
std::ifstream fs(temp2.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp2.c_str());
|
||||
{
|
||||
std::wofstream fs1(temp1.c_str());
|
||||
std::wofstream fs2(temp2.c_str());
|
||||
fs1 << 3.25;
|
||||
fs2 << 4.5;
|
||||
swap(fs1, fs2);
|
||||
fs1 << ' ' << 3.25;
|
||||
fs2 << ' ' << 4.5;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp1.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
}
|
||||
std::remove(temp1.c_str());
|
||||
{
|
||||
std::wifstream fs(temp2.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 4.5);
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp2.c_str());
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// basic_ofstream();
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ofstream fs;
|
||||
}
|
||||
{
|
||||
std::wofstream fs;
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// basic_ofstream(basic_ofstream&& rhs);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fso(temp.c_str());
|
||||
std::ofstream fs = move(fso);
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fso(temp.c_str());
|
||||
std::wofstream fs = move(fso);
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs(temp.c_str());
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fs(temp.c_str());
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp.c_str());
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs(temp);
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fs(temp);
|
||||
fs << 3.25;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp);
|
||||
double x = 0;
|
||||
fs >> x;
|
||||
assert(x == 3.25);
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// void close();
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp.c_str());
|
||||
assert(fs.is_open());
|
||||
fs.close();
|
||||
assert(!fs.is_open());
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fs;
|
||||
assert(!fs.is_open());
|
||||
fs.open(temp.c_str());
|
||||
assert(fs.is_open());
|
||||
fs.close();
|
||||
assert(!fs.is_open());
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// void open(const char* s, ios_base::openmode mode = ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs;
|
||||
assert(!fs.is_open());
|
||||
char c = 'a';
|
||||
fs << c;
|
||||
assert(fs.fail());
|
||||
fs.open(temp.c_str());
|
||||
assert(fs.is_open());
|
||||
fs << c;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp.c_str());
|
||||
char c = 0;
|
||||
fs >> c;
|
||||
assert(c == 'a');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fs;
|
||||
assert(!fs.is_open());
|
||||
wchar_t c = L'a';
|
||||
fs << c;
|
||||
assert(fs.fail());
|
||||
fs.open(temp.c_str());
|
||||
assert(fs.is_open());
|
||||
fs << c;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp.c_str());
|
||||
wchar_t c = 0;
|
||||
fs >> c;
|
||||
assert(c == L'a');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// void open(const string& s, ios_base::openmode mode = ios_base::out);
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs;
|
||||
assert(!fs.is_open());
|
||||
char c = 'a';
|
||||
fs << c;
|
||||
assert(fs.fail());
|
||||
fs.open(temp);
|
||||
assert(fs.is_open());
|
||||
fs << c;
|
||||
}
|
||||
{
|
||||
std::ifstream fs(temp.c_str());
|
||||
char c = 0;
|
||||
fs >> c;
|
||||
assert(c == 'a');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fs;
|
||||
assert(!fs.is_open());
|
||||
wchar_t c = L'a';
|
||||
fs << c;
|
||||
assert(fs.fail());
|
||||
fs.open(temp);
|
||||
assert(fs.is_open());
|
||||
fs << c;
|
||||
}
|
||||
{
|
||||
std::wifstream fs(temp.c_str());
|
||||
wchar_t c = 0;
|
||||
fs >> c;
|
||||
assert(c == L'a');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
|
||||
// basic_filebuf<charT,traits>* rdbuf() const;
|
||||
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include "platform_support.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string temp = get_temp_file_name();
|
||||
{
|
||||
std::ofstream fs(temp.c_str());
|
||||
std::filebuf* fb = fs.rdbuf();
|
||||
assert(fb->sputc('r') == 'r');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
{
|
||||
std::wofstream fs(temp.c_str());
|
||||
std::wfilebuf* fb = fs.rdbuf();
|
||||
assert(fb->sputc(L'r') == L'r');
|
||||
}
|
||||
std::remove(temp.c_str());
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ofstream
|
||||
// : public basic_ostream<charT,traits>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef typename traits_type::int_type int_type;
|
||||
// typedef typename traits_type::pos_type pos_type;
|
||||
// typedef typename traits_type::off_type off_type;
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ofstream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ofstream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_ofstream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ofstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ofstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ofstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
}
|
20
test/std/input.output/file.streams/fstreams/version.pass.cpp
Normal file
20
test/std/input.output/file.streams/fstreams/version.pass.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <fstream>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
12
test/std/input.output/file.streams/nothing_to_do.pass.cpp
Normal file
12
test/std/input.output/file.streams/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iomanip>
|
||||
|
||||
// template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
|
||||
|
||||
// REQUIRES: locale.en_US.UTF-8
|
||||
|
||||
#include <iomanip>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" -$1,234,567.89");
|
||||
std::istream is(&sb);
|
||||
is.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
long double x = 0;
|
||||
is >> std::get_money(x, false);
|
||||
assert(x == -123456789);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" -USD 1,234,567.89");
|
||||
std::istream is(&sb);
|
||||
is.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
long double x = 0;
|
||||
is >> std::get_money(x, true);
|
||||
assert(x == -123456789);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -$1,234,567.89");
|
||||
std::wistream is(&sb);
|
||||
is.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
long double x = 0;
|
||||
is >> std::get_money(x, false);
|
||||
assert(x == -123456789);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -USD 1,234,567.89");
|
||||
std::wistream is(&sb);
|
||||
is.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
long double x = 0;
|
||||
is >> std::get_money(x, true);
|
||||
assert(x == -123456789);
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iomanip>
|
||||
|
||||
// template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
|
||||
|
||||
#include <iomanip>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" Sat Dec 31 23:55:59 2061");
|
||||
std::istream is(&sb);
|
||||
is.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
std::tm t = {0};
|
||||
is >> std::get_time(&t, "%a %b %d %H:%M:%S %Y");
|
||||
assert(t.tm_sec == 59);
|
||||
assert(t.tm_min == 55);
|
||||
assert(t.tm_hour == 23);
|
||||
assert(t.tm_mday == 31);
|
||||
assert(t.tm_mon == 11);
|
||||
assert(t.tm_year == 161);
|
||||
assert(t.tm_wday == 6);
|
||||
assert(is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" Sat Dec 31 23:55:59 2061");
|
||||
std::wistream is(&sb);
|
||||
is.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
std::tm t = {0};
|
||||
is >> std::get_time(&t, L"%a %b %d %H:%M:%S %Y");
|
||||
assert(t.tm_sec == 59);
|
||||
assert(t.tm_min == 55);
|
||||
assert(t.tm_hour == 23);
|
||||
assert(t.tm_mday == 31);
|
||||
assert(t.tm_mon == 11);
|
||||
assert(t.tm_year == 161);
|
||||
assert(t.tm_wday == 6);
|
||||
assert(is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iomanip>
|
||||
|
||||
// template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
|
||||
|
||||
// REQUIRES: locale.en_US.UTF-8
|
||||
|
||||
#include <iomanip>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
class testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
std::basic_string<CharT> str_;
|
||||
public:
|
||||
testbuf()
|
||||
{
|
||||
}
|
||||
|
||||
std::basic_string<CharT> str() const
|
||||
{return std::basic_string<CharT>(base::pbase(), base::pptr());}
|
||||
|
||||
protected:
|
||||
|
||||
virtual typename base::int_type
|
||||
overflow(typename base::int_type __c = base::traits_type::eof())
|
||||
{
|
||||
if (__c != base::traits_type::eof())
|
||||
{
|
||||
int n = str_.size();
|
||||
str_.push_back(__c);
|
||||
str_.resize(str_.capacity());
|
||||
base::setp(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data() + str_.size()));
|
||||
base::pbump(n+1);
|
||||
}
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb;
|
||||
std::ostream os(&sb);
|
||||
os.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
showbase(os);
|
||||
long double x = -123456789;
|
||||
os << std::put_money(x, false);
|
||||
assert(sb.str() == "-$1,234,567.89");
|
||||
}
|
||||
{
|
||||
testbuf<char> sb;
|
||||
std::ostream os(&sb);
|
||||
os.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
showbase(os);
|
||||
long double x = -123456789;
|
||||
os << std::put_money(x, true);
|
||||
assert(sb.str() == "-USD 1,234,567.89");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb;
|
||||
std::wostream os(&sb);
|
||||
os.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
showbase(os);
|
||||
long double x = -123456789;
|
||||
os << std::put_money(x, false);
|
||||
assert(sb.str() == L"-$1,234,567.89");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb;
|
||||
std::wostream os(&sb);
|
||||
os.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
showbase(os);
|
||||
long double x = -123456789;
|
||||
os << std::put_money(x, true);
|
||||
assert(sb.str() == L"-USD 1,234,567.89");
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iomanip>
|
||||
|
||||
// template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
|
||||
|
||||
#include <iomanip>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
template <class CharT>
|
||||
class testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
std::basic_string<CharT> str_;
|
||||
public:
|
||||
testbuf()
|
||||
{
|
||||
}
|
||||
|
||||
std::basic_string<CharT> str() const
|
||||
{return std::basic_string<CharT>(base::pbase(), base::pptr());}
|
||||
|
||||
protected:
|
||||
|
||||
virtual typename base::int_type
|
||||
overflow(typename base::int_type __c = base::traits_type::eof())
|
||||
{
|
||||
if (__c != base::traits_type::eof())
|
||||
{
|
||||
int n = str_.size();
|
||||
str_.push_back(__c);
|
||||
str_.resize(str_.capacity());
|
||||
base::setp(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data() + str_.size()));
|
||||
base::pbump(n+1);
|
||||
}
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb;
|
||||
std::ostream os(&sb);
|
||||
os.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
std::tm t = {0};
|
||||
t.tm_sec = 59;
|
||||
t.tm_min = 55;
|
||||
t.tm_hour = 23;
|
||||
t.tm_mday = 31;
|
||||
t.tm_mon = 11;
|
||||
t.tm_year = 161;
|
||||
t.tm_wday = 6;
|
||||
t.tm_isdst = 0;
|
||||
os << std::put_time(&t, "%a %b %d %H:%M:%S %Y");
|
||||
assert(sb.str() == "Sat Dec 31 23:55:59 2061");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb;
|
||||
std::wostream os(&sb);
|
||||
os.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
std::tm t = {0};
|
||||
t.tm_sec = 59;
|
||||
t.tm_min = 55;
|
||||
t.tm_hour = 23;
|
||||
t.tm_mday = 31;
|
||||
t.tm_mon = 11;
|
||||
t.tm_year = 161;
|
||||
t.tm_wday = 6;
|
||||
os << std::put_time(&t, L"%a %b %d %H:%M:%S %Y");
|
||||
assert(sb.str() == L"Sat Dec 31 23:55:59 2061");
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_iostream;
|
||||
|
||||
// void swap(basic_iostream& rhs);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
struct test_iostream
|
||||
: public std::basic_iostream<CharT>
|
||||
{
|
||||
typedef std::basic_iostream<CharT> base;
|
||||
test_iostream(testbuf<CharT>* sb) : base(sb) {}
|
||||
|
||||
void swap(test_iostream& s) {base::swap(s);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb1;
|
||||
testbuf<char> sb2;
|
||||
test_iostream<char> is1(&sb1);
|
||||
test_iostream<char> is2(&sb2);
|
||||
is1.swap(is2);
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb1;
|
||||
testbuf<wchar_t> sb2;
|
||||
test_iostream<wchar_t> is1(&sb1);
|
||||
test_iostream<wchar_t> is2(&sb2);
|
||||
is1.swap(is2);
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_iostream;
|
||||
|
||||
// basic_iostream& operator=(basic_iostream&& rhs);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
struct test_iostream
|
||||
: public std::basic_iostream<CharT>
|
||||
{
|
||||
typedef std::basic_iostream<CharT> base;
|
||||
test_iostream(testbuf<CharT>* sb) : base(sb) {}
|
||||
|
||||
test_iostream& operator=(test_iostream&& s)
|
||||
{base::operator=(std::move(s)); return *this;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
testbuf<char> sb1;
|
||||
testbuf<char> sb2;
|
||||
test_iostream<char> is1(&sb1);
|
||||
test_iostream<char> is2(&sb2);
|
||||
is2 = (std::move(is1));
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb1;
|
||||
testbuf<wchar_t> sb2;
|
||||
test_iostream<wchar_t> is1(&sb1);
|
||||
test_iostream<wchar_t> is2(&sb2);
|
||||
is2 = (std::move(is1));
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_iostream;
|
||||
|
||||
// basic_iostream(basic_iostream&& rhs);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
struct test_iostream
|
||||
: public std::basic_iostream<CharT>
|
||||
{
|
||||
typedef std::basic_iostream<CharT> base;
|
||||
test_iostream(testbuf<CharT>* sb) : base(sb) {}
|
||||
|
||||
test_iostream(test_iostream&& s)
|
||||
: base(std::move(s)) {}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
testbuf<char> sb;
|
||||
test_iostream<char> is1(&sb);
|
||||
test_iostream<char> is(std::move(is1));
|
||||
assert(is1.rdbuf() == &sb);
|
||||
assert(is1.gcount() == 0);
|
||||
assert(is.gcount() == 0);
|
||||
assert(is.rdbuf() == 0);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == ' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb;
|
||||
test_iostream<wchar_t> is1(&sb);
|
||||
test_iostream<wchar_t> is(std::move(is1));
|
||||
assert(is1.gcount() == 0);
|
||||
assert(is.gcount() == 0);
|
||||
assert(is1.rdbuf() == &sb);
|
||||
assert(is.rdbuf() == 0);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == L' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_iostream;
|
||||
|
||||
// explicit basic_iostream(basic_streambuf<charT,traits>* sb);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb;
|
||||
std::basic_iostream<char> is(&sb);
|
||||
assert(is.rdbuf() == &sb);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == ' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
assert(is.gcount() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb;
|
||||
std::basic_iostream<wchar_t> is(&sb);
|
||||
assert(is.rdbuf() == &sb);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == L' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
assert(is.gcount() == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_iostream :
|
||||
// public basic_istream<charT,traits>,
|
||||
// public basic_ostream<charT,traits>
|
||||
// {
|
||||
// public:
|
||||
// // types:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef typename traits_type::int_type int_type;
|
||||
// typedef typename traits_type::pos_type pos_type;
|
||||
// typedef typename traits_type::off_type off_type;
|
||||
|
||||
#include <istream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_istream<char>, std::basic_iostream<char> >::value), "");
|
||||
static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_iostream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_iostream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_iostream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_iostream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_iostream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_iostream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(bool& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
bool n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
bool n = true;
|
||||
is >> n;
|
||||
assert(n == false);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 1 ");
|
||||
std::istream is(&sb);
|
||||
bool n = 0;
|
||||
is >> n;
|
||||
assert(n == true);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 1 ");
|
||||
std::wistream is(&sb);
|
||||
bool n = 0;
|
||||
is >> n;
|
||||
assert(n == true);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(double& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
double n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
double n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
double n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -123.5 ");
|
||||
std::wistream is(&sb);
|
||||
double n = 10;
|
||||
is >> n;
|
||||
assert(n == -123.5);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(float& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
float n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
float n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
float n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -123.5 ");
|
||||
std::wistream is(&sb);
|
||||
float n = 10;
|
||||
is >> n;
|
||||
assert(n == -123.5);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(int& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
int n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
int n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
int n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -1234567890123456 ");
|
||||
std::wistream is(&sb);
|
||||
int n = 10;
|
||||
is >> n;
|
||||
assert(n == std::numeric_limits<int>::min());
|
||||
assert(!is.eof());
|
||||
assert( is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(long& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
long n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
long n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
long n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -123 ");
|
||||
std::wistream is(&sb);
|
||||
long n = 10;
|
||||
is >> n;
|
||||
assert(n == -123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(long double& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
long double n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
long double n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
long double n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -123.5 ");
|
||||
std::wistream is(&sb);
|
||||
long double n = 10;
|
||||
is >> n;
|
||||
assert(n == -123.5);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(long long& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
long long n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
long long n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
long long n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -123 ");
|
||||
std::wistream is(&sb);
|
||||
long long n = 10;
|
||||
is >> n;
|
||||
assert(n == -123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(void*& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
void* n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
void* n = (void*)1;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 1 ");
|
||||
std::istream is(&sb);
|
||||
void* n = 0;
|
||||
is >> n;
|
||||
assert(n == (void*)1);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 1 ");
|
||||
std::wistream is(&sb);
|
||||
void* n = 0;
|
||||
is >> n;
|
||||
assert(n == (void*)1);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("12345678");
|
||||
std::istream is(&sb);
|
||||
void* n = 0;
|
||||
is >> n;
|
||||
assert(n == (void*)0x12345678);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L"12345678");
|
||||
std::wistream is(&sb);
|
||||
void* n = 0;
|
||||
is >> n;
|
||||
assert(n == (void*)0x12345678);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(short& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
short n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
short n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
short n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" -1234567890 ");
|
||||
std::wistream is(&sb);
|
||||
short n = 10;
|
||||
is >> n;
|
||||
assert(n == std::numeric_limits<short>::min());
|
||||
assert(!is.eof());
|
||||
assert( is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(unsigned int& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
unsigned int n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
unsigned int n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
unsigned int n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123 ");
|
||||
std::wistream is(&sb);
|
||||
unsigned int n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(unsigned long& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
unsigned long n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
unsigned long n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
unsigned long n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123 ");
|
||||
std::wistream is(&sb);
|
||||
unsigned long n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(unsigned long long& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
unsigned long long n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
unsigned long long n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
unsigned long long n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123 ");
|
||||
std::wistream is(&sb);
|
||||
unsigned long long n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// operator>>(unsigned short& val);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
unsigned short n = 0;
|
||||
is >> n;
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("0");
|
||||
std::istream is(&sb);
|
||||
unsigned short n = 10;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123 ");
|
||||
std::istream is(&sb);
|
||||
unsigned short n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123 ");
|
||||
std::wistream is(&sb);
|
||||
unsigned short n = 10;
|
||||
is >> n;
|
||||
assert(n == 123);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// basic_istream<charT,traits>& operator>>(basic_ios<charT,traits>&
|
||||
// (*pf)(basic_ios<charT,traits>&));
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
int f_called = 0;
|
||||
|
||||
template <class CharT>
|
||||
std::basic_ios<CharT>&
|
||||
f(std::basic_ios<CharT>& is)
|
||||
{
|
||||
++f_called;
|
||||
return is;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
is >> f;
|
||||
assert(f_called == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT& c);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
char c = 'z';
|
||||
is >> c;
|
||||
assert( is.eof());
|
||||
assert( is.fail());
|
||||
assert(c == 'z');
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
char c;
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'a');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'b');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'c');
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" abc");
|
||||
std::wistream is(&sb);
|
||||
wchar_t c;
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'a');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'b');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'c');
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// basic_istream<charT,traits>& operator>>(ios_base& (*pf)(ios_base&));
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
int f_called = 0;
|
||||
|
||||
std::ios_base&
|
||||
f(std::ios_base& is)
|
||||
{
|
||||
++f_called;
|
||||
return is;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
is >> f;
|
||||
assert(f_called == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&
|
||||
// (*pf)(basic_istream<charT,traits>&));
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
int f_called = 0;
|
||||
|
||||
template <class CharT>
|
||||
std::basic_istream<CharT>&
|
||||
f(std::basic_istream<CharT>& is)
|
||||
{
|
||||
++f_called;
|
||||
return is;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((std::streambuf*)0);
|
||||
is >> f;
|
||||
assert(f_called == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template<class traits>
|
||||
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char& c);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
signed char c = 'z';
|
||||
is >> c;
|
||||
assert( is.eof());
|
||||
assert( is.fail());
|
||||
assert(c == 'z');
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
signed char c;
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'a');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'b');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'c');
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template<class traits>
|
||||
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char* s);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
signed char s[20];
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::string((char*)s) == "abcdefghijk");
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
is.width(4);
|
||||
signed char s[20];
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::string((char*)s) == "abc");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk");
|
||||
std::istream is(&sb);
|
||||
signed char s[20];
|
||||
is >> s;
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::string((char*)s) == "abcdefghijk");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk");
|
||||
std::istream is(&sb);
|
||||
signed char s[20];
|
||||
is.width(1);
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert( is.fail());
|
||||
assert(std::string((char*)s) == "");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// basic_istream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
class testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
std::basic_string<CharT> str_;
|
||||
public:
|
||||
testbuf()
|
||||
{
|
||||
}
|
||||
testbuf(const std::basic_string<CharT>& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data() + str_.size()));
|
||||
}
|
||||
|
||||
std::basic_string<CharT> str() const
|
||||
{return std::basic_string<CharT>(base::pbase(), base::pptr());}
|
||||
|
||||
protected:
|
||||
|
||||
virtual typename base::int_type
|
||||
overflow(typename base::int_type __c = base::traits_type::eof())
|
||||
{
|
||||
if (__c != base::traits_type::eof())
|
||||
{
|
||||
int n = str_.size();
|
||||
str_.push_back(__c);
|
||||
str_.resize(str_.capacity());
|
||||
base::setp(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data() + str_.size()));
|
||||
base::pbump(n+1);
|
||||
}
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb("testing...");
|
||||
std::istream is(&sb);
|
||||
testbuf<char> sb2;
|
||||
is >> &sb2;
|
||||
assert(sb2.str() == "testing...");
|
||||
assert(is.gcount() == 10);
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template<class traits>
|
||||
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char& c);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
unsigned char c = 'z';
|
||||
is >> c;
|
||||
assert( is.eof());
|
||||
assert( is.fail());
|
||||
assert(c == 'z');
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
unsigned char c;
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'a');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'b');
|
||||
is >> c;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'c');
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template<class traits>
|
||||
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char* s);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
unsigned char s[20];
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::string((char*)s) == "abcdefghijk");
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
is.width(4);
|
||||
unsigned char s[20];
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::string((char*)s) == "abc");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk");
|
||||
std::istream is(&sb);
|
||||
unsigned char s[20];
|
||||
is >> s;
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::string((char*)s) == "abcdefghijk");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk");
|
||||
std::istream is(&sb);
|
||||
unsigned char s[20];
|
||||
is.width(1);
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert( is.fail());
|
||||
assert(std::string((char*)s) == "");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT* s);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk ");
|
||||
std::istream is(&sb);
|
||||
char s[20];
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::string(s) == "abcdefghijk");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" abcdefghijk ");
|
||||
std::wistream is(&sb);
|
||||
is.width(4);
|
||||
wchar_t s[20];
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::wstring(s) == L"abc");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" abcdefghijk");
|
||||
std::wistream is(&sb);
|
||||
wchar_t s[20];
|
||||
is >> s;
|
||||
assert( is.eof());
|
||||
assert(!is.fail());
|
||||
assert(std::wstring(s) == L"abcdefghijk");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abcdefghijk");
|
||||
std::istream is(&sb);
|
||||
char s[20];
|
||||
is.width(1);
|
||||
is >> s;
|
||||
assert(!is.eof());
|
||||
assert( is.fail());
|
||||
assert(std::string(s) == "");
|
||||
assert(is.width() == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits>
|
||||
// basic_istream<charT,traits>&
|
||||
// ws(basic_istream<charT,traits>& is);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" 123");
|
||||
std::istream is(&sb);
|
||||
ws(is);
|
||||
assert(is.good());
|
||||
assert(is.peek() == '1');
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123");
|
||||
std::wistream is(&sb);
|
||||
ws(is);
|
||||
assert(is.good());
|
||||
assert(is.peek() == L'1');
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
ws(is);
|
||||
assert(!is.fail());
|
||||
assert(is.eof());
|
||||
ws(is);
|
||||
assert(is.eof());
|
||||
assert(is.fail());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" ");
|
||||
std::wistream is(&sb);
|
||||
ws(is);
|
||||
assert(!is.fail());
|
||||
assert(is.eof());
|
||||
ws(is);
|
||||
assert(is.eof());
|
||||
assert(is.fail());
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// template <class charT, class traits, class T>
|
||||
// basic_istream<charT, traits>&
|
||||
// operator>>(basic_istream<charT, traits>&& is, T& x);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
testbuf<char> sb(" 123");
|
||||
int i = 0;
|
||||
std::istream(&sb) >> i;
|
||||
assert(i == 123);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123");
|
||||
int i = 0;
|
||||
std::wistream(&sb) >> i;
|
||||
assert(i == 123);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// int_type get();
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
char c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == ' ');
|
||||
assert(is.gcount() == 1);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abc");
|
||||
std::istream is(&sb);
|
||||
char c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == ' ');
|
||||
assert(is.gcount() == 1);
|
||||
c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'a');
|
||||
assert(is.gcount() == 1);
|
||||
c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'b');
|
||||
assert(is.gcount() == 1);
|
||||
c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'c');
|
||||
assert(is.gcount() == 1);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" abc");
|
||||
std::wistream is(&sb);
|
||||
wchar_t c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L' ');
|
||||
assert(is.gcount() == 1);
|
||||
c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'a');
|
||||
assert(is.gcount() == 1);
|
||||
c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'b');
|
||||
assert(is.gcount() == 1);
|
||||
c = is.get();
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'c');
|
||||
assert(is.gcount() == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <istream>
|
||||
|
||||
// basic_istream<charT,traits>& get(char_type& c);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef std::basic_streambuf<CharT> base;
|
||||
private:
|
||||
string_type str_;
|
||||
public:
|
||||
|
||||
testbuf() {}
|
||||
testbuf(const string_type& str)
|
||||
: str_(str)
|
||||
{
|
||||
base::setg(const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()),
|
||||
const_cast<CharT*>(str_.data()) + str_.size());
|
||||
}
|
||||
|
||||
CharT* eback() const {return base::eback();}
|
||||
CharT* gptr() const {return base::gptr();}
|
||||
CharT* egptr() const {return base::egptr();}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
char c;
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == ' ');
|
||||
assert(is.gcount() == 1);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" abc");
|
||||
std::istream is(&sb);
|
||||
char c;
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == ' ');
|
||||
assert(is.gcount() == 1);
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'a');
|
||||
assert(is.gcount() == 1);
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'b');
|
||||
assert(is.gcount() == 1);
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == 'c');
|
||||
assert(is.gcount() == 1);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" abc");
|
||||
std::wistream is(&sb);
|
||||
wchar_t c;
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L' ');
|
||||
assert(is.gcount() == 1);
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'a');
|
||||
assert(is.gcount() == 1);
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'b');
|
||||
assert(is.gcount() == 1);
|
||||
is.get(c);
|
||||
assert(!is.eof());
|
||||
assert(!is.fail());
|
||||
assert(c == L'c');
|
||||
assert(is.gcount() == 1);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user