github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/engine/wazevo/frontend/lower_test.go (about)

     1  package frontend
     2  
     3  import (
     4  	"testing"
     5  	"unsafe"
     6  
     7  	"github.com/wasilibs/wazerox/internal/testing/require"
     8  	"github.com/wasilibs/wazerox/internal/wasm"
     9  )
    10  
    11  func Test_Offsets(t *testing.T) {
    12  	var globalInstance wasm.GlobalInstance
    13  	require.Equal(t, int(unsafe.Offsetof(globalInstance.Val)), globalInstanceValueOffset)
    14  	var memInstance wasm.MemoryInstance
    15  	require.Equal(t, int(unsafe.Offsetof(memInstance.Buffer)), memoryInstanceBufOffset)
    16  	var tableInstance wasm.TableInstance
    17  	require.Equal(t, int(unsafe.Offsetof(tableInstance.References)), tableInstanceBaseAddressOffset)
    18  
    19  	var dataInstance wasm.DataInstance
    20  	var elementInstance wasm.ElementInstance
    21  
    22  	require.Equal(t, int(unsafe.Sizeof(dataInstance)), elementOrDataInstanceSize)
    23  	require.Equal(t, int(unsafe.Sizeof(elementInstance)), elementOrDataInstanceSize)
    24  }