-- Tests.hs -- hgeometric: A geometric library with bindings to GPC. -- Tests.hs is part of hgeometric. -- Copyright (C) 2007 Marco TĂșlio Gontijo e Silva -- hgeometric is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- hgeometric is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- You should have received a copy of the GNU General Public License -- along with hgeometric; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA module Main (main) where import Data.Maybe import Control.Monad import System.Directory import System.Exit import Test.HUnit import Algebra.Geometric import Algebra.Geometric.Polygon.File main :: IO () main = do polygon1 <- fromJust `liftM` readPolygon "tests/FileTestInput.gpf" False let polygon2 :: Polygon polygon2 = polygon1 \\ polygon1 success <- writePolygon output False polygon2 removeFile output let area1 = area polygon1 area2 = area polygon2 result <- runTestTT $ TestList [ success ~=? True, area1 ~=? 1, area2 ~=? 0, area1 ~=? area (polygon1 /\ polygon1 :: Polygon), area2 ~=? area (polygon1 <+> polygon1 :: Polygon), area1 ~=? area (polygon1 \/ polygon1 :: Polygon), area1 ~=? area (polygon1 \\ polygon2 :: Polygon), area2 ~=? area (polygon1 /\ polygon2 :: Polygon), area1 ~=? area (polygon1 <+> polygon2 :: Polygon), area1 ~=? area (polygon1 \/ polygon2 :: Polygon)] when (errors result /= 0 || failures result /= 0) exitFailure output :: String output = "tests/FileTestOutput.gpf"