aboutsummaryrefslogtreecommitdiffstats
path: root/staging_vespalib/src/tests/librarypool/librarypool_test.cpp
blob: 87e04d3ffbd2495854c443a00d10b4f07148438c (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
// 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 <vespa/vespalib/util/librarypool.h>
#include <vespa/vespalib/util/exceptions.h>

using namespace vespalib;

class Test : public TestApp
{
public:
    int Main() override;
};

int
Test::Main()
{
    TEST_INIT("librarypool_test");
    LibraryPool p;
    ASSERT_TRUE(p.get("z") == NULL);
    p.loadLibrary("z");
    ASSERT_TRUE(p.get("z") != NULL);
    ASSERT_TRUE(p.get("z")->GetSymbol("some_symbol_that_is_not_there") == NULL);
    ASSERT_TRUE(p.get("z")->GetSymbol("compress") != NULL);
    try {
        p.loadLibrary("not_found");
        ASSERT_TRUE(false);
    } catch (const IllegalArgumentException & e) {
        ASSERT_TRUE(p.get("not_found") == NULL);
    }
    {
        const LibraryPool & c(p);
        ASSERT_TRUE(c.get("z") != NULL);
        ASSERT_TRUE(c.get("not_found") == NULL);
    }
    TEST_DONE();
}

TEST_APPHOOK(Test)