(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func TestTruncateString(t *testing.T) { |
| 48 | tests := []struct { |
| 49 | name string |
| 50 | str string |
| 51 | limit int |
| 52 | want string |
| 53 | truncated bool |
| 54 | }{ |
| 55 | { |
| 56 | name: "simple truncate 0", |
| 57 | str: "0123", |
| 58 | limit: 0, |
| 59 | want: "", |
| 60 | truncated: true, |
| 61 | }, |
| 62 | { |
| 63 | name: "simple truncate 2", |
| 64 | str: "0123", |
| 65 | limit: 2, |
| 66 | want: "01", |
| 67 | truncated: true, |
| 68 | }, |
| 69 | { |
| 70 | name: "simple truncate 3", |
| 71 | str: "0123", |
| 72 | limit: 3, |
| 73 | want: "012", |
| 74 | truncated: true, |
| 75 | }, |
| 76 | { |
| 77 | name: "simple truncate 4", |
| 78 | str: "0123", |
| 79 | limit: 4, |
| 80 | want: "0123", |
| 81 | truncated: false, |
| 82 | }, |
| 83 | { |
| 84 | name: "simple truncate 20", |
| 85 | str: "0123", |
| 86 | limit: 20, |
| 87 | want: "0123", |
| 88 | truncated: false, |
| 89 | }, |
| 90 | { |
| 91 | name: "unicode truncate 5", |
| 92 | str: "H㐀〾▓朗퐭텟şüöžåйкл¤", |
| 93 | limit: 5, |
| 94 | want: "H㐀〾▓朗", |
| 95 | truncated: true, |
| 96 | }, |
| 97 | { |
| 98 | name: "unicode truncate 10", |
| 99 | str: "H㐀〾▓朗퐭텟şüöžåйкл¤", |
| 100 | limit: 10, |
| 101 | want: "H㐀〾▓朗퐭텟şüö", |
| 102 | truncated: true, |
| 103 | }, |
| 104 | { |
nothing calls this directly
no test coverage detected