-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_test.go
More file actions
45 lines (34 loc) · 959 Bytes
/
example_test.go
File metadata and controls
45 lines (34 loc) · 959 Bytes
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
package mqttpattern_test
import "fmt"
import mqttpattern "github.com/amir-yaghoubi/mqttpattern"
func ExampleMatches() {
fmt.Println(mqttpattern.Matches("foo/+/baz", "foo/bar/baz"))
fmt.Println(mqttpattern.Matches("foo/#", "foo/bar/baz"))
// Output:
// true
// true
}
func ExampleExtract() {
params := mqttpattern.Extract("foo/+something/+otherthing", "foo/bar/baz")
fmt.Printf("%v", params)
// Output:
// map[otherthing:baz something:bar]
}
func ExampleExec() {
params := mqttpattern.Exec("foo/+something/+otherthing", "foo/bar/baz")
fmt.Printf("%v", params)
// Output:
// map[otherthing:baz something:bar]
}
func ExampleFill() {
cleanPattern := mqttpattern.Fill("foo/+bar/#baz", map[string]string{"bar": "BAR", "baz": "BAZ"})
fmt.Printf("%v", cleanPattern)
// Output:
// foo/BAR/BAZ
}
func ExampleClean() {
cleanPattern := mqttpattern.Clean("foo/+something/#otherthing")
fmt.Printf("%v", cleanPattern)
// Output:
// foo/+/#
}