From 0ac76c79b661232e6f1afe39b9201f58c4c04a29 Mon Sep 17 00:00:00 2001 From: Andrej Makarov Date: Tue, 7 Feb 2017 13:58:41 +0000 Subject: [PATCH] Add exercise: gigasecond --- config.json | 7 +++++++ exercises/gigasecond/example.jl | 1 + exercises/gigasecond/gigasecond.jl | 3 +++ exercises/gigasecond/runtests.jl | 15 +++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 exercises/gigasecond/example.jl create mode 100644 exercises/gigasecond/gigasecond.jl create mode 100644 exercises/gigasecond/runtests.jl diff --git a/config.json b/config.json index 424b66c3ab017..97b28126ae4a1 100644 --- a/config.json +++ b/config.json @@ -22,6 +22,13 @@ "exceptions" ] }, + { + "slug": "gigasecond", + "difficulty": 1, + "topics": [ + "dates" + ] + }, { "slug": "difference-of-squares", "difficulty": 1, diff --git a/exercises/gigasecond/example.jl b/exercises/gigasecond/example.jl new file mode 100644 index 0000000000000..174d346ea3014 --- /dev/null +++ b/exercises/gigasecond/example.jl @@ -0,0 +1 @@ +add_gigasecond(date::DateTime) = date + Dates.Second(10^9) diff --git a/exercises/gigasecond/gigasecond.jl b/exercises/gigasecond/gigasecond.jl new file mode 100644 index 0000000000000..3bd78d6fbaa2e --- /dev/null +++ b/exercises/gigasecond/gigasecond.jl @@ -0,0 +1,3 @@ +function add_gigasecond(date::DateTime) + +end diff --git a/exercises/gigasecond/runtests.jl b/exercises/gigasecond/runtests.jl new file mode 100644 index 0000000000000..f38b08ceab02c --- /dev/null +++ b/exercises/gigasecond/runtests.jl @@ -0,0 +1,15 @@ +using Base.Test + +include("gigasecond.jl") + +samples = Dict( + DateTime("2011-04-25") => DateTime("2043-01-01T01:46:40"), + DateTime("1977-06-13") => DateTime("2009-02-19T01:46:40"), + DateTime("1959-07-19") => DateTime("1991-03-27T01:46:40"), + DateTime("2015-01-24T22:00:00") => DateTime("2046-10-02T23:46:40"), + DateTime("2015-01-24T23:59:59") => DateTime("2046-10-03T01:46:39") +) + +@testset "add gigasecond to $sample[1]" for sample in samples + @test add_gigasecond(sample[1]) == sample[2] +end