MCPcopy
hub / github.com/TomWright/dasel / TestValue_String

Function TestValue_String

model/value_test.go:526–572  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

524}
525
526func TestValue_String(t *testing.T) {
527 t.Run("string", func(t *testing.T) {
528 got := model.NewStringValue("hello").String()
529 if !strings.Contains(got, "hello") {
530 t.Errorf("expected output to contain 'hello', got %s", got)
531 }
532 })
533 t.Run("int", func(t *testing.T) {
534 got := model.NewIntValue(42).String()
535 if !strings.Contains(got, "42") {
536 t.Errorf("expected output to contain '42', got %s", got)
537 }
538 })
539 t.Run("float", func(t *testing.T) {
540 got := model.NewFloatValue(3.14).String()
541 if !strings.Contains(got, "3.14") {
542 t.Errorf("expected output to contain '3.14', got %s", got)
543 }
544 })
545 t.Run("bool", func(t *testing.T) {
546 got := model.NewBoolValue(true).String()
547 if !strings.Contains(got, "true") {
548 t.Errorf("expected output to contain 'true', got %s", got)
549 }
550 })
551 t.Run("null", func(t *testing.T) {
552 got := model.NewNullValue().String()
553 if !strings.Contains(got, "null") {
554 t.Errorf("expected output to contain 'null', got %s", got)
555 }
556 })
557 t.Run("slice", func(t *testing.T) {
558 s := model.NewSliceValue()
559 _ = s.Append(model.NewIntValue(1))
560 got := s.String()
561 if !strings.Contains(got, "array") {
562 t.Errorf("expected output to contain 'array', got %s", got)
563 }
564 })
565 t.Run("map", func(t *testing.T) {
566 m := model.NewValue(orderedmap.NewMap().Set("key", "val"))
567 got := m.String()
568 if !strings.Contains(got, "key") {
569 t.Errorf("expected output to contain 'key', got %s", got)
570 }
571 })
572}

Callers

nothing calls this directly

Calls 13

StringMethod · 0.95
NewStringValueFunction · 0.92
NewIntValueFunction · 0.92
NewFloatValueFunction · 0.92
NewBoolValueFunction · 0.92
NewNullValueFunction · 0.92
NewSliceValueFunction · 0.92
NewValueFunction · 0.92
NewMapFunction · 0.92
AppendMethod · 0.80
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected