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.
26 lines
527 B
26 lines
527 B
7 years ago
|
package main
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func TestConvertIntoMap(t *testing.T) {
|
||
|
data := "minh:3,mike:2"
|
||
|
res := ConvertIntoMap(data)
|
||
|
if len(res) != 2 {
|
||
|
t.Errorf("Result should have 2 pairs (key, value)")
|
||
|
}
|
||
|
if val, ok := res["minh"]; !ok {
|
||
|
t.Errorf("Result should contain key minh")
|
||
|
} else {
|
||
|
if res["minh"] != 3 {
|
||
|
t.Errorf("Value of minh should be 3")
|
||
|
}
|
||
|
}
|
||
|
if val, ok := res["mike"]; !ok {
|
||
|
t.Errorf("Result should contain key mike")
|
||
|
} else {
|
||
|
if res["minh"] != 3 {
|
||
|
t.Errorf("Value of minh should be 2")
|
||
|
}
|
||
|
}
|
||
|
}
|