Skip to content

Commit 765490b

Browse files
author
Dane Springmeyer
committed
apply clang-format
1 parent f06b9b5 commit 765490b

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

include/gzip/compress.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Compressor
2424
}
2525

2626
template <typename InputType>
27-
void compress(InputType & output,
27+
void compress(InputType& output,
2828
const char* data,
2929
std::size_t size) const
3030
{
@@ -59,18 +59,18 @@ class Compressor
5959
constexpr int window_bits = 15 + 16; // gzip with windowbits of 15
6060

6161
constexpr int mem_level = 8;
62-
// The memory requirements for deflate are (in bytes):
63-
// (1 << (window_bits+2)) + (1 << (mem_level+9))
64-
// with a default value of 8 for mem_level and our window_bits of 15
65-
// this is 128Kb
62+
// The memory requirements for deflate are (in bytes):
63+
// (1 << (window_bits+2)) + (1 << (mem_level+9))
64+
// with a default value of 8 for mem_level and our window_bits of 15
65+
// this is 128Kb
6666

67-
#pragma GCC diagnostic push
68-
#pragma GCC diagnostic ignored "-Wold-style-cast"
67+
#pragma GCC diagnostic push
68+
#pragma GCC diagnostic ignored "-Wold-style-cast"
6969
if (deflateInit2(&deflate_s, level_, Z_DEFLATED, window_bits, mem_level, Z_DEFAULT_STRATEGY) != Z_OK)
7070
{
7171
throw std::runtime_error("deflate init failed");
7272
}
73-
#pragma GCC diagnostic pop
73+
#pragma GCC diagnostic pop
7474

7575
deflate_s.next_in = reinterpret_cast<z_const Bytef*>(data);
7676
deflate_s.avail_in = static_cast<unsigned int>(size);

include/gzip/decompress.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Decompressor
2121
}
2222

2323
template <typename OutputType>
24-
void decompress(OutputType & output,
24+
void decompress(OutputType& output,
2525
const char* data,
2626
std::size_t size) const
2727
{
@@ -43,13 +43,13 @@ class Decompressor
4343
// (8 to 15) + 32 to automatically detect gzip/zlib header
4444
constexpr int window_bits = 15 + 32; // auto with windowbits of 15
4545

46-
#pragma GCC diagnostic push
47-
#pragma GCC diagnostic ignored "-Wold-style-cast"
46+
#pragma GCC diagnostic push
47+
#pragma GCC diagnostic ignored "-Wold-style-cast"
4848
if (inflateInit2(&inflate_s, window_bits) != Z_OK)
4949
{
5050
throw std::runtime_error("inflate init failed");
5151
}
52-
#pragma GCC diagnostic pop
52+
#pragma GCC diagnostic pop
5353
inflate_s.next_in = reinterpret_cast<z_const Bytef*>(data);
5454

5555
#ifdef DEBUG

include/gzip/utils.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ inline bool is_compressed(const char* data, std::size_t size)
1919
// gzip
2020
(static_cast<uint8_t>(data[0]) == 0x1F && static_cast<uint8_t>(data[1]) == 0x8B));
2121
}
22-
2322
}

test/test.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ TEST_CASE("successful compress")
2222
std::string value = gzip::compress(pointer, data.size());
2323
REQUIRE(!value.empty());
2424
}
25-
2625
}
2726

2827
TEST_CASE("fail compress - throws max size limit")
@@ -89,7 +88,7 @@ TEST_CASE("round trip compression - gzip")
8988
{
9089
const std::string data("this is a sentence that will be compressed into something");
9190

92-
CHECK(!gzip::is_compressed(data.data(),data.size()));
91+
CHECK(!gzip::is_compressed(data.data(), data.size()));
9392

9493
SECTION("compression level - invalid")
9594
{
@@ -101,28 +100,28 @@ TEST_CASE("round trip compression - gzip")
101100
SECTION("no compression")
102101
{
103102
int level = Z_NO_COMPRESSION;
104-
std::string compressed_data = gzip::compress(data.data(),data.size());
105-
CHECK(gzip::is_compressed(compressed_data.data(),compressed_data.size()));
106-
std::string new_data = gzip::decompress(compressed_data.data(),compressed_data.size());
103+
std::string compressed_data = gzip::compress(data.data(), data.size());
104+
CHECK(gzip::is_compressed(compressed_data.data(), compressed_data.size()));
105+
std::string new_data = gzip::decompress(compressed_data.data(), compressed_data.size());
107106
CHECK(data == new_data);
108107
}
109108

110109
SECTION("default compression level")
111110
{
112111
int level = Z_DEFAULT_COMPRESSION;
113-
std::string compressed_data = gzip::compress(data.data(),data.size());
114-
CHECK(gzip::is_compressed(compressed_data.data(),compressed_data.size()));
115-
std::string new_data = gzip::decompress(compressed_data.data(),compressed_data.size());
112+
std::string compressed_data = gzip::compress(data.data(), data.size());
113+
CHECK(gzip::is_compressed(compressed_data.data(), compressed_data.size()));
114+
std::string new_data = gzip::decompress(compressed_data.data(), compressed_data.size());
116115
CHECK(data == new_data);
117116
}
118117

119118
SECTION("compression level -- min to max")
120119
{
121120
for (int level = Z_BEST_SPEED; level <= Z_BEST_COMPRESSION; ++level)
122121
{
123-
std::string compressed_data = gzip::compress(data.data(),data.size());
124-
CHECK(gzip::is_compressed(compressed_data.data(),compressed_data.size()));
125-
std::string new_data = gzip::decompress(compressed_data.data(),compressed_data.size());
122+
std::string compressed_data = gzip::compress(data.data(), data.size());
123+
CHECK(gzip::is_compressed(compressed_data.data(), compressed_data.size()));
124+
std::string new_data = gzip::decompress(compressed_data.data(), compressed_data.size());
126125
CHECK(data == new_data);
127126
}
128127
}

0 commit comments

Comments
 (0)