summary refs log blame commit diff stats
path: root/apod/randomdate_test.go
blob: 8ac82bccae2f3bd5ada2e3efa20124cf619d55dd (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                                              
package apod

import (
	"regexp"
	"testing"
)

// TestRandDate tests the RandDate func. We're not actually testing
// much, there are many cases and we really can't test for all, we'll
// have to run this test a lot of times for that. Even after that it
// doesn't guarantee anything because our test itself is flawed.
func TestRandDate(t *testing.T) {
	date := RandDate()
	re := regexp.MustCompile("((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])")
	if !re.MatchString(date) {
		t.Errorf("Date format is incorrect, got %s, want YYYY-MM-DD.", date)
	}
}