Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Tan <vtan@fortinet.com>
  • Loading branch information
vtan-fortinet committed Feb 16, 2024
1 parent 8c0fd9a commit f7513b3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,26 @@ func TestStdDecoder_DecodeRaw(t *testing.T) {
expect: nil,
err: fmt.Errorf(errFormatInvalidFieldTypeOrType, "struct", "map", "string"),
},
{
name: "struct response empty",
testFile: "response_empty_string.xml",
v: &struct {
Struct struct {
Somestring string `xmlrpc:"somestring" json:"somestring"`
}
}{},
expect: &struct {
Struct struct {
Somestring string `xmlrpc:"somestring" json:"somestring"`
}
}{
Struct: struct {
Somestring string `xmlrpc:"somestring" json:"somestring"`
}{
Somestring: ``,
},
},
},
}

for _, tt := range tests {
Expand Down
17 changes: 17 additions & 0 deletions testdata/response_empty_string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>somestring</name>
<value>
<string></string>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>

0 comments on commit f7513b3

Please sign in to comment.