forked from chyeh/nqm-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_test.go
45 lines (41 loc) · 1.69 KB
/
parse_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"reflect"
"testing"
)
func TestParseRow(t *testing.T) {
tests := []string{
"www.google.com : 7.23 6.93 5.73 5.60",
"www.youtube.com : 4.55 6.60 6.61 7.99",
"www.facebook.com : 64.82 69.21 70.67 70.90",
"210.242.127.93 : 7.08 9.59 7.51 7.16",
"210.242.127.118 : 8.46 5.56 8.39 6.46",
"31.13.95.36 : 95.41 97.45 100.51 102.43",
}
expecteds := [][]string{
{"www.google.com", "7.23", "6.93", "5.73", "5.60"}, {"www.youtube.com", "4.55", "6.60", "6.61", "7.99"}, {"www.facebook.com", "64.82", "69.21", "70.67", "70.90"},
{"210.242.127.93", "7.08", "9.59", "7.51", "7.16"}, {"210.242.127.118", "8.46", "5.56", "8.39", "6.46"}, {"31.13.95.36", "95.41", "97.45", "100.51", "102.43"},
}
for i, v := range tests {
if !reflect.DeepEqual(expecteds[i], parseRow(v)) {
t.Error(expecteds[i], parseRow(v))
}
t.Log(expecteds[i], parseRow(v))
}
}
func TestParse(t *testing.T) {
tests := [][]string{
{"www.google.com : 7.23 6.93 5.73 5.60", "www.youtube.com : 4.55 6.60 6.61 7.99", "www.facebook.com : 64.82 69.21 70.67 70.90"},
{"210.242.127.93 : 7.08 9.59 7.51 7.16", "210.242.127.118 : 8.46 5.56 8.39 6.46", "31.13.95.36 : 95.41 97.45 100.51 102.43"},
}
expecteds := [][][]string{
{{"www.google.com", "7.23", "6.93", "5.73", "5.60"}, {"www.youtube.com", "4.55", "6.60", "6.61", "7.99"}, {"www.facebook.com", "64.82", "69.21", "70.67", "70.90"}},
{{"210.242.127.93", "7.08", "9.59", "7.51", "7.16"}, {"210.242.127.118", "8.46", "5.56", "8.39", "6.46"}, {"31.13.95.36", "95.41", "97.45", "100.51", "102.43"}},
}
for i, v := range tests {
if !reflect.DeepEqual(expecteds[i], Parse(v)) {
t.Error(expecteds[i], Parse(v))
}
t.Log(expecteds[i], Parse(v))
}
}