Skip to content
Snippets Groups Projects
Commit 8799c54c authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] Test MathUtility::canBeInterpretedAsInteger() with bool

Add test cases to see how canBeInterpretedAsInteger()
returns with bool input.

Change-Id: I7b0c8e959660170ee20e845d932da896d82b27d6
Resolves: #103176
Releases: main
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83077


Tested-by: default avatarMathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarMathias Brodala <mbrodala@pagemachine.de>
Tested-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent b9d67ade
Branches
Tags
No related merge requests found
......@@ -23,14 +23,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
final class MathUtilityTest extends UnitTestCase
{
//////////////////////////////////
// Tests concerning forceIntegerInRange
//////////////////////////////////
/**
* Data provider for forceIntegerInRangeForcesIntegerIntoBoundaries
*
* @return array expected values, arithmetic expression
*/
public static function forceIntegerInRangeForcesIntegerIntoDefaultBoundariesDataProvider(): array
{
return [
......@@ -59,9 +51,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertEquals(42, MathUtility::forceIntegerInRange('', 0, 2000000000, 42));
}
//////////////////////////////////
// Tests concerning convertToPositiveInteger
//////////////////////////////////
/**
* @test
*/
......@@ -78,14 +67,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertEquals(123, MathUtility::convertToPositiveInteger(123));
}
///////////////////////////////
// Tests concerning canBeInterpretedAsInteger
///////////////////////////////
/**
* Data provider for canBeInterpretedAsIntegerReturnsTrue
*
* @return array Data sets
*/
public static function functionCanBeInterpretedAsIntegerValidDataProvider(): array
{
return [
......@@ -96,6 +77,7 @@ final class MathUtilityTest extends UnitTestCase
'negative int as string' => ['-32425'],
'zero' => [0],
'zero as string' => ['0'],
'true' => [true],
];
}
......@@ -108,11 +90,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertTrue(MathUtility::canBeInterpretedAsInteger($int));
}
/**
* Data provider for canBeInterpretedAsIntegerReturnsFalse
*
* @return array Data sets
*/
public static function functionCanBeInterpretedAsIntegerInvalidDataProvider(): array
{
$objectWithNumericalStringRepresentation = new MathUtilityTestClassWithStringRepresentationFixture();
......@@ -138,6 +115,7 @@ final class MathUtilityTest extends UnitTestCase
'float as string trailing zero would evaluate to int 10' => ['10.0'],
'float as string trailing zeros would evaluate to int 10' => ['10.00'],
'null' => [null],
'false' => [false],
'empty array' => [[]],
'int in array' => [[32425]],
'int as string in array' => [['32425']],
......@@ -157,9 +135,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertFalse(MathUtility::canBeInterpretedAsInteger($int));
}
///////////////////////////////
// Tests concerning canBeInterpretedAsFloat
///////////////////////////////
public static function functionCanBeInterpretedAsFloatValidDataProvider(): array
{
// testcases for Integer apply for float as well
......@@ -188,11 +163,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertTrue(MathUtility::canBeInterpretedAsFloat($val));
}
/**
* Data provider for canBeInterpretedAsFloatReturnsFalse
*
* @return array Data sets
*/
public static function functionCanBeInterpretedAsFloatInvalidDataProvider(): array
{
$objectWithNumericalStringRepresentation = new MathUtilityTestClassWithStringRepresentationFixture();
......@@ -233,14 +203,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertFalse(MathUtility::canBeInterpretedAsFloat($int));
}
//////////////////////////////////
// Tests concerning calculateWithPriorityToAdditionAndSubtraction
//////////////////////////////////
/**
* Data provider for calculateWithPriorityToAdditionAndSubtraction
*
* @return array expected values, arithmetic expression
*/
public static function calculateWithPriorityToAdditionAndSubtractionDataProvider(): array
{
return [
......@@ -269,14 +231,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertEquals($expected, MathUtility::calculateWithPriorityToAdditionAndSubtraction($expression));
}
//////////////////////////////////
// Tests concerning calcParenthesis
//////////////////////////////////
/**
* Data provider for calcParenthesis
*
* @return array expected values, arithmetic expression
*/
public static function calculateWithParenthesesDataProvider(): array
{
return [
......@@ -297,9 +251,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertEquals($expected, MathUtility::calculateWithParentheses($expression));
}
//////////////////////////////////
// Tests concerning isIntegerInRange
//////////////////////////////////
/**
* @test
*/
......@@ -332,9 +283,6 @@ final class MathUtilityTest extends UnitTestCase
self::assertFalse(MathUtility::isIntegerInRange(10, 1, 2));
}
/**
* Data provider or isIntegerInRangeRejectsOtherDataTypes
*/
public static function isIntegerInRangeRejectsOtherDataTypesDataProvider(): array
{
return [
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment