github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekatime/till_next_test.go (about) 1 // Copyright © 2021. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekatime_test 7 8 import ( 9 "testing" 10 "time" 11 12 "github.com/qioalice/ekago/v3/ekatime" 13 14 "github.com/stretchr/testify/require" 15 ) 16 17 func TestTimestamp_TillNext(t *testing.T) { 18 ts := ekatime.NewDate(2012, ekatime.MONTH_JANUARY, 12).WithTime(13, 14, 15) 19 for _, n := range []struct { 20 expected time.Duration 21 range_ ekatime.Timestamp 22 }{ 23 {45*time.Minute + 45*time.Second, 2 * ekatime.SECONDS_IN_HOUR}, 24 {105*time.Minute + 45*time.Second, 3 * ekatime.SECONDS_IN_HOUR}, 25 {15*time.Minute + 45*time.Second, 30 * ekatime.SECONDS_IN_MINUTE}, 26 } { 27 require.Equal(t, n.expected, ts.TillNext(n.range_)) 28 } 29 }