module Jerimum.Tests.Unit.PostgreSQL.Types.Int32ArrayTest
  ( tests
  ) where

import Jerimum.PostgreSQL.Types.Int32Array
import Jerimum.Tests.Unit.PostgreSQL.Types.Helpers
import Test.Tasty
import Test.Tasty.QuickCheck

tests :: TestTree
tests = testGroup "PostgreSQL.Types.Int32Array" [testCborCodec, testTextCodec]

testCborCodec :: TestTree
testCborCodec =
  testGroup
    "cbor codec"
    [ testProperty "identity" $ \xs ->
        Right xs ==
        runDecoder int32ArrayDecoderV0 (runEncoder $ int32ArrayEncoderV0 xs)
    ]

testTextCodec :: TestTree
testTextCodec =
  testGroup
    "text codec"
    [ testProperty "identity" $ \xs ->
        Just xs === parseInt32Array (formatInt32Array xs)
    ]
