| 669 | } |
| 670 | |
| 671 | func TestArray_InList(t *testing.T) { |
| 672 | t.Run("basic", func(t *testing.T) { |
| 673 | cases := []struct { |
| 674 | name string |
| 675 | value []interface{} |
| 676 | testList []interface{} |
| 677 | wantInList chainResult |
| 678 | }{ |
| 679 | { |
| 680 | name: "one element list with equal array", |
| 681 | value: []interface{}{"foo", "bar"}, |
| 682 | testList: []interface{}{ |
| 683 | []interface{}{"foo", "bar"}, |
| 684 | }, |
| 685 | wantInList: success, |
| 686 | }, |
| 687 | { |
| 688 | name: "one element list with inequal array", |
| 689 | value: []interface{}{"foo", "bar"}, |
| 690 | testList: []interface{}{ |
| 691 | []interface{}{"bar", "foo"}, |
| 692 | }, |
| 693 | wantInList: failure, |
| 694 | }, |
| 695 | { |
| 696 | name: "list with inequal and equal arrays", |
| 697 | value: []interface{}{"foo", "bar"}, |
| 698 | testList: []interface{}{ |
| 699 | []interface{}{"bar", "foo"}, |
| 700 | []interface{}{"foo", "bar"}, |
| 701 | }, |
| 702 | wantInList: success, |
| 703 | }, |
| 704 | { |
| 705 | name: "list with inequal arrays", |
| 706 | value: []interface{}{"foo", "bar"}, |
| 707 | testList: []interface{}{ |
| 708 | []interface{}{"bar", "foo"}, |
| 709 | []interface{}{"FOO", "BAR"}, |
| 710 | }, |
| 711 | wantInList: failure, |
| 712 | }, |
| 713 | } |
| 714 | |
| 715 | for _, tc := range cases { |
| 716 | t.Run(tc.name, func(t *testing.T) { |
| 717 | reporter := newMockReporter(t) |
| 718 | |
| 719 | NewArray(reporter, tc.value).InList(tc.testList...). |
| 720 | chain.assert(t, tc.wantInList) |
| 721 | |
| 722 | NewArray(reporter, tc.value).NotInList(tc.testList...). |
| 723 | chain.assert(t, !tc.wantInList) |
| 724 | }) |
| 725 | } |
| 726 | }) |
| 727 | |
| 728 | t.Run("canonization", func(t *testing.T) { |