Skip to content

Commit 301b91c

Browse files
committed
Add more misc_url and misc_zero test suites
1 parent 62011ac commit 301b91c

File tree

4 files changed

+452
-0
lines changed

4 files changed

+452
-0
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
%%% % DO NOT EDIT: this file was generated by 'just codegen'
2+
%%% % @generated SignedSource<<4ee7f9c5ea27037bb6c7f9118c9d5f9e>>
3+
%%%-----------------------------------------------------------------------------
4+
%%% %CopyrightBegin%
5+
%%%
6+
%%% SPDX-License-Identifier: Apache-2.0
7+
%%%
8+
%%% Copyright (c) Meta Platforms, Inc. and affiliates.
9+
%%% Copyright (c) WhatsApp LLC
10+
%%%
11+
%%% Licensed under the Apache License, Version 2.0 (the "License");
12+
%%% you may not use this file except in compliance with the License.
13+
%%% You may obtain a copy of the License at
14+
%%%
15+
%%% http://www.apache.org/licenses/LICENSE-2.0
16+
%%%
17+
%%% Unless required by applicable law or agreed to in writing, software
18+
%%% distributed under the License is distributed on an "AS IS" BASIS,
19+
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
%%% See the License for the specific language governing permissions and
21+
%%% limitations under the License.
22+
%%%
23+
%%% %CopyrightEnd%
24+
%%%-----------------------------------------------------------------------------
25+
%%% % @format
26+
-module(markdown_misc_url_SUITE).
27+
-moduledoc """
28+
29+
""".
30+
-moduledoc #{author => ["Andrew Bennett <[email protected]>"]}.
31+
-moduledoc #{created => "2025-10-28", modified => "2025-10-28"}.
32+
-moduledoc #{copyright => "Meta Platforms, Inc. and affiliates."}.
33+
-compile(warn_missing_spec_all).
34+
-oncall("whatsapp_clr").
35+
36+
-include_lib("markdown/include/markdown_mdast.hrl").
37+
-include_lib("markdown/include/markdown_util.hrl").
38+
-include_lib("stdlib/include/assert.hrl").
39+
40+
-behaviour(ct_suite).
41+
42+
%% ct_suite callbacks
43+
-export([
44+
all/0,
45+
groups/0,
46+
init_per_suite/1,
47+
end_per_suite/1,
48+
init_per_group/2,
49+
end_per_group/2
50+
]).
51+
52+
%% Test Cases
53+
-export([
54+
test_misc_url_case_1/1,
55+
test_misc_url_case_2/1,
56+
test_misc_url_case_3/1,
57+
test_misc_url_case_4/1,
58+
test_misc_url_case_5/1,
59+
test_misc_url_case_6/1
60+
]).
61+
62+
%%%=============================================================================
63+
%%% ct_suite callbacks
64+
%%%=============================================================================
65+
66+
-spec all() -> markdown_test:all().
67+
all() ->
68+
[
69+
{group, static}
70+
].
71+
72+
-spec groups() -> markdown_test:groups().
73+
groups() ->
74+
[
75+
{static, [parallel], [
76+
test_misc_url_case_1,
77+
test_misc_url_case_2,
78+
test_misc_url_case_3,
79+
test_misc_url_case_4,
80+
test_misc_url_case_5,
81+
test_misc_url_case_6
82+
]}
83+
].
84+
85+
-spec init_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:init_per_suite().
86+
init_per_suite(Config) ->
87+
Config.
88+
89+
-spec end_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:end_per_suite().
90+
end_per_suite(_Config) ->
91+
ok.
92+
93+
-spec init_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
94+
markdown_test:init_per_group().
95+
init_per_group(_Group, Config) ->
96+
Config.
97+
98+
-spec end_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
99+
markdown_test:end_per_group().
100+
end_per_group(_Group, _Config) ->
101+
ok.
102+
103+
%%%=============================================================================
104+
%%% Test Cases
105+
%%%=============================================================================
106+
107+
-spec test_misc_url_case_1(Config) -> markdown_test:testcase() when
108+
Config :: ct_suite:ct_config().
109+
test_misc_url_case_1(_Config) ->
110+
?assertMatch(
111+
{ok, <<"<p><a href=\"https://%25\">https://%</a></p>"/utf8>>},
112+
markdown:to_html(<<"<https://%>"/utf8>>),
113+
"should support incorrect percentage encoded values (0)"
114+
),
115+
ok.
116+
117+
-spec test_misc_url_case_2(Config) -> markdown_test:testcase() when
118+
Config :: ct_suite:ct_config().
119+
test_misc_url_case_2(_Config) ->
120+
?assertMatch(
121+
{ok, <<"<p><a href=\"%25\"></a></p>"/utf8>>},
122+
markdown:to_html(<<"[](<%>)"/utf8>>),
123+
"should support incorrect percentage encoded values (1)"
124+
),
125+
ok.
126+
127+
-spec test_misc_url_case_3(Config) -> markdown_test:testcase() when
128+
Config :: ct_suite:ct_config().
129+
test_misc_url_case_3(_Config) ->
130+
?assertMatch(
131+
{ok, <<"<p><a href=\"%25%20\"></a></p>"/utf8>>},
132+
markdown:to_html(<<"[](<%%20>)"/utf8>>),
133+
"should support incorrect percentage encoded values (2)"
134+
),
135+
ok.
136+
137+
-spec test_misc_url_case_4(Config) -> markdown_test:testcase() when
138+
Config :: ct_suite:ct_config().
139+
test_misc_url_case_4(_Config) ->
140+
?assertMatch(
141+
{ok, <<"<p><a href=\"%25a%20\"></a></p>"/utf8>>},
142+
markdown:to_html(<<"[](<%a%20>)"/utf8>>),
143+
"should support incorrect percentage encoded values (3)"
144+
),
145+
ok.
146+
147+
-spec test_misc_url_case_5(Config) -> markdown_test:testcase() when
148+
Config :: ct_suite:ct_config().
149+
test_misc_url_case_5(_Config) ->
150+
?assertMatch(
151+
{ok, <<"<p><a href=\"%F0%9F%A4%94\"></a></p>"/utf8>>},
152+
markdown:to_html(<<"[](<🤔>)"/utf8>>),
153+
"should support an emoji"
154+
),
155+
ok.
156+
157+
-spec test_misc_url_case_6(Config) -> markdown_test:testcase() when
158+
Config :: ct_suite:ct_config().
159+
test_misc_url_case_6(_Config) ->
160+
?assertMatch(
161+
{ok,
162+
<<"<p><a href=\"%EF%BF%BD%01%02%03%04%05%06%07%08%09%0B%0C%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22#$%25&amp;'()*+,-./0123456789:;%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F\"></a></p>"/utf8>>},
163+
markdown:to_html(
164+
<<"[](<\x00\x01\x02\x03\x04\x05\x06\x07\b\t\v\f\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;\\<=\\>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~>)"/utf8>>
165+
),
166+
"should support ascii characters"
167+
),
168+
ok.
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
%%% % DO NOT EDIT: this file was generated by 'just codegen'
2+
%%% % @generated SignedSource<<ee54db57b616fdd0496d8ca965896451>>
3+
%%%-----------------------------------------------------------------------------
4+
%%% %CopyrightBegin%
5+
%%%
6+
%%% SPDX-License-Identifier: Apache-2.0
7+
%%%
8+
%%% Copyright (c) Meta Platforms, Inc. and affiliates.
9+
%%% Copyright (c) WhatsApp LLC
10+
%%%
11+
%%% Licensed under the Apache License, Version 2.0 (the "License");
12+
%%% you may not use this file except in compliance with the License.
13+
%%% You may obtain a copy of the License at
14+
%%%
15+
%%% http://www.apache.org/licenses/LICENSE-2.0
16+
%%%
17+
%%% Unless required by applicable law or agreed to in writing, software
18+
%%% distributed under the License is distributed on an "AS IS" BASIS,
19+
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
%%% See the License for the specific language governing permissions and
21+
%%% limitations under the License.
22+
%%%
23+
%%% %CopyrightEnd%
24+
%%%-----------------------------------------------------------------------------
25+
%%% % @format
26+
-module(markdown_misc_zero_SUITE).
27+
-moduledoc """
28+
29+
""".
30+
-moduledoc #{author => ["Andrew Bennett <[email protected]>"]}.
31+
-moduledoc #{created => "2025-10-28", modified => "2025-10-28"}.
32+
-moduledoc #{copyright => "Meta Platforms, Inc. and affiliates."}.
33+
-compile(warn_missing_spec_all).
34+
-oncall("whatsapp_clr").
35+
36+
-include_lib("markdown/include/markdown_mdast.hrl").
37+
-include_lib("markdown/include/markdown_util.hrl").
38+
-include_lib("stdlib/include/assert.hrl").
39+
40+
-behaviour(ct_suite).
41+
42+
%% ct_suite callbacks
43+
-export([
44+
all/0,
45+
groups/0,
46+
init_per_suite/1,
47+
end_per_suite/1,
48+
init_per_group/2,
49+
end_per_group/2
50+
]).
51+
52+
%% Test Cases
53+
-export([
54+
test_misc_zero_case_1/1,
55+
test_misc_zero_case_2/1,
56+
test_misc_zero_case_3/1,
57+
%% This doesn’t make sense in markdown, as character escapes only work on
58+
59+
%% ascii punctuation, but it’s good to demonstrate the behavior.
60+
test_misc_zero_case_4/1,
61+
test_misc_zero_case_5/1
62+
]).
63+
64+
%%%=============================================================================
65+
%%% ct_suite callbacks
66+
%%%=============================================================================
67+
68+
-spec all() -> markdown_test:all().
69+
all() ->
70+
[
71+
{group, static}
72+
].
73+
74+
-spec groups() -> markdown_test:groups().
75+
groups() ->
76+
[
77+
{static, [parallel], [
78+
test_misc_zero_case_1,
79+
test_misc_zero_case_2,
80+
test_misc_zero_case_3,
81+
%% This doesn’t make sense in markdown, as character escapes only work on
82+
83+
%% ascii punctuation, but it’s good to demonstrate the behavior.
84+
test_misc_zero_case_4,
85+
test_misc_zero_case_5
86+
]}
87+
].
88+
89+
-spec init_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:init_per_suite().
90+
init_per_suite(Config) ->
91+
Config.
92+
93+
-spec end_per_suite(Config :: ct_suite:ct_config()) -> markdown_test:end_per_suite().
94+
end_per_suite(_Config) ->
95+
ok.
96+
97+
-spec init_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
98+
markdown_test:init_per_group().
99+
init_per_group(_Group, Config) ->
100+
Config.
101+
102+
-spec end_per_group(GroupName :: ct_suite:ct_groupname(), Config :: ct_suite:ct_config()) ->
103+
markdown_test:end_per_group().
104+
end_per_group(_Group, _Config) ->
105+
ok.
106+
107+
%%%=============================================================================
108+
%%% Test Cases
109+
%%%=============================================================================
110+
111+
-spec test_misc_zero_case_1(Config) -> markdown_test:testcase() when
112+
Config :: ct_suite:ct_config().
113+
test_misc_zero_case_1(_Config) ->
114+
?assertMatch(
115+
{ok, <<""/utf8>>},
116+
markdown:to_html(<<""/utf8>>),
117+
"should support no markdown"
118+
),
119+
ok.
120+
121+
-spec test_misc_zero_case_2(Config) -> markdown_test:testcase() when
122+
Config :: ct_suite:ct_config().
123+
test_misc_zero_case_2(_Config) ->
124+
?assertMatch(
125+
{ok, <<"<p>asd�asd</p>"/utf8>>},
126+
markdown:to_html(<<"asd\x00asd"/utf8>>),
127+
"should replace `\\0` w/ a replacement characters (`�`)"
128+
),
129+
ok.
130+
131+
-spec test_misc_zero_case_3(Config) -> markdown_test:testcase() when
132+
Config :: ct_suite:ct_config().
133+
test_misc_zero_case_3(_Config) ->
134+
?assertMatch(
135+
{ok, <<"<p>�</p>"/utf8>>},
136+
markdown:to_html(<<"&#0;"/utf8>>),
137+
"should replace NUL in a character reference"
138+
),
139+
ok.
140+
141+
-spec test_misc_zero_case_4(Config) -> markdown_test:testcase() when
142+
Config :: ct_suite:ct_config().
143+
test_misc_zero_case_4(_Config) ->
144+
%% This doesn’t make sense in markdown, as character escapes only work on
145+
%% ascii punctuation, but it’s good to demonstrate the behavior.
146+
?assertMatch(
147+
{ok, <<"<p>\\0</p>"/utf8>>},
148+
markdown:to_html(<<"\\0"/utf8>>),
149+
"should not support NUL in a character escape"
150+
),
151+
ok.
152+
153+
-spec test_misc_zero_case_5(Config) -> markdown_test:testcase() when
154+
Config :: ct_suite:ct_config().
155+
test_misc_zero_case_5(_Config) ->
156+
?assertEqual(
157+
{ok,
158+
markdown_mdast_node:root(#markdown_mdast_root{
159+
children = ?'vec!'([]),
160+
position = {some, markdown_unist_position:new(1, 1, 0, 1, 1, 0)}
161+
})},
162+
markdown:to_mdast(<<""/utf8>>, markdown_parse_options:new(#{})),
163+
"should support no markdown (ast)"
164+
),
165+
ok.

codegen/test/misc_url.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# yaml-language-server: $schema=./schema.json
2+
3+
###-----------------------------------------------------------------------------
4+
### %CopyrightBegin%
5+
###
6+
### SPDX-License-Identifier: Apache-2.0
7+
###
8+
### Copyright (c) Meta Platforms, Inc. and affiliates.
9+
### Copyright (c) WhatsApp LLC
10+
###
11+
### Licensed under the Apache License, Version 2.0 (the "License");
12+
### you may not use this file except in compliance with the License.
13+
### You may obtain a copy of the License at
14+
###
15+
### http://www.apache.org/licenses/LICENSE-2.0
16+
###
17+
### Unless required by applicable law or agreed to in writing, software
18+
### distributed under the License is distributed on an "AS IS" BASIS,
19+
### WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
### See the License for the specific language governing permissions and
21+
### limitations under the License.
22+
###
23+
### %CopyrightEnd%
24+
###-----------------------------------------------------------------------------
25+
26+
---
27+
suite:
28+
name: misc_url
29+
created: 2025-10-28
30+
modified: 2025-10-28
31+
to_html:
32+
- name: test_misc_url_case_1
33+
input: <https://%>
34+
output: "<p><a href=\"https://%25\">https://%</a></p>"
35+
message: should support incorrect percentage encoded values (0)
36+
- name: test_misc_url_case_2
37+
input: '[](<%>)'
38+
output: "<p><a href=\"%25\"></a></p>"
39+
message: should support incorrect percentage encoded values (1)
40+
- name: test_misc_url_case_3
41+
input: '[](<%%20>)'
42+
output: "<p><a href=\"%25%20\"></a></p>"
43+
message: should support incorrect percentage encoded values (2)
44+
- name: test_misc_url_case_4
45+
input: '[](<%a%20>)'
46+
output: "<p><a href=\"%25a%20\"></a></p>"
47+
message: should support incorrect percentage encoded values (3)
48+
- name: test_misc_url_case_5
49+
input: '[](<🤔>)'
50+
output: "<p><a href=\"%F0%9F%A4%94\"></a></p>"
51+
message: should support an emoji
52+
- name: test_misc_url_case_6
53+
input: "[](<\0\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;\\<=\\>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f>)"
54+
output: "<p><a href=\"%EF%BF%BD%01%02%03%04%05%06%07%08%09%0B%0C%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22#$%25&amp;'()*+,-./0123456789:;%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F\"></a></p>"
55+
message: "should support ascii characters"
56+
to_html_with_options: []
57+
to_mdast: []

0 commit comments

Comments
 (0)