// Test that a script can call a go function to reverse a []uint8 array
Test that a script can call a go function to reverse a []uint8 array
// Test that a script can call a go function to reverse a [] uint8 array
func TestUint8Array(t *testing.T) {
	t.Parallel()
	iso := v8.NewIsolate()
	ctx := v8.NewContext(iso)
	if err := injectUint8ArrayTester(ctx); err != nil {
		t.Error(err)
	}
	if val, err := ctx.RunScript("native.reverseUint8Array(new Uint8Array([0,1,2,3,4,5,6,7,8,9]))", ""); err != nil {
		t.Error(err)
	} else {
		if !val.IsUint8Array() {
			t.Errorf("Expected uint8 array return value")
		}
		arr := val.Uint8Array()
		if len(arr) != 10 {
			t.Errorf("Got wrong array length %d, expected 10", len(arr))
		}
		for i := 0; i < 10; i++ {
			if arr[i] != uint8(10-i-1) {
				t.Errorf("Incorrect byte at index %d (whole array: %v)", i, arr)
			}
		}
	}
}
func TestUint8Array ( t * testing . T ) { t . Parallel ( ) iso := v8 . NewIsolate ( ) ctx := v8 . NewContext ( iso ) if err := injectUint8ArrayTester ( ctx ) ; err != nil { t . Error ( err ) } if val , err := ctx . RunScript ( " " , " " ) ; err != nil { t . Error ( err ) } else { if ! val . IsUint8Array ( ) { t . Errorf ( " " ) } arr := val . Uint8Array ( ) if len ( arr ) != 10 { t . Errorf ( " " , len ( arr ) ) } for i := 0 ; i < 10 ; i ++ { if arr [ i ] != uint8 ( 10 - i - 1 ) { t . Errorf ( " " , i , arr ) } } } }
Test that a script can call a go function to reverse a []uint8 array
Test that a script can call a go function to reverse a [] uint8 array