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 
32 #include <stdio.h>
33 #include <switch.h>
34 #include <test/switch_test.h>
35 
36 FST_MINCORE_BEGIN("./conf")
37 
FST_SUITE_BEGIN(SWITCH_STANDARD_STREAM)38 FST_SUITE_BEGIN(SWITCH_STANDARD_STREAM)
39 
40 FST_SETUP_BEGIN()
41 {
42 }
43 FST_SETUP_END()
44 
FST_TEARDOWN_BEGIN()45 FST_TEARDOWN_BEGIN()
46 {
47 }
48 FST_TEARDOWN_END()
49 
FST_TEST_BEGIN(benchmark)50 FST_TEST_BEGIN(benchmark)
51 {
52 	switch_stream_handle_t stream = { 0 };
53 	SWITCH_STANDARD_STREAM(stream);
54 
55 	char expected_result[] = {'A', 0x00, 0x01, 0x02, 'B'};
56 	char raw_data[] = {0x00, 0x01, 0x02};
57 
58 	stream.write_function(&stream, "%s", "A");
59 	stream.raw_write_function(&stream, (uint8_t *) raw_data, sizeof(raw_data));
60 	stream.write_function(&stream, "B");
61 
62 	fst_requires(stream.data_len == sizeof(expected_result));
63 	fst_requires(memcmp(stream.data, expected_result, sizeof(expected_result)) == 0);
64 
65 	switch_safe_free(stream.data);
66 }
67 FST_TEST_END()
68 
69 FST_SUITE_END()
70 
71 FST_MINCORE_END()
72 
73 /* For Emacs:
74  * Local Variables:
75  * mode:c
76  * indent-tabs-mode:t
77  * tab-width:4
78  * c-basic-offset:4
79  * End:
80  * For VIM:
81  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
82  */
83