db5230a0c360d856db91300b42f94e76365c60c7
[apps/native/boot-animation.git] / test / unit / unit_test / unit_test_function_test / unit_test_log_buf_function.c
1 /*
2  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "../../../../inc/test.h"
19 #if (TEST_MODE == TEST_UNIT)
20
21 #include "unit_test_function.h"
22
23 extern char * __t__get_unit_log_buf(void);
24
25 static Eina_Bool __unit_test_write_log(void);
26 static Eina_Bool __unit_test_clear_log(void);
27
28 void unit_test_log_buf_function(void)
29 {
30         __unit_test_run_function( __unit_test_write_log() == EINA_TRUE);
31         __unit_test_run_function(__unit_test_clear_log() == EINA_TRUE);
32 }
33
34 static Eina_Bool __unit_test_write_log(void)
35 {
36         char * buf = __t__get_unit_log_buf();
37         strcpy(buf, "");
38         TEST_ASSERT_EQUAL_STRING(buf, "");
39
40         unit_write_log("write");
41         unit_write_log("log");
42
43         TEST_ASSERT_EQUAL_STRING(buf, "write\nlog\n");
44
45         return EINA_TRUE;
46 }
47
48 static Eina_Bool __unit_test_clear_log(void)
49 {
50         char * buf = __t__get_unit_log_buf();
51         strcpy(buf, "clear");
52         TEST_ASSERT_EQUAL_STRING(buf, "clear");
53
54         unit_clear_log();
55
56         TEST_ASSERT_EQUAL_STRING(buf, "");
57
58         return EINA_TRUE;
59 }
60
61 #endif