BIND 10 trac978, updated. 6fe98e3c2a669c9dc779980426a81fbe1ddcfff3 [trac978] Test for the defaultActionLoader
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jun 15 09:17:20 UTC 2011
The branch, trac978 has been updated
via 6fe98e3c2a669c9dc779980426a81fbe1ddcfff3 (commit)
from edfe1b966d53caf3ed9e17cd525b0d94beff0aaf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6fe98e3c2a669c9dc779980426a81fbe1ddcfff3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Jun 15 11:16:43 2011 +0200
[trac978] Test for the defaultActionLoader
-----------------------------------------------------------------------
Summary of changes:
src/lib/acl/Makefile.am | 3 ++
src/lib/acl/tests/loader_test.cc | 43 ++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/acl/Makefile.am b/src/lib/acl/Makefile.am
index dee81f9..d3222ae 100644
--- a/src/lib/acl/Makefile.am
+++ b/src/lib/acl/Makefile.am
@@ -9,4 +9,7 @@ lib_LTLIBRARIES = libacl.la
libacl_la_SOURCES = check.h acl.h
libacl_la_SOURCES += loader.h loader.cc
+libacl_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
+libacl_la_LIBADD += $(top_builddir)/src/lib/cc/libcc.la
+
CLEANFILES = *.gcno *.gcda
diff --git a/src/lib/acl/tests/loader_test.cc b/src/lib/acl/tests/loader_test.cc
index 036e69e..4cf15bf 100644
--- a/src/lib/acl/tests/loader_test.cc
+++ b/src/lib/acl/tests/loader_test.cc
@@ -14,10 +14,53 @@
#include <acl/loader.h>
+#include <string>
+#include <gtest/gtest.h>
+
using namespace isc::acl;
+using namespace std;
+using isc::data::ConstElementPtr;
namespace {
+// Just for convenience, create JSON objects from JSON string
+ConstElementPtr el(const string& JSON) {
+ return (isc::data::Element::fromJSON(JSON));
+}
+
+// We don't use the EXPECT_THROW macro, as it doesn't allow us
+// to examine the exception. We want to check the element is stored
+// there as well.
+void testActionLoaderException(const string& JSON) {
+ SCOPED_TRACE("Should throw with input: " + JSON);
+ ConstElementPtr elem(el(JSON));
+ try {
+ defaultActionLoader(elem);
+ FAIL() << "It did not throw";
+ }
+ catch (const LoaderError& error) {
+ // Yes, comparing for pointer equality, that is enough, it
+ // should return the exact instance of the JSON object
+ EXPECT_EQ(elem, error.element());
+ }
+}
+
+// Test the defaultActionLoader function
+TEST(LoaderHelpers, DefaultActionLoader) {
+ // First the three valid inputs
+ EXPECT_EQ(ACCEPT, defaultActionLoader(el("\"ACCEPT\"")));
+ EXPECT_EQ(REJECT, defaultActionLoader(el("\"REJECT\"")));
+ EXPECT_EQ(DROP, defaultActionLoader(el("\"DROP\"")));
+ // Now few invalid ones
+ // String, but unknown one
+ testActionLoaderException("\"UNKNOWN\"");
+ testActionLoaderException("42");
+ testActionLoaderException("true");
+ testActionLoaderException("null");
+ testActionLoaderException("[]");
+ testActionLoaderException("{}");
+}
+
Loader<bool> loader;
}
More information about the bind10-changes
mailing list