module Jerimum.Tests.Integration.PostgreSQL.Types.FloatTests where

import Jerimum.PostgreSQL.Types.Numeric
import Jerimum.Tests.Integration.DataTypeHelper
import Jerimum.Tests.Integration.Resource
import Test.Tasty

tests :: TestTree
tests =
  testGroup
    "FLOAT"
    [ testGroup
        "data type"
        [ buildTest
            (testDataType
               "real"
               (fromFloat32 Nothing, fromFloat32 (Just 0), 0 :: Float))
        , buildTest
            (testDataType
               "float4"
               (fromFloat32 Nothing, fromFloat32 (Just 0), 0 :: Float))
        , buildTest
            (testDataType
               "float(24)"
               (fromFloat32 Nothing, fromFloat32 (Just 0), 0 :: Float))
        , buildTest
            (testDataType
               "double precision"
               (fromFloat64 Nothing, fromFloat64 (Just 0), 0 :: Double))
        , buildTest
            (testDataType
               "float8"
               (fromFloat64 Nothing, fromFloat64 (Just 0), 0 :: Double))
        , buildTest
            (testDataType
               "float(53)"
               (fromFloat64 Nothing, fromFloat64 (Just 0), 0 :: Double))
        ]
    , testGroup
        "from field"
        [ buildTest
            (testDataTypeFromField
               "real"
               (fromFloat32 Nothing, fromFloat32 (Just 0), 0 :: Float))
        , buildTest
            (testDataTypeFromField
               "float4"
               (fromFloat32 Nothing, fromFloat32 (Just 0), 0 :: Float))
        , buildTest
            (testDataTypeFromField
               "float(24)"
               (fromFloat32 Nothing, fromFloat32 (Just 0), 0 :: Float))
        , buildTest
            (testDataTypeFromField
               "double precision"
               (fromFloat64 Nothing, fromFloat64 (Just 0), 0 :: Double))
        , buildTest
            (testDataTypeFromField
               "float8"
               (fromFloat64 Nothing, fromFloat64 (Just 0), 0 :: Double))
        , buildTest
            (testDataTypeFromField
               "float(53)"
               (fromFloat64 Nothing, fromFloat64 (Just 0), 0 :: Double))
        ]
    ]
