mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #4520 from kidrigger/wip-date-test
tests/date: Added tests for date ISO8601 formats.
This commit is contained in:
commit
5298ba8250
1 changed files with 55 additions and 2 deletions
|
@ -45,8 +45,12 @@ fn test_date_rfc_3339() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_rfc_8601() {
|
fn test_date_rfc_8601() {
|
||||||
|
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2},\d{9}[+-]\d{2}:\d{2}\n$").unwrap();
|
||||||
for param in ["--iso-8601", "--i"] {
|
for param in ["--iso-8601", "--i"] {
|
||||||
new_ucmd!().arg(format!("{param}=ns")).succeeds();
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=ns"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +63,57 @@ fn test_date_rfc_8601_invalid_arg() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_rfc_8601_second() {
|
fn test_date_rfc_8601_second() {
|
||||||
|
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}\n$").unwrap();
|
||||||
for param in ["--iso-8601", "--i"] {
|
for param in ["--iso-8601", "--i"] {
|
||||||
new_ucmd!().arg(format!("{param}=second")).succeeds();
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=second"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=seconds"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_date_rfc_8601_minute() {
|
||||||
|
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}[+-]\d{2}:\d{2}\n$").unwrap();
|
||||||
|
for param in ["--iso-8601", "--i"] {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=minute"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=minutes"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_date_rfc_8601_hour() {
|
||||||
|
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}T\d{2}[+-]\d{2}:\d{2}\n$").unwrap();
|
||||||
|
for param in ["--iso-8601", "--i"] {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=hour"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=hours"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_date_rfc_8601_date() {
|
||||||
|
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}\n$").unwrap();
|
||||||
|
for param in ["--iso-8601", "--i"] {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg(format!("{param}=date"))
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue