diff options
author | Tor Egge <Tor.Egge@oath.com> | 2018-02-01 14:55:54 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2018-02-01 15:14:57 +0000 |
commit | 7b9dd4b44b8d84f901b2bb496c7d7f7ca01028ba (patch) | |
tree | bc49b1db867448ac8766adbd56b4b39a3e913f75 /document/src/tests/fixed_bucket_spaces_test.cpp | |
parent | 53ba441f3939f747159a581c4844ce8382679e34 (diff) |
Move FixedBucketSpaces to document module.
Diffstat (limited to 'document/src/tests/fixed_bucket_spaces_test.cpp')
-rw-r--r-- | document/src/tests/fixed_bucket_spaces_test.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/document/src/tests/fixed_bucket_spaces_test.cpp b/document/src/tests/fixed_bucket_spaces_test.cpp new file mode 100644 index 00000000000..fab38c638a7 --- /dev/null +++ b/document/src/tests/fixed_bucket_spaces_test.cpp @@ -0,0 +1,62 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include <vespa/document/bucket/fixed_bucket_spaces.h> +#include <cppunit/extensions/HelperMacros.h> + +namespace document { + +struct FixedBucketSpacesTest : CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(FixedBucketSpacesTest); + CPPUNIT_TEST(bucket_space_from_name_is_defined_for_default_space); + CPPUNIT_TEST(bucket_space_from_name_is_defined_for_global_space); + CPPUNIT_TEST(bucket_space_from_name_throws_exception_for_unknown_space); + CPPUNIT_TEST(name_from_bucket_space_is_defined_for_default_space); + CPPUNIT_TEST(name_from_bucket_space_is_defined_for_global_space); + CPPUNIT_TEST(name_from_bucket_space_throws_exception_for_unknown_space); + CPPUNIT_TEST_SUITE_END(); + + void bucket_space_from_name_is_defined_for_default_space(); + void bucket_space_from_name_is_defined_for_global_space(); + void bucket_space_from_name_throws_exception_for_unknown_space(); + void name_from_bucket_space_is_defined_for_default_space(); + void name_from_bucket_space_is_defined_for_global_space(); + void name_from_bucket_space_throws_exception_for_unknown_space(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(FixedBucketSpacesTest); + +void FixedBucketSpacesTest::bucket_space_from_name_is_defined_for_default_space() { + CPPUNIT_ASSERT_EQUAL(FixedBucketSpaces::default_space(), FixedBucketSpaces::from_string("default")); +} + +void FixedBucketSpacesTest::bucket_space_from_name_is_defined_for_global_space() { + CPPUNIT_ASSERT_EQUAL(FixedBucketSpaces::global_space(), FixedBucketSpaces::from_string("global")); +} + +void FixedBucketSpacesTest::bucket_space_from_name_throws_exception_for_unknown_space() { + try { + FixedBucketSpaces::from_string("banana"); + CPPUNIT_FAIL("Expected exception on unknown bucket space name"); + } catch (document::UnknownBucketSpaceException& e) { + } +} + +void FixedBucketSpacesTest::name_from_bucket_space_is_defined_for_default_space() { + CPPUNIT_ASSERT_EQUAL(vespalib::stringref("default"), + FixedBucketSpaces::to_string(FixedBucketSpaces::default_space())); +} + +void FixedBucketSpacesTest::name_from_bucket_space_is_defined_for_global_space() { + CPPUNIT_ASSERT_EQUAL(vespalib::stringref("global"), + FixedBucketSpaces::to_string(FixedBucketSpaces::global_space())); +} + +void FixedBucketSpacesTest::name_from_bucket_space_throws_exception_for_unknown_space() { + try { + FixedBucketSpaces::to_string(BucketSpace(4567)); + CPPUNIT_FAIL("Expected exception on unknown bucket space value"); + } catch (document::UnknownBucketSpaceException& e) { + } +} + +} |