forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arm/newlib: Add pseudomodule to enable floating point printf support
- Loading branch information
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
APPLICATION = test_printf_float | ||
include ../Makefile.tests_common | ||
|
||
USEMODULE += printf_float | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2016 Alexandre Abadie <[email protected]> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup tests | ||
* @{ | ||
* | ||
* @file | ||
* @brief print floating point values test application | ||
* | ||
* This test is supposed to check that floating point values can be | ||
* displayed with printf function. | ||
* | ||
* @author Alexandre Abadie <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <inttypes.h> | ||
|
||
static const char * expected_result = "2016.0"; | ||
static const double floating_point_value = 2016.0317; | ||
|
||
int main(void) | ||
{ | ||
const uint8_t str_len = strlen(expected_result); | ||
char result[str_len]; | ||
snprintf(result, str_len + 1, | ||
"%.f", floating_point_value); | ||
|
||
printf("Value displayed: %s\n", result); | ||
|
||
if (strcmp(result, expected_result) == 0) { | ||
printf("[OK]\n"); | ||
} | ||
else { | ||
printf("[FAILED] Values are not equal:\n" | ||
"actual: %s\n" | ||
"expected: %s\n", result, expected_result); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |