wasmer/lib/runtime-c-api/tests/test-tables.c

45 lines
1.4 KiB
C
Raw Normal View History

2019-02-09 19:37:07 +00:00
#include <stdio.h>
#include "../wasmer.h"
#include <assert.h>
#include <stdint.h>
int main()
{
wasmer_table_t *table = NULL;
wasmer_limits_t descriptor;
descriptor.min = 10;
2019-02-09 19:58:50 +00:00
descriptor.max = 15;
2019-02-12 01:07:28 +00:00
wasmer_result_t table_result = wasmer_table_new(&table, descriptor);
2019-02-09 19:37:07 +00:00
printf("Table result: %d\n", table_result);
2019-02-12 01:07:28 +00:00
assert(table_result == WASMER_OK);
2019-02-09 19:37:07 +00:00
uint32_t len = wasmer_table_length(table);
printf("Table length: %d\n", len);
2019-02-09 19:58:50 +00:00
assert(len == 15);
2019-02-12 01:07:28 +00:00
// wasmer_result_t grow_result1 = wasmer_table_grow(&table, 5);
// assert(grow_result1 == WASMER_OK);
2019-02-09 19:58:50 +00:00
// uint32_t len_grow1 = wasmer_table_length(table);
// printf("Table length: %d\n", len_grow1);
// assert(len_grow1 == 15);
// // Try to grow beyond max
2019-02-12 01:07:28 +00:00
// wasmer_result_t grow_result2 = wasmer_table_grow(&table, 1);
// assert(grow_result2 == WASMER_ERROR);
2019-02-09 19:58:50 +00:00
// uint32_t len_grow2 = wasmer_table_length(table);
// printf("Table length: %d\n", len_grow2);
// assert(len_grow2 == 15);
2019-02-09 19:37:07 +00:00
2019-02-10 23:57:23 +00:00
// wasmer_table_t *table_bad = NULL;
// wasmer_limits_t bad_descriptor;
// bad_descriptor.min = 15;
// bad_descriptor.max = 10;
2019-02-12 01:07:28 +00:00
// wasmer_result_t table_bad_result = wasmer_table_new(&table_bad, bad_descriptor);
2019-02-10 23:57:23 +00:00
// printf("Table result: %d\n", table_bad_result);
2019-02-12 01:07:28 +00:00
// assert(table_result == WASMER_ERROR);
2019-02-10 23:57:23 +00:00
2019-02-09 19:37:07 +00:00
printf("Destroy table\n");
wasmer_table_destroy(table);
return 0;
}