Added a helper function for the Omega Test tests, and added a further test
This commit is contained in:
parent
ed43b750c1
commit
6598ebd3c8
|
@ -20,6 +20,7 @@ module RainUsageCheckTest (tests) where
|
|||
|
||||
import Control.Monad.Identity
|
||||
import Data.Graph.Inductive
|
||||
import Data.Array
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Set as Set
|
||||
import Prelude hiding (fail)
|
||||
|
@ -299,18 +300,31 @@ testArrayCheck :: Test
|
|||
testArrayCheck = TestList
|
||||
[
|
||||
-- x_1 = 0
|
||||
TestCase $ assertEqual "testArrayCheck 0" (Just []) (solveConstraints [simpleArray [(0,0),(1,1)]] [])
|
||||
-- x_1 = 0, 3x_1 >= 0
|
||||
,TestCase $ assertEqual "testArrayCheck 0a" (Just [simpleArray [(0,0),(1,0)]]) (solveConstraints [simpleArray [(0,0),(1,1)]] [simpleArray [(0,0),(1,3)]])
|
||||
-- x_1 = 7
|
||||
,TestCase $ assertEqual "testArrayCheck 1" (Just []) (solveConstraints [simpleArray [(0,-7),(1,1)]] [])
|
||||
pass (0, [], [[0,1]], [])
|
||||
-- x_1 = 0, 3x_1 >= 0 --> 0 >= 0
|
||||
,pass (1, [[0,0]], [[0,1]], [[0,3]])
|
||||
-- -7 + x_1 = 0
|
||||
,pass (2, [], [[-7,1]], [])
|
||||
-- x_1 = 9, 3 + 2x_1 >= 0 --> 21 >= 0
|
||||
,pass (3, [[21,0]], [[-9,1]], [[3,2]])
|
||||
|
||||
|
||||
-- Impossible/inconsistent equality constraints:
|
||||
|
||||
-- -7 = 0
|
||||
,TestCase $ assertEqual "testArrayCheck 2" (Nothing) (solveConstraints [simpleArray [(0,7),(1,0)]] [])
|
||||
,TestCase $ assertEqual "testArrayCheck 1002" (Nothing) (solveConstraints [simpleArray [(0,7),(1,0)]] [])
|
||||
-- x_1 = 3, x_1 = 4
|
||||
,TestCase $ assertEqual "testArrayCheck 3" (Nothing) (solveConstraints [simpleArray [(0,-3),(1,1)], simpleArray [(0,-4),(1,1)]] [])
|
||||
,TestCase $ assertEqual "testArrayCheck 1003" (Nothing) (solveConstraints [simpleArray [(0,-3),(1,1)], simpleArray [(0,-4),(1,1)]] [])
|
||||
-- x_1 + x_2 = 0, x_1 + x_2 = -3
|
||||
,TestCase $ assertEqual "testArrayCheck 4" (Nothing) (solveConstraints [simpleArray [(0,0),(1,1),(2,1)], simpleArray [(0,3),(1,1),(2,1)]] [])
|
||||
,TestCase $ assertEqual "testArrayCheck 1004" (Nothing) (solveConstraints [simpleArray [(0,0),(1,1),(2,1)], simpleArray [(0,3),(1,1),(2,1)]] [])
|
||||
]
|
||||
where
|
||||
pass :: (Int, [[Integer]], [[Integer]], [[Integer]]) -> Test
|
||||
pass (ind, expIneq, inpEq, inpIneq) = TestCase $ assertEqual ("testArrayCheck " ++ show ind)
|
||||
(Just $ arrayise expIneq) (solveConstraints (arrayise inpEq) (arrayise inpIneq))
|
||||
|
||||
arrayise :: [[Integer]] -> [Array Int Integer]
|
||||
arrayise = map (simpleArray . zip [0..])
|
||||
|
||||
|
||||
tests :: Test
|
||||
|
|
Loading…
Reference in New Issue
Block a user