-i, --integer <n> get a integer
-j <n> get a integer, too
+ -m, --magnitude <n> get a magnitude
--set23 set integer to 23
-t <time> get timestamp of <time>
-L, --length <str> get length of <str>
cat >expect.template <<EOF
boolean: 0
integer: 0
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7
test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'
+test_expect_success 'OPT_INT() negative' 'check integer: -2345 -i -2345'
+
+test_expect_success 'OPT_MAGNITUDE() simple' '
+ check magnitude: 2345678 -m 2345678
+'
+
+test_expect_success 'OPT_MAGNITUDE() kilo' '
+ check magnitude: 239616 -m 234k
+'
+
+test_expect_success 'OPT_MAGNITUDE() mega' '
+ check magnitude: 104857600 -m 100m
+'
+
+test_expect_success 'OPT_MAGNITUDE() giga' '
+ check magnitude: 1073741824 -m 1g
+'
+
+test_expect_success 'OPT_MAGNITUDE() 3giga' '
+ check magnitude: 3221225472 -m 3g
+'
+
cat > expect << EOF
boolean: 2
integer: 1729
+magnitude: 16384
timestamp: 0
string: 123
abbrev: 7
EOF
test_expect_success 'short options' '
- test-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \
- > output 2> output.err &&
+ test-parse-options -s123 -b -i 1729 -m 16k -b -vv -n -F my.file \
+ >output 2>output.err &&
test_cmp expect output &&
test_must_be_empty output.err
'
cat > expect << EOF
boolean: 2
integer: 1729
+magnitude: 16384
timestamp: 0
string: 321
abbrev: 10
EOF
test_expect_success 'long options' '
- test-parse-options --boolean --integer 1729 --boolean --string2=321 \
- --verbose --verbose --no-dry-run --abbrev=10 --file fi.le\
- --obsolete > output 2> output.err &&
+ test-parse-options --boolean --integer 1729 --magnitude 16k \
+ --boolean --string2=321 --verbose --verbose --no-dry-run \
+ --abbrev=10 --file fi.le --obsolete \
+ >output 2>output.err &&
test_must_be_empty output.err &&
test_cmp expect output
'
cat > expect << EOF
boolean: 1
integer: 13
+magnitude: 0
timestamp: 0
string: 123
abbrev: 7
cat > expect << EOF
boolean: 0
integer: 2
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7
cat > expect << EOF
boolean: 0
integer: 0
+magnitude: 0
timestamp: 0
string: 123
abbrev: 7
cat > expect <<EOF
boolean: 0
integer: 0
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7
cat > expect <<EOF
boolean: 0
integer: 0
+magnitude: 0
timestamp: 1
string: (not set)
abbrev: 7
Callback: "four", 0
boolean: 5
integer: 4
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7
cat > expect <<EOF
boolean: 1
integer: 23
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7
cat > expect <<EOF
boolean: 6
integer: 0
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7
cat > expect <<EOF
boolean: 0
integer: 12345
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7
cat >expect <<EOF
boolean: 0
integer: 0
+magnitude: 0
timestamp: 0
string: (not set)
abbrev: 7