|
| 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(<<"�"/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. |
0 commit comments