29 namespace bfs = boost::filesystem;
32 TEST ( iszfstream, basictest ) {
34 ss <<
"expecto patronum" << endl <<
"obliviate" << endl <<
"avada kedavra";
36 EXPECT_EQ ( teststream.
is_open(), true );
38 EXPECT_EQ ( teststream.
is_open(), false );
39 teststream.
open ( ss );
40 EXPECT_EQ ( teststream.
is_open(), true );
41 EXPECT_EQ ( teststream.
eof(), false );
44 EXPECT_EQ ( line,
"expecto patronum" );
46 EXPECT_EQ ( line,
"obliviate" );
48 EXPECT_EQ ( line,
"" );
50 EXPECT_EQ ( line,
"avada kedavra" );
51 EXPECT_EQ ( teststream.
eof(), true );
54 TEST ( oszfstream, basictest ) {
57 EXPECT_EQ ( teststream.
is_open(), true );
59 EXPECT_EQ ( teststream.
is_open(), false );
60 teststream.
open ( ss );
61 EXPECT_EQ ( teststream.
is_open(), true );
62 std::string line =
"obliviate";
63 teststream << line << endl;
65 *
static_cast<std::stringstream *
> ( teststream.
getStream() ) >> line2;
66 EXPECT_EQ ( line, line2 );
70 TEST (ioszfstream, combinedtest) {
72 o <<
"expecto" << endl ;
73 o <<
"patronum" << endl;
78 EXPECT_EQ (
"expecto", line);
80 EXPECT_EQ (
"patronum", line);
81 bfs::remove ( bfs::path (
"test.gz") );
85 TEST ( iszfstream, fastforwardread ) {
87 std::stringstream *ss =
new std::stringstream;
90 *ss <<
"three" << endl;
91 *ss <<
"four" << endl;
97 finished = ffr ( 2, &line );
98 EXPECT_EQ ( line,
"two" );
99 EXPECT_EQ ( finished,
false );
100 finished = ffr ( 4, &line );
101 EXPECT_EQ ( line,
"four" );
102 EXPECT_EQ ( finished,
false );
103 finished = ffr ( 5, &line );
104 EXPECT_EQ ( line,
"five" );
105 EXPECT_EQ ( finished,
false );
106 finished = ffr ( 6, &line );
108 EXPECT_EQ ( line,
"" );
109 EXPECT_EQ ( finished,
true );
112 finished = ffr ( 1, &line );
113 EXPECT_EQ ( line,
"" );
117 ss =
new std::stringstream;
118 *ss <<
"one" << endl;
123 finished = ffr ( 1, &line );
124 EXPECT_EQ (finished,
false);
125 EXPECT_EQ (line,
"one");
126 finished = ffr ( 2, &line );
127 EXPECT_EQ (finished,
true);
128 EXPECT_EQ (line,
"");
138 int main (
int argc,
char **argv ) {
139 ::testing::InitGoogleTest ( &argc, argv );
140 return RUN_ALL_TESTS();
Wrapper stream class that writes to pipes, text files or gzipped files.
Convenience class that reads "quickly" until a queried line.
std::ostream * getStream()
Returns internal stream.
void open(const std::stringstream &ss)
int main(int argc, char **argv)
main function. If compiled individualy, will kickoff any tests in this file.
bool is_open()
Checks if the file/pipe is open.
iszfstream & getline(iszfstream &izs, std::string &line)
Static variables for logger. Include only once from main file.
bool is_open()
Checks whether the file is open.
TEST(iszfstream, basictest)
Test iszfstream.
void open(const std::stringstream &ss)
virtual int eof()
Checks for end-of-file.
Wrapper stream class that reads pipes, text files or gzipped files.
Unit testing: google testing common header.
Static variable for custom_assert. Include only once from main file.
void close()
Closes the file.