blob: f4927821d2757068f98b4b53e0d36fe87d3b7449 [file] [log] [blame]
Shock Jiang30ad8922014-09-04 15:08:52 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento28229df2020-01-04 15:11:25 -05002/*
Davide Pesavento7f27ec12022-03-10 20:10:54 -05003 * Copyright (c) 2014-2022, 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
Davide Pesaventobdd88c12020-11-26 00:35:08 -050022#include "boost-test.hpp"
Shock Jiang30ad8922014-09-04 15:08:52 -070023
Davide Pesavento28229df2020-01-04 15:11:25 -050024#include <boost/test/tools/output_test_stream.hpp>
Davide Pesavento28229df2020-01-04 15:11:25 -050025
Shock Jiang30ad8922014-09-04 15:08:52 -070026namespace ndn {
27namespace ndns {
28namespace tests {
29
Shock Jiang3c723182014-09-10 16:41:18 -070030BOOST_AUTO_TEST_SUITE(Zone)
Shock Jiang30ad8922014-09-04 15:08:52 -070031
Shock Jiang3c723182014-09-10 16:41:18 -070032BOOST_AUTO_TEST_CASE(Basic)
Shock Jiang30ad8922014-09-04 15:08:52 -070033{
34 Name zoneName("/net/ndnsim");
Shock Jiang3c723182014-09-10 16:41:18 -070035 ndns::Zone zone1;
Shock Jiang30ad8922014-09-04 15:08:52 -070036 zone1.setName(zoneName);
37 zone1.setId(2);
Shock Jiangfc171d92014-09-26 09:33:40 -070038 zone1.setTtl(time::seconds(4000));
Shock Jiang30ad8922014-09-04 15:08:52 -070039
Shock Jiang30ad8922014-09-04 15:08:52 -070040 BOOST_CHECK_EQUAL(zone1.getId(), 2);
41 BOOST_CHECK_EQUAL(zone1.getName(), zoneName);
Shock Jiangfc171d92014-09-26 09:33:40 -070042 BOOST_CHECK_EQUAL(zone1.getTtl(), time::seconds(4000));
43
Shock Jiang3c723182014-09-10 16:41:18 -070044 ndns::Zone zone2(zoneName);
Shock Jiangfc171d92014-09-26 09:33:40 -070045 BOOST_CHECK_EQUAL(zone1, zone2);
46 BOOST_CHECK_EQUAL(zone2.getName(), zone1.getName());
47
Shock Jiang3c723182014-09-10 16:41:18 -070048 BOOST_CHECK_NE(zone1, ndns::Zone("/net/ndnsim2"));
Shock Jiang30ad8922014-09-04 15:08:52 -070049}
50
Shock Jiangb7370c22014-09-05 14:43:22 -070051BOOST_AUTO_TEST_CASE(Ostream)
52{
53 ndns::Zone zone("/test");
54 zone.setId(1);
55
56 boost::test_tools::output_test_stream os;
57 os << zone;
58 BOOST_CHECK(os.is_equal("Zone: Id=1 Name=/test"));
59}
60
Shock Jiang30ad8922014-09-04 15:08:52 -070061BOOST_AUTO_TEST_SUITE_END()
62
63} // namespace tests
64} // namespace ndns
65} // namespace ndn