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
36
37
38
39
40
41
42
43
|
/* 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"
"git.thomasvoss.com/euro-cash.eu/lib/mintage"
)
func TestFormatInt(t *testing.T) {
for _, x := range [...]struct {
n int
s string
}{
{0, "0"},
{123, "123"},
{81758, "81.758"},
{752759237528, "752.759.237.528"},
{mintage.Unknown, "?"},
} {
s := formatInt(x.n)
if s != x.s {
t.Fatalf(`Expected s="%s"; got "%s"`, x.s, 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")},
{mintage.Unknown, len("?")},
} {
n := intlen(x.x)
if n != x.y {
t.Fatalf("Expected n=%d; got %d", x.y, n)
}
}
}
|