-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils_test.go
67 lines (56 loc) · 1.51 KB
/
utils_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
package mango
import "testing"
func TestKellyBet(t *testing.T) {
prob := 0.6
payout := 2.0
expected := 0.2
result := KellyBet(prob, payout)
if result != expected {
t.Errorf("Expected %f, but got %f", expected, result)
}
}
func TestGetUsernames(t *testing.T) {
text := `export const BOT_USERNAMES = [
'pos',
'v',
'acc',
'jerk',
]
export const CORE_USERNAMES = [
'Austin',
'JamesGrugett',
'SG',
]
export const CHECK_USERNAMES = [
'EliezerYudkowsky',
'memestiny',
'ScottAlexander',
]`
expectedBotUsernames := []string{"pos", "v", "acc", "jerk"}
expectedCoreUsernames := []string{"Austin", "JamesGrugett", "SG"}
expectedCheckUsernames := []string{"EliezerYudkowsky", "memestiny", "ScottAlexander"}
botUsernames := getUsernames(Bot, text)
coreUsernames := getUsernames(Core, text)
checkUsernames := getUsernames(Check, text)
if !stringSliceEqual(botUsernames, expectedBotUsernames) {
t.Errorf("Expected BOT_USERNAMES %v, but got %v", expectedBotUsernames, botUsernames)
}
if !stringSliceEqual(coreUsernames, expectedCoreUsernames) {
t.Errorf("Expected CORE_USERNAMES %v, but got %v", expectedCoreUsernames, coreUsernames)
}
if !stringSliceEqual(checkUsernames, expectedCheckUsernames) {
t.Errorf("Expected CHECK_USERNAMES %v, but got %v", expectedCheckUsernames, checkUsernames)
}
}
// Helper function to compare string slices
func stringSliceEqual(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}