blob: facc918b254e0ae7a2fb30b3baebac3f49ff6ca3 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vbench/test/all.h>
using namespace vbench;
using OutputWriter = vespalib::OutputWriter;
using SimpleBuffer = vespalib::SimpleBuffer;
TEST("line reader") {
SimpleBuffer buffer;
{
OutputWriter dst(buffer, 64);
dst.write("foo\n");
dst.write("bar\r\n");
dst.write("\n");
dst.write("\rbaz\n");
dst.write("\r\n");
dst.write("zzz");
}
{
LineReader src(buffer);
string str;
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("foo", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("bar", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("\rbaz", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("zzz", str);
EXPECT_TRUE(!src.readLine(str));
EXPECT_EQUAL("", str);
}
}
TEST_MAIN() { TEST_RUN_ALL(); }
|