File: utils_test.go

package info (click to toggle)
golang-github-checkpoint-restore-checkpointctl 1.3.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 524 kB
  • sloc: ansic: 208; makefile: 172; sh: 40
file content (32 lines) | stat: -rw-r--r-- 584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package internal

import (
	"fmt"
	"testing"
)

func TestFormatTime(t *testing.T) {
	tests := []struct {
		input    uint32
		expected string
	}{
		{1, "1 µs"},
		{500, "500 µs"},
		{999, "999 µs"},
		{1001, "1.001 ms"},
		{1100, "1.1 ms"},
		{13400, "13.4 ms"},
		{1340001, "1.34 s"},
		{1340520, "1.3405 s"},
		{1340560, "1.3406 s"},
	}

	for _, test := range tests {
		t.Run(fmt.Sprintf("Input-%d", test.input), func(t *testing.T) {
			result := FormatTime(test.input)
			if result != test.expected {
				t.Errorf("Expected %s, but got %s", test.expected, result)
			}
		})
	}
}