blob: ae13d360a744884a5540428a97c1c5e255f3cd0c [file] [log] [blame]
Shock Jiang30ad8922014-09-04 15:08:52 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyevfde570c2016-12-19 16:02:55 -08003 * Copyright (c) 2014-2016, Regents of the University of California.
Shock Jiang30ad8922014-09-04 15:08:52 -07004 *
5 * This file is part of NDNS (Named Data Networking Domain Name Service).
6 * See AUTHORS.md for complete list of NDNS authors and contributors.
7 *
8 * NDNS is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
Shock Jiangeb37bef2014-10-19 20:21:46 -070020#include "daemon/zone.hpp"
Shock Jiang30ad8922014-09-04 15:08:52 -070021
Alexander Afanasyevfde570c2016-12-19 16:02:55 -080022#include "test-common.hpp"
Shock Jiang30ad8922014-09-04 15:08:52 -070023
24namespace ndn {
25namespace ndns {
26namespace tests {
27
Shock Jiang3c723182014-09-10 16:41:18 -070028BOOST_AUTO_TEST_SUITE(Zone)
Shock Jiang30ad8922014-09-04 15:08:52 -070029
Shock Jiang3c723182014-09-10 16:41:18 -070030BOOST_AUTO_TEST_CASE(Basic)
Shock Jiang30ad8922014-09-04 15:08:52 -070031{
32 Name zoneName("/net/ndnsim");
Shock Jiang3c723182014-09-10 16:41:18 -070033 ndns::Zone zone1;
Shock Jiang30ad8922014-09-04 15:08:52 -070034 zone1.setName(zoneName);
35 zone1.setId(2);
Shock Jiangfc171d92014-09-26 09:33:40 -070036 zone1.setTtl(time::seconds(4000));
Shock Jiang30ad8922014-09-04 15:08:52 -070037
Shock Jiang30ad8922014-09-04 15:08:52 -070038 BOOST_CHECK_EQUAL(zone1.getId(), 2);
39 BOOST_CHECK_EQUAL(zone1.getName(), zoneName);
Shock Jiangfc171d92014-09-26 09:33:40 -070040 BOOST_CHECK_EQUAL(zone1.getTtl(), time::seconds(4000));
41
Shock Jiang3c723182014-09-10 16:41:18 -070042 ndns::Zone zone2(zoneName);
Shock Jiangfc171d92014-09-26 09:33:40 -070043 BOOST_CHECK_EQUAL(zone1, zone2);
44 BOOST_CHECK_EQUAL(zone2.getName(), zone1.getName());
45
Shock Jiang3c723182014-09-10 16:41:18 -070046 BOOST_CHECK_NE(zone1, ndns::Zone("/net/ndnsim2"));
Shock Jiang30ad8922014-09-04 15:08:52 -070047}
48
Shock Jiangb7370c22014-09-05 14:43:22 -070049BOOST_AUTO_TEST_CASE(Ostream)
50{
51 ndns::Zone zone("/test");
52 zone.setId(1);
53
54 boost::test_tools::output_test_stream os;
55 os << zone;
56 BOOST_CHECK(os.is_equal("Zone: Id=1 Name=/test"));
57}
58
Shock Jiang30ad8922014-09-04 15:08:52 -070059BOOST_AUTO_TEST_SUITE_END()
60
61} // namespace tests
62} // namespace ndns
63} // namespace ndn