summaryrefslogtreecommitdiff
path: root/go/book-store/book_store_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/book-store/book_store_test.go')
-rw-r--r--go/book-store/book_store_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/go/book-store/book_store_test.go b/go/book-store/book_store_test.go
new file mode 100644
index 0000000..4309b65
--- /dev/null
+++ b/go/book-store/book_store_test.go
@@ -0,0 +1,24 @@
+package bookstore
+
+import (
+ "testing"
+)
+
+func TestCost(t *testing.T) {
+ for _, testCase := range testCases {
+ cost := Cost(testCase.basket)
+ if testCase.expected != cost {
+ t.Fatalf("FAIL: %s\n\tCost(%v) expected %v, got %v",
+ testCase.description, testCase.basket, testCase.expected, cost)
+ }
+ t.Logf("PASS: %s", testCase.description)
+ }
+}
+
+func BenchmarkCost(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ for _, testCase := range testCases {
+ Cost(testCase.basket)
+ }
+ }
+}