-- HUnit unit tests for Data.FsmActions.Graph -- Copyright (c) 2009 Andy Gimblett - http://www.cs.swan.ac.uk/~csandy/ -- BSD Licence (see http://www.opensource.org/licenses/bsd-license.php) module Tests.Data.FsmActions.Graph ( tests ) where import Data.Graph.Inductive.Graph import Data.List import Test.HUnit.Base import Data.FsmActions import Data.FsmActions.Graph import qualified Tests.Data.FsmActions.FsmMatrix as FsmMatrix -- Various tests on FSM -> FGL conversion. They should have the same -- number of states. -- Count the number of different labels in a graph. uniqueLabels :: (Eq sy, Graph gr) => gr a sy -> Int uniqueLabels = length . nub . map (\(_,_,l) -> l) . labEdges -- Both these tests should pass for any FSM. testFsmToFGL :: Eq sy => FSM sy -> Test testFsmToFGL fsm = test [ "states" ~: length (states fsm) ~?= length (labNodes fgl) ,"alphabet" ~: length (alphabet fsm) ~?= uniqueLabels fgl ] where fgl = fsmToFGL fsm Keep tests :: Test tests = test [ "eg2" ~: testFsmToFGL FsmMatrix.eg2 ]