Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // test <cstdio> |
| 11 | |
| 12 | #include <cstdio> |
| 13 | #include <type_traits> |
| 14 | |
| 15 | #ifndef BUFSIZ |
| 16 | #error BUFSIZ not defined |
| 17 | #endif |
| 18 | |
| 19 | #ifndef EOF |
| 20 | #error EOF not defined |
| 21 | #endif |
| 22 | |
| 23 | #ifndef FILENAME_MAX |
| 24 | #error FILENAME_MAX not defined |
| 25 | #endif |
| 26 | |
| 27 | #ifndef FOPEN_MAX |
| 28 | #error FOPEN_MAX not defined |
| 29 | #endif |
| 30 | |
| 31 | #ifndef L_tmpnam |
| 32 | #error L_tmpnam not defined |
| 33 | #endif |
| 34 | |
| 35 | #ifndef NULL |
| 36 | #error NULL not defined |
| 37 | #endif |
| 38 | |
| 39 | #ifndef SEEK_CUR |
| 40 | #error SEEK_CUR not defined |
| 41 | #endif |
| 42 | |
| 43 | #ifndef SEEK_END |
| 44 | #error SEEK_END not defined |
| 45 | #endif |
| 46 | |
| 47 | #ifndef SEEK_SET |
| 48 | #error SEEK_SET not defined |
| 49 | #endif |
| 50 | |
| 51 | #ifndef TMP_MAX |
| 52 | #error TMP_MAX not defined |
| 53 | #endif |
| 54 | |
| 55 | #ifndef _IOFBF |
| 56 | #error _IOFBF not defined |
| 57 | #endif |
| 58 | |
| 59 | #ifndef _IOLBF |
| 60 | #error _IOLBF not defined |
| 61 | #endif |
| 62 | |
| 63 | #ifndef _IONBF |
| 64 | #error _IONBF not defined |
| 65 | #endif |
| 66 | |
| 67 | #ifndef stderr |
| 68 | #error stderr not defined |
| 69 | #endif |
| 70 | |
| 71 | #ifndef stdin |
| 72 | #error stdin not defined |
| 73 | #endif |
| 74 | |
| 75 | #ifndef stdout |
| 76 | #error stdout not defined |
| 77 | #endif |
| 78 | |
| 79 | #include <cstdarg> |
| 80 | |
Howard Hinnant | f57bd56 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 81 | #pragma clang diagnostic push |
| 82 | #pragma clang diagnostic ignored "-Wformat-zero-length" |
| 83 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 84 | int main() |
| 85 | { |
| 86 | std::FILE* fp = 0; |
| 87 | std::fpos_t fpos = {0}; |
| 88 | std::size_t s = 0; |
| 89 | char* cp = 0; |
| 90 | std::va_list va; |
| 91 | static_assert((std::is_same<decltype(std::remove("")), int>::value), ""); |
| 92 | static_assert((std::is_same<decltype(std::rename("","")), int>::value), ""); |
| 93 | static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), ""); |
| 94 | static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), ""); |
| 95 | static_assert((std::is_same<decltype(std::fclose(fp)), int>::value), ""); |
| 96 | static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), ""); |
| 97 | static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), ""); |
| 98 | static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), ""); |
| 99 | static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), ""); |
| 100 | static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), ""); |
Howard Hinnant | f1151ef | 2011-05-14 00:04:05 +0000 | [diff] [blame] | 101 | static_assert((std::is_same<decltype(std::fprintf(fp," ")), int>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | static_assert((std::is_same<decltype(std::fscanf(fp,"")), int>::value), ""); |
Howard Hinnant | f1151ef | 2011-05-14 00:04:05 +0000 | [diff] [blame] | 103 | static_assert((std::is_same<decltype(std::printf(" ")), int>::value), ""); |
| 104 | static_assert((std::is_same<decltype(std::scanf(" ")), int>::value), ""); |
| 105 | static_assert((std::is_same<decltype(std::snprintf(cp,0," ")), int>::value), ""); |
| 106 | static_assert((std::is_same<decltype(std::sprintf(cp," ")), int>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 107 | static_assert((std::is_same<decltype(std::sscanf("","")), int>::value), ""); |
| 108 | static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), ""); |
| 109 | static_assert((std::is_same<decltype(std::vfscanf(fp,"",va)), int>::value), ""); |
Howard Hinnant | f1151ef | 2011-05-14 00:04:05 +0000 | [diff] [blame] | 110 | static_assert((std::is_same<decltype(std::vprintf(" ",va)), int>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 111 | static_assert((std::is_same<decltype(std::vscanf("",va)), int>::value), ""); |
Howard Hinnant | f1151ef | 2011-05-14 00:04:05 +0000 | [diff] [blame] | 112 | static_assert((std::is_same<decltype(std::vsnprintf(cp,0," ",va)), int>::value), ""); |
| 113 | static_assert((std::is_same<decltype(std::vsprintf(cp," ",va)), int>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 114 | static_assert((std::is_same<decltype(std::vsscanf("","",va)), int>::value), ""); |
| 115 | static_assert((std::is_same<decltype(std::fgetc(fp)), int>::value), ""); |
| 116 | static_assert((std::is_same<decltype(std::fgets(cp,0,fp)), char*>::value), ""); |
| 117 | static_assert((std::is_same<decltype(std::fputc(0,fp)), int>::value), ""); |
| 118 | static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), ""); |
| 119 | static_assert((std::is_same<decltype(std::getc(fp)), int>::value), ""); |
| 120 | static_assert((std::is_same<decltype(std::getchar()), int>::value), ""); |
Marshall Clow | 1206720 | 2013-10-12 19:09:47 +0000 | [diff] [blame] | 121 | #if _LIBCPP_STD_VER <= 11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 122 | static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), ""); |
Marshall Clow | 1206720 | 2013-10-12 19:09:47 +0000 | [diff] [blame] | 123 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 124 | static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), ""); |
| 125 | static_assert((std::is_same<decltype(std::putchar(0)), int>::value), ""); |
| 126 | static_assert((std::is_same<decltype(std::puts("")), int>::value), ""); |
| 127 | static_assert((std::is_same<decltype(std::ungetc(0,fp)), int>::value), ""); |
| 128 | static_assert((std::is_same<decltype(std::fread((void*)0,0,0,fp)), std::size_t>::value), ""); |
| 129 | static_assert((std::is_same<decltype(std::fwrite((const void*)0,0,0,fp)), std::size_t>::value), ""); |
| 130 | static_assert((std::is_same<decltype(std::fgetpos(fp, &fpos)), int>::value), ""); |
| 131 | static_assert((std::is_same<decltype(std::fseek(fp, 0,0)), int>::value), ""); |
| 132 | static_assert((std::is_same<decltype(std::fsetpos(fp, &fpos)), int>::value), ""); |
| 133 | static_assert((std::is_same<decltype(std::ftell(fp)), long>::value), ""); |
| 134 | static_assert((std::is_same<decltype(std::rewind(fp)), void>::value), ""); |
| 135 | static_assert((std::is_same<decltype(std::clearerr(fp)), void>::value), ""); |
| 136 | static_assert((std::is_same<decltype(std::feof(fp)), int>::value), ""); |
| 137 | static_assert((std::is_same<decltype(std::ferror(fp)), int>::value), ""); |
| 138 | static_assert((std::is_same<decltype(std::perror("")), void>::value), ""); |
| 139 | } |