Alexander Afanasyev | 6ee98ff | 2018-02-13 19:12:28 -0500 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame] | 3 | * Copyright (c) 2012-2024 University of California, Los Angeles |
Alexander Afanasyev | 6ee98ff | 2018-02-13 19:12:28 -0500 | [diff] [blame] | 4 | * |
| 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 Pesavento | 07684bc | 2021-02-07 20:09:28 -0500 | [diff] [blame] | 20 | #include "detail/bzip2-helper.hpp" |
Alexander Afanasyev | 6ee98ff | 2018-02-13 19:12:28 -0500 | [diff] [blame] | 21 | |
Davide Pesavento | fae9def | 2019-01-29 14:34:33 -0500 | [diff] [blame] | 22 | #include "tests/boost-test.hpp" |
Alexander Afanasyev | 6ee98ff | 2018-02-13 19:12:28 -0500 | [diff] [blame] | 23 | |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame] | 24 | namespace chronosync::tests { |
Alexander Afanasyev | 6ee98ff | 2018-02-13 19:12:28 -0500 | [diff] [blame] | 25 | |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame] | 26 | BOOST_AUTO_TEST_SUITE(Bzip2HelperTests) |
Alexander Afanasyev | 6ee98ff | 2018-02-13 19:12:28 -0500 | [diff] [blame] | 27 | |
| 28 | BOOST_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 | |
| 46 | BOOST_AUTO_TEST_SUITE_END() |
| 47 | |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame] | 48 | } // namespace chronosync::tests |