switch_console.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  3. * Copyright (C) 2005-2018, Anthony Minessale II <anthm@freeswitch.org>
  4. *
  5. * Version: MPL 1.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Anthony Minessale II <anthm@freeswitch.org>
  21. * Portions created by the Initial Developer are Copyright (C)
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. * Konstantin Molchanov <molchanov.kv@gmail.com>
  26. *
  27. *
  28. * switch_console.c -- tests switch_console
  29. *
  30. */
  31. #include <switch.h>
  32. #include <test/switch_test.h>
  33. FST_MINCORE_BEGIN("./conf")
  34. FST_SUITE_BEGIN(SWITCH_STANDARD_STREAM)
  35. FST_SETUP_BEGIN()
  36. {
  37. }
  38. FST_SETUP_END()
  39. FST_TEARDOWN_BEGIN()
  40. {
  41. }
  42. FST_TEARDOWN_END()
  43. FST_TEST_BEGIN(benchmark)
  44. {
  45. char expected_result[] = {'A', 0x00, 0x01, 0x02, 'B'};
  46. char raw_data[] = {0x00, 0x01, 0x02};
  47. switch_stream_handle_t stream = { 0 };
  48. SWITCH_STANDARD_STREAM(stream);
  49. stream.write_function(&stream, "%s", "A");
  50. stream.raw_write_function(&stream, (uint8_t *) raw_data, sizeof(raw_data));
  51. stream.write_function(&stream, "B");
  52. fst_requires(stream.data_len == sizeof(expected_result));
  53. fst_requires(memcmp(stream.data, expected_result, sizeof(expected_result)) == 0);
  54. switch_safe_free(stream.data);
  55. }
  56. FST_TEST_END()
  57. FST_SUITE_END()
  58. FST_MINCORE_END()
  59. /* For Emacs:
  60. * Local Variables:
  61. * mode:c
  62. * indent-tabs-mode:t
  63. * tab-width:4
  64. * c-basic-offset:4
  65. * End:
  66. * For VIM:
  67. * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
  68. */