You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "libavutil/common.h"
  19. #include "libavcodec/htmlsubtitles.c"
  20. static const char * const test_cases[] = {
  21. /* latin guillemets and other < > garbage */
  22. "<<hello>>", // guillemets
  23. "<<<b>hello</b>>>", // guillemets + tags
  24. "< hello < 2000 > world >", // unlikely tags due to spaces
  25. "<h1>TITLE</h1>", // likely unhandled tags
  26. "< font color=red >red</font>", // invalid format of valid tag
  27. "Foo <foo@bar.com>", // not a tag (not alnum)
  28. "<b> foo <I> bar </B> bla </i>", // broken nesting
  29. "A<br>B<BR/>C<br / >D< Br >E<brk><brk/>", // misc line breaks
  30. };
  31. int main(void)
  32. {
  33. int i;
  34. AVBPrint dst;
  35. av_bprint_init(&dst, 0, AV_BPRINT_SIZE_UNLIMITED);
  36. for (i = 0; i < FF_ARRAY_ELEMS(test_cases); i++) {
  37. int ret = ff_htmlmarkup_to_ass(NULL, &dst, test_cases[i]);
  38. if (ret < 0)
  39. return ret;
  40. printf("%s --> %s\n", test_cases[i], dst.str);
  41. av_bprint_clear(&dst);
  42. }
  43. av_bprint_finalize(&dst, NULL);
  44. return 0;
  45. }