From f6b5f1ba1b7ec435a6237f0d389656f5677b1491 Mon Sep 17 00:00:00 2001 From: Yaron Wittenstein Date: Wed, 31 Jul 2019 14:32:38 +0300 Subject: [PATCH] wasmer-c-api: adding `asserts` to `tests/test-context.c` --- lib/runtime-c-api/tests/test-context.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/runtime-c-api/tests/test-context.c b/lib/runtime-c-api/tests/test-context.c index cc8bfcef5..5e792fa84 100644 --- a/lib/runtime-c-api/tests/test-context.c +++ b/lib/runtime-c-api/tests/test-context.c @@ -73,11 +73,21 @@ int main() counter->amount = 5; wasmer_instance_context_data_set(instance, counter); - wasmer_result_t call1_result = wasmer_instance_call(instance, "inc_and_get", NULL, 0, NULL, 0); - printf("Call result: %d\n", call1_result); + wasmer_value_t result_one; + wasmer_value_t params[] = {}; + wasmer_value_t results[] = {result_one}; - wasmer_result_t call2_result = wasmer_instance_call(instance, "inc_and_get", NULL, 0, NULL, 0); + wasmer_result_t call1_result = wasmer_instance_call(instance, "inc_and_get", params, 0, results, 1); + printf("Call result: %d\n", call1_result); + printf("Result: %d\n", results[0].value.I32); + assert(results[0].value.I32 == 5); + assert(call1_result == WASMER_OK); + + wasmer_result_t call2_result = wasmer_instance_call(instance, "inc_and_get", params, 0, results, 1); printf("Call result: %d\n", call2_result); + printf("Result: %d\n", results[0].value.I32); + assert(results[0].value.I32 == 10); + assert(call2_result == WASMER_OK); return 0; }