blob: 9514d619f7758efd3efa636f41414464df88bfe3 (
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
|
// 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("buffered output") {
SimpleBuffer buffer;
{ // produce data
BufferedOutput dst(buffer, 3);
dst.append('a').append('b').append('c').append('\n');
dst.append("foo bar").append('\n');
dst.append(string("str")).append('\n');
dst.printf("%d + %d = %d\n", 2, 2, 4);
}
{ // verify data
LineReader src(buffer);
string str;
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("abc", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("foo bar", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("str", str);
EXPECT_TRUE(src.readLine(str));
EXPECT_EQUAL("2 + 2 = 4", str);
EXPECT_TRUE(!src.readLine(str));
EXPECT_EQUAL("", str);
}
}
TEST_MAIN() { TEST_RUN_ALL(); }
|