blob: 550651ad4b22027ee20cf7d01a4b3ba756cd8a03 [file] [log] [blame]
Davide Pesavento409cc202015-09-19 14:13:16 +02001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2015 Regents of the University of California.
4 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
22#include "util/backports.hpp"
23
24#include "boost-test.hpp"
25
26namespace ndn {
27namespace tests {
28
29BOOST_AUTO_TEST_SUITE(Util)
30BOOST_AUTO_TEST_SUITE(TestBackports)
31
32BOOST_AUTO_TEST_CASE(MakeUnique)
33{
34 std::unique_ptr<int> v0 = make_unique<int>();
35 std::unique_ptr<int> v1 = make_unique<int>(1728);
36 BOOST_CHECK_EQUAL(*v0, 0);
37 BOOST_CHECK_EQUAL(*v1, 1728);
38
39 auto str = make_unique<std::string>("meow");
40 BOOST_CHECK_EQUAL(*str, "meow");
41
42 class Movable
43 {
44 public:
45 Movable()
46 : value(42)
47 {
48 }
49
50 Movable(const Movable&) = delete;
51 Movable(Movable&&) = default;
52
53 public:
54 int value;
55 };
56
57 class Container
58 {
59 public:
60 explicit
61 Container(Movable m)
62 : m(std::move(m))
63 {
64 }
65
66 public:
67 Movable m;
68 };
69
70 Movable m;
71 auto ptr = make_unique<Container>(std::move(m));
72 BOOST_CHECK_EQUAL(ptr->m.value, 42);
73}
74
75BOOST_AUTO_TEST_SUITE_END()
76BOOST_AUTO_TEST_SUITE_END()
77
78} // namespace tests
79} // namespace ndn