35template <
class CharT,
class FileStream>
39 rw_assert (!!
f, 0, __LINE__,
"basic_ifstream<%s, Traits>", type);
41 const CharT delim =
f.widen (
'\xff');
44 const std::size_t bufsize =
sizeof buf /
sizeof *
buf;
49 while (
f.get (
buf, bufsize, delim)) {
52 "%d. basic_ifstream<%s>::get (%p, %d, '\\x%x')",
53 n, type,
buf, bufsize, delim);
61 "%d. basic_ifstream<%s>::get ('\\x%x'); expected '\\x%x'",
67 rw_assert ((std::ios::eofbit | std::ios::failbit) ==
f.rdstate (),
68 0, __LINE__,
"basic_ifstream<%s>::get(...)", type);
75 typedef CharT char_type;
76 typedef std::char_traits<char_type> traits_type;
80 const std::size_t nelems =
sizeof array /
sizeof *
array;
87 rw_fatal (0 != fname, 0, __LINE__,
"tmpnam(%#p) != 0", fname);
90 std::basic_ofstream<char_type, traits_type>
f (fname);
93 "basic_ofstream <%s>::basic_ofstream (#%s)",
100 for (std::size_t
i = 0; std::size_t (
i) < nelems / 2; ++
i) {
101 *
p++ = char_type (
i + 1);
104 *
p++ =
f.widen (
'\xff');
111 "basic_ofstream<%s>::write (%p, %d)",
112 tname,
array, nelems);
117 "basic_ofstream<%s>::close()", tname);
121 std::basic_ifstream<char_type, traits_type>
f (fname);
124 "basic_ifstream<%s>::basic_ifstream (%#s)",
131 rw_assert ((std::ios::eofbit | std::ios::failbit) ==
f.rdstate (),
133 "basic_ifstream<%s>::get(...)", tname);
138 rw_assert ((std::ios::eofbit | std::ios::failbit) ==
f.rdstate (),
140 "basic_ifstream<%s>::get(...)", tname);
151#ifndef _RWSTD_NO_WCHAR_T
162int main (
int argc,
char *argv[])
164 return rw_test (argc, argv, __FILE__,
void run_test(CharT, const char *tname)
void test_get(FileStream &f, const char *type, const CharT array[], std::size_t)
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_fatal(int expr, const char *filename, int line, const char *fmtspec,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)