MCPcopy Create free account
hub / github.com/apache/mesos / TEST

Function TEST

src/tests/common/recordio_tests.cpp:68–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67
68TEST(RecordIOReaderTest, EndOfFile)
69{
70 // Write some data to the pipe so that records
71 // are available before any reads occur.
72 string data;
73
74 data += ::recordio::encode("HELLO");
75 data += ::recordio::encode("WORLD!");
76
77 process::http::Pipe pipe;
78 pipe.writer().write(data);
79
80 mesos::internal::recordio::Reader<string> reader(
81 strings::lower, pipe.reader());
82
83 AWAIT_EXPECT_EQ(Result<string>::some("hello"), reader.read());
84 AWAIT_EXPECT_EQ(Result<string>::some("world!"), reader.read());
85
86 // Have multiple outstanding reads before we close the pipe.
87 Future<Result<string>> read1 = reader.read();
88 Future<Result<string>> read2 = reader.read();
89
90 EXPECT_TRUE(read1.isPending());
91 EXPECT_TRUE(read2.isPending());
92
93 pipe.writer().write(::recordio::encode("goodbye"));
94 pipe.writer().close();
95
96 AWAIT_EXPECT_EQ(Result<string>::some("goodbye"), read1);
97 AWAIT_EXPECT_EQ(Result<string>::none(), read2);
98
99 // Subsequent reads should return EOF.
100 AWAIT_EXPECT_EQ(Result<string>::none(), reader.read());
101}
102
103
104TEST(RecordIOReaderTest, DecodingFailure)

Callers

nothing calls this directly

Calls 10

trimFunction · 0.85
writerMethod · 0.80
readerMethod · 0.80
readAllMethod · 0.80
encodeFunction · 0.50
writeMethod · 0.45
readMethod · 0.45
isPendingMethod · 0.45
closeMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected