Skip to content

Commit

Permalink
Loads DLL successfully
Browse files Browse the repository at this point in the history
Contact me if something doesn't work right!
  • Loading branch information
ZILtoid1991 committed Jan 5, 2019
1 parent c522391 commit c0f0e50
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
7 changes: 7 additions & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ homepage ""
authors "Laszlo Szeremi"
license "Boost"

sourcePaths "source/"
targetType "staticLibrary"
targetPath "lib"
targetName "BindBC_zstandard"
Expand All @@ -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/"
}
2 changes: 0 additions & 2 deletions source/bindbc/zstandard/bind.d

This file was deleted.

5 changes: 5 additions & 0 deletions source/bindbc/zstandard/package.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module bindbc.zstandard;

public import bindbc.zstandard.dynload;
public import bindbc.zstandard.zstd;
public import bindbc.zstandard.config;
33 changes: 33 additions & 0 deletions test.d
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit c0f0e50

Please sign in to comment.