-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Closed
Labels
addonsIssues and PRs related to native addons.Issues and PRs related to native addons.testIssues and PRs related to the tests.Issues and PRs related to the tests.zlibIssues and PRs related to the zlib subsystem.Issues and PRs related to the zlib subsystem.

Description
Just like #6274 we need a test for zlib usage. The node.exe binary on Windows does not export zlib symbols and this can be fixed by linking against a .def file with these symbols added.
A basic test could be something like this:
#include <zlib.h>
#include <cassert>
int main() {
z_stream zStream = {};
int err = deflateInit2(&zStream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
assert(Z_OK == err);
unsigned char helloString[] = "hello";
unsigned char expectedDeflation[] = {0xca, 0x48, 0xcd, 0xc9, 0xc9, 0x7, 0x0, 0x0, 0x0, 0xff, 0xff};
unsigned char outputString[512];
zStream.avail_in = sizeof(helloString) - 1;
zStream.next_in = (unsigned char *) helloString;
zStream.avail_out = sizeof(outputString);
zStream.next_out = outputString;
err = deflate(&zStream, Z_SYNC_FLUSH);
assert(err == Z_OK || err == Z_STREAM_END);
int deflatedLength = sizeof(outputString) - zStream.avail_out;
for (int i = 0; i < deflatedLength; i++) {
assert(outputString[i] == expectedDeflation[i]);
}
deflateEnd(&zStream);
}
Metadata
Metadata
Assignees
Labels
addonsIssues and PRs related to native addons.Issues and PRs related to native addons.testIssues and PRs related to the tests.Issues and PRs related to the tests.zlibIssues and PRs related to the zlib subsystem.Issues and PRs related to the zlib subsystem.