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

Merge pull request #11053 from cladmi/pr/tests/bloom_bytes/float_handling

tests/bloom_bytes: replace %f with fmt/print_float
This commit is contained in:
Martine Lenders 2019-02-26 21:27:02 +01:00 committed by GitHub
commit a2c14b33ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 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");

View File

@ -16,11 +16,11 @@ TIMEOUT = 150
def testfunc(child):
child.expect_exact("Testing Bloom filter.")
child.expect_exact("m: 4096 k: 8")
child.expect("adding 512 elements took \d+ms", timeout=TIMEOUT)
child.expect("checking 10000 elements took \d+ms", timeout=TIMEOUT)
child.expect("\d+ elements probably in the filter.")
child.expect("\d+ elements not in the filter.")
child.expect(".+ false positive rate.")
child.expect(r"adding 512 elements took \d+ms", timeout=TIMEOUT)
child.expect(r"checking 10000 elements took \d+ms", timeout=TIMEOUT)
child.expect(r"\d+ elements probably in the filter.")
child.expect(r"\d+ elements not in the filter.")
child.expect(r"0\.\d+ false positive rate.")
child.expect_exact("All done!")