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
33
34
35
|
/* This file contains tests for utility functions used in the mfmt
binary. Tests of the actual application are in main_test.go. */
package main
import "testing"
func TestFormatInt(t *testing.T) {
for _, x := range [...]struct{ x, y string }{
{"?", "?"},
{"0", "0"},
{"123", "123"},
{"81758", "81.758"},
{"752759237528", "752.759.237.528"},
} {
s := formatMintage(x.x)
if s != x.y {
t.Fatalf(`Expected s="%s"; got "%s"`, x.y, s)
}
}
}
func TestIntLen(t *testing.T) {
for _, x := range [...]struct{ x, y int }{
{0, len("0")},
{123, len("123")},
{81758, len("81758")},
{752759237528, len("752759237528")},
} {
n := intlen(x.x)
if n != x.y {
t.Fatalf("Expected n=%d; got %d", x.y, n)
}
}
}
|