diff --git a/dub.sdl b/dub.sdl index e2fded5..74e1318 100644 --- a/dub.sdl +++ b/dub.sdl @@ -4,6 +4,7 @@ homepage "" authors "Laszlo Szeremi" license "Boost" +sourcePaths "source/" targetType "staticLibrary" targetPath "lib" targetName "BindBC_zstandard" @@ -26,3 +27,9 @@ configuration "staticBC" { versions "BindZSTD_Static" excludedSourceFiles "source/bindbc/zstandard/dynload.d" } + +buildType "unittest" { + buildOptions "unittests" "debugMode" "debugInfo" + sourceFiles "test.d" + sourcePaths "source/" +} \ No newline at end of file diff --git a/source/bindbc/zstandard/bind.d b/source/bindbc/zstandard/bind.d deleted file mode 100644 index d3b742e..0000000 --- a/source/bindbc/zstandard/bind.d +++ /dev/null @@ -1,2 +0,0 @@ -module bindbc.zstandard.bind; - diff --git a/source/bindbc/zstandard/package.d b/source/bindbc/zstandard/package.d new file mode 100644 index 0000000..ad74634 --- /dev/null +++ b/source/bindbc/zstandard/package.d @@ -0,0 +1,5 @@ +module bindbc.zstandard; + +public import bindbc.zstandard.dynload; +public import bindbc.zstandard.zstd; +public import bindbc.zstandard.config; \ No newline at end of file diff --git a/test.d b/test.d new file mode 100644 index 0000000..ea2482c --- /dev/null +++ b/test.d @@ -0,0 +1,33 @@ +module test; + +import bindbc.zstandard; +import bindbc.loader.sharedlib; + +import std.stdio; +import std.conv : to; +/* + For testing dynamic linkage + */ + +unittest{ + if(loadZstandard("G:/Developing/zstd-v1.3.7-win32/dll/libzstd.dll") == ZSTDSupport.noLibrary){ + const(ErrorInfo)[] errorlist = errors; + foreach(e; errorlist){ + writeln(to!string(e.error)); + writeln(to!string(e.message)); + } + + } + ubyte[] origFile, compOut, decompOut; + + File file = File("zstd.exe"); + origFile.length = cast(size_t)file.size; + decompOut.length = cast(size_t)file.size; + compOut.length = cast(size_t)file.size; + file.rawRead(origFile); + size_t outputSize = ZSTD_compress(compOut.ptr, compOut.length, origFile.ptr, origFile.length, ZSTD_maxCLevel()); + ZSTD_decompress(decompOut.ptr, decompOut.length, compOut.ptr, outputSize); + for(int i ; i < origFile.length ; i++){ + assert(decompOut[i] == origFile[i], "Error at position " ~ to!string(i)); + } +} \ No newline at end of file