mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1002 B
54 lines
1002 B
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
5 years ago
|
"strings"
|
||
|
|
||
5 years ago
|
"./student"
|
||
5 years ago
|
)
|
||
|
|
||
5 years ago
|
func compare(a, b string) int {
|
||
|
return strings.Compare(a, b)
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
type node struct {
|
||
|
s string
|
||
|
toCompare string
|
||
|
}
|
||
|
|
||
|
table := []node{}
|
||
|
|
||
|
// the first 15 values are returning 0 for this test
|
||
|
for i := 0; i < 15; i++ {
|
||
5 years ago
|
wordToTest := lib.RandASCII()
|
||
5 years ago
|
|
||
|
val := node{
|
||
|
s: wordToTest,
|
||
|
toCompare: wordToTest,
|
||
|
}
|
||
|
table = append(table, val)
|
||
|
}
|
||
|
|
||
|
// the next 15 values are supposed to return 1 or -1 for this test
|
||
|
for i := 0; i < 15; i++ {
|
||
5 years ago
|
wordToTest := lib.RandASCII()
|
||
|
wrongMatch := lib.RandASCII()
|
||
5 years ago
|
|
||
|
val := node{
|
||
|
s: wordToTest,
|
||
|
toCompare: wrongMatch,
|
||
|
}
|
||
|
table = append(table, val)
|
||
|
}
|
||
|
// those are the test values from the README examples
|
||
|
table = append(table,
|
||
|
node{s: "Hello!", toCompare: "Hello!"},
|
||
|
node{s: "Salut!", toCompare: "lut!"},
|
||
|
node{s: "Ola!", toCompare: "Ol"},
|
||
|
)
|
||
|
|
||
|
for _, arg := range table {
|
||
5 years ago
|
lib.Challenge("Compare", student.Compare, compare, arg.s, arg.toCompare)
|
||
5 years ago
|
}
|
||
|
}
|