summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNathan Gass2008-08-06 14:20:36 +0000
committerNathan Gass2008-08-06 14:20:36 +0000
commita9ad07045a2f21ca1ec39ca5e7d636a61e4705ab (patch)
treed39b1b99db461fc0628bc39bc39c6e3d441fb5a3 /tests
parent9d93a6860b5c7f43c5909072ef84847e580f003e (diff)
downloaditools-a9ad07045a2f21ca1ec39ca5e7d636a61e4705ab.tar.gz
itools-a9ad07045a2f21ca1ec39ca5e7d636a61e4705ab.tar.bz2
itools-a9ad07045a2f21ca1ec39ca5e7d636a61e4705ab.zip
debuged, added basic tests
Diffstat (limited to 'tests')
-rwxr-xr-xtests/getopt.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/getopt.t b/tests/getopt.t
new file mode 100755
index 0000000..41e985d
--- /dev/null
+++ b/tests/getopt.t
@@ -0,0 +1,24 @@
+#!/www/server/bin/php -qC
+<?php
+
+# Tests for getopt in it.class
+
+require 'searchlib/search_test.class';
+
+$usage = "Usage: doesnotexist.php [OPTIONS]
+Some help to a not existing program
+ -h,--help the help argument
+ -a,--argument=ARG the arg argument
+";
+
+function getopt_ok($argv, $exp, $name)
+{
+ $_SERVER['argv'] = array_merge(array('doesnotexist.php'), $argv);
+ $got = it::getopt($GLOBALS['usage']);
+ return is($got['argument'], $exp, $name);
+}
+
+$testarg = "blah gnaber";
+getopt_ok(array('-a', $testarg), $testarg, "Short version");
+getopt_ok(array('--argument', $testarg), $testarg, "Long version with space");
+getopt_ok(array("--argument=$testarg"), $testarg, "Long version with equal");