-#include "eval_context.h"
-#include "parser.h"
-
+#include <eval/eval_context.h>
+#include <eval/parser.h>
+#include <exceptions/exceptions.h>
#include <fstream>
-EvalContext::EvalContext ()
+EvalContext::EvalContext()
: trace_scanning (false), trace_parsing (false)
{
variables["one"] = 1;
variables["two"] = 2;
}
-EvalContext::~EvalContext ()
+EvalContext::~EvalContext()
{
}
EvalContext::parseString(const std::string& str)
{
remove("/tmp/eval");
- std::fstream f("/tmp/eval", std::ios::trunc);
+ std::fstream f("/tmp/eval", std::ios::out);
+ if (!f.good()) {
+ isc_throw(isc::Unexpected, "Can't write /tmp/eval file");
+ }
f << str;
f.close();
TESTS += libeval_unittests
libeval_unittests_SOURCES = token_unittest.cc main.cc
+libeval_unittests_SOURCES += context_unittest.cc
libeval_unittests_CXXFLAGS = $(AM_CXXFLAGS)
libeval_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
libeval_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
--- /dev/null
+// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <config.h>
+#include <eval/token.h>
+#include <eval/eval_context.h>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <gtest/gtest.h>
+
+using namespace std;
+using namespace isc::dhcp;
+
+namespace {
+
+TEST(EvalContextTest, basic) {
+
+ EvalContext tmp;
+
+ EXPECT_NO_THROW(tmp.parseString("option[123] == \"MSFT\""));
+}
+
+
+};