MCPcopy Create free account
hub / github.com/astercloud/aster / TestTruncate

Function TestTruncate

pkg/memory/quality_analyzer_test.go:465–500  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

463}
464
465func TestTruncate(t *testing.T) {
466 tests := []struct {
467 name string
468 input string
469 maxLen int
470 want string
471 }{
472 {
473 name: "short string",
474 input: "hello",
475 maxLen: 10,
476 want: "hello",
477 },
478 {
479 name: "exact length",
480 input: "hello",
481 maxLen: 5,
482 want: "hello",
483 },
484 {
485 name: "long string",
486 input: "hello world this is a long string",
487 maxLen: 10,
488 want: "hello worl...",
489 },
490 }
491
492 for _, tt := range tests {
493 t.Run(tt.name, func(t *testing.T) {
494 got := truncate(tt.input, tt.maxLen)
495 if got != tt.want {
496 t.Errorf("truncate() = %q, want %q", got, tt.want)
497 }
498 })
499 }
500}

Callers

nothing calls this directly

Calls 2

truncateFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected