diff options
author | MaurĂcio Antunes <mauricio.abreua@gmail.com> | 2022-11-30 21:00:29 -0300 |
---|---|---|
committer | MaurĂcio Antunes <mauricio.abreua@gmail.com> | 2022-11-30 21:00:29 -0300 |
commit | 2b847a4987a8302b0fc23111766e01849ac65354 (patch) | |
tree | 9296bb7ca71038113bd7348d5eee09104f056b36 /exercises/maps/maps3/main_test.go | |
parent | 1891a778f4a9f5ff945d7598836d478f6de82161 (diff) |
feat: add new maps exercise
Diffstat (limited to 'exercises/maps/maps3/main_test.go')
-rw-r--r-- | exercises/maps/maps3/main_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/exercises/maps/maps3/main_test.go b/exercises/maps/maps3/main_test.go new file mode 100644 index 0000000..8e786f1 --- /dev/null +++ b/exercises/maps/maps3/main_test.go @@ -0,0 +1,46 @@ +// maps3 +// Make me compile! +// +// I AM NOT DONE +package main + +import "testing" + +func TestGetPhone(t *testing.T) { + phoneBook := map[string]string{ + "Ana": "+01 101 102", + "John": "+01 333 666", + } + + phone, _ := phoneBook["Anna"] // something seems wrong here + expectedPhone := "+01 101 102" + if phone != expectedPhone { + t.Errorf("phone should be %s but got %s", expectedPhone, phone) + } +} + +func TestInsertPhone(t *testing.T) { + phoneBook := map[string]string{ + "Ana": "+01 101 102", + "John": "+01 333 666", + } + + phone, _ := phoneBook["Laura"] // don't change this line + expectedPhone := "+11 99 98 97" + if phone != expectedPhone { + t.Errorf("phone should be %s but got %s", expectedPhone, phone) + } +} + +func TestDeletePhone(t *testing.T) { + phoneBook := map[string]string{ + "Ana": "+01 101 102", + "John": "+01 333 666", + } // don't change the original map + + totalPhones := len(phoneBook) + expectedTotalPhones := 1 + if totalPhones != expectedTotalPhones { + t.Errorf("phoneBook should have only %d contact, but got %d", expectedTotalPhones, totalPhones) + } +} |