From f60d6189eb400ad7b30f0fe7be07805517d8b6b7 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 27 Jul 2021 12:39:47 +0200 Subject: [PATCH] Add test for large edge sets --- tests/abc/testEdgeSet.nim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/abc/testEdgeSet.nim b/tests/abc/testEdgeSet.nim index 13f0188..052d889 100644 --- a/tests/abc/testEdgeSet.nim +++ b/tests/abc/testEdgeSet.nim @@ -1,4 +1,5 @@ import std/sequtils +import std/random import abc/dag/edgeset import ./basics @@ -40,3 +41,14 @@ suite "DAG edge set": check neighboursC.len == 2 check "a" in neighboursB 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)