Skip to content

Commit dc11be8

Browse files
authored
1 parent 593cc1e commit dc11be8

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

example_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package osmshortlink_test
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/stefanb/osmshortlink-go"
7+
)
8+
9+
func ExampleCreate() {
10+
shortLink, err := osmshortlink.Create(46.05141, 14.50604, 17)
11+
if err != nil {
12+
panic(err)
13+
}
14+
fmt.Println(shortLink)
15+
// Output: https://osm.org/go/0Ik3VNr_A-?m
16+
}
17+
18+
func ExampleEncode() {
19+
shortLink, err := osmshortlink.Encode(46.05141, 14.50604, 17)
20+
if err != nil {
21+
panic(err)
22+
}
23+
fmt.Println(shortLink)
24+
// Output: 0Ik3VNr_A-
25+
}
26+
27+
func ExampleDecode() {
28+
latitude, longitude, zoom, err := osmshortlink.Decode("0Ik3VNr_A-")
29+
if err != nil {
30+
panic(err)
31+
}
32+
fmt.Println(latitude, longitude, zoom)
33+
// Output: 46.05140447616577 14.506051540374756 17
34+
}

osmshortlink_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package osmshortlink
22

33
import (
4-
"fmt"
54
"math"
65
"testing"
76
)
@@ -200,30 +199,3 @@ func TestDecodeShortLinkString(t *testing.T) {
200199
})
201200
}
202201
}
203-
204-
func ExampleCreate() {
205-
shortLink, err := Create(46.05141, 14.50604, 17)
206-
if err != nil {
207-
panic(err)
208-
}
209-
fmt.Println(shortLink)
210-
// Output: https://osm.org/go/0Ik3VNr_A-?m
211-
}
212-
213-
func ExampleEncode() {
214-
shortLink, err := Encode(46.05141, 14.50604, 17)
215-
if err != nil {
216-
panic(err)
217-
}
218-
fmt.Println(shortLink)
219-
// Output: 0Ik3VNr_A-
220-
}
221-
222-
func ExampleDecode() {
223-
latitude, longitude, zoom, err := Decode("0Ik3VNr_A-")
224-
if err != nil {
225-
panic(err)
226-
}
227-
fmt.Println(latitude, longitude, zoom)
228-
// Output: 46.05140447616577 14.506051540374756 17
229-
}

0 commit comments

Comments
 (0)