/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.epics.util.text;

import java.text.NumberFormat;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;

/**
 *
 * @author carcassi
 */
public class NumberFormatsTest {
    
    public NumberFormatsTest() {
    }

    @Test
    public void format() {
        NumberFormat format = NumberFormats.format(2);
        assertThat(format.format(2.0), equalTo("2.00"));
        assertThat(format.format(Double.NaN), equalTo("NaN"));
        assertThat(format.format(Double.POSITIVE_INFINITY), equalTo("Infinity"));
        assertThat(format.format(Double.NEGATIVE_INFINITY), equalTo("-Infinity"));
        assertThat(NumberFormats.format(2), sameInstance(format));
    }

    @Test
    public void toStringFormat() {
        NumberFormat format = NumberFormats.toStringFormat();
        assertThat(format.format(2.0), equalTo("2.0"));
        assertThat(format.format(Double.NaN), equalTo("NaN"));
        assertThat(format.format(Double.POSITIVE_INFINITY), equalTo("Infinity"));
        assertThat(format.format(Double.NEGATIVE_INFINITY), equalTo("-Infinity"));
        assertThat(NumberFormats.toStringFormat(), sameInstance(format));
    }
}
@@ -157,24 +157,74 @@
 berFormat;%0D%0A
+import static org.hamcrest.CoreMatchers.equalTo;%0D%0A
 import org.j
@@ -231,24 +231,24 @@
 unit.Test;%0D%0A
-
 import stati
@@ -459,24 +459,25 @@
  void format
+1
 () %7B%0D%0A      
@@ -807,32 +807,32 @@
 %22-Infinity%22));%0D%0A
-
         assertTh
@@ -881,32 +881,738 @@
 ormat));%0D%0A    %7D%0D
+%0A    %0D%0A    @Test%0D%0A    public void format2() %7B%0D%0A        NumberFormat f = NumberFormats.format(3);%0D%0A        assertThat(f.format(1234.4567), equalTo(%221234.457%22));%0D%0A        assertThat(f.format(123), equalTo(%22123.000%22));%0D%0A        assertThat(f.format(123.4), equalTo(%22123.400%22));%0D%0A%0D%0A        f = NumberFormats.format(0);%0D%0A        assertThat(f.format(1234.4567), equalTo(%221234%22));%0D%0A        assertThat(f.format(123), equalTo(%22123%22));%0D%0A        assertThat(f.format(123.4), equalTo(%22123%22));%0D%0A%0D%0A        f = NumberFormats.format(4);%0D%0A        assertThat(f.format(1234.4567), equalTo(%221234.4567%22));%0D%0A        assertThat(f.format(123), equalTo(%22123.0000%22));%0D%0A        assertThat(f.format(123.4), equalTo(%22123.4000%22));%0D%0A    %7D%0D
 %0A%0D%0A    @Test%0D%0A  

moving test from pvmanager.util