Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
bbd173fc
Commit
bbd173fc
authored
Nov 07, 2011
by
Nigel Tao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
html: be able to test more than one testdata file.
R=andybalholm CC=golang-dev
https://golang.org/cl/5351041
parent
ea9e9386
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
10 deletions
+27
-10
src/pkg/html/parse_test.go
src/pkg/html/parse_test.go
+27
-10
No files found.
src/pkg/html/parse_test.go
View file @
bbd173fc
...
...
@@ -23,6 +23,7 @@ func pipeErr(err error) io.Reader {
}
func
readDat
(
filename
string
,
c
chan
io
.
Reader
)
{
defer
close
(
c
)
f
,
err
:=
os
.
Open
(
"testdata/webkit/"
+
filename
)
if
err
!=
nil
{
c
<-
pipeErr
(
err
)
...
...
@@ -125,17 +126,27 @@ func dump(n *Node) (string, error) {
}
func
TestParser
(
t
*
testing
.
T
)
{
// TODO(nigeltao): Process all the .dat files, not just the first one.
filenames
:=
[]
string
{
"tests1.dat"
,
testFiles
:=
[]
struct
{
filename
string
// n is the number of test cases to run from that file.
// -1 means all test cases.
n
int
}{
// TODO(nigeltao): Process all the test cases from all the .dat files.
{
"tests1.dat"
,
87
},
{
"tests2.dat"
,
0
},
{
"tests3.dat"
,
0
},
}
for
_
,
filename
:=
range
filenam
es
{
for
_
,
tf
:=
range
testFil
es
{
rc
:=
make
(
chan
io
.
Reader
)
go
readDat
(
filename
,
rc
)
// TODO(nigeltao): Process all test cases, not just a subset.
for
i
:=
0
;
i
<
87
;
i
++
{
go
readDat
(
tf
.
filename
,
rc
)
for
i
:=
0
;
i
!=
tf
.
n
;
i
++
{
// Parse the #data section.
b
,
err
:=
ioutil
.
ReadAll
(
<-
rc
)
dataReader
:=
<-
rc
if
dataReader
==
nil
{
break
}
b
,
err
:=
ioutil
.
ReadAll
(
dataReader
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -158,7 +169,7 @@ func TestParser(t *testing.T) {
t
.
Fatal
(
err
)
}
if
want
:=
string
(
b
);
got
!=
want
{
t
.
Errorf
(
"%s test #%d %q, got vs want:
\n
----
\n
%s----
\n
%s----"
,
filename
,
i
,
text
,
got
,
want
)
t
.
Errorf
(
"%s test #%d %q, got vs want:
\n
----
\n
%s----
\n
%s----"
,
tf
.
filename
,
i
,
text
,
got
,
want
)
continue
}
if
renderTestBlacklist
[
text
]
{
...
...
@@ -178,10 +189,16 @@ func TestParser(t *testing.T) {
t
.
Fatal
(
err
)
}
if
got
!=
got1
{
t
.
Errorf
(
"%s test #%d %q, got vs got1:
\n
----
\n
%s----
\n
%s----"
,
filename
,
i
,
text
,
got
,
got1
)
t
.
Errorf
(
"%s test #%d %q, got vs got1:
\n
----
\n
%s----
\n
%s----"
,
tf
.
filename
,
i
,
text
,
got
,
got1
)
continue
}
}
// Drain any untested cases for the test file.
for
r
:=
range
rc
{
if
_
,
err
:=
ioutil
.
ReadAll
(
r
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment