diff options
author | Rob Landley <rob@landley.net> | 2016-10-19 20:51:28 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-10-19 20:51:28 -0500 |
commit | 354ff6831412eb88c64e9f497a382d926dc7b9bd (patch) | |
tree | afd03ab495e50e08bb0ea06b7ea7d41b8b2cee34 /tests | |
parent | ee14fc396dff50a263b62670f5484efcd6316aeb (diff) | |
download | toybox-354ff6831412eb88c64e9f497a382d926dc7b9bd.tar.gz |
More touch tests, and a fix found by one. (The three -t formats can only
reliably be distinguished by checking length, because %H amd %m and such
can match different numbers of digits.)
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/touch.test | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/touch.test b/tests/touch.test index d5bef815..1b71c5eb 100755 --- a/tests/touch.test +++ b/tests/touch.test @@ -15,6 +15,19 @@ testing "-t" \ "touch -t 201201231234 walrus && date -r walrus +%Y%m%d-%H%M%S.%N" \ "20120123-123400.000000000\n" "" "" +# Yes, the year could roll over while you're running this test. I do not care. +testing "-t MMDDhhmm" \ + "touch -t 01231234 input && date +%Y-%m-%d:%H-%M-%S -r input" \ + "$(date +%Y)-01-23:12-34-00\n" "" "" + +testing "-t YYMMDDhhmm" \ + "touch -t 2101231234 input && date +%Y-%m-%d:%H-%M-%S -r input" \ + "$(date +%C)21-01-23:12-34-00\n" "" "" + +testing "-t CCYYMMDDhhmm" \ + "touch -t 201201231234 walrus && date -r walrus +%Y%m%d-%H%M%S.%N" \ + "20120123-123400.000000000\n" "" "" + testing "-t seconds" \ "touch -t 201201231234.56 walrus && date -r walrus +%Y%m%d-%H%M%S.%N" \ "20120123-123456.000000000\n" "" "" @@ -27,6 +40,10 @@ testing "-d" \ "touch -d 2009-02-13T23:31:30Z walrus && date -r walrus +%s" \ "1234567890\n" "" "" +testing "-d with space" \ + "touch -d '2009-02-13 23:31:30Z' walrus && date -r walrus +%s" \ + "1234567890\n" "" "" + testing "-d nanoseconds" \ "touch -d 2009-02-13T23:31:30.123456789Z walrus && date -r walrus +%s.%N" \ "1234567890.123456789\n" "" "" @@ -40,6 +57,11 @@ testing "-t MMDDhhmm" \ "touch -t 01231234 input && date +%Y-%m-%d:%H-%M-%S -r input" \ "$(date +%Y)-01-23:12-34-00\n" "" "" +testing "-t CCMMDDhhmm" \ + "touch -t 2101231234 input && date +%Y-%m-%d:%H-%M-%S -r input" \ + "$(date +%C)21-01-23:12-34-00\n" "" "" + + #testing "-a" #testing "-m" #testing "-am" |