Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion test/example/c-api-kitchen-sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,10 +1526,28 @@ void test_core() {
BinaryenModulePrint(module);

// Verify it validates
assert(BinaryenModuleValidate(module));
int valid = BinaryenModuleValidate(module);
assert(valid);

// Verify no error occurs when writing out the code to binary.
size_t bufferSize = 10 * 1024 * 1024;
char* buffer = malloc(bufferSize);
size_t written = BinaryenModuleWrite(module, buffer, bufferSize);
// We wrote bytes, and we did not reach the end of the buffer (which would
// truncate).
assert(written > 0 && written < bufferSize);

// Clean up the module, which owns all the objects we created above
BinaryenModuleDispose(module);

// See we can read the bytes and get a valid module from there.
BinaryenModuleRef readModule = BinaryenModuleRead(buffer, written);
BinaryenModuleSetFeatures(readModule, BinaryenFeatureAll());
valid = BinaryenModuleValidate(readModule);
assert(valid);
BinaryenModuleDispose(readModule);

free(buffer);
}

void test_unreachable() {
Expand Down