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:
parent
f5c79ba821
commit
124e1dd3fa
@ -8,6 +8,8 @@ USEMODULE += bloom
|
|||||||
USEMODULE += random
|
USEMODULE += random
|
||||||
USEMODULE += xtimer
|
USEMODULE += xtimer
|
||||||
|
|
||||||
|
USEMODULE += fmt
|
||||||
|
|
||||||
DISABLE_MODULE += auto_init
|
DISABLE_MODULE += auto_init
|
||||||
|
|
||||||
TEST_ON_CI_WHITELIST += all
|
TEST_ON_CI_WHITELIST += all
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
|
#include "fmt.h"
|
||||||
|
|
||||||
#include "hashes.h"
|
#include "hashes.h"
|
||||||
#include "bloom.h"
|
#include "bloom.h"
|
||||||
@ -109,7 +110,14 @@ int main(void)
|
|||||||
printf("%d elements probably in the filter.\n", in);
|
printf("%d elements probably in the filter.\n", in);
|
||||||
printf("%d elements not in the filter.\n", not_in);
|
printf("%d elements not in the filter.\n", not_in);
|
||||||
double false_positive_rate = (double) in / (double) lenA;
|
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);
|
bloom_del(&bloom);
|
||||||
printf("\nAll done!\n");
|
printf("\nAll done!\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user