Skip to content

Commit 3327644

Browse files
committed
Quick Save
1 parent bcee865 commit 3327644

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

demos/timefmt/demo.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/basj
1+
#!/bin/bash
22

33
echo ' running: timefmt -if "2006-01-02" -of "01/02/2006" "2017-12-02"'
44
echo 'expected: 12/02/2017'

test_cmds.bash

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -664,25 +664,66 @@ function test_jsonrange(){
664664
}
665665

666666
function test_range(){
667-
echo "test_range skipping, not implemented";
667+
EXPECTED="1 2 3 4 5"
668+
RESULT=$(range 1 5)
669+
assert_equal "test_range (range 1 5)" "$EXPECTED" "$RESULT"
670+
671+
EXPECTED="-2 -1 0 1 2 3 4 5 6"
672+
RESULT=$(range -- -2 6)
673+
assert_equal "test_range (range -- -2 6)" "$EXPECTED" "$RESULT"
674+
675+
EXPECTED="2 4 6 8 10"
676+
RESULT=$(range -increment=2 2 10)
677+
assert_equal "test_range (range -increment=2 2 10)" "$EXPECTED" "$RESULT"
678+
679+
EXPECTED="10 9 8 7 6 5 4 3 2 1"
680+
RESULT=$(range 10 1)
681+
assert_equal "test_range (range 10 1)" "$EXPECTED" "$RESULT"
682+
683+
I=$(range -random 0 10)
684+
if [[ "$I" -lt "0" || "$I" -gt "10" ]]; then
685+
echo "range -random 0 10: $I (error, out of range)"
686+
exit 1
687+
fi
688+
echo "test_range OK";
668689
}
669690

670691
function test_reldate(){
671-
echo "test_reldate skipping, not implemented";
692+
EXPECTED='2014-08-04'
693+
RESULT=$(reldate -from=2014-08-01 3 days)
694+
assert_equal "test_reldate (1)" "$EXPECTED" "$RESULT"
695+
696+
EXPECTED='2014-08-06'
697+
RESULT=$(reldate --from=2014-08-03 3 days)
698+
assert_equal "test_reldate (2)" "$EXPECTED" "$RESULT"
699+
700+
EXPECTED='2014-07-31'
701+
RESULT=$(reldate --from=2014-08-03 -- -3 days)
702+
assert_equal "test_reldate (3)" "$EXPECTED" "$RESULT"
703+
704+
EXPECTED='2015-02-09'
705+
RESULT=$(reldate --from=2015-02-10 Monday)
706+
assert_equal "test_reldate (4)" "$EXPECTED" "$RESULT"
707+
echo "test_reldate OK";
672708
}
673709

674710
function test_timefmt(){
675-
echo "test_timefmt skipping, not implemented";
711+
712+
EXPECTED='12/02/2017'
713+
RESULT=$(timefmt -if "2006-01-02" -of "01/02/2006" "2017-12-02")
714+
assert_equal "test_timefmt (1)" "$EXPECTED" "$RESULT"
715+
716+
EXPECTED='02 Dec 17 08:08 UTC'
717+
RESULT=$(timefmt -input-format mysql -output-format RFC822 "2017-12-02 08:08:08")
718+
assert_equal "test_timefmt (2)" "$EXPECTED" "$RESULT"
719+
720+
echo "test_timefmt OK";
676721
}
677722

678723
function test_urlparse(){
679724
echo "test_urlparse skipping, not implemented";
680725
}
681726

682-
function test_vcard2json(){
683-
echo "test_vcard2json skipping, not implemented";
684-
}
685-
686727
function test_xlsx2csv(){
687728
echo "test_xlsx2csv skipping, not implemented";
688729
}
@@ -713,7 +754,6 @@ test_reldate
713754
test_string
714755
test_timefmt
715756
test_urlparse
716-
test_vcard2json
717757
test_xlsx2csv
718758
test_xlsx2json
719759
echo "Success!"

0 commit comments

Comments
 (0)