Skip to content

Commit 619cf67

Browse files
committed
Merge branch 'unit-tests' into develop
2 parents 9baa3cd + ff27c8c commit 619cf67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4435
-291
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ roadmap.txt
5858
*.dfo
5959
.PVS-Studio/
6060
pvs-studio-analyzer.stacktrace.txt
61+
62+
# Test data
63+
tests/data/

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "7-zip"]
22
path = third_party/7-zip
3-
url = https://github.com/rikyoz/7-Zip
3+
url = https://github.com/rikyoz/7-Zip

cmake/CompilerOptions.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
7777
if( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.8 )
7878
target_compile_options( ${LIB_TARGET} PRIVATE -Wdouble-promotion )
7979
endif()
80+
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0 )
81+
target_compile_options( ${LIB_TARGET} PRIVATE -Wno-missing-braces -Wmissing-field-initializers )
82+
endif()
8083
endif()
8184

8285
if( APPLE )

include/bit7z/bitarchivereader.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BitArchiveReader final : public BitAbstractArchiveOpener, public BitInputA
2929
* @brief Constructs a BitArchiveReader object, opening the input file archive.
3030
*
3131
* @note When bit7z is compiled using the `BIT7Z_AUTO_FORMAT` option, the format
32-
* argument has default value BitFormat::Auto (automatic format detection of the input archive).
32+
* argument has the default value BitFormat::Auto (automatic format detection of the input archive).
3333
* On the contrary, when `BIT7Z_AUTO_FORMAT` is not defined (i.e., no auto format detection available),
3434
* the format argument must be specified.
3535
*
@@ -47,7 +47,7 @@ class BitArchiveReader final : public BitAbstractArchiveOpener, public BitInputA
4747
* @brief Constructs a BitArchiveReader object, opening the archive in the input buffer.
4848
*
4949
* @note When bit7z is compiled using the `BIT7Z_AUTO_FORMAT` option, the format
50-
* argument has default value BitFormat::Auto (automatic format detection of the input archive).
50+
* argument has the default value BitFormat::Auto (automatic format detection of the input archive).
5151
* On the contrary, when `BIT7Z_AUTO_FORMAT` is not defined (i.e., no auto format detection available),
5252
* the format argument must be specified.
5353
*
@@ -65,7 +65,7 @@ class BitArchiveReader final : public BitAbstractArchiveOpener, public BitInputA
6565
* @brief Constructs a BitArchiveReader object, opening the archive from the standard input stream.
6666
*
6767
* @note When bit7z is compiled using the `BIT7Z_AUTO_FORMAT` option, the format
68-
* argument has default value BitFormat::Auto (automatic format detection of the input archive).
68+
* argument has the default value BitFormat::Auto (automatic format detection of the input archive).
6969
* On the contrary, when `BIT7Z_AUTO_FORMAT` is not defined (i.e., no auto format detection available),
7070
* the format argument must be specified.
7171
*

include/bit7z/bitformat.hpp

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ namespace bit7z {
2424
* @brief The FormatFeatures enum specifies the features supported by an archive file format.
2525
*/
2626
enum struct FormatFeatures : unsigned {
27-
MultipleFiles = 1 << 0, ///< The format can compress/extract multiple files (2^0 = 0000001)
28-
SolidArchive = 1 << 1, ///< The format supports solid archives (2^1 = 0000010)
29-
CompressionLevel = 1 << 2, ///< The format is able to use different compression levels (2^2 = 0000100)
30-
Encryption = 1 << 3, ///< The format supports archive encryption (2^3 = 0001000)
31-
HeaderEncryption = 1 << 4, ///< The format can encrypt the file names (2^4 = 0010000)
32-
MultipleMethods = 1 << 5 ///< The format can use different compression methods (2^6 = 0100000)
27+
MultipleFiles = 1u << 0, ///< The format can compress/extract multiple files (2^0 = 0000001)
28+
SolidArchive = 1u << 1, ///< The format supports solid archives (2^1 = 0000010)
29+
CompressionLevel = 1u << 2, ///< The format is able to use different compression levels (2^2 = 0000100)
30+
Encryption = 1u << 3, ///< The format supports archive encryption (2^3 = 0001000)
31+
HeaderEncryption = 1u << 4, ///< The format can encrypt the file names (2^4 = 0010000)
32+
MultipleMethods = 1u << 5 ///< The format can use different compression methods (2^6 = 0100000)
3333
};
3434

3535
template< typename E >
@@ -175,62 +175,62 @@ namespace BitFormat {
175175
*/
176176
extern const BitInFormat Auto;
177177
#endif
178-
extern const BitInFormat Rar, ///< RAR Archive Format
179-
Arj, ///< ARJ Archive Format
180-
Z, ///< Z Archive Format
181-
Lzh, ///< LZH Archive Format
182-
Cab, ///< CAB Archive Format
183-
Nsis, ///< NSIS Archive Format
184-
Lzma, ///< LZMA Archive Format
185-
Lzma86, ///< LZMA86 Archive Format
186-
Ppmd, ///< PPMD Archive Format
187-
Vhdx, ///< VHDX Archive Format
188-
COFF, ///< COFF Archive Format
189-
Ext, ///< EXT Archive Format
190-
VMDK, ///< VMDK Archive Format
191-
VDI, ///< VDI Archive Format
192-
QCow, ///< QCOW Archive Format
193-
GPT, ///< GPT Archive Format
194-
Rar5, ///< RAR5 Archive Format
195-
IHex, ///< IHEX Archive Format
196-
Hxs, ///< HXS Archive Format
197-
TE, ///< TE Archive Format
198-
UEFIc, ///< UEFIc Archive Format
199-
UEFIs, ///< UEFIs Archive Format
200-
SquashFS, ///< SquashFS Archive Format
201-
CramFS, ///< CramFS Archive Format
202-
APM, ///< APM Archive Format
203-
Mslz, ///< MSLZ Archive Format
204-
Flv, ///< FLV Archive Format
205-
Swf, ///< SWF Archive Format
206-
Swfc, ///< SWFC Archive Format
207-
Ntfs, ///< NTFS Archive Format
208-
Fat, ///< FAT Archive Format
209-
Mbr, ///< MBR Archive Format
210-
Vhd, ///< VHD Archive Format
211-
Pe, ///< PE Archive Format
212-
Elf, ///< ELF Archive Format
213-
Macho, ///< MACHO Archive Format
214-
Udf, ///< UDF Archive Format
215-
Xar, ///< XAR Archive Format
216-
Mub, ///< MUB Archive Format
217-
Hfs, ///< HFS Archive Format
218-
Dmg, ///< DMG Archive Format
219-
Compound, ///< COMPOUND Archive Format
220-
Iso, ///< ISO Archive Format
221-
Chm, ///< CHM Archive Format
222-
Split, ///< SPLIT Archive Format
223-
Rpm, ///< RPM Archive Format
224-
Deb, ///< DEB Archive Format
225-
Cpio; ///< CPIO Archive Format
226-
227-
extern const BitInOutFormat Zip, ///< ZIP Archive Format
228-
BZip2, ///< BZIP2 Archive Format
229-
SevenZip, ///< 7Z Archive Format
230-
Xz, ///< XZ Archive Format
231-
Wim, ///< WIM Archive Format
232-
Tar, ///< TAR Archive Format
233-
GZip; ///< GZIP Archive Format
178+
extern const BitInFormat Rar; ///< RAR Archive Format
179+
extern const BitInFormat Arj; ///< ARJ Archive Format
180+
extern const BitInFormat Z; ///< Z Archive Format
181+
extern const BitInFormat Lzh; ///< LZH Archive Format
182+
extern const BitInFormat Cab; ///< CAB Archive Format
183+
extern const BitInFormat Nsis; ///< NSIS Archive Format
184+
extern const BitInFormat Lzma; ///< LZMA Archive Format
185+
extern const BitInFormat Lzma86; ///< LZMA86 Archive Format
186+
extern const BitInFormat Ppmd; ///< PPMD Archive Format
187+
extern const BitInFormat Vhdx; ///< VHDX Archive Format
188+
extern const BitInFormat COFF; ///< COFF Archive Format
189+
extern const BitInFormat Ext; ///< EXT Archive Format
190+
extern const BitInFormat VMDK; ///< VMDK Archive Format
191+
extern const BitInFormat VDI; ///< VDI Archive Format
192+
extern const BitInFormat QCow; ///< QCOW Archive Format
193+
extern const BitInFormat GPT; ///< GPT Archive Format
194+
extern const BitInFormat Rar5; ///< RAR5 Archive Format
195+
extern const BitInFormat IHex; ///< IHEX Archive Format
196+
extern const BitInFormat Hxs; ///< HXS Archive Format
197+
extern const BitInFormat TE; ///< TE Archive Format
198+
extern const BitInFormat UEFIc; ///< UEFIc Archive Format
199+
extern const BitInFormat UEFIs; ///< UEFIs Archive Format
200+
extern const BitInFormat SquashFS; ///< SquashFS Archive Format
201+
extern const BitInFormat CramFS; ///< CramFS Archive Format
202+
extern const BitInFormat APM; ///< APM Archive Format
203+
extern const BitInFormat Mslz; ///< MSLZ Archive Format
204+
extern const BitInFormat Flv; ///< FLV Archive Format
205+
extern const BitInFormat Swf; ///< SWF Archive Format
206+
extern const BitInFormat Swfc; ///< SWFC Archive Format
207+
extern const BitInFormat Ntfs; ///< NTFS Archive Format
208+
extern const BitInFormat Fat; ///< FAT Archive Format
209+
extern const BitInFormat Mbr; ///< MBR Archive Format
210+
extern const BitInFormat Vhd; ///< VHD Archive Format
211+
extern const BitInFormat Pe; ///< PE Archive Format
212+
extern const BitInFormat Elf; ///< ELF Archive Format
213+
extern const BitInFormat Macho; ///< MACHO Archive Format
214+
extern const BitInFormat Udf; ///< UDF Archive Format
215+
extern const BitInFormat Xar; ///< XAR Archive Format
216+
extern const BitInFormat Mub; ///< MUB Archive Format
217+
extern const BitInFormat Hfs; ///< HFS Archive Format
218+
extern const BitInFormat Dmg; ///< DMG Archive Format
219+
extern const BitInFormat Compound; ///< COMPOUND Archive Format
220+
extern const BitInFormat Iso; ///< ISO Archive Format
221+
extern const BitInFormat Chm; ///< CHM Archive Format
222+
extern const BitInFormat Split; ///< SPLIT Archive Format
223+
extern const BitInFormat Rpm; ///< RPM Archive Format
224+
extern const BitInFormat Deb; ///< DEB Archive Format
225+
extern const BitInFormat Cpio; ///< CPIO Archive Format
226+
227+
extern const BitInOutFormat Zip; ///< ZIP Archive Format
228+
extern const BitInOutFormat BZip2; ///< BZIP2 Archive Format
229+
extern const BitInOutFormat SevenZip; ///< 7Z Archive Format
230+
extern const BitInOutFormat Xz; ///< XZ Archive Format
231+
extern const BitInOutFormat Wim; ///< WIM Archive Format
232+
extern const BitInOutFormat Tar; ///< TAR Archive Format
233+
extern const BitInOutFormat GZip; ///< GZIP Archive Format
234234
} // namespace BitFormat
235235

236236

include/bit7z/bitwindows.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636

3737
// Avoiding accidentally including p7zip's MyWindows.h, so that its inclusion is not needed in client code!
3838
#ifndef __MYWINDOWS_H
39-
#define __MYWINDOWS_H
39+
#define __MYWINDOWS_H // NOLINT
4040
#endif
4141

4242
// Avoiding accidentally including 7-zip's MyWindows.h, so that its inclusion is not needed in client code!
4343
#ifndef __MY_WINDOWS_H
44-
#define __MY_WINDOWS_H
44+
#define __MY_WINDOWS_H // NOLINT
4545
#endif
4646

4747
using std::size_t;

src/bitabstractarchivecreator.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ auto isValidCompressionMethod( const BitInOutFormat& format, BitCompressionMetho
4040
}
4141

4242
auto isValidDictionarySize( BitCompressionMethod method, uint32_t dictionary_size ) noexcept -> bool {
43-
static constexpr auto MAX_LZMA_DICTIONARY_SIZE = 1536 * ( 1 << 20 ); // less than 1536 MiB
44-
static constexpr auto MAX_PPMD_DICTIONARY_SIZE = ( 1 << 30 ); // less than 1 GiB, i.e., 2^30 bytes
45-
static constexpr auto MAX_BZIP2_DICTIONARY_SIZE = 900 * ( 1 << 10 ); // less than 900 KiB
43+
static constexpr auto MAX_LZMA_DICTIONARY_SIZE = 1536 * ( 1LL << 20 ); // less than 1536 MiB
44+
static constexpr auto MAX_PPMD_DICTIONARY_SIZE = ( 1LL << 30 ); // less than 1 GiB, i.e., 2^30 bytes
45+
static constexpr auto MAX_BZIP2_DICTIONARY_SIZE = 900 * ( 1LL << 10 ); // less than 900 KiB
4646

4747
switch ( method ) {
4848
case BitCompressionMethod::Lzma:
@@ -267,15 +267,16 @@ auto BitAbstractArchiveCreator::archiveProperties() const -> ArchiveProperties {
267267
properties.setProperty( L"x", static_cast< uint32_t >( mCompressionLevel ) );
268268

269269
if ( mFormat.hasFeature( FormatFeatures::MultipleMethods ) && mCompressionMethod != mFormat.defaultMethod() ) {
270-
properties.setProperty( mFormat == BitFormat::SevenZip ? L"0" : L"m", methodName( mCompressionMethod ) );
270+
const auto* property_name = ( mFormat == BitFormat::SevenZip ) ? L"0" : L"m";
271+
properties.setProperty( property_name, methodName( mCompressionMethod ) );
271272
}
272273
}
273274
if ( mFormat.hasFeature( FormatFeatures::SolidArchive ) ) {
274275
properties.setProperty( L"s", mSolidMode );
275276
#ifndef _WIN32
276277
if ( mSolidMode ) {
277278
/* NOTE: Apparently, p7zip requires the filters to be set off for the solid compression to work.
278-
The most strange thing is... according to my tests this happens only in WSL!
279+
The strangest thing is... in my tests this happens only in WSL!
279280
I've tested the same code on a Linux VM, and it works without disabling the filters! */
280281
// TODO: So, for now I disable them, but this will need further investigation!
281282
properties.setProperty( L"f", false );

src/bitexception.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ BitException::BitException( const char* const message, std::error_code code, con
3737
}
3838

3939
BitException::BitException( const std::string& message, std::error_code code )
40-
: system_error( code, message.c_str() ) {}
40+
: system_error( code, message ) {}
4141

4242
auto BitException::failedFiles() const noexcept -> const FailedFiles& {
4343
return mFailedFiles;

src/bititemsvector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using filesystem::FSItem;
2222
using filesystem::FSIndexer;
2323

2424
void BitItemsVector::indexDirectory( const fs::path& in_dir, const tstring& filter, IndexingOptions options ) {
25-
//Note: if in_dir is an invalid path, FSItem constructor throws a BitException!
25+
// Note: if in_dir is an invalid path, FSItem constructor throws a BitException!
2626
const FSItem dir_item{ in_dir, options.retain_folder_structure ? in_dir : fs::path{} };
2727
if ( filter.empty() && !dir_item.inArchivePath().empty() ) {
2828
mItems.emplace_back( std::make_unique< FSItem >( dir_item ) );

src/internal/cbufferinstream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ STDMETHODIMP CBufferInStream::Read( void* data, UInt32 size, UInt32* processedSi
4949
* So we just read all the remaining bytes, not more or less. */
5050

5151
/* Note: here remaining is > 0 */
52-
std::copy_n( mCurrentPosition, remaining, static_cast< byte_t* >( data ) );
52+
std::copy_n( mCurrentPosition, remaining, static_cast< byte_t* >( data ) ); //-V2571
5353
std::advance( mCurrentPosition, remaining );
5454

5555
if ( processedSize != nullptr ) {

0 commit comments

Comments
 (0)