| 1 | fn count_str(array []string) int { |
| 2 | return array.len |
| 3 | } |
| 4 | |
| 5 | fn count_int(array []int) int { |
| 6 | return array.len |
| 7 | } |
| 8 | |
| 9 | fn count[T](array []T) int { |
| 10 | return array.len |
| 11 | } |
| 12 | |
| 13 | fn test_generics_with_empty_array_arg() { |
| 14 | assert count_str(['one', 'two']) == 2 |
| 15 | assert count_str([]string{}) == 0 |
| 16 | assert count_str([]) == 0 |
| 17 | |
| 18 | assert count_int([1, 2]) == 2 |
| 19 | assert count_int([]int{}) == 0 |
| 20 | assert count_int([]) == 0 |
| 21 | |
| 22 | assert count[f64]([1.0, 2.0]) == 2 |
| 23 | assert count[f64]([]f64{}) == 0 |
| 24 | assert count[f64]([]) == 0 |
| 25 | |
| 26 | assert count[int]([1, 2]) == 2 |
| 27 | assert count[int]([]int{}) == 0 |
| 28 | assert count[int]([]) == 0 |
| 29 | } |
| 30 | |