MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestCoinChange

Function TestCoinChange

dynamic/coinchange_test.go:9–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestCoinChange(t *testing.T) {
10 coinCombination := []int32{1, 2, 5, 10}
11 targets := []struct {
12 target int32
13 expected int32
14 }{
15 {4, 2},
16 {5, 3},
17 {10, 8},
18 {15, 19},
19 {20, 34},
20 }
21
22 for _, v := range targets {
23 t.Run(fmt.Sprintf("target: %d ", v.target), func(t *testing.T) {
24 result := dynamic.CoinChange(coinCombination, v.target)
25 if result != v.expected {
26 t.Errorf("target: %d Expected %d, got %d", v.target, v.expected, result)
27 }
28 })
29 }
30
31}

Callers

nothing calls this directly

Calls 1

CoinChangeFunction · 0.92

Tested by

no test coverage detected