1 /* Example test application for testable component.
2 
3    This example code is in the Public Domain (or CC0 licensed, at your option.)
4 
5    Unless required by applicable law or agreed to in writing, this
6    software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7    CONDITIONS OF ANY KIND, either express or implied.
8 */
9 
10 #include <stdio.h>
11 #include <string.h>
12 #include "unity.h"
13 
14 static void print_banner(const char* text);
15 
app_main(void)16 void app_main(void)
17 {
18     /* These are the different ways of running registered tests.
19      * In practice, only one of them is usually needed.
20      *
21      * UNITY_BEGIN() and UNITY_END() calls tell Unity to print a summary
22      * (number of tests executed/failed/ignored) of tests executed between these calls.
23      */
24     print_banner("Executing one test by its name");
25     UNITY_BEGIN();
26     unity_run_test_by_name("Mean of an empty array is zero");
27     UNITY_END();
28 
29     print_banner("Running tests with [mean] tag");
30     UNITY_BEGIN();
31     unity_run_tests_by_tag("[mean]", false);
32     UNITY_END();
33 
34     print_banner("Running tests without [fails] tag");
35     UNITY_BEGIN();
36     unity_run_tests_by_tag("[fails]", true);
37     UNITY_END();
38 
39     print_banner("Running all the registered tests");
40     UNITY_BEGIN();
41     unity_run_all_tests();
42     UNITY_END();
43 
44     print_banner("Starting interactive test menu");
45     /* This function will not return, and will be busy waiting for UART input.
46      * Make sure that task watchdog is disabled if you use this function.
47      */
48     unity_run_menu();
49 }
50 
print_banner(const char * text)51 static void print_banner(const char* text)
52 {
53     printf("\n#### %s #####\n\n", text);
54 }
55