Skip to content

Commit fb535ec

Browse files
committed
Added tests for latex formatted units
1 parent 4e1b1a4 commit fb535ec

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/Entity/Parameters/PartParameterTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ public function formattedValueDataProvider(): \Iterator
6767
yield ['10.23 V (9 V ... 11 V) [Test]', 9, 10.23, 11, 'V', 'Test'];
6868
}
6969

70+
public function formattedValueWithLatexDataProvider(): \Iterator
71+
{
72+
yield ['Text Test', null, null, null, 'V', 'Text Test'];
73+
yield ['10.23 $\mathrm{V}$', null, 10.23, null, 'V', ''];
74+
yield ['10.23 $\mathrm{V}$ [Text]', null, 10.23, null, 'V', 'Text'];
75+
yield ['max. 10.23 $\mathrm{V}$', null, null, 10.23, 'V', ''];
76+
yield ['max. 10.23 [Text]', null, null, 10.23, '', 'Text'];
77+
yield ['min. 10.23 $\mathrm{V}$', 10.23, null, null, 'V', ''];
78+
yield ['10.23 $\mathrm{V}$ ... 11 $\mathrm{V}$', 10.23, null, 11, 'V', ''];
79+
yield ['10.23 $\mathrm{V}$ (9 $\mathrm{V}$ ... 11 $\mathrm{V}$)', 9, 10.23, 11, 'V', ''];
80+
yield ['10.23 $\mathrm{V}$ (9 $\mathrm{V}$ ... 11 $\mathrm{V}$) [Test]', 9, 10.23, 11, 'V', 'Test'];
81+
}
82+
7083
/**
7184
* @dataProvider valueWithUnitDataProvider
7285
*/
@@ -117,4 +130,22 @@ public function testGetFormattedValue(string $expected, ?float $min, ?float $typ
117130
$param->setValueText($text);
118131
$this->assertSame($expected, $param->getFormattedValue());
119132
}
133+
134+
/**
135+
* @dataProvider formattedValueWithLatexDataProvider
136+
*
137+
* @param float $min
138+
* @param float $typical
139+
* @param float $max
140+
*/
141+
public function testGetFormattedValueWithLatex(string $expected, ?float $min, ?float $typical, ?float $max, string $unit, string $text): void
142+
{
143+
$param = new PartParameter();
144+
$param->setUnit($unit);
145+
$param->setValueMin($min);
146+
$param->setValueTypical($typical);
147+
$param->setValueMax($max);
148+
$param->setValueText($text);
149+
$this->assertSame($expected, $param->getFormattedValue(true));
150+
}
120151
}

0 commit comments

Comments
 (0)