aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/data/memory_input/memory_input_test.cpp
blob: b3ed505b6e53f4d165a1b9b3b7f98d23da132644 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/data/memory_input.h>

using namespace vespalib;

TEST("require that MemoryInput wrapper works as expected") {
    const char *data = "1234567890";
    Memory memory(data);
    EXPECT_EQUAL(memory.size, 10u);
    MemoryInput input(memory);
    EXPECT_EQUAL(input.obtain(), memory);
    input.evict(5);
    EXPECT_EQUAL(input.obtain(), Memory(data + 5));    
    EXPECT_EQUAL(input.obtain(), Memory(data + 5));    
    input.evict(5);
    EXPECT_EQUAL(input.obtain(), Memory());
}

TEST_MAIN() { TEST_RUN_ALL(); }