aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/tests/identity/identity.cpp
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /messagebus/src/tests/identity/identity.cpp
Publish
Diffstat (limited to 'messagebus/src/tests/identity/identity.cpp')
-rw-r--r--messagebus/src/tests/identity/identity.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/messagebus/src/tests/identity/identity.cpp b/messagebus/src/tests/identity/identity.cpp
new file mode 100644
index 00000000000..95c499e3ff2
--- /dev/null
+++ b/messagebus/src/tests/identity/identity.cpp
@@ -0,0 +1,43 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/fastos/fastos.h>
+#include <vespa/log/log.h>
+LOG_SETUP("identity_test");
+#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/messagebus/network/identity.h>
+
+using namespace mbus;
+
+TEST_SETUP(Test);
+
+int
+Test::Main()
+{
+ TEST_INIT("identity_test");
+ Identity ident("foo/bar/baz");
+ EXPECT_TRUE(ident.getServicePrefix() == "foo/bar/baz");
+ {
+ std::vector<string> tmp = Identity::split("foo/bar/baz");
+ ASSERT_TRUE(tmp.size() == 3);
+ EXPECT_TRUE(tmp[0] == "foo");
+ EXPECT_TRUE(tmp[1] == "bar");
+ EXPECT_TRUE(tmp[2] == "baz");
+ }
+ {
+ std::vector<string> tmp = Identity::split("//");
+ ASSERT_TRUE(tmp.size() == 3);
+ EXPECT_TRUE(tmp[0] == "");
+ EXPECT_TRUE(tmp[1] == "");
+ EXPECT_TRUE(tmp[2] == "");
+ }
+ {
+ std::vector<string> tmp = Identity::split("foo");
+ ASSERT_TRUE(tmp.size() == 1);
+ EXPECT_TRUE(tmp[0] == "foo");
+ }
+ {
+ std::vector<string> tmp = Identity::split("");
+ ASSERT_TRUE(tmp.size() == 1);
+ EXPECT_TRUE(tmp[0] == "");
+ }
+ TEST_DONE();
+}