mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 07:26:46 +00:00
Migrate from gometalinter.v2 to golangci-lint (#249)
* Migrate from gometalinter.v2 to golangci-lint
This commit is contained in:
@@ -8,15 +8,16 @@ import (
|
||||
|
||||
func TestLenByPrice(t *testing.T) {
|
||||
p := pair.NewCurrencyPair("BTC", "USD")
|
||||
i := Item{
|
||||
Exchange: "ANX",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1200,
|
||||
Volume: 5,
|
||||
Items = []Item{
|
||||
{
|
||||
Exchange: "ANX",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1200,
|
||||
Volume: 5,
|
||||
},
|
||||
}
|
||||
|
||||
Items = append(Items, i)
|
||||
if ByPrice.Len(Items) < 1 {
|
||||
t.Error("Test Failed - stats LenByPrice() length not correct.")
|
||||
}
|
||||
@@ -24,78 +25,77 @@ func TestLenByPrice(t *testing.T) {
|
||||
|
||||
func TestLessByPrice(t *testing.T) {
|
||||
p := pair.NewCurrencyPair("BTC", "USD")
|
||||
i := Item{
|
||||
Exchange: "alphapoint",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1200,
|
||||
Volume: 5,
|
||||
|
||||
Items = []Item{
|
||||
{
|
||||
Exchange: "alphapoint",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1200,
|
||||
Volume: 5,
|
||||
},
|
||||
{
|
||||
Exchange: "bitfinex",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1198,
|
||||
Volume: 20,
|
||||
},
|
||||
}
|
||||
|
||||
i2 := Item{
|
||||
Exchange: "bitfinex",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1198,
|
||||
Volume: 20,
|
||||
}
|
||||
|
||||
Items = append(Items, i)
|
||||
Items = append(Items, i2)
|
||||
|
||||
if !ByPrice.Less(Items, 2, 1) {
|
||||
if !ByPrice.Less(Items, 1, 0) {
|
||||
t.Error("Test Failed - stats LessByPrice() incorrect return.")
|
||||
}
|
||||
if ByPrice.Less(Items, 1, 2) {
|
||||
if ByPrice.Less(Items, 0, 1) {
|
||||
t.Error("Test Failed - stats LessByPrice() incorrect return.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwapByPrice(t *testing.T) {
|
||||
p := pair.NewCurrencyPair("BTC", "USD")
|
||||
i := Item{
|
||||
Exchange: "bitstamp",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1324,
|
||||
Volume: 5,
|
||||
|
||||
Items = []Item{
|
||||
{
|
||||
Exchange: "bitstamp",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 1324,
|
||||
Volume: 5,
|
||||
},
|
||||
{
|
||||
Exchange: "btcc",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 7863,
|
||||
Volume: 20,
|
||||
},
|
||||
}
|
||||
|
||||
i2 := Item{
|
||||
Exchange: "btcc",
|
||||
Pair: p,
|
||||
AssetType: "SPOT",
|
||||
Price: 7863,
|
||||
Volume: 20,
|
||||
}
|
||||
|
||||
Items = append(Items, i)
|
||||
Items = append(Items, i2)
|
||||
ByPrice.Swap(Items, 3, 4)
|
||||
if Items[3].Exchange != "btcc" || Items[4].Exchange != "bitstamp" {
|
||||
ByPrice.Swap(Items, 0, 1)
|
||||
if Items[0].Exchange != "btcc" || Items[1].Exchange != "bitstamp" {
|
||||
t.Error("Test Failed - stats SwapByPrice did not swap values.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLenByVolume(t *testing.T) {
|
||||
if ByVolume.Len(Items) != 5 {
|
||||
if ByVolume.Len(Items) != 2 {
|
||||
t.Error("Test Failed - stats lenByVolume did not swap values.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLessByVolume(t *testing.T) {
|
||||
if !ByVolume.Less(Items, 1, 2) {
|
||||
if !ByVolume.Less(Items, 1, 0) {
|
||||
t.Error("Test Failed - stats LessByVolume() incorrect return.")
|
||||
}
|
||||
if ByVolume.Less(Items, 2, 1) {
|
||||
if ByVolume.Less(Items, 0, 1) {
|
||||
t.Error("Test Failed - stats LessByVolume() incorrect return.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwapByVolume(t *testing.T) {
|
||||
ByPrice.Swap(Items, 3, 4)
|
||||
ByPrice.Swap(Items, 0, 1)
|
||||
|
||||
if Items[4].Exchange != "btcc" || Items[3].Exchange != "bitstamp" {
|
||||
if Items[1].Exchange != "btcc" || Items[0].Exchange != "bitstamp" {
|
||||
t.Error("Test Failed - stats SwapByVolume did not swap values.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user