Skip to content

Commit 956d015

Browse files
committed
test: add code coverage for nodejs
1 parent 5ea97db commit 956d015

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

tests/basic_tests.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,25 @@ bool nodejs1() {
139139
TEST_SUCCEED()
140140
}
141141

142+
bool nodejs2() {
143+
TEST_START()
144+
auto url = ada::parse("data:space ?test");
145+
TEST_ASSERT(url->get_search(), "?test", "search is not equal");
146+
url->set_search("");
147+
TEST_ASSERT(url->get_search(), "", "search should have been empty");
148+
TEST_ASSERT(url->get_pathname(), "space", "pathname should have been 'space' without trailing spaces");
149+
TEST_ASSERT(url->get_href(), "data:space", "href is not equal");
150+
TEST_SUCCEED()
151+
}
152+
142153
int main() {
143154
bool success = set_host_should_return_false_sometimes()
144155
&& set_host_should_return_true_sometimes()
145156
&& set_hostname_should_return_false_sometimes()
146157
&& set_hostname_should_return_true_sometimes()
147158
&& readme1() && readme2() && readme3()
148159
&& readme4() && readme5() && readme6()
149-
&& readme7() && nodejs1();
160+
&& readme7() && nodejs1() && nodejs2();
150161
if(success) { return EXIT_SUCCESS; }
151162
return EXIT_FAILURE;
152163
}

tests/wpt/ada_extra_urltestdata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,20 @@
206206
"input": "file://localhost:8098/path/to/file.txt",
207207
"base": "about:blank",
208208
"failure": true
209+
},
210+
{
211+
"input": "data:space ?test#test",
212+
"base": "about:blank",
213+
"href": "data:space ?test#test",
214+
"origin": "null",
215+
"protocol": "data:",
216+
"username": "",
217+
"password": "",
218+
"host": "",
219+
"hostname": "",
220+
"port": "",
221+
"pathname": "space ",
222+
"search": "?test",
223+
"hash": "#test"
209224
}
210225
]

0 commit comments

Comments
 (0)