blob: 7ced0cd8923f10ac40b23fe927cc989928acdcdd (
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
42
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
#include <vbench/test/all.h>
using namespace vbench;
TEST("input file reader") {
{
InputFileReader reader("not_found.txt");
EXPECT_TRUE(reader.tainted());
}
{
InputFileReader reader(TEST_PATH("simple_test_input.txt"));
EXPECT_TRUE(!reader.tainted());
string line;
EXPECT_TRUE(reader.readLine(line));
EXPECT_EQUAL("foo", line);
EXPECT_TRUE(reader.readLine(line));
EXPECT_EQUAL("bar", line);
EXPECT_TRUE(reader.readLine(line));
EXPECT_EQUAL("baz", line);
EXPECT_TRUE(!reader.readLine(line));
TEST_FLUSH();
}
{
InputFileReader reader(TEST_PATH("hard_test_input.txt"));
EXPECT_TRUE(!reader.tainted());
string line;
EXPECT_TRUE(reader.readLine(line));
EXPECT_EQUAL("foo", line);
EXPECT_TRUE(reader.readLine(line));
EXPECT_EQUAL("bar", line);
EXPECT_TRUE(reader.readLine(line));
EXPECT_EQUAL("baz", line);
EXPECT_TRUE(reader.readLine(line));
EXPECT_EQUAL("\r", line);
EXPECT_TRUE(!reader.readLine(line));
TEST_FLUSH();
}
}
TEST_MAIN() { TEST_RUN_ALL(); }
|