diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vespalib/src/tests/box |
Publish
Diffstat (limited to 'vespalib/src/tests/box')
-rw-r--r-- | vespalib/src/tests/box/.gitignore | 2 | ||||
-rw-r--r-- | vespalib/src/tests/box/CMakeLists.txt | 8 | ||||
-rw-r--r-- | vespalib/src/tests/box/FILES | 1 | ||||
-rw-r--r-- | vespalib/src/tests/box/box_test.cpp | 32 |
4 files changed, 43 insertions, 0 deletions
diff --git a/vespalib/src/tests/box/.gitignore b/vespalib/src/tests/box/.gitignore new file mode 100644 index 00000000000..76ae8a62fd2 --- /dev/null +++ b/vespalib/src/tests/box/.gitignore @@ -0,0 +1,2 @@ +vespalib_box_test_app +Testing diff --git a/vespalib/src/tests/box/CMakeLists.txt b/vespalib/src/tests/box/CMakeLists.txt new file mode 100644 index 00000000000..c115383fcd2 --- /dev/null +++ b/vespalib/src/tests/box/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +vespa_add_executable(vespalib_box_test_app + SOURCES + box_test.cpp + DEPENDS + vespalib +) +vespa_add_test(NAME vespalib_box_test_app COMMAND vespalib_box_test_app) diff --git a/vespalib/src/tests/box/FILES b/vespalib/src/tests/box/FILES new file mode 100644 index 00000000000..df0cdaa9666 --- /dev/null +++ b/vespalib/src/tests/box/FILES @@ -0,0 +1 @@ +box_test.cpp diff --git a/vespalib/src/tests/box/box_test.cpp b/vespalib/src/tests/box/box_test.cpp new file mode 100644 index 00000000000..a3683758097 --- /dev/null +++ b/vespalib/src/tests/box/box_test.cpp @@ -0,0 +1,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/test_kit.h> +#include <vespa/vespalib/util/box.h> + +using namespace vespalib; + +void checkValues(const std::vector<int> &values, size_t n) { + ASSERT_EQUAL(n, values.size()); + for (size_t i = 0; i < n; ++i) { + EXPECT_EQUAL(int(10 + (10 * i)), values[i]); + } +} + +TEST("require that boxes can be created and converted to vector") { + Box<int> box; + box.add(10).add(20).add(30); + checkValues(box, 3); +} + +TEST("require that boxes can be created in place") { + checkValues(Box<int>().add(10).add(20).add(30), 3); +} + +TEST("require that make_box works") { + checkValues(make_box(10), 1); + checkValues(make_box(10, 20), 2); + checkValues(make_box(10, 20, 30), 3); + checkValues(make_box(10, 20, 30, 40), 4); + checkValues(make_box(10, 20, 30, 40, 50), 5); +} + +TEST_MAIN() { TEST_RUN_ALL(); } |