From eb409d4936270f6098daee34ed170de68f63b689 Mon Sep 17 00:00:00 2001 From: tphyhFighting <2363176358@qq.com> Date: Mon, 14 Feb 2022 11:32:13 +0800 Subject: [PATCH] add: leetcode 540 test --- ...0.Single Element in a Sorted Array_test.go | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 leetcode/0540.Single-Element-in-a-Sorted-Array/540.Single Element in a Sorted Array_test.go diff --git a/leetcode/0540.Single-Element-in-a-Sorted-Array/540.Single Element in a Sorted Array_test.go b/leetcode/0540.Single-Element-in-a-Sorted-Array/540.Single Element in a Sorted Array_test.go new file mode 100644 index 00000000..77871f6b --- /dev/null +++ b/leetcode/0540.Single-Element-in-a-Sorted-Array/540.Single Element in a Sorted Array_test.go @@ -0,0 +1,46 @@ +package leetcode + +import ( + "fmt" + "testing" +) + +type question540 struct { + para540 + ans540 +} + +// para 是参数 +type para540 struct { + nums []int +} + +// ans 是答案 +type ans540 struct { + ans int +} + +func Test_Problem540(t *testing.T) { + + qs := []question540{ + + { + para540{[]int{1, 1, 2, 3, 3, 4, 4, 8, 8}}, + ans540{2}, + }, + + { + para540{[]int{3, 3, 7, 7, 10, 11, 11}}, + ans540{10}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 540------------------------\n") + + for _, q := range qs { + _, p := q.ans540, q.para540 + fmt.Printf("【input】:%v ", p.nums) + fmt.Printf("【output】:%v \n", singleNonDuplicate(p.nums)) + } + fmt.Printf("\n\n\n") +}