| 1 | package csvscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/csv`/ |
| 2 | |
| 3 | import ( |
| 4 | "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.25 testing/" |
| 6 | ) |
| 7 | |
| 8 | func TestValueToStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/csv`/TestValueToString().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 9 | tests := []struct { |
| 10 | desc string |
| 11 | in func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) |
| 12 | exp string |
| 13 | }{ |
| 14 | { |
| 15 | desc: "basic string", |
| 16 | in: func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 17 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("hello"), nil |
| 18 | }, |
| 19 | exp: "hello", |
| 20 | }, |
| 21 | { |
| 22 | desc: "string", |
| 23 | in: func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 24 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("hello, there!!"), nil |
| 25 | }, |
| 26 | exp: "hello, there!!", |
| 27 | }, |
| 28 | { |
| 29 | desc: "int", |
| 30 | in: func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 31 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewIntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewIntValue().(123), nil |
| 32 | }, |
| 33 | exp: "123", |
| 34 | }, |
| 35 | { |
| 36 | desc: "float", |
| 37 | in: func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 38 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewFloatValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewFloatValue().(1.234), nil |
| 39 | }, |
| 40 | exp: "1.234", |
| 41 | }, |
| 42 | { |
| 43 | desc: "null", |
| 44 | in: func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 45 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewNullValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewNullValue().(), nil |
| 46 | }, |
| 47 | exp: "", |
| 48 | }, |
| 49 | { |
| 50 | desc: "bool true", |
| 51 | in: func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 52 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewBoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewBoolValue().(true), nil |
| 53 | }, |
| 54 | exp: "true", |
| 55 | }, |
| 56 | { |
| 57 | desc: "bool false", |
| 58 | in: func() (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 59 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewBoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewBoolValue().(false), nil |
| 60 | }, |
| 61 | exp: "false", |
| 62 | }, |
| 63 | } |
| 64 | |
| 65 | for _, testCase := range tests { |
| 66 | tc := testCase |
| 67 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().(tc.desc, func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 68 | in, err := tc.in() |
| 69 | if err != nil { |
| 70 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 71 | } |
| 72 | got, err := valueToStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/csv`/valueToString().(in) |
| 73 | if err != nil { |
| 74 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 75 | } |
| 76 | if got != tc.exp { |
| 77 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("expected '%s' but got '%s'", tc.exp, got) |
| 78 | } |
| 79 | }) |
| 80 | } |
| 81 | } |