add string method to the Nature type
This commit is contained in:
@@ -13,3 +13,10 @@ const (
|
|||||||
// Resgates ou alienação de unidades de participação ou liquidação de fundos de investimento
|
// Resgates ou alienação de unidades de participação ou liquidação de fundos de investimento
|
||||||
NatureG20 Nature = "G20"
|
NatureG20 Nature = "G20"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (n Nature) String() string {
|
||||||
|
if n == "" {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
return string(n)
|
||||||
|
}
|
||||||
|
|||||||
38
internal/nature_test.go
Normal file
38
internal/nature_test.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package internal_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nmoniz/any2anexoj/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNature_StringUnknow(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
nature internal.Nature
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "return unknown",
|
||||||
|
want: "unknown",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "return unknown",
|
||||||
|
nature: internal.NatureG01,
|
||||||
|
want: "G01",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "return unknown",
|
||||||
|
nature: internal.NatureG20,
|
||||||
|
want: "G20",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := tt.nature.String()
|
||||||
|
if tt.want != got {
|
||||||
|
t.Fatalf("want %q but got %q", tt.want, got)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user