package markinfo import "testing" func TestSymbolType(t *testing.T) { r, _ := SymbolType("EURUSD") if r != DIRECT_RATES { t.Errorf("SymbolType failed. Got %d, expected %d.", r, DIRECT_RATES) } r, _ = SymbolType("USDJPY") if r != INDIRECT_RATES { t.Errorf("SymbolType failed. Got %d, expected %d.", r, INDIRECT_RATES) } r, _ = SymbolType("EURJPY") if r != CROSS_RATES { t.Errorf("SymbolType failed. Got %d, expected %d.", r, CROSS_RATES) } _, err := SymbolType("EURJPY1") if err == nil { t.Errorf("SymbolType failed. unknow symbol ,but return no error.") } } func TestID(t *testing.T) { r, _ := SymbolId("EURUSD") if r != 2 { t.Errorf("SymbolUnit failed. Got %d, expected %d.", r, 2) } } func TestName(t *testing.T) { r, _ := SymbolName(2) if r != "EURUSD" { t.Errorf("SymbolUnit failed. Got %s, expected %s.", r, "EURUSD") } } func TestGetMap(t *testing.T) { r := SymbolMap() if r["EURUSD"] != 2 { t.Errorf("SymbolMap failed. ") } } func TestSymbolId2(t *testing.T) { id1, _ := SymbolId2("sh000001") id2, _ := SymbolId2("sz000001") if id1 == id2 { t.Errorf("deal sh000001 error.") } name1, _ := CustomSymbolName(id1) name2, _ := CustomSymbolName(id2) if name1 != "sh000001" { t.Errorf("SymbolName get sh000001 error.") } if name2 != "sz000001" { t.Errorf("SymbolName get sz000001 error.") } }