Commit 794ed258 authored by Francis Dupont's avatar Francis Dupont

[4501] Some attempts to improve coverage

parent ceb1ba08
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2015,2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -33,6 +33,7 @@ public:
/// @brief Thrown if the queue manager's receive handler is passed
/// a failure result.
/// @todo use or remove it.
class D2QueueMgrReceiveError : public isc::Exception {
public:
D2QueueMgrReceiveError(const char* file, size_t line, const char* what) :
......@@ -41,6 +42,7 @@ public:
/// @brief Thrown if the request queue is full when an enqueue is attempted.
/// @todo use or remove it.
class D2QueueMgrQueueFull : public isc::Exception {
public:
D2QueueMgrQueueFull(const char* file, size_t line, const char* what) :
......
......@@ -1337,6 +1337,7 @@ TEST_F(D2CfgMgrTest, fullConfig) {
// Verify that the forward manager can be retrieved.
DdnsDomainListMgrPtr mgr = context->getForwardMgr();
ASSERT_TRUE(mgr);
EXPECT_EQ("forward-ddns", mgr->getName());
// Verify that the forward manager has the correct number of domains.
DdnsDomainMapPtr domains = mgr->getDomains();
......@@ -1360,6 +1361,7 @@ TEST_F(D2CfgMgrTest, fullConfig) {
// Verify that the reverse manager can be retrieved.
mgr = context->getReverseMgr();
ASSERT_TRUE(mgr);
EXPECT_EQ("reverse-ddns", mgr->getName());
// Verify that the reverse manager has the correct number of domains.
domains = mgr->getDomains();
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2015,2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -7,6 +7,7 @@
#include <config.h>
#include <d2/d2_zone.h>
#include <gtest/gtest.h>
#include <sstream>
using namespace std;
using namespace isc;
......@@ -41,6 +42,21 @@ TEST(D2ZoneTest, toText) {
EXPECT_EQ("foo.example.com. IN SOA\n", zone2.toText());
}
// Same than for toText() but using the << operator.
TEST(D2ZoneTest, output) {
// Create first object.
D2Zone zone1(Name("example.com"), RRClass::ANY());
ostringstream ss;
ss << zone1;
EXPECT_EQ("example.com. ANY SOA\n", ss.str());
// Create another object with different parameters to make sure that the
// function's output changes accordingly.
D2Zone zone2(Name("foo.example.com"), RRClass::IN());
ostringstream ss2;
ss2 << zone2;
EXPECT_EQ("foo.example.com. IN SOA\n", ss2.str());
}
// This test verifies that the equality and inequality operators behave as
// expected.
TEST(D2ZoneTest, compare) {
......
......@@ -150,7 +150,7 @@ LFCController::parseArgs(int argc, char* argv[]) {
opterr = 0;
optind = 1;
while ((ch = getopt(argc, argv, ":46dvVWp:x:i:o:c:f:")) != -1) {
while ((ch = getopt(argc, argv, ":46dhvVWp:x:i:o:c:f:")) != -1) {
switch (ch) {
case '4':
// Process DHCPv4 lease files.
......@@ -236,6 +236,7 @@ LFCController::parseArgs(int argc, char* argv[]) {
case '?':
// Unknown argument
// note this will catch all the prevous ... name missing
isc_throw(InvalidUsage, "Unknown argument");
case ':':
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -145,6 +145,30 @@ TEST_F(LFCControllerTest, initialValues) {
EXPECT_TRUE(lfc_controller.getPidFile().empty());
}
/// @brief Verify that parsing -v/V/W/h works well.
TEST_F(LFCControllerTest, version) {
LFCController lfc_controller;
int argc = 2;
char *argv_v[] = { const_cast<char*>("progName"),
const_cast<char*>("-v") };
char *argv_V[] = { const_cast<char*>("progName"),
const_cast<char*>("-V") };
char *argv_W[] = { const_cast<char*>("progName"),
const_cast<char*>("-W") };
char *argv_h[] = { const_cast<char*>("progName"),
const_cast<char*>("-h") };
ASSERT_EXIT(lfc_controller.parseArgs(argc, argv_v),
::testing::ExitedWithCode(0), "");
ASSERT_EXIT(lfc_controller.parseArgs(argc, argv_V),
::testing::ExitedWithCode(0), "");
ASSERT_EXIT(lfc_controller.parseArgs(argc, argv_W),
::testing::ExitedWithCode(0), "");
ASSERT_EXIT(lfc_controller.parseArgs(argc, argv_h),
::testing::ExitedWithCode(0), "Usage");
}
/// @brief Verify that parsing a full command line works.
/// Parse a complete command line then verify the parsed
/// and saved data matches our expectations.
......@@ -663,4 +687,6 @@ TEST_F(LFCControllerTest, launch6) {
EXPECT_TRUE(noExistIOFP());
}
// @todo double launch (how to do that)
} // end of anonymous namespace
// Copyright (C) 2009-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2009-2015,2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -36,6 +36,17 @@ TEST_F(ExceptionTest, basicMethods) {
}
}
// Same than basicMethods but using a string (vs char *)
TEST_F(ExceptionTest, string) {
try {
isc_throw(Exception, std::string(teststring));
} catch (Exception& ex) {
EXPECT_EQ(ex.getMessage(), std::string(teststring));
EXPECT_EQ(ex.getFile(), std::string(__FILE__));
EXPECT_EQ(ex.getLine(), __LINE__ - 4);
}
}
// Test to see if it works as a proper derived class of std::exception.
TEST_F(ExceptionTest, stdInheritance) {
try {
......
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2015,2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -18,6 +18,14 @@ using namespace isc::log::interprocess;
using isc::util::unittests::parentReadState;
namespace {
TEST(InterprocessSyncFileTest, BadFile) {
InterprocessSyncFile sync("/no-such--dir/or--file");
InterprocessSyncLocker locker(sync);
EXPECT_FALSE(locker.isLocked());
ASSERT_THROW(locker.lock(), InterprocessSyncFileError);
}
TEST(InterprocessSyncFileTest, TestLock) {
InterprocessSyncFile sync("test");
InterprocessSyncLocker locker(sync);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment