forked from segmentio/go-snakecase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnake_test.go
52 lines (47 loc) · 1.42 KB
/
snake_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
package snakecase
import "testing"
var ops int = 1e6
type sample struct {
str, out string
}
func TestSnakecase(t *testing.T) {
samples := []sample{
{"@49L0S145_¬fwHƒ0TSLNVp", "49l0s145_fw_h_0tslnvp"},
{"lk0B@bFmjrLQ_Z6YL", "lk0_b_b_fmjr_lq_z6yl"},
{"samPLE text", "sam_ple_text"},
{"sample text", "sample_text"},
{"sample-text", "sample_text"},
{"sample_text", "sample_text"},
{"sample___text", "sample_text"},
{"sampleText", "sample_text"},
{"inviteYourCustomersAddInvites", "invite_your_customers_add_invites"},
{"sample 2 Text", "sample_2_text"},
{" sample 2 Text ", "sample_2_text"},
{" $#$sample 2 Text ", "sample_2_text"},
{"SAMPLE 2 TEXT", "sample_2_text"},
{"___$$Base64Encode", "base64_encode"},
{"FOO:BAR$BAZ", "foo_bar_baz"},
{"FOO#BAR#BAZ", "foo_bar_baz"},
{"something.com", "something_com"},
{"$something%", "something"},
{"something.com", "something_com"},
{"•¶§ƒ˚foo˙∆˚¬", "foo"},
{"CStringRef", "cstring_ref"},
{"5test", "5test"},
{"test5", "test5"},
{"THE5r", "the5r"},
{"5TEst", "5test"},
{"_5TEst", "5test"},
{"@%#&5TEst", "5test"},
{"edf_6N", "edf_6n"},
{"f_pX9", "f_p_x9"},
{"p_z9Rg", "p_z9_rg"},
{"2FA Enabled", "2fa_enabled"},
{"Enabled 2FA", "enabled_2fa"},
}
for _, sample := range samples {
if out := Snakecase(sample.str); out != sample.out {
t.Errorf("got %q from %q, expected %q", out, sample.str, sample.out)
}
}
}