github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/testing/binaryencoding/section_test.go (about)

     1  package binaryencoding
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/wasilibs/wazerox/internal/testing/require"
     7  	"github.com/wasilibs/wazerox/internal/wasm"
     8  )
     9  
    10  func TestEncodeFunctionSection(t *testing.T) {
    11  	require.Equal(t, []byte{wasm.SectionIDFunction, 0x2, 0x01, 0x05}, EncodeFunctionSection([]wasm.Index{5}))
    12  }
    13  
    14  // TestEncodeStartSection uses the same index as TestEncodeFunctionSection to highlight the encoding is different.
    15  func TestEncodeStartSection(t *testing.T) {
    16  	require.Equal(t, []byte{wasm.SectionIDStart, 0x01, 0x05}, EncodeStartSection(5))
    17  }