esp-idf/examples/system/unit_test/main/example_unit_test_main.c
Sudeep Mohanty a9fda54d39 esp_hw_support/esp_system: Re-evaluate header inclusions and include directories
This commit updates the visibility of various header files and cleans up
some unnecessary inclusions. Also, this commit removes certain header
include paths which were maintained for backward compatibility.
2022-03-07 11:18:08 +05:30

41 lines
1.2 KiB
C

/* Example application which uses testable component.
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "esp_random.h"
#include "testable.h"
/* This application has a test subproject in 'test' directory, all the
* interesting things happen there. See ../test/main/example_idf_test_runner_test.c
* and the makefiles in ../test/ directory.
*
* This specific app_main function is provided only to illustrate the layout
* of a project.
*/
void app_main(void)
{
const int count = 32;
const int max = 100;
printf("In main application. Collecting %d random numbers from 1 to %d:\n", count, max);
int *numbers = calloc(count, sizeof(numbers[0]));
for (int i = 0; i < count; ++i) {
numbers[i] = 1 + esp_random() % (max - 1);
printf("%4d ", numbers[i]);
if ((i + 1) % 10 == 0) {
printf("\n");
}
}
int mean = testable_mean(numbers, count);
printf("\nMean: %d\n", mean);
free(numbers);
}