File: sstream1.cpp

package info (click to toggle)
stlport4.5 4.5.3-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,888 kB
  • ctags: 15,821
  • sloc: ansic: 45,266; cpp: 18,450; sh: 257; asm: 93; makefile: 64; perl: 58
file content (45 lines) | stat: -rw-r--r-- 1,083 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// STLport regression testsuite component.
// To compile as a separate example, please #define MAIN.

#include <sstream>
#include <cassert>

#ifdef MAIN 
#define sstream1_test main
#endif

int sstream1_test(int, char**)
{
    
    std::istringstream iss;
	int x[9];
	std::fill_n(x, 9, 999);
	iss.str(std::string("0-0+0 010-010+010 0x1-0x1+0x1"));
	iss >> std::hex;
	iss >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> x[5] >> x[6] >> x[7] >> x[8];
	assert(x[0] == 0x0);
	assert(x[1] == -0x0);
	assert(x[2] == +0x0);
	assert(x[3] == 0x010);
	assert(x[4] == -0x010);
	assert(x[5] == +0x010);
	assert(x[6] == 0x1);
	assert(x[7] == -0x1);
	assert(x[8] == +0x1);
	
	iss.clear();
	iss.str(std::string("0-0+0 010-010+010 0x1-0x1+0x1"));
	iss.unsetf(std::ios_base::dec | std::ios_base::hex);
	std::fill_n(x, 9, 999);
	iss >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> x[5] >> x[6] >> x[7] >> x[8];
	assert(x[0] == 0);
	assert(x[1] == -0);
	assert(x[2] == +0);
	assert(x[3] == 010);
	assert(x[4] == -010);
	assert(x[5] == +010);
	assert(x[6] == 0x1);
	assert(x[7] == -0x1);
	assert(x[8] == +0x1);
}