summaryrefslogtreecommitdiff
path: root/tests/UnitTests/framework/I18N/testChoiceFormat.php
blob: 8cc3f1d3d7f09ebe2a2e3c75194616975fe48769 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
Prado::using('System.I18N.core.ChoiceFormat');

class testChoiceFormat extends UnitTestCase
{
	function testChoiceFormat()
	{
		$this->UnitTestCase();
	}

	function testChoices()
	{
		$choice = new ChoiceFormat();
		$string = '[0] are no files |[1] is one file |(1,Inf] are {number} files';
		
		$want = 'are no files';
		$this->assertEqual($want, $choice->format($string, 0));

		$want = 'is one file';
		$this->assertEqual($want, $choice->format($string, 1));

		$want = 'are {number} files';
		$this->assertEqual($want, $choice->format($string, 5));

		$this->assertFalse($choice->format($string, -1));

		$string = '{1,2} one two |{3,4} three four |[2,5] two to five inclusive';
		$this->assertEqual($choice->format($string,1),'one two');
		$this->assertEqual($choice->format($string,2.1),'two to five inclusive');
		$this->assertEqual($choice->format($string,3),'three four');
	}
}

?>