From fb535ec6f7908dc0164de23978307e5692deec62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 29 Mar 2025 12:37:17 +0100 Subject: [PATCH] Added tests for latex formatted units --- tests/Entity/Parameters/PartParameterTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/Entity/Parameters/PartParameterTest.php b/tests/Entity/Parameters/PartParameterTest.php index c42b3cbe..0e426d52 100644 --- a/tests/Entity/Parameters/PartParameterTest.php +++ b/tests/Entity/Parameters/PartParameterTest.php @@ -67,6 +67,19 @@ class PartParameterTest extends TestCase yield ['10.23 V (9 V ... 11 V) [Test]', 9, 10.23, 11, 'V', 'Test']; } + public function formattedValueWithLatexDataProvider(): \Iterator + { + yield ['Text Test', null, null, null, 'V', 'Text Test']; + yield ['10.23 $\mathrm{V}$', null, 10.23, null, 'V', '']; + yield ['10.23 $\mathrm{V}$ [Text]', null, 10.23, null, 'V', 'Text']; + yield ['max. 10.23 $\mathrm{V}$', null, null, 10.23, 'V', '']; + yield ['max. 10.23 [Text]', null, null, 10.23, '', 'Text']; + yield ['min. 10.23 $\mathrm{V}$', 10.23, null, null, 'V', '']; + yield ['10.23 $\mathrm{V}$ ... 11 $\mathrm{V}$', 10.23, null, 11, 'V', '']; + yield ['10.23 $\mathrm{V}$ (9 $\mathrm{V}$ ... 11 $\mathrm{V}$)', 9, 10.23, 11, 'V', '']; + yield ['10.23 $\mathrm{V}$ (9 $\mathrm{V}$ ... 11 $\mathrm{V}$) [Test]', 9, 10.23, 11, 'V', 'Test']; + } + /** * @dataProvider valueWithUnitDataProvider */ @@ -117,4 +130,22 @@ class PartParameterTest extends TestCase $param->setValueText($text); $this->assertSame($expected, $param->getFormattedValue()); } + + /** + * @dataProvider formattedValueWithLatexDataProvider + * + * @param float $min + * @param float $typical + * @param float $max + */ + public function testGetFormattedValueWithLatex(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void + { + $param = new PartParameter(); + $param->setUnit($unit); + $param->setValueMin($min); + $param->setValueTypical($typical); + $param->setValueMax($max); + $param->setValueText($text); + $this->assertSame($expected, $param->getFormattedValue(true)); + } }