Skip to content

Commit f4278de

Browse files
committed
docs: Added an example to TruncateLabel().
1 parent 4e9c027 commit f4278de

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

corefunc/truncate_label_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,50 @@ import (
1010
"github.com/google/go-cmp/cmp"
1111
)
1212

13+
func ExampleTruncateLabel() {
14+
length1 := TruncateLabel(1, "NW-TEST-FIRST", "Name of my monitor")
15+
fmt.Println(length1)
16+
17+
length3 := TruncateLabel(3, "NW-TEST-FIRST", "Name of my monitor")
18+
fmt.Println(length3)
19+
20+
length5 := TruncateLabel(5, "NW-TEST-FIRST", "Name of my monitor")
21+
fmt.Println(length5)
22+
23+
length7 := TruncateLabel(7, "NW-TEST-FIRST", "Name of my monitor")
24+
fmt.Println(length7)
25+
26+
length10 := TruncateLabel(10, "NW-TEST-FIRST", "Name of my monitor")
27+
fmt.Println(length10)
28+
29+
length20 := TruncateLabel(20, "NW-TEST-FIRST", "Name of my monitor")
30+
fmt.Println(length20)
31+
32+
length32 := TruncateLabel(32, "NW-TEST-FIRST", "Name of my monitor")
33+
fmt.Println(length32)
34+
35+
length64 := TruncateLabel(64, "NW-TEST-FIRST", "Name of my monitor")
36+
fmt.Println(length64)
37+
38+
length128 := TruncateLabel(128, "NW-TEST-FIRST", "Name of my monitor")
39+
fmt.Println(length128)
40+
41+
length256 := TruncateLabel(256, "NW-TEST-FIRST", "Name of my monitor")
42+
fmt.Println(length256)
43+
44+
// Output:
45+
// …
46+
// …
47+
// …: …
48+
// …: Nam…
49+
// N…: Name…
50+
// NW-TES…: Name of my…
51+
// NW-TEST-FIRS…: Name of my monit…
52+
// NW-TEST-FIRST: Name of my monitor
53+
// NW-TEST-FIRST: Name of my monitor
54+
// NW-TEST-FIRST: Name of my monitor
55+
}
56+
1357
func TestTruncateLabel(t *testing.T) {
1458
for name, tc := range testfixtures.TruncateLabelTestTable {
1559
t.Run(name, func(t *testing.T) {

0 commit comments

Comments
 (0)