-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpersian_test.go
81 lines (64 loc) · 2.09 KB
/
persian_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
72
73
74
75
76
77
78
79
80
81
package persian
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_toPersianDigits(t *testing.T) {
str := "123salam456"
assert.Equal(t, "۱۲۳salam۴۵۶", ToPersianDigits(str))
}
func Test_toPersianDigitsFromInt(t *testing.T) {
value := 123
assert.Equal(t, "۱۲۳", ToPersianDigitsFromInt(value))
}
func Test_toEnglishDigits(t *testing.T) {
str := "۱۲۳salam۴۵۶"
assert.Equal(t, "123salam456", ToEnglishDigits(str))
}
func Test_onlyEnglishNumbers(t *testing.T) {
value := "salam123hello456۱۲۳سلام۴۵۶"
assert.Equal(t, "123456", OnlyEnglishNumbers(value))
}
func Test_onlyPersianNumbers(t *testing.T) {
value := "salam123hello456۱۲۳سلام۴۵۶"
assert.Equal(t, "۱۲۳۴۵۶", OnlyPersianNumbers(value))
}
func Test_switchToPersianKey(t *testing.T) {
value := "sghl o,fd ? o,fl llk,k"
assert.Equal(t, "سلام خوبی ؟ خوبم ممنون", SwitchToPersianKey(value))
}
func Test_switchToEnglishKey(t *testing.T) {
value := "اثغ صاشفس عح ؟"
assert.Equal(t, "hey whats up ?", SwitchToEnglishKey(value))
}
func Test_Currency(t *testing.T) {
value := "123۴۵۶7"
assert.Equal(t, "۱،۲۳۴،۵۶۷", Currency(value))
}
func Test_toman(t *testing.T) {
value := "123۴۵۶7"
assert.Equal(t, "۱،۲۳۴،۵۶۷ تومان", Toman(value))
}
func Test_rial(t *testing.T) {
value := "123۴۵۶7"
assert.Equal(t, "۱،۲۳۴،۵۶۷ ﷼", Rial(value))
}
func Test_fixArabic(t *testing.T) {
value := "عليرضا"
assert.Equal(t, "علیرضا", FixArabic(value))
}
func Test_checkIsEnglish(t *testing.T) {
value := "علي"
assert.Equal(t, false, CheckIsEnglish(value))
value = "ali"
assert.Equal(t, true, CheckIsEnglish(value))
}
func Test_onlyPersianAlpha(t *testing.T) {
value := "123456شاهینshaahin"
assert.Equal(t, "شاهین", OnlyPersianAlpha(value))
}
func Test_Normalize(t *testing.T) {
anormalValue := "متن نانرمال عربي و فارسی با عددهای ۱ و 1"
normalValue := "متن نا نرمال عربی و فارسی با عددهای ۱ و 1"
assert.Equal(t,normalValue,Normalize(anormalValue))
}