Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
27.filebuf.sgetn.stdcxx-161.cpp
Go to the documentation of this file.
1
29#include <fstream>
30#include <cassert>
31#include <cstdio>
32
33#include <rw_file.h>
34
35int main ()
36{
37 std::filebuf fb;
38
39 const char* const tmpfname = rw_tmpnam (0);
40
41 assert (0 != fb.open (tmpfname, std::ios::out));
42 assert (6 == fb.sputn ("ABCDEF", 6));
43 assert (0 != fb.close ());
44
45 assert (0 != fb.open (tmpfname,
46 std::ios::in | std::ios::out | std::ios::stdio));
47
48 assert (3 == fb.sputn ("abc", 3));
49 assert (-1 != fb.pubsync ());
50
51 char buf [3] = "";
52 assert (3 == fb.sgetn (buf, sizeof buf));
53 assert (0 == std::filebuf::traits_type::compare ("DEF", buf, 3));
54
55 fb.close ();
56
57 std::remove (tmpfname);
58
59#ifndef _RWSTD_NO_WCHAR_T
60
61 std::wfilebuf wfb;
62
63 assert (0 != wfb.open (tmpfname, std::ios::out));
64 assert (6 == wfb.sputn (L"ABCDEF", 6));
65 assert (0 != wfb.close ());
66
67 assert (0 != wfb.open (tmpfname,
68 std::ios::in | std::ios::out | std::ios::stdio));
69
70 assert (3 == wfb.sputn (L"abc", 3));
71 assert (-1 != wfb.pubsync ());
72
73 wchar_t wbuf [3] = L"";
74 assert (3 == wfb.sgetn (wbuf, sizeof wbuf / sizeof *wbuf));
75 assert (0 == std::wfilebuf::traits_type::compare (L"DEF", wbuf, 3));
76
77 wfb.close ();
78
79 std::remove (tmpfname);
80
81#endif // _RWSTD_NO_WCHAR_T
82
83 return 0;
84}
#define buf
Definition 17.names.cpp:452
#define assert(expr)
Definition _cassert.h:40
_TEST_EXPORT const char * rw_tmpnam(char *)
Definition file.cpp:206