Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 7 | // #include "unit-under-test.hpp" |
| 8 | // Unit being tested MUST be included first, to ensure header compiles on its own. |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 9 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 10 | #include "tests/test-common.hpp" |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 11 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 12 | namespace nfd { |
| 13 | namespace tests { |
| 14 | // Unit tests SHOULD go inside nfd::tests namespace. |
| 15 | |
| 16 | // Test suite SHOULD use BaseFixture or a subclass of it. |
| 17 | BOOST_FIXTURE_TEST_SUITE(TestSkeleton, BaseFixture) |
| 18 | |
| 19 | BOOST_AUTO_TEST_CASE(Test1) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 20 | { |
| 21 | int i = 0; |
| 22 | /** |
| 23 | * For reference of available Boost.Test macros, @see http://www.boost.org/doc/libs/1_55_0/libs/test/doc/html/utf/testing-tools/reference.html |
| 24 | */ |
| 25 | |
| 26 | BOOST_REQUIRE_NO_THROW(i = 1); |
| 27 | BOOST_REQUIRE_EQUAL(i, 1); |
| 28 | } |
| 29 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 30 | // Custom fixture SHOULD derive from BaseFixture. |
| 31 | class Test2Fixture : protected BaseFixture |
| 32 | { |
| 33 | }; |
| 34 | |
| 35 | BOOST_FIXTURE_TEST_CASE(Test2, Test2Fixture) |
| 36 | { |
| 37 | // g_io is a shorthand of getGlobalIoService() |
| 38 | // resetGlobalIoService() is automatically called after each test case |
| 39 | g_io.run(); |
| 40 | } |
| 41 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 42 | BOOST_AUTO_TEST_SUITE_END() |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 43 | |
| 44 | } // namespace tests |
| 45 | } // namespace nfd |