-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRpcFunction_test.go
More file actions
63 lines (49 loc) · 1.54 KB
/
RpcFunction_test.go
File metadata and controls
63 lines (49 loc) · 1.54 KB
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
package jrm1
import (
"encoding/json"
"fmt"
"testing"
"github.com/vault-thirteen/auxie/tester"
)
type Sheisse struct {
}
func (s *Sheisse) TestFunction(_ *json.RawMessage, _ *ResponseMetaData) (result any, re *RpcError) {
return
}
func Test_RpcFunction_GetName(t *testing.T) {
aTest := tester.New(t)
var fname string
// Test #1.
rpcFn := RpcFunction(RpcFunctionExampleOne)
fname = rpcFn.GetName()
aTest.MustBeEqual(fname, "RpcFunctionExampleOne")
// Test #2.
shs := Sheisse{}
fn2 := RpcFunction(shs.TestFunction)
fname = fn2.GetName()
aTest.MustBeEqual(fname, "TestFunction")
}
func Test_CheckFunctionName(t *testing.T) {
aTest := tester.New(t)
aTest.MustBeNoError(CheckFunctionName("0123456789"))
aTest.MustBeNoError(CheckFunctionName("abcdefghijklmnopqrstuvwxyz"))
aTest.MustBeNoError(CheckFunctionName("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
aTest.MustBeNoError(CheckFunctionName("_"))
aTest.MustBeAnError(CheckFunctionName("*"))
}
func Test_isValidSymbolForFuncName(t *testing.T) {
aTest := tester.New(t)
validSymbols := []rune{}
for _, s := range []rune("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + "_") {
validSymbols = append(validSymbols, s)
}
aTest.MustBeEqual(len(validSymbols), 26+26+10+1)
for _, s := range validSymbols {
fmt.Printf("%s", string(s))
aTest.MustBeEqual(isValidSymbolForFuncName(s), true)
}
fmt.Println()
aTest.MustBeEqual(isValidSymbolForFuncName('*'), false)
aTest.MustBeEqual(isValidSymbolForFuncName('.'), false)
aTest.MustBeEqual(isValidSymbolForFuncName(' '), false)
}