blob: 3b213f8e4f54ccf99cca377c829918de0054026c [file] [log] [blame]
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -05001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Davide Pesavento07684bc2021-02-07 20:09:28 -05003 * Copyright (c) 2012-2021 University of California, Los Angeles
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -05004 *
5 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
7 *
8 * ChronoSync 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, either
10 * version 3 of the License, or (at your option) any later version.
11 *
12 * ChronoSync 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 * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
Davide Pesavento07684bc2021-02-07 20:09:28 -050020#include "detail/bzip2-helper.hpp"
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -050021
Davide Pesaventofae9def2019-01-29 14:34:33 -050022#include "tests/boost-test.hpp"
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -050023
24namespace chronosync {
25namespace test {
26
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -050027BOOST_AUTO_TEST_SUITE(TestBzip2Helper)
28
29BOOST_AUTO_TEST_CASE(Basic)
30{
31 std::string message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
32 "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
33 "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris "
34 "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in "
35 "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
36 "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
37 "mollit anim id est laborum.";
38
39 auto compressed = bzip2::compress(message.data(), message.size());
40 BOOST_CHECK_LT(compressed->size(), message.size());
41
42 auto decompressed = bzip2::decompress(reinterpret_cast<const char*>(compressed->data()), compressed->size());
43 BOOST_CHECK_EQUAL(message.size(), decompressed->size());
44 BOOST_CHECK_EQUAL(message, std::string(reinterpret_cast<const char*>(decompressed->data()), decompressed->size()));
45}
46
47BOOST_AUTO_TEST_SUITE_END()
48
49} // namespace test
50} // namespace chronosync