blob: bb39dcceafd85461c3712eaf6f54435fceb09da3 (
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 2016 Yahoo Inc. 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;
TEST("input file reader") {
{
InputFileReader reader("not_found.txt");
EXPECT_TRUE(reader.tainted());
}
{
InputFileReader reader(vespalib::TestApp::GetSourceDirectory() + "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(vespalib::TestApp::GetSourceDirectory() + "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(); }
|