diff --git a/tests/bloom/Makefile b/tests/bloom/Makefile deleted file mode 100644 index 9ba8574cb2..0000000000 --- a/tests/bloom/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -APPLICATION = bloom -include ../Makefile.tests_common - -BOARD_INSUFFICIENT_RAM := chronos msb-430 msb-430h redbee-econotag \ - telosb wsn430-v1_3b wsn430-v1_4 z1 stm32f0discovery \ - spark-core - -BOARD_BLACKLIST := arduino-mega2560 -# arduino-mega2560: Errors in assembly, e.g: -# Error: value of 105617 too large for field of 2 bytes at 20018 - -USEMODULE += hashes -USEMODULE += bloom - -APPDEPS = $(BINDIR)projdeps/sets.h - -INCLUDES += -I$(BINDIR)projdeps - -DISABLE_MODULE += auto_init - -include $(RIOTBASE)/Makefile.include - -$(BINDIR)projdeps/sets.h: generate_sets.py words.txt.gz - mkdir -p ${@D} - ./generate_sets.py words.txt.gz $@ diff --git a/tests/bloom/generate_sets.py b/tests/bloom/generate_sets.py deleted file mode 100755 index 3dbffc8f3b..0000000000 --- a/tests/bloom/generate_sets.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python2 - -import gzip -import random -import sys - -sizeOfA = 10 * 1000 -sizeOfB = 20 - -print sys.argv -if len(sys.argv) == 5: - sizeOfA = int(sys.argv[3]) - sizeOfB = int(sys.argv[4]) - -# read all words -lines = [line.strip() for line in gzip.open(sys.argv[1])] - -# get A lines -A = random.sample(lines, sizeOfA + sizeOfB) - -# get B from the first sieOfB element -B = A[:sizeOfB] -A = A[sizeOfB:] - -SetsFile = open(sys.argv[2], 'w') -SetsFile.write('const int lenA = ' + str(sizeOfA) + ';\n') -SetsFile.write('const char* const A[' + str(sizeOfA) + '] = {') -SetsFile.writelines(",".join('"' + x + '"\n' for x in A)) -SetsFile.write('};\n') - -SetsFile.write('const int lenB = ' + str(sizeOfB) + ';\n') -SetsFile.write('const char* const B[' + str(sizeOfB) + '] = {') -SetsFile.writelines(",".join('"' + x + '"\n' for x in B)) -SetsFile.write('};\n') - -print("sets.h: sizeOfA = " + str(len(A) + len(B)) + " generated...") diff --git a/tests/bloom/main.c b/tests/bloom/main.c deleted file mode 100644 index 02f992ef58..0000000000 --- a/tests/bloom/main.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2013 Freie Universität Berlin - * - * 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 Bloom filter test application - * - * @author Christian Mehlis - * - * @} - */ - -#include -#include - -#include "hashes.h" -#include "bloom.h" - -#include "sets.h" - -int main(void) -{ - bloom_t *bloom = bloom_new(1 << 7, 6, fnv_hash, sax_hash, sdbm_hash, - djb2_hash, kr_hash, dek_hash, rotating_hash, one_at_a_time_hash); - - printf("Testing Bloom filter.\n\n"); - printf("m: %zd\nk: %zd\n\n", bloom->m, bloom->k); - - for (int i = 0; i < lenB; i++) { - bloom_add(bloom, (const uint8_t *) B[i], strlen(B[i])); - printf("Added \"%s\"\n", B[i]); - } - - int in = 0; - int not_in = 0; - - for (int i = 0; i < lenA; i++) { - if (bloom_check(bloom, (const uint8_t *) A[i], strlen(A[i]))) { - in++; - } - else { - not_in++; - } - } - - printf("\n"); - 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); - - bloom_del(bloom); - printf("\nAll done!\n"); - return 0; -} diff --git a/tests/bloom/words.txt.gz b/tests/bloom/words.txt.gz deleted file mode 100644 index 9faa840b4f..0000000000 Binary files a/tests/bloom/words.txt.gz and /dev/null differ diff --git a/tests/unittests/tests-bloom/Makefile b/tests/unittests/tests-bloom/Makefile new file mode 100644 index 0000000000..735fc873b8 --- /dev/null +++ b/tests/unittests/tests-bloom/Makefile @@ -0,0 +1,3 @@ +MODULE = tests-bloom + +include $(RIOTBASE)/Makefile.base diff --git a/tests/unittests/tests-bloom/Makefile.include b/tests/unittests/tests-bloom/Makefile.include new file mode 100644 index 0000000000..7180393b0e --- /dev/null +++ b/tests/unittests/tests-bloom/Makefile.include @@ -0,0 +1,3 @@ +USEMODULE += bloom +USEMODULE += hashes + diff --git a/tests/unittests/tests-bloom/tests-bloom-sets.h b/tests/unittests/tests-bloom/tests-bloom-sets.h new file mode 100644 index 0000000000..ae1c43925d --- /dev/null +++ b/tests/unittests/tests-bloom/tests-bloom-sets.h @@ -0,0 +1,1032 @@ +/* + * Copyright (C) 2014 Philipp Rosenkranz + * + * 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. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +const int lenA = 1000; +const char* const A[1000] = {"osteopathic" +,"whatnot" +,"fractable" +,"superinnocent" +,"prebendal" +,"thisness" +,"chemotherapeutic" +,"Narcissine" +,"laurustinus" +,"Shojo" +,"Phoenicopteriformes" +,"aureateness" +,"copastor" +,"undevious" +,"motherlessness" +,"Romishness" +,"laxifoliate" +,"sitio" +,"adjudicator" +,"Provencial" +,"polymorph" +,"nontelephonic" +,"unbickering" +,"trabuch" +,"mudee" +,"urotoxin" +,"charqui" +,"ghoulery" +,"yok" +,"forfaulture" +,"acalephoid" +,"colorimetrist" +,"belitter" +,"neurochitin" +,"althea" +,"palliata" +,"sundowning" +,"infraglacial" +,"space" +,"Itylus" +,"interpunction" +,"hydrolysis" +,"potentiometer" +,"desexualization" +,"cystous" +,"vela" +,"ethereally" +,"bespeakable" +,"Ostmannic" +,"cheesebox" +,"hysteralgic" +,"precondemn" +,"sarracenia" +,"demarchy" +,"whealy" +,"overgarrison" +,"redisseisin" +,"canapina" +,"Gemarist" +,"herewithal" +,"septoic" +,"buzzgloak" +,"pogonology" +,"secretion" +,"tragicomical" +,"compensator" +,"inclosure" +,"scandalous" +,"scribbledom" +,"basidia" +,"trilby" +,"sarcoenchondroma" +,"seminality" +,"nutlet" +,"anaerophyte" +,"murder" +,"pinkeen" +,"Dipsacaceae" +,"subpunctuation" +,"unprobationary" +,"whewl" +,"exiguity" +,"saltery" +,"undegrading" +,"insurrectionism" +,"saccate" +,"geographic" +,"kindhearted" +,"admonitive" +,"seemlihead" +,"wicopy" +,"imine" +,"hypochilium" +,"timeservingness" +,"inwrap" +,"swaddle" +,"furrower" +,"unmagical" +,"gittith" +,"plagioclinal" +,"valorousness" +,"glottid" +,"duodenojejunostomy" +,"supersubtle" +,"unconstricted" +,"suslik" +,"nonmicrobic" +,"honeylipped" +,"cho" +,"pendanting" +,"alkalimeter" +,"guttler" +,"blazing" +,"croceous" +,"laminarite" +,"Wichita" +,"podge" +,"pentateuchal" +,"snakeneck" +,"peevedly" +,"candela" +,"pulicosity" +,"nonjoinder" +,"tastingly" +,"archimpressionist" +,"crossness" +,"myxomycete" +,"preclothe" +,"indulgentially" +,"staminal" +,"noggen" +,"howdah" +,"telarian" +,"dismal" +,"unknown" +,"lambhood" +,"prorecall" +,"rangle" +,"antritis" +,"hemigeusia" +,"bake" +,"chape" +,"vitrifiability" +,"unkinlike" +,"lungie" +,"jive" +,"Vampyrum" +,"discontentedness" +,"Nimrodical" +,"cruelness" +,"unportrayed" +,"hypohyal" +,"monoxime" +,"noddle" +,"hemoglobinocholia" +,"restproof" +,"Georgie" +,"superopposition" +,"periastrum" +,"unpacable" +,"unbatted" +,"malleinize" +,"milksoppery" +,"hydrobromate" +,"unregard" +,"interstreet" +,"unprofuse" +,"pharmacal" +,"Harelda" +,"amphiploidy" +,"quadridentate" +,"inviscation" +,"reattainment" +,"tay" +,"kupfferite" +,"thurrock" +,"berri" +,"metalworker" +,"kronen" +,"presentiveness" +,"footpick" +,"bullwhacker" +,"fibroid" +,"chololithic" +,"reagitation" +,"sned" +,"complexionist" +,"improvise" +,"retinene" +,"Bumbledom" +,"orthodoxness" +,"integrand" +,"arctian" +,"plethory" +,"duteous" +,"preaccess" +,"Tareq" +,"depressive" +,"codworm" +,"sitting" +,"undivinely" +,"lubrication" +,"liturgically" +,"derailment" +,"hypodermoclysis" +,"unclerical" +,"foolscap" +,"saccharogalactorrhea" +,"sideline" +,"predicableness" +,"dorbeetle" +,"Molinism" +,"uncommendableness" +,"els" +,"auditorium" +,"wakingly" +,"septennium" +,"Tarai" +,"girling" +,"foison" +,"quadripolar" +,"obfuscable" +,"churchcraft" +,"germless" +,"zimbalon" +,"homesickness" +,"dinnery" +,"Stymphalides" +,"Spartacan" +,"coelia" +,"hemicrane" +,"conductorial" +,"hardly" +,"Nemastomaceae" +,"amaltas" +,"uncensuring" +,"archaeology" +,"nobbler" +,"epanaphoral" +,"Erymanthian" +,"felicide" +,"aegerian" +,"varlet" +,"dextrorotation" +,"Extravagantes" +,"jetter" +,"undergirth" +,"unvenerated" +,"brachiolarian" +,"overremissly" +,"Costata" +,"medievally" +,"settling" +,"ingestible" +,"bedrug" +,"orthoepical" +,"undervocabularied" +,"cloudage" +,"Granth" +,"superabound" +,"Clarissa" +,"ward" +,"mulefoot" +,"Derotrema" +,"repugnance" +,"tubicolar" +,"bookwright" +,"mohur" +,"retropubic" +,"recrank" +,"ungrained" +,"bandannaed" +,"barbastel" +,"wreathwise" +,"tannoid" +,"nervulose" +,"akund" +,"Mahra" +,"livelily" +,"theriotheism" +,"tanghin" +,"inoriginate" +,"cyanogenetic" +,"availingly" +,"ammelin" +,"electrophoric" +,"thumbbird" +,"selachoid" +,"Corynocarpaceae" +,"kikawaeo" +,"nursable" +,"Pishquow" +,"unamenable" +,"rivetless" +,"Negrophobe" +,"uncorrectable" +,"decomponible" +,"parasynapsis" +,"unbeclogged" +,"enwreathe" +,"Ctenacanthus" +,"thrombocytopenia" +,"infusorial" +,"Guato" +,"placentalian" +,"clinium" +,"xylographically" +,"prettyface" +,"Hysteriales" +,"cyrtoceratitic" +,"partridgeberry" +,"hematology" +,"unnucleated" +,"impatiency" +,"castellany" +,"makable" +,"juvenilely" +,"arthrotome" +,"preponderancy" +,"hypercalcemia" +,"cobless" +,"squander" +,"reticulocytosis" +,"vegetoalkaline" +,"dod" +,"protectorian" +,"radiocarpal" +,"taxpaid" +,"algoid" +,"zoodendrium" +,"Carinatae" +,"nonmercantile" +,"Bernoullian" +,"foreboder" +,"geometrically" +,"Drokpa" +,"khilat" +,"prolately" +,"vitrobasalt" +,"autosymbolic" +,"monographically" +,"bittersweet" +,"gentleship" +,"yellowroot" +,"unrestrictive" +,"preterdetermined" +,"bestorm" +,"isocheimal" +,"apricot" +,"commentatorship" +,"functionality" +,"Colubridae" +,"underpole" +,"whey" +,"bottlebird" +,"frondigerous" +,"revisional" +,"testicardine" +,"tetraxonian" +,"overage" +,"virtuose" +,"apepsinia" +,"world" +,"barytine" +,"Molluginaceae" +,"chordoid" +,"Enchodontid" +,"gangliform" +,"imperceptible" +,"loath" +,"unplanned" +,"Mahori" +,"unblightedly" +,"tined" +,"pinprick" +,"juncous" +,"unmisunderstanding" +,"doddering" +,"inirritable" +,"photochronographic" +,"intimater" +,"unposted" +,"octenary" +,"retrieve" +,"superluxurious" +,"Yucatecan" +,"subdiaconate" +,"clavicularium" +,"git" +,"organicist" +,"untranslated" +,"menopause" +,"boatshop" +,"creatininemia" +,"extenuator" +,"polluted" +,"overaccentuate" +,"menosepsis" +,"Kansa" +,"lameness" +,"azulmic" +,"heterodoxness" +,"callower" +,"misted" +,"Axis" +,"doodab" +,"unshadow" +,"restrengthen" +,"unexplicit" +,"bournless" +,"unincreasing" +,"intransitable" +,"balloter" +,"brushiness" +,"pansclerotic" +,"photoengrave" +,"monadism" +,"subtriplicate" +,"enomoty" +,"saccoderm" +,"hydroxylate" +,"unconvincedly" +,"dilker" +,"subovate" +,"cargoose" +,"underbuilder" +,"Brunella" +,"valediction" +,"lapstreaker" +,"variative" +,"diffractively" +,"intercommoner" +,"unbecome" +,"clitorism" +,"gearman" +,"foremade" +,"woodruff" +,"novelize" +,"Leonine" +,"Sak" +,"excursus" +,"emptings" +,"predeprivation" +,"hypopetalous" +,"Pristodus" +,"exhaustion" +,"thronize" +,"chronography" +,"verbolatry" +,"immoralist" +,"orthotoluic" +,"Rorippa" +,"monastic" +,"dentatoserrate" +,"openhanded" +,"bog" +,"hobnob" +,"opprobriousness" +,"ungentlemanlike" +,"calorie" +,"lipodystrophy" +,"prepossess" +,"sublimeness" +,"unloafing" +,"Bramantip" +,"yawper" +,"apoturmeric" +,"warbled" +,"garbler" +,"villageful" +,"Hippopotamidae" +,"severable" +,"Aurorian" +,"befleck" +,"acceptableness" +,"prowl" +,"decapper" +,"prefertilization" +,"vexil" +,"argentojarosite" +,"encreel" +,"heptameter" +,"disaccommodate" +,"unpumped" +,"khahoon" +,"Rhytina" +,"squawweed" +,"interobjective" +,"divertedly" +,"traditious" +,"flamenco" +,"forcipate" +,"obtenebration" +,"wanhope" +,"beneceptor" +,"compulsatorily" +,"Furud" +,"integrable" +,"phenolsulphonephthalein" +,"ziffs" +,"scimitarpod" +,"planetkin" +,"talion" +,"menses" +,"reprobacy" +,"shellproof" +,"nontrading" +,"alkylamine" +,"humpiness" +,"overexpansive" +,"nomisma" +,"superoccipital" +,"Enajim" +,"turfage" +,"contretemps" +,"predelegation" +,"ureteropyelonephritis" +,"scatological" +,"whare" +,"tracheophonine" +,"Quadrula" +,"ancestral" +,"besiegement" +,"gloeosporiose" +,"Byronite" +,"gyromagnetic" +,"Amyris" +,"headland" +,"transoceanic" +,"septier" +,"Tephrosia" +,"hipponosological" +,"she" +,"circuitously" +,"dice" +,"crispated" +,"comolecule" +,"solstitial" +,"vifda" +,"Polystomea" +,"bavary" +,"immotile" +,"extrasomatic" +,"jodhpurs" +,"chieftainess" +,"apocopation" +,"overtimbered" +,"benzene" +,"scumber" +,"Ampullaria" +,"chambermaid" +,"Chinesery" +,"epitrichium" +,"chloric" +,"naillike" +,"Sabbathly" +,"culilawan" +,"trigonocephalous" +,"Musca" +,"donnot" +,"lobose" +,"Suevian" +,"Frenchwise" +,"osteologically" +,"procreatory" +,"unarch" +,"inkmaker" +,"utu" +,"Gutium" +,"banneret" +,"Tamil" +,"destroy" +,"gripgrass" +,"antiprofiteering" +,"grindable" +,"annoyment" +,"eisteddfodic" +,"consumption" +,"arterioarctia" +,"unpursuable" +,"Heteropoda" +,"giganticness" +,"disglut" +,"mumper" +,"bespot" +,"zygosis" +,"retape" +,"juristical" +,"nondepositor" +,"keratome" +,"peristerophily" +,"monosilicate" +,"overgreediness" +,"varsha" +,"hippic" +,"smattery" +,"biological" +,"retranslate" +,"despairer" +,"Proctotrypoidea" +,"resurvey" +,"reconfront" +,"suitably" +,"Pedipalpida" +,"fibromyositis" +,"ink" +,"pilori" +,"cataclasm" +,"flypaper" +,"candleshrift" +,"supracommissure" +,"intraselection" +,"downstate" +,"testify" +,"cryptarchy" +,"milky" +,"glandulosity" +,"idolatrousness" +,"antiprinciple" +,"metameride" +,"blown" +,"floodlike" +,"heterocephalous" +,"premarry" +,"Achaenodon" +,"outly" +,"substrator" +,"impervestigable" +,"Jackye" +,"noninterventionist" +,"thuggeeism" +,"kafir" +,"artificialness" +,"flandan" +,"jubbe" +,"renipericardial" +,"perceptionism" +,"gazetteer" +,"padder" +,"bun" +,"diazoimido" +,"fiendful" +,"backbone" +,"noncollectable" +,"pereion" +,"generally" +,"precontentment" +,"hymnless" +,"polybranch" +,"vibrophone" +,"psykter" +,"Elaeagnaceae" +,"nonprehensile" +,"Suberites" +,"slangster" +,"spinescence" +,"Zolaesque" +,"gazel" +,"pearlitic" +,"mouthwise" +,"antrocele" +,"premuddle" +,"singarip" +,"micropodal" +,"photological" +,"subdelegate" +,"titter" +,"erminee" +,"microcurie" +,"Corylaceae" +,"disbar" +,"Vestigian" +,"ineffulgent" +,"wheelmaking" +,"sarcolemma" +,"Ostyak" +,"cartaceous" +,"subheadwaiter" +,"Tarrateen" +,"erogenic" +,"mongrelity" +,"polygyral" +,"nonsaturated" +,"exultet" +,"hyperpyrexial" +,"undrag" +,"physiopsychology" +,"interlocular" +,"centrolepidaceous" +,"Anabaptistically" +,"Lafite" +,"blepharosphincterectomy" +,"threatening" +,"hypokeimenometry" +,"fallowness" +,"unidolized" +,"Piaroa" +,"shipwrecky" +,"solio" +,"sporidiole" +,"transmundane" +,"honeysweet" +,"pectocellulose" +,"himp" +,"cockiness" +,"Cygninae" +,"Waregga" +,"Millerite" +,"Thesmophorian" +,"daubreelite" +,"practicum" +,"regal" +,"gibbet" +,"aimless" +,"adultery" +,"Puelche" +,"mump" +,"occlusive" +,"unbeatably" +,"rushlighted" +,"separatress" +,"hetaeristic" +,"alimonied" +,"isopag" +,"keratode" +,"consentaneously" +,"empt" +,"consulship" +,"syndicator" +,"aphanipterous" +,"aboriginally" +,"laborhood" +,"conjugateness" +,"befog" +,"pleuron" +,"gun" +,"Clintonia" +,"impofo" +,"window" +,"dissolutional" +,"Rhizina" +,"unfinish" +,"sal" +,"oxyphyllous" +,"regularizer" +,"Rebeccaism" +,"fumble" +,"tricolor" +,"corallinaceous" +,"irrelevancy" +,"bufotalin" +,"embiotocid" +,"cowal" +,"chakari" +,"subsoil" +,"confirm" +,"pedagoguery" +,"exoarteritis" +,"courb" +,"exomphalous" +,"blastomycetic" +,"loessic" +,"screwsman" +,"zoosmosis" +,"Judaic" +,"dinothere" +,"ichthyotomist" +,"soulish" +,"capitalize" +,"Coruminacan" +,"coinhabitant" +,"tracheid" +,"thirl" +,"hydnocarpate" +,"Lycidae" +,"Smyrnean" +,"Triglidae" +,"scouriness" +,"Europasian" +,"unburial" +,"unsprung" +,"resignment" +,"ender" +,"talkie" +,"orisphere" +,"uncompliant" +,"uredinium" +,"posttracheal" +,"hydrosulphuric" +,"semiconic" +,"counterabut" +,"newscaster" +,"vulgarize" +,"lozenge" +,"toadling" +,"magnoferrite" +,"septane" +,"thelphusian" +,"filigree" +,"preimitation" +,"riverweed" +,"adharma" +,"sodbuster" +,"rhomborectangular" +,"horsetail" +,"toozle" +,"infranuclear" +,"glycerite" +,"glottalize" +,"jetty" +,"posticteric" +,"unconstruable" +,"gastroalbuminorrhea" +,"outsit" +,"twafauld" +,"misrender" +,"pedalferic" +,"intensifier" +,"pistol" +,"thermotypic" +,"downway" +,"pastoralness" +,"Stymphalian" +,"adultness" +,"serration" +,"haliography" +,"crouch" +,"outpupil" +,"superindulgence" +,"mancipium" +,"iridoptosis" +,"collegiateness" +,"synonymously" +,"protosalt" +,"praenarial" +,"Leptostraca" +,"orchestrion" +,"overdevotedly" +,"fibroglioma" +,"turio" +,"zeallessness" +,"Spyros" +,"unbilleted" +,"crimp" +,"katabella" +,"epipastic" +,"woodhorse" +,"hereinto" +,"atopite" +,"polypotome" +,"zer" +,"Echeveria" +,"vocicultural" +,"friendliness" +,"leadenly" +,"postseason" +,"hydriatry" +,"biosterin" +,"untamedly" +,"obstructor" +,"dextroversion" +,"leptosome" +,"Kabirpanthi" +,"malodorant" +,"xylographer" +,"fretted" +,"flotage" +,"ipid" +,"glyptician" +,"unseptate" +,"ungraphic" +,"laverwort" +,"Tezcucan" +,"procambium" +,"skirt" +,"seminally" +,"clipsheet" +,"experimentize" +,"ballant" +,"fadeaway" +,"teachment" +,"rated" +,"candlepin" +,"idiopsychological" +,"uncleverly" +,"carnic" +,"fjeld" +,"preregistration" +,"nomogenous" +,"tonneau" +,"Mahican" +,"unsawn" +,"commemorable" +,"changeably" +,"dern" +,"seminarial" +,"pteraspid" +,"underdriven" +,"neoacademic" +,"affray" +,"redecorate" +,"hobbyhorsical" +,"gastrotubotomy" +,"gauntness" +,"calculist" +,"elderbrotherly" +,"religiously" +,"churchful" +,"rocambole" +,"cakey" +,"sledlike" +,"coughroot" +,"witchlike" +,"hexadecyl" +,"gingival" +,"peeress" +,"valid" +,"historician" +,"swiper" +,"neurofibroma" +,"devourment" +,"Ab" +,"oil" +,"Tigrean" +,"broider" +,"unwesternized" +,"becrawl" +,"abiogeny" +,"draffy" +,"bemar" +,"phobiac" +,"Palluites" +,"scheelite" +,"halichondrine" +,"tiarella" +,"sedile" +,"pedodontic" +,"suspensively" +,"Ibycus" +,"misprofessor" +,"below" +,"waylayer" +,"Turki" +,"obviation" +,"illiteral" +,"idolatrize" +,"bifolium" +,"shoplet" +,"coefficient" +,"unnearly" +,"benign" +,"entelam" +,"mousingly" +,"wagonage" +,"supermuscan" +,"xeronate" +,"backstring" +,"dialogize" +,"postsplenic" +,"quartersawed" +,"tradeful" +,"trilite" +,"patricianly" +,"fistlike" +,"bathyseism" +,"precorrectness" +,"snipy" +,"ornithocopros" +,"Polysaccum" +,"sulfarsenide" +,"ultrainclusive" +,"protreasurer" +,"retackle" +,"unexceptionableness" +,"waggishly" +,"atomistically" +,"slaughteringly" +,"shinleaf" +,"collin" +,"sunburnproof" +,"pororoca" +,"fogdom" +,"hysterotraumatism" +,"unvalidly" +,"cadbait" +,"Fascio" +,"ascry" +,"noegenesis" +,"familiarism" +,"diureide" +,"malengine" +,"preconcession" +,"agony" +,"ratskeller" +,"advenient" +,"scratchingly" +,"inobvious" +,"antiprime" +,"calean" +,"oxalonitril" +}; +const int lenB = 10; +const char* const B[10] = {"interbedded" +,"definitively" +,"grasshopper" +,"cadbait" +,"innocuous" +,"sweater" +,"preimitation" +,"progressive" +,"meeting" +,"amplifier" +}; + + +#ifdef __cplusplus +} +#endif + diff --git a/tests/unittests/tests-bloom/tests-bloom.c b/tests/unittests/tests-bloom/tests-bloom.c new file mode 100644 index 0000000000..5ea881255d --- /dev/null +++ b/tests/unittests/tests-bloom/tests-bloom.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2014 Philipp Rosenkranz + * Copyright (C) 2013 Freie Universität Berlin + * + * 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. + */ +#include +#include + +#include "tests-bloom.h" + +#include "hashes.h" +#include "bloom.h" + +#include "tests-bloom-sets.h" + +#define TESTS_BLOOM_BYTES (128) +#define TESTS_BLOOM_HASHF (6) +#define TESTS_BLOOM_PROB_IN_FILTER (4) +#define TESTS_BLOOM_NOT_IN_FILTER (996) +#define TESTS_BLOOM_FALSE_POS_RATE_THR (0.005) + +static bloom_t *bloom; + +static void load_dictionary_fixture(void) +{ + for (int i = 0; i < lenB; i++) + { + bloom_add(bloom, (const uint8_t *) B[i], strlen(B[i])); + } + +} + +static void set_up_bloom(void) +{ + bloom = bloom_new(TESTS_BLOOM_BYTES, TESTS_BLOOM_HASHF, fnv_hash, sax_hash, + sdbm_hash, djb2_hash, kr_hash, dek_hash, rotating_hash, + one_at_a_time_hash); +} + +static void tear_down_bloom(void) +{ + bloom_del(bloom); +} + +static void test_bloom_parameters_bytes_hashf(void) +{ + TEST_ASSERT_EQUAL_INT(TESTS_BLOOM_BYTES, bloom->m); + TEST_ASSERT_EQUAL_INT(TESTS_BLOOM_HASHF, bloom->k); +} + +static void test_bloom_based_on_dictionary_fixture(void) +{ + int in = 0; + int not_in = 0; + double false_positive_rate = 0; + + load_dictionary_fixture(); + + for (int i = 0; i < lenA; i++) + { + if (bloom_check(bloom, (const uint8_t *) A[i], strlen(A[i]))) + { + in++; + } + else + { + not_in++; + } + } + false_positive_rate = (double) in / (double) lenA; + + TEST_ASSERT_EQUAL_INT(TESTS_BLOOM_PROB_IN_FILTER, in); + TEST_ASSERT_EQUAL_INT(TESTS_BLOOM_NOT_IN_FILTER, not_in); + TEST_ASSERT(false_positive_rate < TESTS_BLOOM_FALSE_POS_RATE_THR); +} + +Test *tests_bloom_tests(void) +{ + EMB_UNIT_TESTFIXTURES(fixtures) { + new_TestFixture(test_bloom_parameters_bytes_hashf), + new_TestFixture(test_bloom_based_on_dictionary_fixture), + }; + + EMB_UNIT_TESTCALLER(bloom_tests, set_up_bloom, tear_down_bloom, fixtures); + + return (Test *)&bloom_tests; +} + +void tests_bloom(void) +{ + TESTS_RUN(tests_bloom_tests()); +} diff --git a/tests/unittests/tests-bloom/tests-bloom.h b/tests/unittests/tests-bloom/tests-bloom.h new file mode 100644 index 0000000000..38bd3478c0 --- /dev/null +++ b/tests/unittests/tests-bloom/tests-bloom.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014 Philipp Rosenkranz + * + * 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. + */ + +/** + * @addtogroup unittests + * @{ + * + * @file tests-bloom.h + * @brief Unittests for the ``bloom`` module + * + * @author Philipp Rosenkranz + */ +#ifndef __TESTS_BLOOM_H_ +#define __TESTS_BLOOM_H_ + +#include "../unittests.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The entry point of this test suite. + */ +void tests_bloom(void); + +/** + * @brief Generates tests for bloom + * + * @return embUnit tests if successful, NULL if not. + */ +Test *tests_bloom_tests(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __TESTS_BLOOM_H_ */ +/** @} */