MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / TEST

Function TEST

crates/c-api/tests/table.cc:8–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace wasmtime;
7
8TEST(Table, Smoke) {
9 Engine engine;
10 Store store(engine);
11 Table::create(store, TableType(ValType::funcref(), 1), 3.0).err();
12
13 Val null = std::optional<Func>();
14 Table t =
15 Table::create(store, TableType(ValType::funcref(), 1), null).unwrap();
16 EXPECT_FALSE(t.get(store, 1));
17 EXPECT_TRUE(t.get(store, 0));
18 Val val = *t.get(store, 0);
19 EXPECT_EQ(val.kind(), ValKind::FuncRef);
20 EXPECT_FALSE(val.funcref());
21 EXPECT_EQ(t.grow(store, 4, null).unwrap(), 1);
22 t.set(store, 3, null).unwrap();
23 t.set(store, 3, 3).err();
24 EXPECT_EQ(t.size(store), 5);
25 EXPECT_EQ(t.type(store)->element(), ValType::funcref());
26}

Callers

nothing calls this directly

Calls 12

createFunction · 0.50
TableTypeClass · 0.50
errMethod · 0.45
unwrapMethod · 0.45
getMethod · 0.45
kindMethod · 0.45
funcrefMethod · 0.45
growMethod · 0.45
setMethod · 0.45
sizeMethod · 0.45
elementMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected