mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
currency: Fix edge case in NewCode where all string characters are digits (#1593)
* add fixes and test * glorious: nits, privatise upper case field, add item field for case sensitivity for format checks, rm dead code. * fix potential panic * gk/glorious: nits * gk: nits and other things * improve commentary lol * glorious+gk: nits and improvements (with no sillyness this time) * Update currency/pairs.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * thrasher: nitssssss * linter: fix * bye bye silly boy --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRoleString(t *testing.T) {
|
||||
@@ -456,6 +458,16 @@ func TestBaseCode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewCodeFormatting(t *testing.T) {
|
||||
require.True(t, NewCode("BTC").upperCase)
|
||||
require.False(t, NewCode("btc").upperCase)
|
||||
require.True(t, NewCode("BTC").Equal(NewCode("btc")))
|
||||
require.False(t, NewCode("420").upperCase)
|
||||
require.False(t, NewCode("btc420").upperCase)
|
||||
require.False(t, NewCode("420").Lower().upperCase)
|
||||
require.True(t, NewCode("4BTC").upperCase)
|
||||
}
|
||||
|
||||
func TestCodeString(t *testing.T) {
|
||||
if cc, expected := NewCode("TEST"), "TEST"; cc.String() != expected {
|
||||
t.Errorf("Currency Code String() error expected %s but received %s",
|
||||
|
||||
Reference in New Issue
Block a user