mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-29 19:27:36 +00:00
57 lines
850 B
Go
57 lines
850 B
Go
|
package vm_test
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func TestStringToByteConversion(t *testing.T) {
|
||
|
src := `
|
||
|
package foo
|
||
|
func Main() []byte {
|
||
|
b := []byte("foo")
|
||
|
return b
|
||
|
}
|
||
|
`
|
||
|
eval(t, src, []byte("foo"))
|
||
|
}
|
||
|
|
||
|
func TestStringToByteAppend(t *testing.T) {
|
||
|
src := `
|
||
|
package foo
|
||
|
func Main() []byte {
|
||
|
b := []byte("foo")
|
||
|
c := []byte("bar")
|
||
|
e := append(b, c...)
|
||
|
return e
|
||
|
}
|
||
|
`
|
||
|
eval(t, src, []byte("foobar"))
|
||
|
}
|
||
|
|
||
|
func TestByteConversionInFunctionCall(t *testing.T) {
|
||
|
src := `
|
||
|
package foo
|
||
|
func Main() []byte {
|
||
|
b := []byte("foo")
|
||
|
return handle(b)
|
||
|
}
|
||
|
|
||
|
func handle(b []byte) []byte {
|
||
|
return b
|
||
|
}
|
||
|
`
|
||
|
eval(t, src, []byte("foo"))
|
||
|
}
|
||
|
|
||
|
func TestByteConversionDirectlyInFunctionCall(t *testing.T) {
|
||
|
src := `
|
||
|
package foo
|
||
|
func Main() []byte {
|
||
|
return handle([]byte("foo"))
|
||
|
}
|
||
|
|
||
|
func handle(b []byte) []byte {
|
||
|
return b
|
||
|
}
|
||
|
`
|
||
|
eval(t, src, []byte("foo"))
|
||
|
}
|