TestValueType rests Value.Type method for various kinds of the Value
(t *testing.T)
| 677 | // TestValueType rests Value.Type method for various |
| 678 | // kinds of the Value |
| 679 | func TestValueType(t *testing.T) { |
| 680 | type testData struct { |
| 681 | v Value // Input value |
| 682 | tp Type // Expected output type |
| 683 | } |
| 684 | |
| 685 | tests := []testData{ |
| 686 | {Binary(nil), TypeBinary}, |
| 687 | {Boolean(false), TypeBoolean}, |
| 688 | {Collection(nil), TypeCollection}, |
| 689 | {Integer(0), TypeInteger}, |
| 690 | {Range{}, TypeRange}, |
| 691 | {Resolution{}, TypeResolution}, |
| 692 | {String(""), TypeString}, |
| 693 | {TextWithLang{}, TypeTextWithLang}, |
| 694 | {Time{time.Time{}}, TypeDateTime}, |
| 695 | {Void{}, TypeVoid}, |
| 696 | } |
| 697 | |
| 698 | for _, test := range tests { |
| 699 | tp := test.v.Type() |
| 700 | if tp != test.tp { |
| 701 | t.Errorf("testing %s.Type:\n"+ |
| 702 | "expected: %q\n"+ |
| 703 | "present: %q\n", |
| 704 | reflect.TypeOf(test.v).String(), |
| 705 | test.tp, tp, |
| 706 | ) |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | // TestValueEqualSimilar tests ValueEqual and ValueSimilar |
| 712 | func TestValueEqualSimilar(t *testing.T) { |