-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitle_test.go
71 lines (64 loc) · 1.64 KB
/
title_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"testing"
)
func TestTitle(t *testing.T) {
tests := []struct {
input string
want_symbols [][]string
want_listing Listing
}{ // Empty title
{"", [][]string{{""}}, NoListing},
{
"Binance Will List BRC-20 Sats (1000SATS) with Seed Tag Applied",
[][]string{{"(1000SATS)", "SATS"}},
BinanceListing,
},
{
"KRW, BTC 마켓 디지털 자산 추가 (ALT, PYTH)",
[][]string{{"(ALT,", "ALT"}, {" PYTH)", "PYTH"}},
UpbitListing,
},
{
"Binance Futures Will Launch USDⓈ-M TON Perpetual Contract With Up to 50x Leverage",
[][]string{{"Binance Futures Will Launch USDⓈ-M TON Perpetual Contract", "TON"}},
BinanceFuturesListing,
},
{
"피스 네트워크(PYTH) 원화 마켓 추가 안내",
[][]string{{"(PYTH)", "PYTH"}},
BithumbListing,
},
}
for _, test := range tests {
symbols, listing, err := parse_title(test.input)
if (listing != test.want_listing) &&
(err != nil) {
t.Errorf(
"Listing %q not equal to expected %q",
listing,
test.want_listing,
)
}
if len(symbols) != len(test.want_symbols) {
t.Errorf(
"symbols length %d not equal to expected %d",
len(symbols),
len(test.want_symbols),
)
t.Errorf(
"symbols %q not equal to expected %q",
symbols,
test.want_symbols)
}
if (len(symbols) > 0) && (len(symbols) == len(test.want_symbols)) &&
(listing != NoListing) {
for index, symbol := range symbols {
if (symbol[0] != test.want_symbols[index][0]) ||
(symbol[1] != test.want_symbols[index][1]) {
t.Errorf("symbol %q not equal to expected %q", symbol, test.want_symbols[index])
}
}
}
}
}