MCPcopy Create free account
hub / github.com/bitfield/ftl-code / TestAdd

Function TestAdd

5.1/calculator_test.go:8–26  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestAdd(t *testing.T) {
9 t.Parallel()
10 type testCase struct {
11 a, b float64
12 want float64
13 }
14 testCases := []testCase{
15 {a: 2, b: 2, want: 4},
16 {a: 1, b: 1, want: 2},
17 {a: 5, b: 0, want: 5},
18 }
19 for _, tc := range testCases {
20 got := calculator.Add(tc.a, tc.b)
21 if tc.want != got {
22 t.Errorf("Add(%f, %f): want %f, got %f",
23 tc.a, tc.b, tc.want, got)
24 }
25 }
26}
27
28func TestSubtract(t *testing.T) {
29 t.Parallel()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected