Skip to content

Commit

Permalink
TestCached
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed May 18, 2024
1 parent e04f85c commit c568859
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
29 changes: 29 additions & 0 deletions builtin_test.go
Original file line number Diff line number Diff line change
@@ -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()
}
}
21 changes: 13 additions & 8 deletions hdq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<html><body>hello</body></html>"
doc := hdq.Source([]byte(data))
for _, fn := range fns {
fn(doc)
}
}

0 comments on commit c568859

Please sign in to comment.