blob: 4a94a58ca877a028c250d1398158d3bc35b332c8 [file] [log] [blame]
Junxiao Shi2c29f3a2014-01-24 19:59:00 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev319f2c82015-01-07 14:56:53 -08003 * Copyright (c) 2014-2015, 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 Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
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/>.
Alexander Afanasyev319f2c82015-01-07 14:56:53 -080024 */
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070025
26#include "face/face.hpp"
Junxiao Shicbba04c2014-01-26 14:21:22 -070027#include "dummy-face.hpp"
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070028
Junxiao Shid9ee45c2014-02-27 15:38:11 -070029#include "tests/test-common.hpp"
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070030
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080031namespace nfd {
Junxiao Shid9ee45c2014-02-27 15:38:11 -070032namespace tests {
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070033
Junxiao Shid9ee45c2014-02-27 15:38:11 -070034BOOST_FIXTURE_TEST_SUITE(FaceFace, BaseFixture)
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070035
Junxiao Shi32bfeb32014-01-25 18:22:02 -070036BOOST_AUTO_TEST_CASE(Description)
37{
Junxiao Shi8c8d2182014-01-30 22:33:00 -070038 DummyFace face;
Junxiao Shi32bfeb32014-01-25 18:22:02 -070039 face.setDescription("3pFsKrvWr");
40 BOOST_CHECK_EQUAL(face.getDescription(), "3pFsKrvWr");
41}
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070042
Junxiao Shi08d07a72014-06-09 23:17:57 -070043class FaceFailTestFace : public DummyFace
44{
45public:
46 FaceFailTestFace()
47 : failCount(0)
48 {
Junxiao Shic099ddb2014-12-25 20:53:20 -070049 this->onFail.connect(bind(&FaceFailTestFace::failHandler, this, _1));
Junxiao Shi08d07a72014-06-09 23:17:57 -070050 }
51
52 void
53 failOnce()
54 {
55 this->fail("reason");
56 }
57
58private:
59 void
60 failHandler(const std::string& reason)
61 {
62 BOOST_CHECK_EQUAL(reason, "reason");
63 ++this->failCount;
64 }
65
66public:
67 int failCount;
68};
69
70BOOST_AUTO_TEST_CASE(FailTwice)
71{
72 FaceFailTestFace face;
73 BOOST_CHECK_EQUAL(face.failCount, 0);
74 face.failOnce();
75 BOOST_CHECK_EQUAL(face.failCount, 1);
76 face.failOnce();
77 BOOST_CHECK_EQUAL(face.failCount, 1);
78}
79
Junxiao Shi2c29f3a2014-01-24 19:59:00 -070080BOOST_AUTO_TEST_SUITE_END()
81
Junxiao Shid9ee45c2014-02-27 15:38:11 -070082} // namespace tests
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080083} // namespace nfd