(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestLoopAdd(t *testing.T) { |
| 13 | t.Run("go", func(t *testing.T) { |
| 14 | if x := LoopAdd(100, 0, 1); x != 100 { |
| 15 | t.Fatalf("expect = %d, got = %d", 100, x) |
| 16 | } |
| 17 | if x := LoopAdd(100, 0, 2); x != 200 { |
| 18 | t.Fatalf("expect = %d, got = %d", 200, x) |
| 19 | } |
| 20 | if x := LoopAdd(100, 0, -1); x != -100 { |
| 21 | t.Fatalf("expect = %d, got = %d", -100, x) |
| 22 | } |
| 23 | if x := LoopAdd(100, 50, 1); x != 150 { |
| 24 | t.Fatalf("expect = %d, got = %d", 150, x) |
| 25 | } |
| 26 | }) |
| 27 | t.Run("asm", func(t *testing.T) { |
| 28 | if x := AsmLoopAdd(100, 0, 1); x != 100 { |
| 29 | t.Fatalf("expect = %d, got = %d", 100, x) |
| 30 | } |
| 31 | if x := AsmLoopAdd(100, 0, 2); x != 200 { |
| 32 | t.Fatalf("expect = %d, got = %d", 200, x) |
| 33 | } |
| 34 | if x := AsmLoopAdd(100, 0, -1); x != -100 { |
| 35 | t.Fatalf("expect = %d, got = %d", -100, x) |
| 36 | } |
| 37 | if x := AsmLoopAdd(100, 50, 1); x != 150 { |
| 38 | t.Fatalf("expect = %d, got = %d", 150, x) |
| 39 | } |
| 40 | }) |
| 41 | } |
| 42 | |
| 43 | func BenchmarkLoopAdd(b *testing.B) { |
| 44 | b.Run("go", func(b *testing.B) { |
nothing calls this directly
no test coverage detected