blob: d193d7cc2896957fae3cc919be48e4119033ffc5 [file] [log] [blame]
#!/bin/bash
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
testing "touch" "touch walrus && [ -e walrus ] && echo yes" "yes\n" "" ""
testing "1 2 3" "touch one two three && rm one two three && echo yes" "yes\n" \
"" ""
testing "-c" "touch -c walrus && [ -e walrus ] && echo yes" "yes\n" "" ""
testing "-c missing" "touch -c warrus && [ ! -e warrus ] && echo yes" \
"yes\n" "" ""
testing "-t" \
"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" "" ""
testing "-t nanoseconds" \
"touch -t 201201231234.56123456789 walrus && date -r walrus +%Y%m%d-%H%M%S.%N" \
"20120123-123456.123456789\n" "" ""
testing "-d" \
"touch -d 2009-02-13T23: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" "" ""
testing "-r" \
"touch -r walrus walrus2 && date -r walrus2 +%s.%N" \
"1234567890.123456789\n" "" ""
#testing "-a"
#testing "-m"
#testing "-am"
#testing "-t"
rm walrus walrus2