Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/c-api/tests/table.cc
1692 views
1
#include <wasmtime/table.hh>
2
3
#include <gtest/gtest.h>
4
#include <wasmtime.hh>
5
6
using namespace wasmtime;
7
8
TEST(Table, Smoke) {
9
Engine engine;
10
Store store(engine);
11
Table::create(store, TableType(ValKind::FuncRef, 1), 3.0).err();
12
13
Val null = std::optional<Func>();
14
Table t = Table::create(store, TableType(ValKind::FuncRef, 1), null).unwrap();
15
EXPECT_FALSE(t.get(store, 1));
16
EXPECT_TRUE(t.get(store, 0));
17
Val val = *t.get(store, 0);
18
EXPECT_EQ(val.kind(), ValKind::FuncRef);
19
EXPECT_FALSE(val.funcref());
20
EXPECT_EQ(t.grow(store, 4, null).unwrap(), 1);
21
t.set(store, 3, null).unwrap();
22
t.set(store, 3, 3).err();
23
EXPECT_EQ(t.size(store), 5);
24
EXPECT_EQ(t.type(store)->element().kind(), ValKind::FuncRef);
25
}
26
27