-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test case for floatString.UnmarshalJSON
- remove unused type ntfn in btc/electrum/jsonrpcs.go Signed-off-by: Philemon Ukane <[email protected]>
- Loading branch information
1 parent
af5a590
commit 9977d4b
Showing
2 changed files
with
41 additions
and
1 deletion.
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
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,41 @@ | ||
// This code is available on the terms of the project LICENSE.md file, | ||
// also available online at https://blueoakcouncil.org/license/1.0.0. | ||
|
||
package electrum | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func Test_floatString_UnmarshalJSON(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
arg []byte | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "float64", | ||
arg: []byte{49, 50, 46, 50, 51}, // 12.23 | ||
}, | ||
{ | ||
name: "string float64", | ||
arg: []byte{34, 49, 50, 46, 50, 51, 34}, // "12.23" | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
var fs floatString | ||
if err := fs.UnmarshalJSON(tt.arg); (err != nil) != tt.wantErr { | ||
t.Errorf("%s: error = %v, wantErr %v", tt.name, err, tt.wantErr) | ||
} | ||
|
||
fsStr := fmt.Sprint(fs) | ||
fsByte := []byte(fsStr) | ||
if string(fsByte) != fsStr { | ||
t.Errorf("%s: expected %v got %v", tt.name, string(fsByte), fsStr) | ||
} | ||
}) | ||
} | ||
} |