Skip to content

Commit b618476

Browse files
committed
Add tests.
Signed-off-by: John Plevyak <[email protected]>
1 parent 10c8122 commit b618476

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/proxy-wasm/word.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace proxy_wasm {
2424
struct Word {
2525
Word(uint64_t w) : u64_(w) {} // Implicit conversion into Word.
2626
uint32_t u32() const { return static_cast<uint32_t>(u64_); }
27+
operator uint64_t() const { return u64_; }
2728
uint64_t u64_;
2829
};
2930

wasm_vm_test.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@
55
namespace proxy_wasm {
66
namespace {
77

8-
TEST(WasmVm, Load) {
8+
TEST(WasmVm, Compat) {
99
string_view foo = "foo";
1010
std::string bar = "bar";
1111

1212
EXPECT_NE(foo, bar);
1313
EXPECT_EQ(foo, "foo");
14+
15+
optional<int> o = PROXY_WASM_NULLOPT;
16+
EXPECT_FALSE(o);
17+
18+
o = 1;
19+
EXPECT_TRUE(o);
20+
}
21+
22+
TEST(WasmVm, Word) {
23+
Word w(1);
24+
EXPECT_EQ(w.u32(), 1);
25+
EXPECT_EQ(sizeof(w.u32()), sizeof(uint32_t));
26+
EXPECT_EQ(w, 1);
27+
EXPECT_EQ(sizeof(w), sizeof(uint64_t));
1428
}
1529

1630
} // namespace

0 commit comments

Comments
 (0)