File tree Expand file tree Collapse file tree 5 files changed +16
-8
lines changed
main/java/org/msgpack/value Expand file tree Collapse file tree 5 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -521,6 +521,13 @@ public Variable setFloatValue(double v) {
521521 return this ;
522522 }
523523
524+ public Variable setFloatValue (float v ) {
525+ this .type = Type .DOUBLE ;
526+ this .accessor = floatAccessor ;
527+ this .longValue = (long ) v ; // AbstractNumberValueAccessor uses longValue
528+ return this ;
529+ }
530+
524531 private class FloatValueAccessor extends AbstractNumberValueAccessor implements FloatValue {
525532 @ Override
526533 public FloatValue asFloatValue () {
Original file line number Diff line number Diff line change @@ -128,8 +128,8 @@ class MessagePackerTest extends MessagePackSpec {
128128 def test (bufferSize : Int , stringSize : Int ): Boolean = {
129129 val msgpack = new MessagePack (new MessagePack .ConfigBuilder ().packerBufferSize(bufferSize).build)
130130 val str = " a" * stringSize
131- val rawString = ValueFactory .newRawString (str.getBytes(" UTF-8" ))
132- val array = ValueFactory .newArray (rawString)
131+ val rawString = ValueFactory .newString (str.getBytes(" UTF-8" ))
132+ val array = ValueFactory .newArrayOf (rawString)
133133 val out = new ByteArrayOutputStream ()
134134 val packer = msgpack.newPacker(out)
135135 packer.packValue(array)
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class RawStringValueImplTest extends MessagePackSpec {
77 " StringValue" should {
88 " return the same hash code if they are equal" in {
99 val str = " a"
10- val a1 = ValueFactory .newRawString (str.getBytes(" UTF-8" ))
10+ val a1 = ValueFactory .newString (str.getBytes(" UTF-8" ))
1111 val a2 = ValueFactory .newString(str)
1212
1313 a1.shouldEqual(a2)
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class RawValueImplTest extends MessagePackSpec {
99 " RawValueImple" should {
1010 " toString shouldn't return empty value" in {
1111 val str = " aaa"
12- def newRawStr () = ValueFactory .newRawString (str.getBytes(" UTF-8" ))
12+ def newRawStr () = ValueFactory .newString (str.getBytes(" UTF-8" ))
1313
1414 def pack (v : Value ): Array [Byte ] = {
1515 val out = new ByteArrayOutputStream ()
@@ -28,7 +28,7 @@ class RawValueImplTest extends MessagePackSpec {
2828 {
2929 val rawStr = newRawStr()
3030 pack(rawStr)
31- rawStr.asString ().toString shouldBe str
31+ rawStr.asStringValue ().toString shouldBe str
3232 }
3333 }
3434 }
Original file line number Diff line number Diff line change 11package org .msgpack .value .holder
22
33import org .msgpack .core .MessagePackSpec
4+ import org .msgpack .value .Variable
45
56/**
67 *
@@ -11,13 +12,13 @@ class FloatHolderTest extends MessagePackSpec {
1112
1213 " display value in an appropriate format" in {
1314
14- val h = new FloatHolder
15+ val h = new Variable
1516 val f = 0.1341f
16- h.setFloat (f)
17+ h.setFloatValue (f)
1718 h.toString shouldBe java.lang.Float .toString(f)
1819
1920 val d = 0.1341341344
20- h.setDouble (d)
21+ h.setFloatValue (d)
2122 h.toString shouldBe java.lang.Double .toString(d)
2223 }
2324
You can’t perform that action at this time.
0 commit comments