PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php

29 lines
903 B
PHP
Raw Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering;
use PhpOffice\PhpSpreadsheet\Calculation\Engineering;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PHPUnit\Framework\TestCase;
class ParseComplexTest extends TestCase
{
2020-04-27 10:28:36 +00:00
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
}
2020-05-18 04:49:57 +00:00
public function testParseComplex(): void
{
[$real, $imaginary, $suffix] = [1.23e-4, 5.67e+8, 'j'];
$result = Engineering::parseComplex('1.23e-4+5.67e+8j');
2020-05-18 04:49:57 +00:00
self::assertArrayHasKey('real', $result);
self::assertEquals($real, $result['real']);
self::assertArrayHasKey('imaginary', $result);
self::assertEquals($imaginary, $result['imaginary']);
self::assertArrayHasKey('suffix', $result);
self::assertEquals($suffix, $result['suffix']);
}
}