mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 07:26:44 +00:00
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package translation
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/thrasher-/gocryptotrader/currency/pair"
|
|
)
|
|
|
|
func TestGetTranslation(t *testing.T) {
|
|
currencyPair := pair.NewCurrencyPair("BTC", "USD")
|
|
expected := pair.CurrencyItem("XBT")
|
|
actual, err := GetTranslation(currencyPair.FirstCurrency)
|
|
if err != nil {
|
|
t.Error("GetTranslation: failed to retrieve translation for BTC")
|
|
}
|
|
|
|
if expected != actual {
|
|
t.Error("GetTranslation: translation result was different to expected result")
|
|
}
|
|
|
|
currencyPair.FirstCurrency = "NEO"
|
|
_, err = GetTranslation(currencyPair.FirstCurrency)
|
|
if err == nil {
|
|
t.Error("GetTranslation: no error on non translatable currency")
|
|
}
|
|
|
|
expected = "BTC"
|
|
currencyPair.FirstCurrency = "XBT"
|
|
|
|
actual, err = GetTranslation(currencyPair.FirstCurrency)
|
|
if err != nil {
|
|
t.Error("GetTranslation: failed to retrieve translation for BTC")
|
|
}
|
|
|
|
if expected != actual {
|
|
t.Error("GetTranslation: translation result was different to expected result")
|
|
}
|
|
}
|
|
|
|
func TestHasTranslation(t *testing.T) {
|
|
currencyPair := pair.NewCurrencyPair("BTC", "USD")
|
|
expected := true
|
|
actual := HasTranslation(currencyPair.FirstCurrency)
|
|
if expected != actual {
|
|
t.Error("HasTranslation: translation result was different to expected result")
|
|
}
|
|
|
|
currencyPair.FirstCurrency = "XBT"
|
|
expected = true
|
|
actual = HasTranslation(currencyPair.FirstCurrency)
|
|
if expected != actual {
|
|
t.Error("HasTranslation: translation result was different to expected result")
|
|
}
|
|
|
|
currencyPair.FirstCurrency = "NEO"
|
|
expected = false
|
|
actual = HasTranslation(currencyPair.FirstCurrency)
|
|
if expected != actual {
|
|
t.Error("HasTranslation: translation result was different to expected result")
|
|
}
|
|
}
|