Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
22.locale.num.put.stdcxx-2.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <cstddef>
31#include <ios>
32#include <string>
33#include <sstream>
34
35 void test (std::streamsize prec)
36{
37 const std::size_t len = 0 > prec ? 7 : (1 < prec ? prec + 1 : 2);
38 std::string exp (len, '0');
39 exp [1] = '.';
40
41 std::ostringstream strm;
42 strm.setf (strm.showpoint);
43 strm.precision (prec);
44
45 strm << 0.0f;
46 assert (exp == strm.str ());
47
48 strm.str ("");
49 strm << 0.0;
50 assert (exp == strm.str ());
51
52 strm.str ("");
53 strm << 0.0L;
54 assert (exp == strm.str ());
55}
56
57int main ()
58{
59 test (-2);
60 test (0);
61 test (1);
62 test (5);
63
64 return 0;
65}
#define len
Definition 17.names.cpp:488
#define strm
Definition 17.names.cpp:549
#define assert(expr)
Definition _cassert.h:40