-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add xml support: add unit test for xml parser
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package xml | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestIniParser(t *testing.T) { | ||
parser := &Parser{} | ||
sample := `<note> | ||
<to>foo</to> | ||
<from>bar</from> | ||
<heading>Reminder</heading> | ||
<body>baz</body> | ||
</note>` | ||
|
||
var input interface{} | ||
if err := parser.Unmarshal([]byte(sample), &input); err != nil { | ||
t.Fatalf("parser should not have thrown an error: %v", err) | ||
} | ||
|
||
if input == nil { | ||
t.Error("there should be information parsed but its nil") | ||
} | ||
|
||
inputMap := input.(map[string]interface{}) | ||
item := inputMap["note"] | ||
if len(item.(map[string]interface{})) <= 0 { | ||
t.Error("there should be at least one item defined in the parsed file, but none found") | ||
} | ||
} |