packages feed

wkt-geom-0.0.1: test/Data/WktGeometryCollectionSpec.hs

{-# LANGUAGE OverloadedStrings #-}

module Data.WktGeometryCollectionSpec where

import           Control.Lens    ((^?!))
import qualified Data.Geospatial as Geospatial
import qualified Data.Vector     as Vector
import           Test.Hspec      (Spec, describe, it, shouldBe)
import qualified Text.Trifecta   as Trifecta

import qualified Data.Wkt        as Wkt

import qualified Data.SpecHelper as SpecHelper

spec :: Spec
spec = testGeometryCollection

testGeometryCollection :: Spec
testGeometryCollection =
  describe "simple geometry collections" $ do
    it "Parse empty" $
      Wkt.parseString Wkt.geometryCollection "geometrycollection empty" ^?! Trifecta._Success `shouldBe` Wkt.emptyGeometryCollection
    it "Parse something" $
      Wkt.parseString Wkt.geometryCollection "GeometryCollection(POINT (1 2),POINT (3 4),LINESTRING (15 15, 20 20, 25 25))" ^?! Trifecta._Success `shouldBe` exampleGeometryCollection
    it "Parse something with spaces" $
      Wkt.parseString Wkt.geometryCollection "GeometryCollection ( POINT ( 1 2) , POINT (3 4) , LINESTRING (15 15  , 20 20, 25 25 ) ) " ^?! Trifecta._Success `shouldBe` exampleGeometryCollection

exampleGeometryCollection :: Vector.Vector Geospatial.GeospatialGeometry
exampleGeometryCollection =
  Vector.fromList
    [ Geospatial.Point $ Geospatial.GeoPoint SpecHelper.point1
    , Geospatial.Point $ Geospatial.GeoPoint SpecHelper.point2
    , Geospatial.Line $ Geospatial.GeoLine SpecHelper.lineString4
    ]