Go - Acronym
This commit is contained in:
28
go/pangram/README.md
Normal file
28
go/pangram/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Pangram
|
||||
|
||||
Determine if a sentence is a pangram.
|
||||
|
||||
Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma,
|
||||
"every letter") is a sentence using every letter of the alphabet at least once.
|
||||
The best known English pangram is "The quick brown fox jumps over the lazy dog."
|
||||
|
||||
The alphabet used is ASCII, and case insensitive, from 'a' to 'z'
|
||||
inclusively.
|
||||
|
||||
To run the tests simply run the command `go test` in the exercise directory.
|
||||
|
||||
If the test suite contains benchmarks, you can run these with the `-bench`
|
||||
flag:
|
||||
|
||||
go test -bench .
|
||||
|
||||
For more detailed info about the Go track see the [help
|
||||
page](http://exercism.io/languages/go).
|
||||
|
||||
## Source
|
||||
|
||||
Wikipedia [https://en.wikipedia.org/wiki/Pangram](https://en.wikipedia.org/wiki/Pangram)
|
||||
|
||||
## Submitting Incomplete Problems
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
||||
|
43
go/pangram/pangram_test.go
Normal file
43
go/pangram/pangram_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package pangram
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
const targetTestVersion = 1
|
||||
|
||||
type testCase struct {
|
||||
input string
|
||||
expected bool
|
||||
failureReason string
|
||||
}
|
||||
|
||||
var testCases = []testCase{
|
||||
{"", false, "sentence empty"},
|
||||
{"The quick brown fox jumps over the lazy dog", true, ""},
|
||||
{"a quick movement of the enemy will jeopardize five gunboats", false, "missing character 'x'"},
|
||||
{"the quick brown fish jumps over the lazy dog", false, "another missing character 'x'"},
|
||||
{"the 1 quick brown fox jumps over the 2 lazy dogs", true, ""},
|
||||
{"7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog", false, "missing letters replaced by numbers"},
|
||||
{"\"Five quacking Zephyrs jolt my wax bed.\"", true, ""},
|
||||
{"Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.", true, ""},
|
||||
{"Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.", false, "Panagram in alphabet other than ASCII"},
|
||||
}
|
||||
|
||||
func TestTestVersion(t *testing.T) {
|
||||
if testVersion != targetTestVersion {
|
||||
t.Errorf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPangram(t *testing.T) {
|
||||
for _, test := range testCases {
|
||||
actual := IsPangram(test.input)
|
||||
if actual != test.expected {
|
||||
t.Errorf("Pangram test [%s], expected [%t], actual [%t]", test.input, test.expected, actual)
|
||||
if !test.expected {
|
||||
t.Logf("[%s] should not be a pangram because : %s\n", test.input, test.failureReason)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user