Update getopts to read correctely the ending line

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3526 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2017-04-16 15:17:37 +00:00
parent 2f35b83e7d
commit 064407ff1c
2 changed files with 83 additions and 15 deletions

View File

@@ -39,7 +39,7 @@ class test_getopts extends PHPUnit_Framework_TestCase
public function test_scan1 ()
{
$this->expectException ("Exception", "Provided tokens are not known: -f,ii,-o,1 2,-o,2 2,-o,3");
$this->expectException ("Exception", "Provided tokens are not known: -f,-o,-o,-o");
$getopts = new getopts ();
$getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
@@ -145,6 +145,26 @@ class test_getopts extends PHPUnit_Framework_TestCase
$this->assertSame ($res, array ("-bla", "final"));
}
public function test_restOfLine2 ()
{
$getopts = new getopts ();
$getopts->simulate ("sim\ ulate bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
$res = $getopts->restOfLine ();
$this->assertSame ($res, array ("bla", "final"));
}
public function test_restOfLine3 ()
{
$getopts = new getopts ();
$getopts->simulate ("sim\ ulate -- -bla final");
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
$res = $getopts->restOfLine ();
$this->assertSame ($res, array ("-bla", "final"));
}
public function test_programName1 ()
{
$getopts = new getopts ();