From 7a48c1278f2cdc8ee42de7cd977a414e643ab230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20P=C3=A4tzel?= Date: Tue, 7 Jan 2020 09:17:39 +0100 Subject: [PATCH] Add length test for GA.bestsBy --- src/GA.hs | 6 ++++++ src/Test.hs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/GA.hs b/src/GA.hs index 7ff5702..69c3aed 100644 --- a/src/GA.hs +++ b/src/GA.hs @@ -183,6 +183,12 @@ prop_bestsBy_isBestsBy' k pop = b <- bestsBy' k fitness pop assert $ NE.toList a == b +prop_bestsBy_lengths k pop = + k > 0 ==> monadicIO $ do + (bests, rest) <- bestsBy k fitness pop + assert + $ length bests == min k (length pop) && length bests + length rest == length pop + {-| The @k@ worst individuals in the population. -} diff --git a/src/Test.hs b/src/Test.hs index e0a921d..a7fbe27 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -8,6 +8,6 @@ import qualified Seminar main :: IO () main = do - _ <- Seminar.runTests _ <- GA.runTests + _ <- Seminar.runTests return ()