| /* |
| Copyright 2013 Google Inc. All Rights Reserved. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| */ |
| |
| package checkstyle_test |
| |
| import ( |
| "fmt" |
| "strings" |
| "testing" |
| |
| "gwt.googlesource.com/buildglue.git/checkstyle" |
| ) |
| |
| func TestReadXML(t *testing.T) { |
| input := ` |
| <checkstyle> |
| <file name="/absolute/path/foo"> |
| <error line="15" severity="error" message="hello"/> |
| <error line="27" severity="warning" message="bye bye"/> |
| </file> |
| <file name="blorp"/> |
| <file name="bar"> |
| <error line="42" severity="info" message="woof"/> |
| </file> |
| </checkstyle> |
| ` |
| expect := []checkstyle.File{ |
| {Name: "foo", Errors: []checkstyle.Error{ |
| {Line: 15, Severity: "error", Message: "hello"}, |
| {Line: 27, Severity: "warning", Message: "bye bye"}, |
| }}, |
| {Name: "blorp"}, |
| {Name: "bar", Errors: []checkstyle.Error{ |
| {Line: 42, Severity: "info", Message: "woof"}, |
| }}, |
| } |
| |
| actual, err := checkstyle.ReadXML(strings.NewReader(input), "/absolute/path") |
| if err != nil { |
| t.Error("ReadXML returned failure:", err) |
| } |
| if fmt.Sprintf("%#v", expect) != fmt.Sprintf("%#v", actual) { |
| t.Errorf("expect %#v, actual %#v", expect, actual) |
| } |
| } |