@@ -101,7 +101,7 @@ public function test_validate_success($value, $min, $max, $decpoint = '.')
101101 public function valueProvider ()
102102 {
103103 return array (
104- // $value, $expect, $roundto, $decpoint, $thousands, $trimzeros, $prefix='', $postfix=''
104+ // $value, $expect, $roundto, $decpoint, $thousands, $trimzeros, $prefix='', $postfix='', $engineering = false
105105 array ('5000 ' , '5 000,00 ' , '2 ' , ', ' , ' ' , false ),
106106 array ('5000 ' , '5 000 ' , '2 ' , ', ' , ' ' , true ),
107107 array ('5000 ' , '5 000 ' , '0 ' , ', ' , ' ' , false ),
@@ -117,21 +117,46 @@ public function valueProvider()
117117
118118 array ('-0.55600 ' , '$ -0,556 ' , '4 ' , ', ' , ' ' , true , '$ ' ),
119119 array ('-0.55600 ' , '-0,556 EUR ' , '4 ' , ', ' , ' ' , true , '' , ' EUR ' ),
120+
121+ //engineering notation
122+ array ('1e-18 ' , '1 ' ."\xE2\x80\xAF" .'a ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
123+ array ('1e-15 ' , '1 ' ."\xE2\x80\xAF" .'f ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
124+ array ('1e-12 ' , '1 ' ."\xE2\x80\xAF" .'p ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
125+ array ('1e-9 ' , '1 ' ."\xE2\x80\xAF" .'n ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
126+ array ('1e-6 ' , '1 ' ."\xE2\x80\xAF" .'µ ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
127+ array ('1e-3 ' , '1 ' ."\xE2\x80\xAF" .'m ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
128+
129+ array ('1e3 ' , '1 ' ."\xE2\x80\xAF" .'k ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
130+ array ('1e6 ' , '1 ' ."\xE2\x80\xAF" .'M ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
131+ array ('1e9 ' , '1 ' ."\xE2\x80\xAF" .'G ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
132+ array ('1e12 ' , '1 ' ."\xE2\x80\xAF" .'T ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
133+
134+ array ('1e4 ' , '10 ' . "\xE2\x80\xAF" .'k ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
135+ array ('1e5 ' , '100 ' ."\xE2\x80\xAF" .'k ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
136+
137+ array ('1e-4 ' , '100 ' ."\xE2\x80\xAF" .'µ ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
138+ array ('1e-5 ' , '10 ' . "\xE2\x80\xAF" .'µ ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
139+
140+ //test behaviour if number exceeds prefix array
141+ array ('1e15 ' , '1000 ' . "\xE2\x80\xAF" .'T ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
142+ array ('1e-21 ' , '0.001 ' ."\xE2\x80\xAF" .'a ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ),
143+
120144 );
121145 }
122146
123147 /**
124148 * @dataProvider valueProvider
125149 */
126- public function test_renderValue ($ value , $ expect , $ roundto , $ decpoint , $ thousands , $ trimzeros , $ prefix = '' , $ postfix = '' )
150+ public function test_renderValue ($ value , $ expect , $ roundto , $ decpoint , $ thousands , $ trimzeros , $ prefix = '' , $ postfix = '' , $ engineering = false )
127151 {
128152 $ decimal = new Decimal (array (
129153 'roundto ' => $ roundto ,
130154 'decpoint ' => $ decpoint ,
131155 'thousands ' => $ thousands ,
132156 'trimzeros ' => $ trimzeros ,
133157 'prefix ' => $ prefix ,
134- 'postfix ' => $ postfix
158+ 'postfix ' => $ postfix ,
159+ 'engineering ' => $ engineering
135160 ));
136161 $ R = new \Doku_Renderer_xhtml ();
137162 $ R ->doc = '' ;
0 commit comments