1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-06-29 20:51:45 +00:00
Files
autofile
bech32
cli
clist
common
LICENSE
array.go
async.go
async_test.go
bit_array.go
bit_array_test.go
bytes.go
bytes_test.go
byteslice.go
byteslice_test.go
cmap.go
cmap_test.go
colors.go
date.go
date_test.go
errors.go
errors_test.go
heap.go
int.go
int_test.go
io.go
kvpair.go
math.go
net.go
net_test.go
nil.go
os.go
os_test.go
random.go
random_test.go
repeat_timer.go
repeat_timer_test.go
service.go
service_test.go
string.go
string_test.go
throttle_timer.go
throttle_timer_test.go
types.pb.go
types.proto
word.go
db
flowrate
log
merkle
test
version
.editorconfig
.gitignore
CHANGELOG.md
CODEOWNERS
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
circle.yml
glide.lock
glide.yaml
merge.sh
test.sh
tendermint/common/date_test.go

47 lines
958 B
Go
Raw Normal View History

2017-06-06 04:00:36 -04:00
package common
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
var (
date = time.Date(2015, time.Month(12), 31, 0, 0, 0, 0, time.UTC)
date2 = time.Date(2016, time.Month(12), 31, 0, 0, 0, 0, time.UTC)
2017-06-20 17:18:55 -04:00
zero time.Time
2017-06-06 04:00:36 -04:00
)
func TestParseDateRange(t *testing.T) {
assert := assert.New(t)
var testDates = []struct {
dateStr string
2017-06-20 17:18:55 -04:00
start time.Time
end time.Time
2017-06-06 04:00:36 -04:00
errNil bool
}{
2017-06-20 17:18:55 -04:00
{"2015-12-31:2016-12-31", date, date2, true},
{"2015-12-31:", date, zero, true},
{":2016-12-31", zero, date2, true},
{"2016-12-31", zero, zero, false},
{"2016-31-12:", zero, zero, false},
{":2016-31-12", zero, zero, false},
2017-06-06 04:00:36 -04:00
}
for _, test := range testDates {
start, end, err := ParseDateRange(test.dateStr)
2017-06-20 17:18:55 -04:00
if test.errNil {
2017-06-06 04:00:36 -04:00
assert.Nil(err)
2017-06-20 17:18:55 -04:00
testPtr := func(want, have time.Time) {
assert.True(have.Equal(want))
2017-06-06 04:00:36 -04:00
}
testPtr(test.start, start)
testPtr(test.end, end)
2017-06-20 17:18:55 -04:00
} else {
2017-06-06 04:00:36 -04:00
assert.NotNil(err)
}
}
}