symbol_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package markinfo
  2. import "testing"
  3. func TestSymbolType(t *testing.T) {
  4. r, _ := SymbolType("EURUSD")
  5. if r != DIRECT_RATES {
  6. t.Errorf("SymbolType failed. Got %d, expected %d.", r, DIRECT_RATES)
  7. }
  8. r, _ = SymbolType("USDJPY")
  9. if r != INDIRECT_RATES {
  10. t.Errorf("SymbolType failed. Got %d, expected %d.", r, INDIRECT_RATES)
  11. }
  12. r, _ = SymbolType("EURJPY")
  13. if r != CROSS_RATES {
  14. t.Errorf("SymbolType failed. Got %d, expected %d.", r, CROSS_RATES)
  15. }
  16. _, err := SymbolType("EURJPY1")
  17. if err == nil {
  18. t.Errorf("SymbolType failed. unknow symbol ,but return no error.")
  19. }
  20. }
  21. func TestID(t *testing.T) {
  22. r, _ := SymbolID("EURUSD")
  23. if r != 2 {
  24. t.Errorf("SymbolUnit failed. Got %d, expected %d.", r, 2)
  25. }
  26. }
  27. func TestName(t *testing.T) {
  28. r, _ := SymbolName(2)
  29. if r != "EURUSD" {
  30. t.Errorf("SymbolUnit failed. Got %s, expected %s.", r, "EURUSD")
  31. }
  32. }
  33. func TestGetMap(t *testing.T) {
  34. r := SymbolMap()
  35. if r["EURUSD"] != 2 {
  36. t.Errorf("SymbolMap failed. ")
  37. }
  38. }