diff --git a/duration_test.go b/duration_test.go index 8eae258..93d2a32 100644 --- a/duration_test.go +++ b/duration_test.go @@ -38,6 +38,39 @@ func ExampleHumanDuration() { fmt.Println(HumanDuration(24 * 30 * 24 * time.Hour)) fmt.Println(HumanDuration(24*30*24*time.Hour + 2*7*24*time.Hour)) fmt.Println(HumanDuration(3*365*24*time.Hour + 2*30*24*time.Hour)) + + // Output: + // Less than a second + // 47 seconds + // About a minute + // 3 minutes + // 35 minutes + // 35 minutes + // About an hour + // 2 hours + // 3 hours + // 4 hours + // 4 hours + // 24 hours + // 36 hours + // 2 days + // 7 days + // 13 days + // 2 weeks + // 2 weeks + // 3 weeks + // 4 weeks + // 4 weeks + // 4 weeks + // 6 weeks + // 2 months + // 3 months + // 5 months + // 13 months + // 23 months + // 24 months + // 2 years + // 3 years } func TestHumanDuration(t *testing.T) { diff --git a/size_test.go b/size_test.go index f9b1d59..463f569 100644 --- a/size_test.go +++ b/size_test.go @@ -16,6 +16,15 @@ func ExampleBytesSize() { fmt.Println(BytesSize(3.42 * GiB)) fmt.Println(BytesSize(5.372 * TiB)) fmt.Println(BytesSize(2.22 * PiB)) + + // Output: + // 1KiB + // 1MiB + // 1MiB + // 2MiB + // 3.42GiB + // 5.372TiB + // 2.22PiB } func ExampleHumanSize() { @@ -27,6 +36,16 @@ func ExampleHumanSize() { fmt.Println(HumanSize(float64(3.42 * GB))) fmt.Println(HumanSize(float64(5.372 * TB))) fmt.Println(HumanSize(float64(2.22 * PB))) + + // Output: + // 1kB + // 1.024kB + // 1MB + // 1.049MB + // 2MB + // 3.42GB + // 5.372TB + // 2.22PB } func ExampleFromHumanSize() { @@ -41,6 +60,19 @@ func ExampleFromHumanSize() { fmt.Println(FromHumanSize("32Gb")) fmt.Println(FromHumanSize("32Tb")) fmt.Println(FromHumanSize("32Pb")) + + // Output: + // 32 + // 32 + // 32 + // 32000 + // 32000 + // 32000 + // 32000 + // 32000000 + // 32000000000 + // 32000000000000 + // 32000000000000000 } func ExampleRAMInBytes() { @@ -57,6 +89,21 @@ func ExampleRAMInBytes() { fmt.Println(RAMInBytes("32Pb")) fmt.Println(RAMInBytes("32PB")) fmt.Println(RAMInBytes("32P")) + + // Output: + // 32 + // 32 + // 32 + // 32768 + // 32768 + // 32768 + // 32768 + // 33554432 + // 34359738368 + // 35184372088832 + // 36028797018963968 + // 36028797018963968 + // 36028797018963968 } func TestBytesSize(t *testing.T) { @@ -197,8 +244,14 @@ func BenchmarkParseSize(b *testing.B) { "", "32", "32b", "32 B", "32k", "32.5 K", "32kb", "32 Kb", "32.8Mb", "32.9Gb", "32.777Tb", "32Pb", "0.3Mb", "-1", } { - FromHumanSize(s) - RAMInBytes(s) + _, err := FromHumanSize(s) + if err != nil { + b.Fatal(err) + } + _, err = RAMInBytes(s) + if err != nil { + b.Fatal(err) + } } } } diff --git a/ulimit_test.go b/ulimit_test.go index 0095855..401071f 100644 --- a/ulimit_test.go +++ b/ulimit_test.go @@ -12,6 +12,12 @@ func ExampleParseUlimit() { fmt.Println(ParseUlimit("nofile=1024")) fmt.Println(ParseUlimit("cpu=2:4")) fmt.Println(ParseUlimit("cpu=6")) + + // Output: + // nofile=512:1024 + // nofile=1024:1024 + // cpu=2:4 + // cpu=6:6 } func TestParseUlimitValid(t *testing.T) {