示例#1
0
 public function testStaticArrayS()
 {
     $format = array("int[5]", "float[5]", "bool");
     $array = \Structure\Structure::ArrayS($format);
     $data = array(range(1, 5), range(1.2, 2, 0.2), true);
     $this->assertTrue($array->check($data));
 }
示例#2
0
 public function testFormat3()
 {
     $format = array("full_name" => "string", "height" => "integer", "weight" => "integer", "gender" => "integer[0,2]");
     $formatter = \Structure\Structure::ArrayS($format, null, false, true);
     $array = array("full_name" => "My Name", "height" => 175, "gender" => "-1");
     $this->assertFalse($formatter->check($array));
     $newArray = $formatter->format($array);
     $this->assertTrue($formatter->check($newArray));
 }
示例#3
0
 public function testEmptyArrayDescription()
 {
     $checker = \Structure\Structure::ArrayS("[0]");
     $this->assertTrue($checker->check(array()));
     $this->assertFalse($checker->check(array("abc")));
     $this->assertFalse($checker->check(array(null)));
     $this->assertFalse($checker->check("abc"));
 }