|
| 1 | +%%-------------------------------------------------------------------- |
| 2 | +%% Copyright (C) 2023 hyperimpose.org |
| 3 | +%% |
| 4 | +%% This file is part of irc. |
| 5 | +%% |
| 6 | +%% This program is free software: you can redistribute it and/or modify |
| 7 | +%% it under the terms of the GNU Affero General Public License as published |
| 8 | +%% by the Free Software Foundation, version 3. |
| 9 | +%% |
| 10 | +%% This program is distributed in the hope that it will be useful, |
| 11 | +%% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +%% GNU Affero General Public License for more details. |
| 14 | +%% |
| 15 | +%% You should have received a copy of the GNU Affero General Public License |
| 16 | +%% along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | +%%-------------------------------------------------------------------- |
| 18 | + |
| 19 | +-module(irc_text_tests). |
| 20 | + |
| 21 | +-include_lib("eunit/include/eunit.hrl"). |
| 22 | + |
| 23 | + |
| 24 | +%%% truncate/2, truncate/3 |
| 25 | + |
| 26 | +truncate_bounds_test_() -> |
| 27 | + L = fun (X) -> byte_size(unicode:characters_to_binary(X)) end, |
| 28 | + |
| 29 | + [%% Without Ellipsis |
| 30 | + ?_assert(11 >= L(irc_text:truncate("Hello, World!", 11))), |
| 31 | + ?_assert(26 >= L(irc_text:truncate("Γειά σου, Κόσμε!", 26))), |
| 32 | + %% With Ellipsis |
| 33 | + ?_assert(11 >= L(irc_text:truncate("Hello, World!", 11, <<"...">>))), |
| 34 | + ?_assert(26 >= L(irc_text:truncate("Γειά σου, Κόσμε!", 26, <<"...">>)))]. |
0 commit comments