Created
September 22, 2021 16:32
-
-
Save hibri/83808312b6e270a001522793be1d04a4 to your computer and use it in GitHub Desktop.
kataus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"github.com/stretchr/testify/assert" | |
) | |
func TestAlwaysTrue(t *testing.T) { | |
assert.True(t, true) | |
} | |
func TestEmptyBasketIs0(t *testing.T) { | |
assert.Equal(t, 0, scan("")) | |
} | |
func TestAIs50(t *testing.T) { | |
assert.Equal(t, 50, scan("A")) | |
} | |
func TestBis30(t *testing.T) { | |
assert.Equal(t, 30, scan("B")) | |
} | |
func TestABis80(t *testing.T) { | |
assert.Equal(t, 80, scan("AB")) | |
} | |
func TestAAIs100(t *testing.T) { | |
assert.Equal(t, 100, scan("AA")) | |
} | |
func scan(items string) int { | |
total := 0 | |
prices := map[rune]int{ | |
'A': 50, | |
'B': 30, | |
} | |
for _, char := range items { | |
total += prices[char] | |
} | |
return total | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment