Add test for large edge sets

This commit is contained in:
Mark Spanbroek 2021-07-27 12:39:47 +02:00
parent 4c30560fbc
commit f60d6189eb
1 changed files with 12 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import std/sequtils import std/sequtils
import std/random
import abc/dag/edgeset import abc/dag/edgeset
import ./basics import ./basics
@ -40,3 +41,14 @@ suite "DAG edge set":
check neighboursC.len == 2 check neighboursC.len == 2
check "a" in neighboursB check "a" in neighboursB
check "a" in neighboursC and "b" in neighboursC check "a" in neighboursC and "b" in neighboursC
test "works for large sets":
var large = EdgeSet[int].init
for _ in 0..10_000:
let x, y = rand(100)
if x != y:
let (x, y) = (min(x,y), max(x,y))
large.incl((x,y))
check (x, y) in large
check y in toSeq large.outgoing(x)
check x in toSeq large.incoming(y)