MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestTruncateString

Function TestTruncateString

backend/common/util_test.go:47–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func 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 {

Callers

nothing calls this directly

Calls 3

TruncateStringFunction · 0.85
EqualMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected