Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eecs398-search
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vcday
eecs398-search
Commits
46f1301c
Commit
46f1301c
authored
6 years ago
by
vcday
Browse files
Options
Downloads
Patches
Plain Diff
parser test http pass
parent
81a9772f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
parser/Parser.cpp
+11
-0
11 additions, 0 deletions
parser/Parser.cpp
parser/tests/parserTest.cpp
+25
-6
25 additions, 6 deletions
parser/tests/parserTest.cpp
with
36 additions
and
6 deletions
parser/Parser.cpp
+
11
−
0
View file @
46f1301c
...
...
@@ -138,8 +138,15 @@ string Parser::extractUrl ( string html )
{
url
=
""
;
unsigned
long
closeTag
=
findNext
(
">"
,
foundHref
,
html
);
unsigned
long
closeQuote
=
findNext
(
"
\"
"
,
foundHref
,
html
);
unsigned
long
closeSpace
=
findNext
(
" "
,
foundHref
,
html
);
unsigned
long
closeUrl
=
0
;
// ends in "
// if ( closeQuote < html.size( ) && closeTag < html.size( ) && closeQuote < closeTag && closeQuote < closeSpace )
// {
// closeUrl = closeQuote;
// }
// end == ' >'
if
(
closeSpace
<
html
.
size
(
)
&&
closeTag
<
html
.
size
(
)
&&
closeSpace
<
closeTag
)
{
...
...
@@ -167,6 +174,10 @@ string Parser::extractUrl ( string html )
}
}
while
(
!
url
.
empty
(
)
&&
(
url
.
back
(
)
==
'\"'
||
url
.
back
(
)
==
';'
)
)
{
url
.
pop_back
(
);
}
return
url
;
}
...
...
This diff is collapsed.
Click to expand it.
parser/tests/parserTest.cpp
+
25
−
6
View file @
46f1301c
...
...
@@ -16,7 +16,7 @@
using
namespace
std
;
void
testSimple
(
);
void
test
Complex
(
);
void
test
Http
(
);
void
testURL
(
);
void
testBody
(
);
void
testExtractBody
(
);
...
...
@@ -28,7 +28,7 @@ int main ( )
{
cout
<<
"Testing Parser ... "
<<
endl
<<
endl
;
testSimple
(
);
//
test
Complex
( );
test
Http
(
);
testURL
(
);
testBody
(
);
testExtractBody
(
);
...
...
@@ -90,14 +90,14 @@ void testSimple ( )
cout
<<
"Simple Test Passed!"
<<
endl
<<
endl
;
}
void
test
Complex
(
)
void
test
Http
(
)
{
cout
<<
"Testing Complex: "
<<
endl
;
ProducerConsumerQueue
<
ParsedUrl
>
urlFrontierTest
;
Parser
parser
(
&
urlFrontierTest
);
ParsedUrl
httpURL
=
ParsedUrl
(
"www.veronicacday.com"
);
HttpReader
reader
(
httpURL
);
ParsedUrl
httpURL
=
ParsedUrl
(
"http://veronicacday.com/"
);
HttpReader
reader
(
httpURL
);
auto
success
=
reader
.
request
(
);
if
(
!
success
)
{
...
...
@@ -107,10 +107,29 @@ void testComplex( )
auto
dictionary
=
parser
.
execute
(
&
reader
);
printDictionary
(
*
dictionary
);
urlFrontierTest
.
Pop
(
);
assert
(
urlFrontierTest
.
Pop
(
).
getCompleteUrl
(
)
==
"https://trove.com/"
);
assert
(
urlFrontierTest
.
Pop
(
).
getCompleteUrl
(
)
==
"http://arcinnovations.xyz/"
);
assert
(
urlFrontierTest
.
Pop
(
).
getCompleteUrl
(
)
==
"https://gwydion.co/"
);
assert
(
urlFrontierTest
.
Pop
(
).
getCompleteUrl
(
)
==
"https://madeatmichigan.umich.edu/ventures/venture/gwydion/"
);
assert
(
dictionary
!=
nullptr
);
assert
(
dictionary
->
size
(
)
==
67
);
assert
(
dictionary
->
at
(
"=veronicacday.com/"
).
size
(
)
==
1
&&
dictionary
->
at
(
"=veronicacday.com/"
)[
0
]
==
0
);
assert
(
dictionary
->
at
(
"%serena"
).
size
(
)
==
2
&&
dictionary
->
at
(
"%serena"
)[
1
]
==
24
);
assert
(
dictionary
->
at
(
"#veronica"
).
size
(
)
==
1
&&
dictionary
->
at
(
"#veronica"
)[
0
]
==
2
);
assert
(
dictionary
->
at
(
"#dai"
).
size
(
)
==
1
&&
dictionary
->
at
(
"#dai"
)[
0
]
==
3
);
assert
(
dictionary
->
at
(
"%educ"
).
size
(
)
==
1
&&
dictionary
->
at
(
"%educ"
)[
0
]
==
13
);
assert
(
dictionary
->
at
(
"%surgeri"
).
size
(
)
==
1
&&
dictionary
->
at
(
"%surgeri"
)[
0
]
==
72
);
delete
dictionary
;
dictionary
=
nullptr
;
cout
<<
"Complex Test Passed! "
<<
endl
;
cout
<<
"Complex Test Passed! "
<<
endl
<<
endl
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment