1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 07:02:29 +08:00

test: add test and example for DropWhile

This commit is contained in:
dudaodong
2023-02-09 17:46:40 +08:00
parent 040e112aa6
commit 97447d058e
2 changed files with 46 additions and 2 deletions

View File

@@ -504,6 +504,29 @@ func ExampleDropRight() {
// []
}
func ExampleDropWhile() {
numbers := []int{1, 2, 3, 4, 5}
result1 := DropWhile(numbers, func(n int) bool {
return n != 2
})
result2 := DropWhile(numbers, func(n int) bool {
return true
})
result3 := DropWhile(numbers, func(n int) bool {
return n == 0
})
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
// Output:
// [2 3 4 5]
// []
// [1 2 3 4 5]
}
func ExampleInsertAt() {
result1 := InsertAt([]string{"a", "b", "c"}, 0, "1")
result2 := InsertAt([]string{"a", "b", "c"}, 1, "1")