Skip to content

Commit

Permalink
Fix time range in test cases
Browse files Browse the repository at this point in the history
SQL Server doesn't support leap seconds
  • Loading branch information
spencerjanssen committed Mar 5, 2024
1 parent 8b9f41f commit 7561f55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/Database/ODBC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,9 +1449,6 @@ sql_ss_length_unlimited = 0
type I16 = Int
#endif

-- FIXME fail with Randomized with seed 1862667972
-- (on 9.2 as well)

-------- 'T.fromPtr' but compatible with text v1 and v2

fromPtrCompat :: Ptr Word16 -> I16 -> IO Text
Expand Down
10 changes: 5 additions & 5 deletions test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ instance Arbitrary Day where
instance Arbitrary TimeOfDay where
arbitrary = do
fractional <- choose (0, 9999999) :: Gen Integer
seconds <- choose (0, 86400)
seconds <- choose (0, 86399)
pure
(timeToTimeOfDay
(secondsToDiffTime seconds + (fromRational (fractional % 10000000))))
Expand All @@ -706,7 +706,7 @@ instance Arbitrary LocalTime where
where
arbitraryLimited = do
fractional <- choose (0, 9999999) :: Gen Integer
seconds <- choose (0, 86400)
seconds <- choose (0, 86399)
pure
(timeToTimeOfDay
(secondsToDiffTime seconds + (fromRational (fractional % 10000000))))
Expand All @@ -719,7 +719,7 @@ newtype TestTimeOfDay = TestTimeOfDay TimeOfDay

instance Arbitrary TestTimeOfDay where
arbitrary = do
seconds <- choose (0, 86400)
seconds <- choose (0, 86399)
pure (TestTimeOfDay (timeToTimeOfDay (secondsToDiffTime seconds)))

instance Arbitrary TestDateTime where
Expand All @@ -729,15 +729,15 @@ instance Arbitrary TestDateTime where
fractional <- elements [993, 003, 497, 007, 000, 127] :: Gen Integer
-- Rounded to increments of .000, .003, or .007 seconds
-- from: https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql
seconds <- choose (0, 86400)
seconds <- choose (0, 86399)
pure
(timeToTimeOfDay
(secondsToDiffTime seconds + (fromRational (fractional % 1000))))

deriving instance Arbitrary Datetime2
instance Arbitrary Smalldatetime where
arbitrary = do
minutes <- choose (0, 1440)
minutes <- choose (0, 1439)
day <-
do offset <- choose (0, 179)
pure (addDays offset (fromGregorian 1900 01 01))
Expand Down

0 comments on commit 7561f55

Please sign in to comment.