| 33 | // --------------------------------------------------------------------------- |
| 34 | |
| 35 | TEST(MemInstanceTest, Limit__Pages) { |
| 36 | using MemInst = WasmEdge::Runtime::Instance::MemoryInstance; |
| 37 | WasmEdge::Configure Conf; |
| 38 | Conf.getRuntimeConfigure().setMaxMemoryPage(256); |
| 39 | |
| 40 | MemInst Inst1(WasmEdge::AST::MemoryType(257), |
| 41 | Conf.getRuntimeConfigure().getMaxMemoryPage()); |
| 42 | ASSERT_FALSE(Inst1.getDataPtr() == nullptr); |
| 43 | EXPECT_EQ(Inst1.getPageSize(), 256U); |
| 44 | |
| 45 | MemInst Inst2(WasmEdge::AST::MemoryType(257)); |
| 46 | ASSERT_FALSE(Inst2.getDataPtr() == nullptr); |
| 47 | |
| 48 | MemInst Inst3(WasmEdge::AST::MemoryType(1), |
| 49 | Conf.getRuntimeConfigure().getMaxMemoryPage()); |
| 50 | ASSERT_FALSE(Inst3.getDataPtr() == nullptr); |
| 51 | ASSERT_FALSE(Inst3.growPage(256)); |
| 52 | ASSERT_TRUE(Inst3.growPage(255)); |
| 53 | |
| 54 | MemInst Inst4(WasmEdge::AST::MemoryType(1)); |
| 55 | ASSERT_FALSE(Inst4.getDataPtr() == nullptr); |
| 56 | ASSERT_TRUE(Inst4.growPage(256)); |
| 57 | |
| 58 | MemInst Inst5(WasmEdge::AST::MemoryType(1, 128), |
| 59 | Conf.getRuntimeConfigure().getMaxMemoryPage()); |
| 60 | ASSERT_FALSE(Inst5.getDataPtr() == nullptr); |
| 61 | ASSERT_FALSE(Inst5.growPage(128)); |
| 62 | ASSERT_TRUE(Inst5.growPage(127)); |
| 63 | |
| 64 | MemInst Inst6(WasmEdge::AST::MemoryType(1), |
| 65 | Conf.getRuntimeConfigure().getMaxMemoryPage()); |
| 66 | ASSERT_FALSE(Inst6.growPage(0xFFFFFFFF)); |
| 67 | } |
| 68 | |
| 69 | // --------------------------------------------------------------------------- |
| 70 | // memory.copy overlap regression tests. |
nothing calls this directly
no test coverage detected