1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/bloom_bytes: replace %f with fmt/print_float

Even if using `%f` the `printf_float` module was not used.

When running the test on `samr21-xpro` and `arduino-mega2560` the float
is not printed correctly.

 * samr21-xpro ` false positive rate.`
 * arduino-mega2560 `? false positive rate.`

As the arduino-mega2560 does not handle printf_float use
`fmt/print_float`.

The output should be flushed before using fmt/print functions if
available as they do not use `printf` buffer.
This commit is contained in:
Gaëtan Harter 2019-02-21 16:19:38 +01:00
parent f5c79ba821
commit 124e1dd3fa
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B
2 changed files with 11 additions and 1 deletions

View File

@ -8,6 +8,8 @@ USEMODULE += bloom
USEMODULE += random
USEMODULE += xtimer
USEMODULE += fmt
DISABLE_MODULE += auto_init
TEST_ON_CI_WHITELIST += all

View File

@ -23,6 +23,7 @@
#include <inttypes.h>
#include "xtimer.h"
#include "fmt.h"
#include "hashes.h"
#include "bloom.h"
@ -109,7 +110,14 @@ int main(void)
printf("%d elements probably in the filter.\n", in);
printf("%d elements not in the filter.\n", not_in);
double false_positive_rate = (double) in / (double) lenA;
printf("%f false positive rate.\n", false_positive_rate);
/* Use 'fmt/print_float' to work on all platforms (atmega)
* Stdout should be flushed before to prevent garbled output. */
#ifdef MODULE_NEWLIB
/* no fflush on msp430 */
fflush(stdout);
#endif
print_float(false_positive_rate, 6);
puts(" false positive rate.");
bloom_del(&bloom);
printf("\nAll done!\n");