本文整理匯總了PHP中Assert::strictEqual方法的典型用法代碼示例。如果您正苦於以下問題:PHP Assert::strictEqual方法的具體用法?PHP Assert::strictEqual怎麽用?PHP Assert::strictEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assert
的用法示例。
在下文中一共展示了Assert::strictEqual方法的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);
//.........這裏部分代碼省略.........