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

Function TestAdd

8.1/calculator_test.go:10–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected