76 lines
1.3 KiB
Go
76 lines
1.3 KiB
Go
|
package main
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func TestPhoneticLetters(t *testing.T) {
|
||
|
t.Log("This is the test suite for phonetic-letters")
|
||
|
t.Run("Test the application with one string", testWithOneString)
|
||
|
t.Run("Test the application with two strings", testWithTwoStrings)
|
||
|
t.Run("Test the application with numbers and symbols", testWithNumbersAndSymbols)
|
||
|
}
|
||
|
|
||
|
func testWithOneString(t *testing.T) {
|
||
|
input := "phonetic"
|
||
|
|
||
|
got := phoneticLetters(input)
|
||
|
|
||
|
want := `P - Papa
|
||
|
H - Hotel
|
||
|
O - Oscar
|
||
|
N - November
|
||
|
E - Echo
|
||
|
T - Tango
|
||
|
I - India
|
||
|
C - Charlie
|
||
|
`
|
||
|
|
||
|
if want != got {
|
||
|
t.Errorf("Unexpected result returned from phoneticLetters(); want %s, got %s", want, got)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func testWithTwoStrings(t *testing.T) {
|
||
|
input := []string{"three", "coins"}
|
||
|
|
||
|
got := phoneticLetters(input...)
|
||
|
|
||
|
want := `T - Tango
|
||
|
H - Hotel
|
||
|
R - Romeo
|
||
|
E - Echo
|
||
|
E - Echo
|
||
|
C - Charlie
|
||
|
O - Oscar
|
||
|
I - India
|
||
|
N - November
|
||
|
S - Sierra
|
||
|
`
|
||
|
|
||
|
if want != got {
|
||
|
t.Errorf("Unexpected result returned from phoneticLetters(); want %s, got %s", want, got)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func testWithNumbersAndSymbols(t *testing.T) {
|
||
|
input := "Hello, 8 Worlds!"
|
||
|
|
||
|
got := phoneticLetters(input)
|
||
|
|
||
|
want := `H - Hotel
|
||
|
E - Echo
|
||
|
L - Lima
|
||
|
L - Lima
|
||
|
O - Oscar
|
||
|
W - Whiskey
|
||
|
O - Oscar
|
||
|
R - Romeo
|
||
|
L - Lima
|
||
|
D - Delta
|
||
|
S - Sierra
|
||
|
`
|
||
|
|
||
|
if want != got {
|
||
|
t.Errorf("Unexpected result returned from phoneticLetters(); want %s, got %s", want, got)
|
||
|
}
|
||
|
}
|