Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@ public int hashCode() {

@Override
public String toString() {
return Double.toString(value);
switch(tpe) {
case FLOAT:
return Float.toString((float) value);
case DOUBLE:
return Double.toString(value);
default:
throw new IllegalStateException("cannto reach here");
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.msgpack.value.holder

import org.msgpack.core.MessagePackSpec

/**
*
*/
class FloatHolderTest extends MessagePackSpec {

"FloatHolder" should {

"display value in an appropriate format" in {

val h = new FloatHolder
val f = 0.1341f
h.setFloat(f)
h.toString shouldBe java.lang.Float.toString(f)

val d = 0.1341341344
h.setDouble(d)
h.toString shouldBe java.lang.Double.toString(d)
}

}

}