diff --git a/shop/price.go b/shop/price.go index 279dea1..d2eba10 100644 --- a/shop/price.go +++ b/shop/price.go @@ -1,3 +1,6 @@ +// Package shop prices orders. +// +// Extra lines shift every function down. package shop // Discount returns the price after applying a percentage discount. @@ -26,3 +29,11 @@ func Clamp(v, lo, hi int) int { } return v } + +// Tax returns VAT on an amount. +func Tax(amount int) int { + if amount <= 0 { + return 0 + } + return amount / 5 +} diff --git a/shop/price_test.go b/shop/price_test.go index ed08fbd..fede788 100644 --- a/shop/price_test.go +++ b/shop/price_test.go @@ -22,3 +22,9 @@ func TestClamp(t *testing.T) { t.Fatal("in range") } } + +func TestTax(t *testing.T) { + if Tax(100) != 20 { + t.Fatal("tax") + } +}