blob: bb9087bb80288f528869a3e053859f57422a51e3 [file] [log] [blame]
spirosmastorakisfd334462016-04-18 15:48:31 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3* Copyright (c) 2016 Regents of the University of California.
4*
5* This file is part of the nTorrent codebase.
6*
7* nTorrent 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* nTorrent 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 nTorrent, e.g., in COPYING.md file. If not, see
17* <http://www.gnu.org/licenses/>.
18*
19* See AUTHORS for complete list of nTorrent authors and contributors.
20*/
21
22#include "../boost-test.hpp"
23#include "util/io-util.hpp"
24
25namespace ndn {
26namespace ntorrent {
27namespace tests {
28
29BOOST_AUTO_TEST_SUITE(TestIoUtils)
30
31BOOST_AUTO_TEST_CASE(TestFindType)
32{
33 BOOST_CHECK_EQUAL(IoUtil::findType(Name("NTORRENT/linux/torrent-file/sha256digest")), 0);
34
35 Name n1("NTORRENT/linux/torrent-file");
36 n1.appendSequenceNumber(0);
37 n1 = Name(n1.toUri() + "/sha256digest");
38
39 BOOST_CHECK_EQUAL(IoUtil::findType(n1), 0);
40
41 Name n2("NTORRENT/linux/file0");
42 n2.appendSequenceNumber(0);
43 n2 = Name(n2.toUri() + "/sha256digest");
44
45 BOOST_CHECK_EQUAL(IoUtil::findType(n2), 1);
46
47 Name n3("NTORRENT/linux/file0");
48 n3.appendSequenceNumber(0);
49 n3.appendSequenceNumber(0);
50 n3 = Name(n3.toUri() + "/sha256digest");
51
52 BOOST_CHECK_EQUAL(IoUtil::findType(n3), 2);
53}
54
55BOOST_AUTO_TEST_SUITE_END()
56
57} // namespace tests
58} // namespace nTorrent
59} // namespace ndn