Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 28229df | 2020-01-04 15:11:25 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2020, Regents of the University of California. |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 4 | * |
| 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 Jiang | eb37bef | 2014-10-19 20:21:46 -0700 | [diff] [blame] | 20 | #include "daemon/zone.hpp" |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 21 | |
Davide Pesavento | bdd88c1 | 2020-11-26 00:35:08 -0500 | [diff] [blame] | 22 | #include "boost-test.hpp" |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 23 | |
Davide Pesavento | 28229df | 2020-01-04 15:11:25 -0500 | [diff] [blame] | 24 | #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 Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 30 | namespace ndn { |
| 31 | namespace ndns { |
| 32 | namespace tests { |
| 33 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 34 | BOOST_AUTO_TEST_SUITE(Zone) |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 35 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 36 | BOOST_AUTO_TEST_CASE(Basic) |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 37 | { |
| 38 | Name zoneName("/net/ndnsim"); |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 39 | ndns::Zone zone1; |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 40 | zone1.setName(zoneName); |
| 41 | zone1.setId(2); |
Shock Jiang | fc171d9 | 2014-09-26 09:33:40 -0700 | [diff] [blame] | 42 | zone1.setTtl(time::seconds(4000)); |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 43 | |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 44 | BOOST_CHECK_EQUAL(zone1.getId(), 2); |
| 45 | BOOST_CHECK_EQUAL(zone1.getName(), zoneName); |
Shock Jiang | fc171d9 | 2014-09-26 09:33:40 -0700 | [diff] [blame] | 46 | BOOST_CHECK_EQUAL(zone1.getTtl(), time::seconds(4000)); |
| 47 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 48 | ndns::Zone zone2(zoneName); |
Shock Jiang | fc171d9 | 2014-09-26 09:33:40 -0700 | [diff] [blame] | 49 | BOOST_CHECK_EQUAL(zone1, zone2); |
| 50 | BOOST_CHECK_EQUAL(zone2.getName(), zone1.getName()); |
| 51 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 52 | BOOST_CHECK_NE(zone1, ndns::Zone("/net/ndnsim2")); |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Shock Jiang | b7370c2 | 2014-09-05 14:43:22 -0700 | [diff] [blame] | 55 | BOOST_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 Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 65 | BOOST_AUTO_TEST_SUITE_END() |
| 66 | |
| 67 | } // namespace tests |
| 68 | } // namespace ndns |
| 69 | } // namespace ndn |