| 1 | package issue122 |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | ) |
| 6 | |
| 7 | //go:generate go run asm.go -out issue122.s -stubs stub.go |
| 8 | |
| 9 | func TestTriangle(t *testing.T) { |
| 10 | expect := func(n uint64) uint64 { return n * (n + 1) / 2 } |
| 11 | for n := uint64(1); n < 42; n++ { |
| 12 | if got := Triangle(n); expect(n) != got { |
| 13 | t.Fatalf("Triangle(%v) = %v; expect %v", n, got, expect(n)) |
| 14 | } |
| 15 | } |
| 16 | } |