public function testByteBoundaryDecimalVarint()
{
// Create the table
$query = "CREATE TABLE {$this->tableNamePrefix} (key timeuuid PRIMARY KEY, value_decimal decimal, value_varint varint)";
$this->session->execute(new SimpleStatement($query));
// Iterate through a few byte boundary positive values
foreach (range(1, 20) as $i) {
// Assign the values for the statement
$key = new Timeuuid();
$value_varint = pow(2, 8 * $i) - 1;
$value_decimal = $value_varint / 100;
$values = array($key, new Decimal($value_decimal), new Varint($value_varint));
// Insert the value into the table
$query = "INSERT INTO {$this->tableNamePrefix} (key, value_decimal, value_varint) VALUES (?, ?, ?)";
$statement = new SimpleStatement($query);
$options = new ExecutionOptions(array("arguments" => $values));
$this->session->execute($statement, $options);
// Select the decimal and varint
$query = "SELECT value_decimal, value_varint FROM {$this->tableNamePrefix} WHERE key=?";
$statement = new SimpleStatement($query);
$options = new ExecutionOptions(array("arguments" => array($key)));
$rows = $this->session->execute($statement, $options);
// Ensure the decimal and varint are valid
$this->assertCount(1, $rows);
$row = $rows->first();
$this->assertNotNull($row);
$this->assertArrayHasKey("value_decimal", $row);
$this->assertEquals($values[1], $row["value_decimal"]);
$this->assertArrayHasKey("value_varint", $row);
$this->assertEquals($values[2], $row["value_varint"]);
}
}