Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
time
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rinat Striungis
time
Commits
7c29ef79
Commit
7c29ef79
authored
8 years ago
by
Ashley Yakeley
Browse files
Options
Downloads
Patches
Plain Diff
tests for leap-second conversion
parent
d6863ffe
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
test/Test/TestTAI.hs
+60
-0
60 additions, 0 deletions
test/Test/TestTAI.hs
test/Test/TestUtil.hs
+20
-0
20 additions, 0 deletions
test/Test/TestUtil.hs
test/Test/Tests.hs
+2
-0
2 additions, 0 deletions
test/Test/Tests.hs
time.cabal
+1
-0
1 addition, 0 deletions
time.cabal
with
83 additions
and
0 deletions
test/Test/TestTAI.hs
0 → 100644
+
60
−
0
View file @
7c29ef79
module
Test.TestTAI
(
testTAI
)
where
import
Data.Time
import
Data.Time.Clock.TAI
import
Test.TestUtil
sampleLeapSecondMap
::
LeapSecondMap
Maybe
sampleLeapSecondMap
d
|
d
<
fromGregorian
1972
1
1
=
Nothing
sampleLeapSecondMap
d
|
d
<
fromGregorian
1972
7
1
=
Just
10
sampleLeapSecondMap
d
|
d
<
fromGregorian
1975
1
1
=
Just
11
sampleLeapSecondMap
_
=
Nothing
testTAI
::
TestTree
;
testTAI
=
testGroup
"leap second transition"
$
let
dayA
=
fromGregorian
1972
6
30
dayB
=
fromGregorian
1972
7
1
utcTime1
=
UTCTime
dayA
86399
utcTime2
=
UTCTime
dayA
86400
utcTime3
=
UTCTime
dayB
0
mAbsTime1
=
utcToTAITime
sampleLeapSecondMap
utcTime1
mAbsTime2
=
utcToTAITime
sampleLeapSecondMap
utcTime2
mAbsTime3
=
utcToTAITime
sampleLeapSecondMap
utcTime3
in
[
testCase
"mapping"
$
do
assertEqual
"dayA"
(
Just
10
)
$
sampleLeapSecondMap
dayA
assertEqual
"dayB"
(
Just
11
)
$
sampleLeapSecondMap
dayB
,
testCase
"day length"
$
do
assertEqual
"dayA"
(
Just
86401
)
$
utcDayLength
sampleLeapSecondMap
dayA
assertEqual
"dayB"
(
Just
86400
)
$
utcDayLength
sampleLeapSecondMap
dayB
,
testCase
"differences"
$
do
absTime1
<-
assertJust
mAbsTime1
absTime2
<-
assertJust
mAbsTime2
absTime3
<-
assertJust
mAbsTime3
assertEqual
"absTime2 - absTime1"
1
$
diffAbsoluteTime
absTime2
absTime1
assertEqual
"absTime3 - absTime2"
1
$
diffAbsoluteTime
absTime3
absTime2
,
testGroup
"round-trip"
[
testCase
"1"
$
do
absTime
<-
assertJust
mAbsTime1
utcTime
<-
assertJust
$
taiToUTCTime
sampleLeapSecondMap
absTime
assertEqual
"round-trip"
utcTime1
utcTime
,
testCase
"2"
$
do
absTime
<-
assertJust
mAbsTime2
utcTime
<-
assertJust
$
taiToUTCTime
sampleLeapSecondMap
absTime
assertEqual
"round-trip"
utcTime2
utcTime
,
testCase
"3"
$
do
absTime
<-
assertJust
mAbsTime3
utcTime
<-
assertJust
$
taiToUTCTime
sampleLeapSecondMap
absTime
assertEqual
"round-trip"
utcTime3
utcTime
]
]
This diff is collapsed.
Click to expand it.
test/Test/TestUtil.hs
+
20
−
0
View file @
7c29ef79
...
@@ -37,3 +37,23 @@ diff :: (Show a,Eq a) => a -> a -> Result
...
@@ -37,3 +37,23 @@ diff :: (Show a,Eq a) => a -> a -> Result
diff
expected
found
|
expected
==
found
=
Pass
diff
expected
found
|
expected
==
found
=
Pass
diff
expected
found
=
Fail
(
"expected "
++
(
show
expected
)
++
" but found "
++
(
show
found
))
diff
expected
found
=
Fail
(
"expected "
++
(
show
expected
)
++
" but found "
++
(
show
found
))
-- for tasty-like test code
type
TestTree
=
Test
type
Assertion
=
Either
String
()
testCase
::
String
->
Assertion
->
Test
testCase
name
(
Right
()
)
=
pureTest
name
Pass
testCase
name
(
Left
s
)
=
pureTest
name
(
Fail
s
)
assertFailure
::
String
->
Either
String
a
assertFailure
=
Left
assertEqual
::
(
Show
a
,
Eq
a
)
=>
String
->
a
->
a
->
Assertion
assertEqual
_
expected
found
|
expected
==
found
=
return
()
assertEqual
name
expected
found
=
assertFailure
$
name
++
": expected "
++
(
show
expected
)
++
" but found "
++
(
show
found
)
assertJust
::
Maybe
a
->
Either
String
a
assertJust
(
Just
a
)
=
return
a
assertJust
Nothing
=
assertFailure
"Nothing"
This diff is collapsed.
Click to expand it.
test/Test/Tests.hs
+
2
−
0
View file @
7c29ef79
...
@@ -11,6 +11,7 @@ import Test.TestEaster
...
@@ -11,6 +11,7 @@ import Test.TestEaster
import
Test.TestFormat
import
Test.TestFormat
import
Test.TestMonthDay
import
Test.TestMonthDay
import
Test.TestParseTime
import
Test.TestParseTime
import
Test.TestTAI
import
Test.TestTime
import
Test.TestTime
import
Test.TestTimeZone
import
Test.TestTimeZone
import
Test.TestValid
import
Test.TestValid
...
@@ -25,6 +26,7 @@ tests = [ addDaysTest
...
@@ -25,6 +26,7 @@ tests = [ addDaysTest
,
testFormat
,
testFormat
,
testMonthDay
,
testMonthDay
,
testParseTime
,
testParseTime
,
testTAI
,
testTime
,
testTime
,
testTimeZone
,
testTimeZone
,
testValid
]
,
testValid
]
This diff is collapsed.
Click to expand it.
time.cabal
+
1
−
0
View file @
7c29ef79
...
@@ -140,6 +140,7 @@ test-suite tests
...
@@ -140,6 +140,7 @@ test-suite tests
Test.TestEasterRef
Test.TestEasterRef
Test.TestCalendars
Test.TestCalendars
Test.TestCalendarsRef
Test.TestCalendarsRef
Test.TestTAI
Test.TestTimeZone
Test.TestTimeZone
Test.TestValid
Test.TestValid
Test.LongWeekYears
Test.LongWeekYears
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment