34 'negativeValue' => array(0, -10),
35 'normalValue' => array(30, 30),
36 'veryHighValue' => array(2000000000, PHP_INT_MAX),
37 'zeroValue' => array(0, 0),
38 'anotherNormalValue' => array(12309, 12309)
84 'int' => array(32425),
85 'negative int' => array(-32425),
86 'largest int' => array(PHP_INT_MAX),
87 'int as string' => array(
'32425'),
88 'negative int as string' => array(
'-32425'),
90 'zero as string' => array(
'0')
108 $objectWithNumericalStringRepresentation = new \TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\MathUtilityTestClassWithStringRepresentationFixture();
109 $objectWithNumericalStringRepresentation->setString(
'1234');
110 $objectWithNonNumericalStringRepresentation = new \TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\MathUtilityTestClassWithStringRepresentationFixture();
111 $objectWithNonNumericalStringRepresentation->setString(
'foo');
112 $objectWithEmptyStringRepresentation = new \TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\MathUtilityTestClassWithStringRepresentationFixture();
113 $objectWithEmptyStringRepresentation->setString(
'');
115 'int as string with leading zero' => array(
'01234'),
116 'positive int as string with plus modifier' => array(
'+1234'),
117 'negative int as string with leading zero' => array(
'-01234'),
118 'largest int plus one' => array(PHP_INT_MAX + 1),
119 'string' => array(
'testInt'),
120 'empty string' => array(
''),
121 'int in string' => array(
'5 times of testInt'),
122 'int as string with space after' => array(
'5 '),
123 'int as string with space before' => array(
' 5'),
124 'int as string with many spaces before' => array(
' 5'),
125 'float' => array(3.14159),
126 'float as string' => array(
'3.14159'),
127 'float as string only a dot' => array(
'10.'),
128 'float as string trailing zero would evaluate to int 10' => array(
'10.0'),
129 'float as string trailing zeros would evaluate to int 10' => array(
'10.00'),
130 'null' => array(NULL),
131 'empty array' => array(array()),
132 'int in array' => array(array(32425)),
133 'int as string in array' => array(array(
'32425')),
134 'object without string representation' => array(
new \stdClass()),
135 'object with numerical string representation' => array($objectWithNumericalStringRepresentation),
136 'object without numerical string representation' => array($objectWithNonNumericalStringRepresentation),
137 'object with empty string representation' => array($objectWithEmptyStringRepresentation)
160 $floatTestcases = array(
161 'zero as float' => array((
float) 0),
162 'negative float' => array((
float) -7.5),
163 'negative float as string with exp #1' => array(
'-7.5e3'),
164 'negative float as string with exp #2' => array(
'-7.5e03'),
165 'negative float as string with exp #3' => array(
'-7.5e-3'),
166 'float' => array(3.14159),
167 'float as string' => array(
'3.14159'),
168 'float as string only a dot' => array(
'10.'),
169 'float as string trailing zero' => array(
'10.0'),
170 'float as string trailing zeros' => array(
'10.00'),
172 return array_merge($intTestcases, $floatTestcases);
189 $objectWithNumericalStringRepresentation = new \TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\MathUtilityTestClassWithStringRepresentationFixture();
190 $objectWithNumericalStringRepresentation->setString(
'1234');
191 $objectWithNonNumericalStringRepresentation = new \TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\MathUtilityTestClassWithStringRepresentationFixture();
192 $objectWithNonNumericalStringRepresentation->setString(
'foo');
193 $objectWithEmptyStringRepresentation = new \TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\MathUtilityTestClassWithStringRepresentationFixture();
194 $objectWithEmptyStringRepresentation->setString(
'');
200 'string' => array(
'testInt'),
201 'empty string' => array(
''),
202 'int in string' => array(
'5 times of testInt'),
203 'int as string with space after' => array(
'5 '),
204 'int as string with space before' => array(
' 5'),
205 'int as string with many spaces before' => array(
' 5'),
206 'null' => array(NULL),
207 'empty array' => array(array()),
208 'int in array' => array(array(32425)),
209 'int as string in array' => array(array(
'32425')),
210 'negative float as string with invalid chars in exponent' => array(
'-7.5eX3'),
211 'object without string representation' => array(
new \stdClass()),
212 'object with numerical string representation' => array($objectWithNumericalStringRepresentation),
213 'object without numerical string representation' => array($objectWithNonNumericalStringRepresentation),
214 'object with empty string representation' => array($objectWithEmptyStringRepresentation)
236 'add' => array(9,
'6 + 3'),
237 'substract with positive result' => array(3,
'6 - 3'),
238 'substract with negative result' => array(-3,
'3 - 6'),
239 'multiply' => array(6,
'2 * 3'),
240 'divide' => array(2.5,
'5 / 2'),
241 'modulus' => array(1,
'5 % 2'),
242 'power' => array(8,
'2 ^ 3'),
243 'three operands with non integer result' => array(6.5,
'5 + 3 / 2'),
244 'three operands with power' => array(14,
'5 + 3 ^ 2'),
245 'three operads with modulus' => array(4,
'5 % 2 + 3'),
246 'four operands' => array(3,
'2 + 6 / 2 - 2'),
247 'division by zero when dividing' => array(
'ERROR: dividing by zero',
'2 / 0'),
248 'division by zero with modulus' => array(
'ERROR: dividing by zero',
'2 % 0')
270 'starts with parenthesis' => array(18,
'(6 + 3) * 2'),
271 'ends with parenthesis' => array(6,
'2 * (6 - 3)'),
272 'multiple parentheses' => array(-6,
'(3 - 6) * (4 - 2)'),
273 'nested parentheses' => array(22,
'2 * (3 + 2 + (3 * 2))'),
274 'parenthesis with division' => array(15,
'5 / 2 * (3 * 2)')
322 'negative integer' => array(-1),
323 'float' => array(1.5),
324 'string' => array(
'string'),
325 'array' => array(array()),
326 'object' => array(
new \stdClass()),
327 'boolean FALSE' => array(FALSE),
328 'NULL' => array(NULL)
functionCanBeInterpretedAsFloatValidDataProvider()
canBeInterpretedAsIntegerReturnsFalse($int)
calculateWithPriorityToAdditionAndSubtractionCorrectlyCalculatesExpression($expected, $expression)
forceIntegerInRangeSetsDefaultValueIfZeroValueIsGiven()
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
static canBeInterpretedAsFloat($var)
functionCanBeInterpretedAsIntegerInvalidDataProvider()
isIntegerInRangeRejectsOtherDataTypesDataProvider()
static canBeInterpretedAsInteger($var)
isIntegerInRangeRejectsValueOutsideOfRange()
convertToPositiveIntegerReturnsZeroForNegativeValues()
functionCanBeInterpretedAsIntegerValidDataProvider()
calculateWithParenthesesCorrectlyCalculatesExpression($expected, $expression)
static calculateWithPriorityToAdditionAndSubtraction($string)
static calculateWithParentheses($string)
calculateWithPriorityToAdditionAndSubtractionDataProvider()
isIntegerInRangeAcceptsValueInRange()
isIntegerInRangeRejectsOtherDataTypes($inputValue)
functionCanBeInterpretedAsFloatInvalidDataProvider()
canBeInterpretedAsIntegerReturnsTrue($int)
isIntegerInRangeIncludesLowerBoundary()
canBeInterpretedAsFloatReturnsTrue($val)
calculateWithParenthesesDataProvider()
forceIntegerInRangeForcesIntegerIntoDefaultBoundariesDataProvider()
static isIntegerInRange($value, $minimum, $maximum)
canBeInterpretedAsFloatReturnsFalse($int)
static convertToPositiveInteger($theInt)
isIntegerInRangeIncludesUpperBoundary()
forceIntegerInRangeForcesIntegerIntoDefaultBoundaries($expected, $value)
convertToPositiveIntegerReturnsTheInputValueForPositiveValues()