12345678910111213141516171819202122232425262728 |
- package global
- import "testing"
- // 测试用例
- func TestContainsAllOptimized(t *testing.T) {
- // 定义测试数据
- tests := []struct {
- a []int
- b []int
- result bool
- }{
- {[]int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5}, true},
- {[]int{1, 2, 3, 4, 5}, []int{2, 3, 5}, true},
- {[]int{1, 2, 3, 4, 5}, []int{6}, false},
- {[]int{1, 2, 3, 4, 5}, []int{1, 5}, true},
- {[]int{1, 2, 3, 4, 5}, []int{1, 2, 6}, false},
- {[]int{}, []int{1}, false}, // 边界条件,a为空
- {[]int{1, 2, 3}, []int{}, true}, // 边界条件,b为空
- }
- // 运行测试
- for _, test := range tests {
- if result := ContainsAllOptimized(test.a, test.b); result != test.result {
- t.Errorf("containsAllOptimized(%v, %v) = %v; want %v", test.a, test.b, result, test.result)
- }
- }
- }
|