Skip to content

leap: update example_gen.go & test cases #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions exercises/leap/cases_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package leap

// Source: exercism/x-common
// Commit: 945d08e Merge pull request #50 from soniakeys/master
// Commit: be6fa53 leap: Rewrite the test cases and their descriptions

var testCases = []struct {
year int
expected bool
description string
}{
{1996, true, "leap year"},
{1997, false, "non-leap year"},
{1998, false, "non-leap even year"},
{1900, false, "century"},
{2400, true, "fourth century"},
{2000, true, "Y2K"},
{2015, false, "year not divisible by 4: common year"},
{2016, true, "year divisible by 4, not divisible by 100: leap year"},
{2100, false, "year divisible by 100, not divisible by 400: common year"},
{2000, true, "year divisible by 400: leap year"},
}
2 changes: 1 addition & 1 deletion exercises/leap/example.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package leap

const testVersion = 2
const testVersion = 3

func IsLeapYear(i int) bool {
return i%4 == 0 && i%100 != 0 || i%400 == 0
Expand Down
2 changes: 1 addition & 1 deletion exercises/leap/example_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func main() {
log.Fatal(err)
}
var j js
if err := gen.Gen("leap.json", &j, t); err != nil {
if err := gen.Gen("leap", &j, t); err != nil {
log.Fatal(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/leap/leap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package leap

// testVersion should match the targetTestVersion in the test file.
const testVersion = 2
const testVersion = 3

// It's good style to write a comment here documenting IsLeapYear.
func IsLeapYear(int) bool {
Expand Down
2 changes: 1 addition & 1 deletion exercises/leap/leap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "testing"
// Also define a testVersion with a value that matches
// the targetTestVersion here.

const targetTestVersion = 2
const targetTestVersion = 3

func TestLeapYears(t *testing.T) {
if testVersion != targetTestVersion {
Expand Down