Skip to content

Commit 759685c

Browse files
committed
made the tests for OS neutral
1 parent 91bf485 commit 759685c

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

pairtree.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// pairtree.go implements encoding/decoding of object identifiers and pairtree paths (ppaths) per
2+
// pairtree.go implements encoding/decoding of object identifiers and pairtree paths (paths) per
33
// https://confluence.ucop.edu/download/attachments/14254128/PairtreeSpec.pdf?version=2&modificationDate=1295552323000&api=v2
44
//
55
// Author R. S. Doiel, <[email protected]>
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
const (
28-
Version = `v0.0.3`
28+
Version = `v0.0.4`
2929
)
3030

3131
var (
@@ -89,8 +89,6 @@ func charDecode(s string) string {
8989

9090
// Encode takes a string and encodes it as a pairtree path.
9191
func Encode(src string) string {
92-
//s := charEncode(src)
93-
//s := []rune(src)
9492
s := charEncode([]rune(src))
9593
results := []rune{}
9694
for i := 0; i < len(s); i += 2 {

pairtree_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package pairtree
2121

2222
import (
2323
"os"
24-
"path"
24+
"path/filepath"
2525
"testing"
2626
)
2727

@@ -55,15 +55,15 @@ func TestCharEncoding(t *testing.T) {
5555
func TestBasic(t *testing.T) {
5656
// Test Basic encoding
5757
testEncodings := map[string]string{
58-
"abcd": path.Join("ab", "cd") + pathSep,
59-
"abcdefg": path.Join("ab", "cd", "ef", "g") + pathSep,
60-
"12-986xy4": path.Join("12", "-9", "86", "xy", "4") + pathSep,
61-
"2018-06-01": path.Join("20", "18", "-0", "6-", "01") + pathSep,
62-
"a": path.Join("a") + pathSep,
63-
"ab": path.Join("ab") + pathSep,
64-
"abc": path.Join("ab", "c") + pathSep,
65-
"abcde": path.Join("ab", "cd", "e") + pathSep,
66-
"mnopqz": path.Join("mn", "op", "qz") + pathSep,
58+
"abcd": filepath.Join("ab", "cd") + pathSep,
59+
"abcdefg": filepath.Join("ab", "cd", "ef", "g") + pathSep,
60+
"12-986xy4": filepath.Join("12", "-9", "86", "xy", "4") + pathSep,
61+
"2018-06-01": filepath.Join("20", "18", "-0", "6-", "01") + pathSep,
62+
"a": filepath.Join("a") + pathSep,
63+
"ab": filepath.Join("ab") + pathSep,
64+
"abc": filepath.Join("ab", "c") + pathSep,
65+
"abcde": filepath.Join("ab", "cd", "e") + pathSep,
66+
"mnopqz": filepath.Join("mn", "op", "qz") + pathSep,
6767
}
6868
for src, expected := range testEncodings {
6969
result := Encode(src)
@@ -88,12 +88,12 @@ func TestBasic(t *testing.T) {
8888

8989
func TestAdvanced(t *testing.T) {
9090
testData := map[string]string{
91-
"ark:/13030/xt12t3": path.Join("ar", "k+", "=1", "30", "30",
91+
"ark:/13030/xt12t3": filepath.Join("ar", "k+", "=1", "30", "30",
9292
"=x", "t1", "2t", "3") + pathSep,
93-
"http://n2t.info/urn:nbn:se:kb:repos-1": path.Join("ht", "tp",
93+
"http://n2t.info/urn:nbn:se:kb:repos-1": filepath.Join("ht", "tp",
9494
"+=", "=n", "2t", ",i", "nf", "o=", "ur", "n+", "nb", "n+",
9595
"se", "+k", "b+", "re", "po", "s-", "1") + pathSep,
96-
"what-the-*@?#!^!?": path.Join("wh", "at", "-t", "he", "-^",
96+
"what-the-*@?#!^!?": filepath.Join("wh", "at", "-t", "he", "-^",
9797
"2a", "@^", "3f", "#!", "^5", "e!", "^3",
9898
"f") + pathSep,
9999
}
@@ -113,7 +113,7 @@ func TestAdvanced(t *testing.T) {
113113

114114
func TestUTF8Names(t *testing.T) {
115115
testData := map[string]string{
116-
"Hänggi-P": path.Join("Hä", "ng", "gi", "-P") + pathSep,
116+
"Hänggi-P": filepath.Join("Hä", "ng", "gi", "-P") + pathSep,
117117
}
118118
for src, expected := range testData {
119119
result := Encode(src)

0 commit comments

Comments
 (0)