mirror of
https://github.com/aclindsa/ofxgo.git
synced 2025-07-01 11:48:38 -04:00
Add comments for generated constants
This commit is contained in:
@ -1183,6 +1183,51 @@ func TestSyncMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOfxSec(t *testing.T) {
|
||||
e, err := ofxgo.NewOfxSec("NONE")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error creating new OfxSec from string \"NONE\"\n")
|
||||
}
|
||||
if !e.Valid() {
|
||||
t.Fatalf("OfxSec unexpectedly invalid\n")
|
||||
}
|
||||
err = e.FromString("TYPE 1")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on OfxSec.FromString(\"TYPE 1\")\n")
|
||||
}
|
||||
if e.String() != "TYPE 1" {
|
||||
t.Fatalf("OfxSec.String() expected to be \"TYPE 1\"\n")
|
||||
}
|
||||
|
||||
marshalHelper(t, "TYPE 1", &e)
|
||||
|
||||
overwritten, err := ofxgo.NewOfxSec("THISWILLNEVERBEAVALIDENUMSTRING")
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error creating new OfxSec from string \"THISWILLNEVERBEAVALIDENUMSTRING\"\n")
|
||||
}
|
||||
if overwritten.Valid() {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not be valid\n")
|
||||
}
|
||||
if !strings.Contains(strings.ToLower(overwritten.String()), "invalid") {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not return valid string from String()\n")
|
||||
}
|
||||
|
||||
b, err := xml.Marshal(&overwritten)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on xml.Marshal(OfxSec): %s\n", err)
|
||||
}
|
||||
if string(b) != "" {
|
||||
t.Fatalf("Expected empty string, got '%s'\n", string(b))
|
||||
}
|
||||
|
||||
unmarshalHelper(t, "TYPE 1", &e, &overwritten)
|
||||
|
||||
err = xml.Unmarshal([]byte("<GARBAGE><!LALDK>"), &overwritten)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error unmarshalling garbage value\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebtType(t *testing.T) {
|
||||
e, err := ofxgo.NewDebtType("COUPON")
|
||||
if err != nil {
|
||||
@ -1543,51 +1588,6 @@ func TestStockType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOfxSec(t *testing.T) {
|
||||
e, err := ofxgo.NewOfxSec("NONE")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error creating new OfxSec from string \"NONE\"\n")
|
||||
}
|
||||
if !e.Valid() {
|
||||
t.Fatalf("OfxSec unexpectedly invalid\n")
|
||||
}
|
||||
err = e.FromString("TYPE 1")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on OfxSec.FromString(\"TYPE 1\")\n")
|
||||
}
|
||||
if e.String() != "TYPE 1" {
|
||||
t.Fatalf("OfxSec.String() expected to be \"TYPE 1\"\n")
|
||||
}
|
||||
|
||||
marshalHelper(t, "TYPE 1", &e)
|
||||
|
||||
overwritten, err := ofxgo.NewOfxSec("THISWILLNEVERBEAVALIDENUMSTRING")
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error creating new OfxSec from string \"THISWILLNEVERBEAVALIDENUMSTRING\"\n")
|
||||
}
|
||||
if overwritten.Valid() {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not be valid\n")
|
||||
}
|
||||
if !strings.Contains(strings.ToLower(overwritten.String()), "invalid") {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not return valid string from String()\n")
|
||||
}
|
||||
|
||||
b, err := xml.Marshal(&overwritten)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on xml.Marshal(OfxSec): %s\n", err)
|
||||
}
|
||||
if string(b) != "" {
|
||||
t.Fatalf("Expected empty string, got '%s'\n", string(b))
|
||||
}
|
||||
|
||||
unmarshalHelper(t, "TYPE 1", &e, &overwritten)
|
||||
|
||||
err = xml.Unmarshal([]byte("<GARBAGE><!LALDK>"), &overwritten)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error unmarshalling garbage value\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHolderType(t *testing.T) {
|
||||
e, err := ofxgo.NewHolderType("INDIVIDUAL")
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user