blob: 99f6966169d4352f48ee08d68571d0f41f62a953 [file] [log] [blame]
Junxiao Shi38f4ce92016-08-04 10:01:52 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2016, 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.
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 */
25
Junxiao Shi331ade72016-08-19 14:07:19 +000026#include "nfdc/format-helpers.hpp"
Junxiao Shi38f4ce92016-08-04 10:01:52 +000027
28#include "tests/test-common.hpp"
29
30namespace nfd {
31namespace tools {
Junxiao Shi331ade72016-08-19 14:07:19 +000032namespace nfdc {
Junxiao Shi38f4ce92016-08-04 10:01:52 +000033namespace tests {
34
35using boost::test_tools::output_test_stream;
36
Junxiao Shi331ade72016-08-19 14:07:19 +000037BOOST_AUTO_TEST_SUITE(Nfdc)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000038BOOST_AUTO_TEST_SUITE(TestFormatHelpers)
39
40BOOST_AUTO_TEST_SUITE(Xml)
41
42BOOST_AUTO_TEST_CASE(TextEscaping)
43{
44 output_test_stream os;
45 os << xml::Text{"\"less than\" & 'greater than' surround XML <element> tag name"};
46
47 BOOST_CHECK(os.is_equal("&quot;less than&quot; &amp; &apos;greater than&apos;"
48 " surround XML &lt;element&gt; tag name"));
49}
50
51BOOST_AUTO_TEST_SUITE_END() // Xml
52
53BOOST_AUTO_TEST_SUITE(Text)
54
Junxiao Shi6c135622016-11-21 14:30:33 +000055BOOST_AUTO_TEST_CASE(Space)
56{
57 output_test_stream os;
58 os << 'A' << text::Spaces{-1} << 'B' << text::Spaces{0} << 'C' << text::Spaces{5} << 'D';
59
60 BOOST_CHECK(os.is_equal("ABC D"));
61}
62
Junxiao Shi38f4ce92016-08-04 10:01:52 +000063BOOST_AUTO_TEST_CASE(Sep)
64{
65 output_test_stream os;
66 text::Separator sep(",");
67 for (int i = 1; i <= 3; ++i) {
68 os << sep << i;
69 }
70
71 BOOST_CHECK(os.is_equal("1,2,3"));
72}
73
74BOOST_AUTO_TEST_SUITE_END() // Text
75
76BOOST_AUTO_TEST_SUITE_END() // TestFormatHelpers
Junxiao Shi331ade72016-08-19 14:07:19 +000077BOOST_AUTO_TEST_SUITE_END() // Nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +000078
79} // namespace tests
Junxiao Shi331ade72016-08-19 14:07:19 +000080} // namespace nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +000081} // namespace tools
82} // namespace nfd