blob: 07e4d2bff61ffa82f08a1802c355f1ea06555329 [file] [log] [blame]
Junxiao Shi2713a3b2015-06-22 16:19:05 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventob07d7a92020-05-13 23:30:07 -04002/*
Davide Pesaventob3570c62022-02-19 19:19:00 -05003 * Copyright (c) 2014-2022 Arizona Board of Regents.
Junxiao Shi2713a3b2015-06-22 16:19:05 -07004 *
5 * This file is part of ndn-tools (Named Data Networking Essential Tools).
6 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
7 *
8 * ndn-tools 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 * ndn-tools 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 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
Davide Pesaventob07d7a92020-05-13 23:30:07 -040020// The unit being tested should be included first, to ensure the header compiles on its own.
Junxiao Shi2713a3b2015-06-22 16:19:05 -070021// For further information about test naming conventions, see
Davide Pesaventob07d7a92020-05-13 23:30:07 -040022// https://redmine.named-data.net/projects/nfd/wiki/UnitTesting
23//#include "unit-under-test.hpp"
Junxiao Shi2713a3b2015-06-22 16:19:05 -070024
25#include "tests/test-common.hpp"
Davide Pesavento66777622020-10-09 18:46:03 -040026#include "tests/io-fixture.hpp" // optional, for IoFixture
27//#include "tests/key-chain-fixture.hpp" // optional, for KeyChainFixture
Junxiao Shi2713a3b2015-06-22 16:19:05 -070028
Davide Pesaventob07d7a92020-05-13 23:30:07 -040029// Unit tests should go inside the ndn::tool_name::tests namespace.
Davide Pesaventob3570c62022-02-19 19:19:00 -050030namespace ndn::tool_name::tests {
Junxiao Shi2713a3b2015-06-22 16:19:05 -070031
Davide Pesaventob07d7a92020-05-13 23:30:07 -040032// Common fixtures in ndn::tests can be imported if needed.
Junxiao Shi2713a3b2015-06-22 16:19:05 -070033using namespace ndn::tests;
34
Davide Pesaventob3570c62022-02-19 19:19:00 -050035// See https://redmine.named-data.net/projects/nfd/wiki/UnitTesting
36// for a guide on how to name a test suite.
Junxiao Shi2713a3b2015-06-22 16:19:05 -070037BOOST_AUTO_TEST_SUITE(TestSkeleton)
38
39BOOST_AUTO_TEST_CASE(Test1)
40{
41 int i = 0;
42
43 // For reference of available Boost.Test macros, see
Davide Pesavento2ab04a22023-09-15 22:08:22 -040044 // https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/testing_tools/summary.html
Junxiao Shi2713a3b2015-06-22 16:19:05 -070045
46 BOOST_REQUIRE_NO_THROW(i = 1);
Davide Pesaventob07d7a92020-05-13 23:30:07 -040047 BOOST_CHECK_EQUAL(i, 1);
Junxiao Shi2713a3b2015-06-22 16:19:05 -070048}
49
Davide Pesavento66777622020-10-09 18:46:03 -040050// Use ClockFixture or IoFixture to mock clocks.
51BOOST_FIXTURE_TEST_CASE(Test2, IoFixture)
Junxiao Shi2713a3b2015-06-22 16:19:05 -070052{
Davide Pesaventob07d7a92020-05-13 23:30:07 -040053 // advanceClocks() increments mock clocks.
Davide Pesavento66777622020-10-09 18:46:03 -040054 advanceClocks(500_ms);
Junxiao Shi2713a3b2015-06-22 16:19:05 -070055}
56
Davide Pesaventob3570c62022-02-19 19:19:00 -050057BOOST_AUTO_TEST_SUITE_END() // TestSkeleton
Junxiao Shi2713a3b2015-06-22 16:19:05 -070058
Davide Pesaventob3570c62022-02-19 19:19:00 -050059} // namespace ndn::tool_name::tests