blob: ed57285cb9f45388107460adcfacfc3fde5e34a3 [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/*
3 * Copyright (c) 2014-2020, 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#if BOOST_VERSION >= 105900
25#include <boost/test/tools/output_test_stream.hpp>
26#else
27#include <boost/test/output_test_stream.hpp>
28#endif
29
Shock Jiang30ad8922014-09-04 15:08:52 -070030namespace ndn {
31namespace ndns {
32namespace tests {
33
Shock Jiang3c723182014-09-10 16:41:18 -070034BOOST_AUTO_TEST_SUITE(Zone)
Shock Jiang30ad8922014-09-04 15:08:52 -070035
Shock Jiang3c723182014-09-10 16:41:18 -070036BOOST_AUTO_TEST_CASE(Basic)
Shock Jiang30ad8922014-09-04 15:08:52 -070037{
38 Name zoneName("/net/ndnsim");
Shock Jiang3c723182014-09-10 16:41:18 -070039 ndns::Zone zone1;
Shock Jiang30ad8922014-09-04 15:08:52 -070040 zone1.setName(zoneName);
41 zone1.setId(2);
Shock Jiangfc171d92014-09-26 09:33:40 -070042 zone1.setTtl(time::seconds(4000));
Shock Jiang30ad8922014-09-04 15:08:52 -070043
Shock Jiang30ad8922014-09-04 15:08:52 -070044 BOOST_CHECK_EQUAL(zone1.getId(), 2);
45 BOOST_CHECK_EQUAL(zone1.getName(), zoneName);
Shock Jiangfc171d92014-09-26 09:33:40 -070046 BOOST_CHECK_EQUAL(zone1.getTtl(), time::seconds(4000));
47
Shock Jiang3c723182014-09-10 16:41:18 -070048 ndns::Zone zone2(zoneName);
Shock Jiangfc171d92014-09-26 09:33:40 -070049 BOOST_CHECK_EQUAL(zone1, zone2);
50 BOOST_CHECK_EQUAL(zone2.getName(), zone1.getName());
51
Shock Jiang3c723182014-09-10 16:41:18 -070052 BOOST_CHECK_NE(zone1, ndns::Zone("/net/ndnsim2"));
Shock Jiang30ad8922014-09-04 15:08:52 -070053}
54
Shock Jiangb7370c22014-09-05 14:43:22 -070055BOOST_AUTO_TEST_CASE(Ostream)
56{
57 ndns::Zone zone("/test");
58 zone.setId(1);
59
60 boost::test_tools::output_test_stream os;
61 os << zone;
62 BOOST_CHECK(os.is_equal("Zone: Id=1 Name=/test"));
63}
64
Shock Jiang30ad8922014-09-04 15:08:52 -070065BOOST_AUTO_TEST_SUITE_END()
66
67} // namespace tests
68} // namespace ndns
69} // namespace ndn