| Conditions | 4 |
| Total Lines | 26 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package gost |
||
| 9 | func TestParseCwe(t *testing.T) { |
||
| 10 | var tests = []struct { |
||
| 11 | in string |
||
| 12 | out []string |
||
| 13 | }{ |
||
| 14 | { |
||
| 15 | in: "CWE-665->(CWE-200|CWE-89)", |
||
| 16 | out: []string{"CWE-665", "CWE-200", "CWE-89"}, |
||
| 17 | }, |
||
| 18 | { |
||
| 19 | in: "CWE-841->CWE-770->CWE-454", |
||
| 20 | out: []string{"CWE-841", "CWE-770", "CWE-454"}, |
||
| 21 | }, |
||
| 22 | { |
||
| 23 | in: "(CWE-122|CWE-125)", |
||
| 24 | out: []string{"CWE-122", "CWE-125"}, |
||
| 25 | }, |
||
| 26 | } |
||
| 27 | |||
| 28 | r := RedHat{} |
||
| 29 | for i, tt := range tests { |
||
| 30 | out := r.parseCwe(tt.in) |
||
| 31 | sort.Strings(out) |
||
| 32 | sort.Strings(tt.out) |
||
| 33 | if !reflect.DeepEqual(tt.out, out) { |
||
| 34 | t.Errorf("[%d]expected: %s, actual: %s", i, tt.out, out) |
||
| 35 | } |
||
| 38 |