Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014, Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | **/ |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 25 | |
| 26 | #include "face/face.hpp" |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 27 | #include "face/local-face.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 28 | #include "dummy-face.hpp" |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 29 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 30 | #include "tests/test-common.hpp" |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 31 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 32 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 33 | namespace tests { |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 34 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 35 | BOOST_FIXTURE_TEST_SUITE(FaceFace, BaseFixture) |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 36 | |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 37 | BOOST_AUTO_TEST_CASE(Description) |
| 38 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 39 | DummyFace face; |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 40 | face.setDescription("3pFsKrvWr"); |
| 41 | BOOST_CHECK_EQUAL(face.getDescription(), "3pFsKrvWr"); |
| 42 | } |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 43 | |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 44 | BOOST_AUTO_TEST_CASE(LocalControlHeaderEnabled) |
| 45 | { |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 46 | DummyLocalFace face; |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 47 | |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 48 | BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(), false); |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 49 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 50 | face.setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID, true); |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 51 | BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(), true); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 52 | BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID), true); |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 53 | BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled( |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 54 | LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID), false); |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 55 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 56 | face.setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID, false); |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 57 | BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled(), false); |
| 58 | BOOST_CHECK_EQUAL(face.isLocalControlHeaderEnabled( |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 59 | LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID), false); |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 62 | class FaceFailTestFace : public DummyFace |
| 63 | { |
| 64 | public: |
| 65 | FaceFailTestFace() |
| 66 | : failCount(0) |
| 67 | { |
| 68 | this->onFail += bind(&FaceFailTestFace::failHandler, this, _1); |
| 69 | } |
| 70 | |
| 71 | void |
| 72 | failOnce() |
| 73 | { |
| 74 | this->fail("reason"); |
| 75 | } |
| 76 | |
| 77 | private: |
| 78 | void |
| 79 | failHandler(const std::string& reason) |
| 80 | { |
| 81 | BOOST_CHECK_EQUAL(reason, "reason"); |
| 82 | ++this->failCount; |
| 83 | } |
| 84 | |
| 85 | public: |
| 86 | int failCount; |
| 87 | }; |
| 88 | |
| 89 | BOOST_AUTO_TEST_CASE(FailTwice) |
| 90 | { |
| 91 | FaceFailTestFace face; |
| 92 | BOOST_CHECK_EQUAL(face.failCount, 0); |
| 93 | face.failOnce(); |
| 94 | BOOST_CHECK_EQUAL(face.failCount, 1); |
| 95 | face.failOnce(); |
| 96 | BOOST_CHECK_EQUAL(face.failCount, 1); |
| 97 | } |
| 98 | |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 99 | BOOST_AUTO_TEST_SUITE_END() |
| 100 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 101 | } // namespace tests |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 102 | } // namespace nfd |