1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests: fix warnings when doing ./v -W -progress -check-syntax test-fixed

This commit is contained in:
Delyan Angelov
2020-10-26 14:41:57 +02:00
parent 9772eb7c96
commit 0c192cfd64
17 changed files with 143 additions and 156 deletions

View File

@@ -24,7 +24,7 @@ fn test_is_leap_year() {
assert time.is_leap_year(2100) == false
}
fn check_days_in_month(month, year, expected int) bool {
fn check_days_in_month(month int, year int, expected int) bool {
res := time.days_in_month(month, year) or {
return false
}
@@ -89,18 +89,21 @@ fn test_format_ss() {
}
fn test_format_ss_milli() {
assert '11.07.1980 21:23:42.123' == time_to_test.get_fmt_str(.dot, .hhmmss24_milli, .ddmmyyyy)
assert '11.07.1980 21:23:42.123' ==
time_to_test.get_fmt_str(.dot, .hhmmss24_milli, .ddmmyyyy)
assert '1980-07-11 21:23:42.123' == time_to_test.format_ss_milli()
}
fn test_format_ss_micro() {
assert '11.07.1980 21:23:42.123456' == time_to_test.get_fmt_str(.dot, .hhmmss24_micro, .ddmmyyyy)
assert '11.07.1980 21:23:42.123456' ==
time_to_test.get_fmt_str(.dot, .hhmmss24_micro, .ddmmyyyy)
assert '1980-07-11 21:23:42.123456' == time_to_test.format_ss_micro()
}
fn test_smonth() {
month_names := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
month_names := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',
'Dec',
]
for i, name in month_names {
month_num := i + 1
t := time.Time{
@@ -117,7 +120,7 @@ fn test_smonth() {
}
fn test_day_of_week() {
for i in 0..7 {
for i in 0 .. 7 {
day_of_week := i + 1
// 2 Dec 2019 is Monday
t := time.Time{
@@ -164,33 +167,30 @@ fn test_str() {
// not optimal test but will find obvious bugs
fn test_now() {
now := time.now()
// The year the test was built
assert now.year >= 2020
assert now.month > 0
assert now.month <= 12
assert now.minute >= 0
assert now.minute < 60
assert now.second >=0
assert now.second <= 60 // <= 60 cause of leap seconds
assert now.microsecond >= 0
assert now.microsecond < 1000000
assert now.year >= 2020
assert now.month > 0
assert now.month <= 12
assert now.minute >= 0
assert now.minute < 60
assert now.second >= 0
assert now.second <= 60 // <= 60 cause of leap seconds
assert now.microsecond >= 0
assert now.microsecond < 1000000
}
fn test_utc() {
now := time.utc()
// The year the test was built
assert now.year >= 2020
assert now.month > 0
assert now.month <= 12
assert now.minute >= 0
assert now.minute < 60
assert now.second >=0
assert now.second <= 60 // <= 60 cause of leap seconds
assert now.microsecond >= 0
assert now.microsecond < 1000000
assert now.year >= 2020
assert now.month > 0
assert now.month <= 12
assert now.minute >= 0
assert now.minute < 60
assert now.second >= 0
assert now.second <= 60 // <= 60 cause of leap seconds
assert now.microsecond >= 0
assert now.microsecond < 1000000
}
fn test_unix_time() {
@@ -203,10 +203,10 @@ fn test_unix_time() {
//
utm1 := t1.unix_time_milli()
utm2 := t2.unix_time_milli()
assert (utm1 - u64(ut1)*1000) < 1000
assert (utm2 - u64(ut2)*1000) < 1000
assert (utm1 - u64(ut1) * 1000) < 1000
assert (utm2 - u64(ut2) * 1000) < 1000
//
//println('utm1: $utm1 | utm2: $utm2')
// println('utm1: $utm1 | utm2: $utm2')
assert utm2 - utm1 > 2
assert utm2 - utm1 < 999
}