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 | 07684bc | 2021-02-07 20:09:28 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2012-2021 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 | |
| 24 | namespace chronosync { |
| 25 | namespace test { |
| 26 | |
Alexander Afanasyev | 6ee98ff | 2018-02-13 19:12:28 -0500 | [diff] [blame] | 27 | BOOST_AUTO_TEST_SUITE(TestBzip2Helper) |
| 28 | |
| 29 | BOOST_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 | |
| 47 | BOOST_AUTO_TEST_SUITE_END() |
| 48 | |
| 49 | } // namespace test |
| 50 | } // namespace chronosync |