Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, 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 | |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 22 | #include "test-common.hpp" |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 23 | |
| 24 | namespace ndn { |
| 25 | namespace ndns { |
| 26 | namespace tests { |
| 27 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 28 | BOOST_AUTO_TEST_SUITE(Zone) |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 29 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 30 | BOOST_AUTO_TEST_CASE(Basic) |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 31 | { |
| 32 | Name zoneName("/net/ndnsim"); |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 33 | ndns::Zone zone1; |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 34 | zone1.setName(zoneName); |
| 35 | zone1.setId(2); |
Shock Jiang | fc171d9 | 2014-09-26 09:33:40 -0700 | [diff] [blame] | 36 | zone1.setTtl(time::seconds(4000)); |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 37 | |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 38 | BOOST_CHECK_EQUAL(zone1.getId(), 2); |
| 39 | BOOST_CHECK_EQUAL(zone1.getName(), zoneName); |
Shock Jiang | fc171d9 | 2014-09-26 09:33:40 -0700 | [diff] [blame] | 40 | BOOST_CHECK_EQUAL(zone1.getTtl(), time::seconds(4000)); |
| 41 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 42 | ndns::Zone zone2(zoneName); |
Shock Jiang | fc171d9 | 2014-09-26 09:33:40 -0700 | [diff] [blame] | 43 | BOOST_CHECK_EQUAL(zone1, zone2); |
| 44 | BOOST_CHECK_EQUAL(zone2.getName(), zone1.getName()); |
| 45 | |
Shock Jiang | 3c72318 | 2014-09-10 16:41:18 -0700 | [diff] [blame] | 46 | BOOST_CHECK_NE(zone1, ndns::Zone("/net/ndnsim2")); |
Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Shock Jiang | b7370c2 | 2014-09-05 14:43:22 -0700 | [diff] [blame] | 49 | BOOST_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 Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame] | 59 | BOOST_AUTO_TEST_SUITE_END() |
| 60 | |
| 61 | } // namespace tests |
| 62 | } // namespace ndns |
| 63 | } // namespace ndn |