Skip to content

Instantly share code, notes, and snippets.

@hibri
Created September 22, 2021 16:32
Show Gist options
  • Select an option

  • Save hibri/83808312b6e270a001522793be1d04a4 to your computer and use it in GitHub Desktop.

Select an option

Save hibri/83808312b6e270a001522793be1d04a4 to your computer and use it in GitHub Desktop.

Revisions

  1. hibri created this gist Sep 22, 2021.
    48 changes: 48 additions & 0 deletions tests.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    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
    }