From 6f461d71adf21d8d1d3a929d01e0a53b9682d421 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Wed, 2 Jun 2021 11:33:18 +0200 Subject: [PATCH] Additional unit tests for null/empty arguments passed to complex --- unitTests/classes/src/ComplexTest.php | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/unitTests/classes/src/ComplexTest.php b/unitTests/classes/src/ComplexTest.php index 88fe91d..d9992b3 100644 --- a/unitTests/classes/src/ComplexTest.php +++ b/unitTests/classes/src/ComplexTest.php @@ -105,6 +105,36 @@ public function testInstantiateWithArguments() $this->assertEquals('i', $defaultComplexSuffix); } + /** + * @dataProvider providerArguments + */ + public function testInstantiateWithEmptyArguments($expected, $arguments) + { + $complexObject = new Complex(...$arguments); + + $defaultComplexReal = $complexObject->getReal(); + $this->assertEquals($expected[0], $defaultComplexReal); + + $defaultComplexImaginary = $complexObject->getImaginary(); + $this->assertEquals($expected[1], $defaultComplexImaginary); + + $defaultComplexSuffix = $complexObject->getSuffix(); + $this->assertEquals($expected[2], $defaultComplexSuffix); + } + + public function providerArguments() + { + return [ + 'Imaginary with suffix' => [[0.0, 2.34, 'j'], [null, 2.34, 'j']], + 'Imaginary without suffix' => [[0.0, 2.34, 'i'], [null, 2.34]], + 'Imaginary with empty suffix' => [[0.0, 2.34, 'i'], [null, 2.34, '']], + 'Imaginary with null suffix' => [[0.0, 2.34, 'i'], [null, 2.34, null]], + 'Real with suffix' => [[1.23, 0.0, ''], [1.23, null, 'j']], + 'Complex with empty suffix' => [[1.23, 2.34, 'i'], [1.23, 2.34, '']], + 'Complex with null suffix' => [[1.23, 2.34, 'i'], [1.23, 2.34, null]], + ]; + } + public function testInstantiateWithArray() { $complexObject = new Complex(