{-# LANGUAGE NoImplicitPrelude #-}

module Test.Data.Raft.Term where

import           Control.Applicative
import           Control.Monad
import           Test.Tasty.QuickCheck

import           Data.Raft.Term
import           Data.RaftPrelude

instance Arbitrary Term where
  arbitrary = Term <$> arbitrary

orderedTermPair :: Gen (Term, Term)
orderedTermPair = do
  anchor <- arbitrary
  larger <- largerTerm anchor
  return (anchor, larger)

smallerTerm :: Term -> Gen Term
smallerTerm (Term x) = Term <$> choose (minBound, x - 1)

largerTerm :: Term -> Gen Term
largerTerm (Term x) = Term <$> choose (x + 1, maxBound)

