eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
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.

encoding.c 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2017 Reece H. Dunn
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program 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
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write see:
  16. * <http://www.gnu.org/licenses/>.
  17. */
  18. #include "config.h"
  19. #include <assert.h>
  20. #include <stdint.h>
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <espeak-ng/espeak_ng.h>
  24. #include "encoding.h"
  25. void
  26. test_unbound_text_decoder()
  27. {
  28. printf("testing unbound text decoder\n");
  29. espeak_ng_TEXT_DECODER *decoder = create_text_decoder();
  30. assert(decoder != NULL);
  31. assert(text_decoder_eof(decoder) == 1);
  32. assert(text_decoder_getc(decoder) == 0);
  33. destroy_text_decoder(decoder);
  34. }
  35. void
  36. test_unknown_encoding()
  37. {
  38. printf("testing unknown encodings\n");
  39. assert(espeak_ng_EncodingFromName(NULL) == ESPEAKNG_ENCODING_UNKNOWN);
  40. assert(espeak_ng_EncodingFromName("") == ESPEAKNG_ENCODING_UNKNOWN);
  41. assert(espeak_ng_EncodingFromName("abcxyz") == ESPEAKNG_ENCODING_UNKNOWN);
  42. assert(espeak_ng_EncodingFromName("US") == ESPEAKNG_ENCODING_UNKNOWN); // wrong case
  43. }
  44. void
  45. test_us_ascii_encoding()
  46. {
  47. printf("testing US-ASCII encoding\n");
  48. assert(espeak_ng_EncodingFromName("US-ASCII") == ESPEAKNG_ENCODING_US_ASCII);
  49. assert(espeak_ng_EncodingFromName("iso-ir-6") == ESPEAKNG_ENCODING_US_ASCII);
  50. assert(espeak_ng_EncodingFromName("ANSI_X3.4-1968") == ESPEAKNG_ENCODING_US_ASCII);
  51. assert(espeak_ng_EncodingFromName("ANSI_X3.4-1986") == ESPEAKNG_ENCODING_US_ASCII);
  52. assert(espeak_ng_EncodingFromName("ISO_646.irv:1991") == ESPEAKNG_ENCODING_US_ASCII);
  53. assert(espeak_ng_EncodingFromName("ISO646-US") == ESPEAKNG_ENCODING_US_ASCII);
  54. assert(espeak_ng_EncodingFromName("us") == ESPEAKNG_ENCODING_US_ASCII);
  55. assert(espeak_ng_EncodingFromName("IBM367") == ESPEAKNG_ENCODING_US_ASCII);
  56. assert(espeak_ng_EncodingFromName("cp367") == ESPEAKNG_ENCODING_US_ASCII);
  57. assert(espeak_ng_EncodingFromName("csASCII") == ESPEAKNG_ENCODING_US_ASCII);
  58. }
  59. int
  60. main(int argc, char **argv)
  61. {
  62. test_unbound_text_decoder();
  63. test_unknown_encoding();
  64. test_us_ascii_encoding();
  65. printf("done\n");
  66. return EXIT_SUCCESS;
  67. }