Android Open Source - Sensoria Test Float Formatter






From Project

Back to project page Sensoria.

License

The source code is released under:

MIT License

If you think the Android project Sensoria listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.grocs.sensors.ui;
/*  ww w.j a v  a 2s.com*/
import com.grocs.sensors.ui.FloatFormatter;

import junit.framework.TestCase;

public class TestFloatFormatter extends TestCase {
  public void testPrecisionOnDefaultConstructor() {
    FloatFormatter ff = new FloatFormatter();
    assertEquals("+3", ff.doConvert((float) 3.4567));
    assertEquals("-3", ff.doConvert((float) -3.4567));
    assertEquals("+5", ff.doConvert((float) 4.5678));
    assertEquals("-5", ff.doConvert((float) -4.5678));
  }

  public void testPrecisionZero() {
    FloatFormatter ff = new FloatFormatter(0);
    assertEquals("+3", ff.doConvert((float) 3.4567));
    assertEquals("-3", ff.doConvert((float) -3.4567));
    assertEquals("+5", ff.doConvert((float) 4.5678));
    assertEquals("-5", ff.doConvert((float) -4.5678));
  }

  public void testPrecisionOne() {
    FloatFormatter ff = new FloatFormatter(1);
    assertEquals("+2.3", ff.doConvert((float) 2.3456));
    assertEquals("-2.3", ff.doConvert((float) -2.3456));
    assertEquals("+3.5", ff.doConvert((float) 3.4567));
    assertEquals("-3.5", ff.doConvert((float) -3.4567));
  }

  public void testPrecisionTwo() {
    FloatFormatter ff = new FloatFormatter(2);
    assertEquals("+1.23", ff.doConvert((float) 1.2345));
    assertEquals("-1.23", ff.doConvert((float) -1.2345));
    assertEquals("+2.35", ff.doConvert((float) 2.3456));
    assertEquals("-2.35", ff.doConvert((float) -2.3456));
  }

  public void testPrecisionMinusOne() {
    try {
      new FloatFormatter(-1);
    } catch (IllegalArgumentException iae) {
      return;
    } catch (Throwable t) {
    }
    fail("exception expected here !");
  }
}




Java Source Code List

com.grocs.sensors.common.FloatConvertor.java
com.grocs.sensors.common.ISensorData.java
com.grocs.sensors.common.ISensorDescription.java
com.grocs.sensors.common.SensorCollector.java
com.grocs.sensors.common.SensorConstants.java
com.grocs.sensors.common.SensorDataComparator.java
com.grocs.sensors.common.SensorDataManagerListener.java
com.grocs.sensors.common.SensorDataManager.java
com.grocs.sensors.common.SensorData.java
com.grocs.sensors.common.SensorDescriptions.java
com.grocs.sensors.common.SensorFilter.java
com.grocs.sensors.common.SensorUtils.java
com.grocs.sensors.common.TestFloatConvertor.java
com.grocs.sensors.ui.ActivityDetail.java
com.grocs.sensors.ui.Activity.java
com.grocs.sensors.ui.EntryAdapter.java
com.grocs.sensors.ui.FloatFormatter.java
com.grocs.sensors.ui.SensorEntryComparator.java
com.grocs.sensors.ui.SensorEntry.java
com.grocs.sensors.ui.SensorPreferenceActivity.java
com.grocs.sensors.ui.TestFloatFormatter.java