init
This commit is contained in:
commit
6b4240ac0a
57
main_test.go
Normal file
57
main_test.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
type Type int
|
||||
|
||||
const (
|
||||
TypeChild Type = iota
|
||||
TypeChildren
|
||||
TypeAllChildren
|
||||
)
|
||||
|
||||
type Node struct {
|
||||
Prev *Node
|
||||
Next *Node
|
||||
Name []byte
|
||||
Type Type
|
||||
}
|
||||
|
||||
// func extractPath(cur *Node) string {
|
||||
// var path []byte
|
||||
|
||||
// if cur.Next.Next == nil {
|
||||
// return "/"
|
||||
// }
|
||||
|
||||
// for ; cur != nil; cur = cur.Next {
|
||||
// path = append(path, cur.Name...)
|
||||
// if cur.Next.Next == nil {
|
||||
// break
|
||||
// }
|
||||
// path = append(path, '/')
|
||||
// }
|
||||
// return string(path)
|
||||
// }
|
||||
|
||||
func xPath(spath string) string {
|
||||
var path []byte = make([]byte, len(spath))
|
||||
copy(path, spath)
|
||||
|
||||
for i := 0; i < len(path); i++ {
|
||||
c := path[i]
|
||||
if c == '/' {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
// t.Error(xPath("/a/../../b/../c//.//"))
|
||||
// t.Error(xPath("/a/./b/../../c/"))
|
||||
// t.Error(xPath("/"))
|
||||
// t.Error(xPath("/a//b////c/d//././/.."))
|
||||
}
|
Loading…
Reference in New Issue
Block a user