add assignment or operator for multiple name suggestions
includes tests and config update
Change-Id: I4facf792d89c5ce34bc09f5495c45d0a3bab458a
diff --git a/tests/unit-tests/config-files/config-ca-5 b/tests/unit-tests/config-files/config-ca-5
index 0d1e6b3..f867534 100644
--- a/tests/unit-tests/config-files/config-ca-5
+++ b/tests/unit-tests/config-files/config-ca-5
@@ -24,6 +24,8 @@
],
"name-assignment":
{
- "param": "/group/email"
+ "param": "/group/email",
+ "param": "/group/name",
+ "random": ""
}
}
\ No newline at end of file
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index 6ad1577..87de3f2 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -58,8 +58,10 @@
std::vector<std::tuple<std::string, std::string>> params;
params.emplace_back("email", "1@1.edu");
params.emplace_back("group", "irl");
- BOOST_CHECK_EQUAL(config.m_nameAssignmentFunc(params).size(), 1);
+ params.emplace_back("name", "ndncert");
+ BOOST_CHECK_EQUAL(config.m_nameAssignmentFunc(params).size(), 3);
BOOST_CHECK_EQUAL(config.m_nameAssignmentFunc(params)[0], Name("/irl/1@1.edu"));
+ BOOST_CHECK_EQUAL(config.m_nameAssignmentFunc(params)[1], Name("/irl/ndncert"));
}
BOOST_AUTO_TEST_CASE(CAConfigFileWithErrors)
diff --git a/tests/unit-tests/name-assignment.t.cpp b/tests/unit-tests/name-assignment.t.cpp
index 1fc7f6a..1e7dd0e 100644
--- a/tests/unit-tests/name-assignment.t.cpp
+++ b/tests/unit-tests/name-assignment.t.cpp
@@ -21,6 +21,7 @@
#include <name-assignments/assignment-random.hpp>
#include <name-assignments/assignment-param.hpp>
#include <name-assignments/assignment-hash.hpp>
+#include <name-assignments/assignment-or.hpp>
#include "test-common.hpp"
namespace ndn {
@@ -71,6 +72,40 @@
BOOST_CHECK_EQUAL(func(requirements).begin()->size(), 1);
}
+BOOST_AUTO_TEST_CASE(NameAssignmentOr)
+{
+ AssignmentParam paramAssignment;
+ AssignmentOr orAssignment;
+ std::list<NameAssignmentFunc> func2Subfuncs;
+ auto func1 = orAssignment.getFunction(func2Subfuncs);
+ BOOST_CHECK_EQUAL(func1(std::vector<std::tuple<std::string, std::string>>()).size(), 0);
+
+ auto funcUnit = paramAssignment.getFunction("/abc/xyz/");
+ func2Subfuncs.push_back(funcUnit);
+ func2Subfuncs.push_back(funcUnit);
+ auto func2 = orAssignment.getFunction(func2Subfuncs);
+ std::list<NameAssignmentFunc> func3Subfuncs;
+ func3Subfuncs.push_back(func2);
+ func3Subfuncs.push_back(funcUnit);
+ auto func3 = orAssignment.getFunction(func3Subfuncs);
+ std::vector<std::tuple<std::string, std::string>> requirements;
+ requirements.emplace_back("abc", "123");
+ BOOST_CHECK_EQUAL(func3(requirements).size(), 0);
+ requirements.emplace_back("xyz", "789");
+ BOOST_CHECK_EQUAL(func3(requirements).size(), 3);
+}
+
+BOOST_AUTO_TEST_CASE(NameAssignmentOrOperatorString)
+{
+ AssignmentOr orAssignment;
+ auto func = orAssignment.getFunction(R"({"param": "/abc/xyz/", "param": "/abc/xyz"})");
+ std::vector<std::tuple<std::string, std::string>> requirements;
+ requirements.emplace_back("abc", "123");
+ BOOST_CHECK_EQUAL(func(requirements).size(), 0);
+ requirements.emplace_back("xyz", "789");
+ BOOST_CHECK_EQUAL(func(requirements).size(), 2);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests