-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent really small speed values so that they are not displayed in s…
…cientific notation in JSON messages
- Loading branch information
1 parent
fd46869
commit 66085f2
Showing
8 changed files
with
120 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
networksurvey/src/test/java/com/craxiom/networksurvey/util/FormatUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.craxiom.networksurvey.util; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class FormatUtilsTest | ||
{ | ||
@Test | ||
public void formatSpeed_withSpeed() | ||
{ | ||
float inputSpeed = 15.5f; | ||
float formattedSpeed = FormatUtils.formatSpeed(inputSpeed); | ||
assertEquals(15.5f, formattedSpeed, 0.0f); | ||
} | ||
|
||
@Test | ||
public void formatSpeed_withLowSpeed() | ||
{ | ||
float inputSpeed = 0.5f; | ||
float formattedSpeed = FormatUtils.formatSpeed(inputSpeed); | ||
assertEquals(0.5f, formattedSpeed, 0.0f); | ||
} | ||
|
||
@Test | ||
public void formatSpeed_withoutSpeed() | ||
{ | ||
float inputSpeed = 10000000f; | ||
float formattedSpeed = FormatUtils.formatSpeed(inputSpeed); | ||
assertEquals(10000000f, formattedSpeed, 0.0f); | ||
} | ||
|
||
@Test | ||
public void formatSpeed_smallSpeed() | ||
{ | ||
float inputSpeed = 0.000000000000082499864f; | ||
float formattedSpeed = FormatUtils.formatSpeed(inputSpeed); | ||
assertEquals(0.0f, formattedSpeed, 0.0f); | ||
|
||
String floatString = Float.toString(formattedSpeed); | ||
assertEquals("0.0", floatString); | ||
} | ||
} | ||
|