blob: 7494668d6318b416c26957df2235241ead991a2d [file] [log] [blame]
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -05001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Davide Pesavento30c41ec2024-02-12 17:36:35 -05003 * Copyright (c) 2012-2024 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
Davide Pesavento30c41ec2024-02-12 17:36:35 -050024namespace chronosync::tests {
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -050025
Davide Pesavento30c41ec2024-02-12 17:36:35 -050026BOOST_AUTO_TEST_SUITE(Bzip2HelperTests)
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -050027
28BOOST_AUTO_TEST_CASE(Basic)
29{
30 std::string message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
31 "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
32 "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris "
33 "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in "
34 "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
35 "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
36 "mollit anim id est laborum.";
37
38 auto compressed = bzip2::compress(message.data(), message.size());
39 BOOST_CHECK_LT(compressed->size(), message.size());
40
41 auto decompressed = bzip2::decompress(reinterpret_cast<const char*>(compressed->data()), compressed->size());
42 BOOST_CHECK_EQUAL(message.size(), decompressed->size());
43 BOOST_CHECK_EQUAL(message, std::string(reinterpret_cast<const char*>(decompressed->data()), decompressed->size()));
44}
45
46BOOST_AUTO_TEST_SUITE_END()
47
Davide Pesavento30c41ec2024-02-12 17:36:35 -050048} // namespace chronosync::tests