mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-10-31 21:14:37 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			632 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			632 B
		
	
	
	
		
			C
		
	
	
	
	
	
| /* mean.c: Implementation of a mean function of testable component.
 | |
|    See test/test_mean.c for the associated unit test.
 | |
| 
 | |
|    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 "testable.h"
 | |
| 
 | |
| 
 | |
| int testable_mean(const int* values, int count)
 | |
| {
 | |
|     if (count == 0) {
 | |
|         return 0;
 | |
|     }
 | |
|     int sum = 0;
 | |
|     for (int i = 0; i < count; ++i) {
 | |
|         sum += values[i];
 | |
|     }
 | |
|     return sum / count;
 | |
| }
 | 
