本文整理汇总了PHP中Assert::ok方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::ok方法的具体用法?PHP Assert::ok怎么用?PHP Assert::ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert
的用法示例。
在下文中一共展示了Assert::ok方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fuzzTest1
function fuzzTest1(Assert $assert)
{
// Values we're testing against: chosen to ensure no bits get chopped
// off anywhere, and also be different from eachother.
$bool_val = true;
$char_val = -127;
// 0x81
$uchar_val = 0xff;
$short_val = -32222;
// 0x8222;
$ushort_val = 0xfeee;
$int_val = 0x7fffffff | 0;
// for now
$uint_val = 1;
$long_val = 2;
$ulong_val = 3;
// var uint_val = 0xFDDDDDDD;
// var long_val = new flatbuffers.Long(0x44444444, 0x84444444);
// var ulong_val = new flatbuffers.Long(0xCCCCCCCC, 0xFCCCCCCC);
$float_val = 3.14159;
$double_val = 3.14159265359;
$test_values_max = 11;
$fields_per_object = 4;
// current implementation is not good at encoding.
$num_fuzz_objects = 1000;
$builder = new Google\FlatBuffers\FlatBufferBuilder(1);
// can't use same implementation due to PHP_INTMAX overflow issue.
// we use mt_rand function to reproduce fuzzy test.
mt_srand(48271);
$objects = array();
// Generate num_fuzz_objects random objects each consisting of
// fields_per_object fields, each of a random type.
for ($i = 0; $i < $num_fuzz_objects; $i++) {
$builder->startObject($fields_per_object);
for ($f = 0; $f < $fields_per_object; $f++) {
$choice = mt_rand() % $test_values_max;
switch ($choice) {
case 0:
$builder->addBoolX($f, $bool_val, 0);
break;
case 1:
$builder->addByteX($f, $char_val, 0);
break;
case 2:
$builder->addSbyteX($f, $uchar_val, 0);
break;
case 3:
$builder->addShortX($f, $short_val, 0);
break;
case 4:
$builder->addUshortX($f, $ushort_val, 0);
break;
case 5:
$builder->addIntX($f, $int_val, 0);
break;
case 6:
$builder->addUintX($f, $uint_val, 0);
break;
case 7:
$builder->addLongX($f, $long_val, 0);
break;
case 8:
$builder->addUlongX($f, $ulong_val, 0);
break;
case 9:
$builder->addFloatX($f, $float_val, 0);
break;
case 10:
$builder->addDoubleX($f, $double_val, 0);
break;
}
}
$objects[] = $builder->endObject();
}
$builder->prep(8, 0);
// Align whole buffer.
mt_srand(48271);
// Reset
$builder->finish($objects[count($objects) - 1]);
$view = Google\FlatBuffers\ByteBuffer::wrap($builder->sizedByteArray());
for ($i = 0; $i < $num_fuzz_objects; $i++) {
$offset = $view->capacity() - $objects[$i];
for ($f = 0; $f < $fields_per_object; $f++) {
$choice = mt_rand() % $test_values_max;
$vtable_offset = fieldIndexToOffset($f);
$vtable = $offset - $view->getInt($offset);
$assert->ok($vtable_offset < $view->getShort($vtable));
$field_offset = $offset + $view->getShort($vtable + $vtable_offset);
switch ($choice) {
case 0:
$assert->strictEqual(!!$view->getBool($field_offset), $bool_val);
break;
case 1:
$assert->strictEqual($view->getSbyte($field_offset), $char_val);
break;
case 2:
$assert->strictEqual($view->getByte($field_offset), $uchar_val);
break;
case 3:
$assert->strictEqual($view->getShort($field_offset), $short_val);
//.........这里部分代码省略.........