diff --git a/builtin_test.go b/builtin_test.go new file mode 100644 index 0000000..486943b --- /dev/null +++ b/builtin_test.go @@ -0,0 +1,29 @@ +/* +Copyright 2024 The GoPlus Authors (goplus.org) +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package hdq + +import "testing" + +func TestCached(t *testing.T) { + cached := []cachedGetter{ + new(fixNodes), + new(anyNodes), + new(oneNode), + } + for _, v := range cached { + v.Cached() + } +} diff --git a/hdq_test.go b/hdq_test.go index f31c911..25de7cb 100644 --- a/hdq_test.go +++ b/hdq_test.go @@ -69,17 +69,22 @@ func TestSource(t *testing.T) { } func TestErrNodeSet(t *testing.T) { - doc := hdq.NodeSet{Err: hdq.ErrInvalidNode} - fns := []func() hdq.NodeSet{ - doc.Child, - doc.Parent, - doc.PrevSiblings, - doc.NextSiblings, - doc.Any, + docErr := hdq.NodeSet{Err: hdq.ErrInvalidNode} + fns := []func(hdq.NodeSet) hdq.NodeSet{ + (hdq.NodeSet).Child, + (hdq.NodeSet).Parent, + (hdq.NodeSet).PrevSiblings, + (hdq.NodeSet).NextSiblings, + (hdq.NodeSet).Any, } for _, fn := range fns { - if v := fn(); v != doc { + if v := fn(docErr); v != docErr { t.Fatal("ErrNodeSet failed:", v) } } + const data = "hello" + doc := hdq.Source([]byte(data)) + for _, fn := range fns { + fn(doc) + } }