You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package stario
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_Slice(t *testing.T) {
|
|
|
|
var data = InputMsg{
|
|
|
|
msg: "true,false,true,true,false,0,1,hello",
|
|
|
|
err: nil,
|
|
|
|
skipSliceSigErr: false,
|
|
|
|
}
|
|
|
|
res, err := data.IgnoreSliceParseError(true).SliceBool(",")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(res)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(res) == 0 {
|
|
|
|
t.Fatal(res)
|
|
|
|
}
|
|
|
|
fmt.Println(res)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSliceMsg(t *testing.T) {
|
|
|
|
var data = InputMsg{
|
|
|
|
msg: "",
|
|
|
|
err: nil,
|
|
|
|
skipSliceSigErr: false,
|
|
|
|
}
|
|
|
|
res, err := data.SliceString(",")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(res)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(res) != 0 {
|
|
|
|
t.Fatal(res)
|
|
|
|
}
|
|
|
|
fmt.Println(len(res))
|
|
|
|
res2, err := data.SliceInt64(",")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(res2)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(res2) != 0 {
|
|
|
|
t.Fatal(res2)
|
|
|
|
}
|
|
|
|
fmt.Println(len(res2))
|
|
|
|
}
|