packb supports use_single_float option.

This commit is contained in:
INADA Naoki 2012-09-21 14:15:30 +09:00
parent 397d772e11
commit 51335bbee4
3 changed files with 16 additions and 3 deletions

View file

@ -2,6 +2,7 @@
# coding: utf-8
import six
import struct
from nose import main
from nose.tools import *
from nose.plugins.skip import SkipTest
@ -86,5 +87,9 @@ def testDecodeBinary():
re = unpackb(packb("abc"), encoding=None)
assert_equal(re, b"abc")
def testPackFloat():
assert_equal(packb(1.0, use_single_float=True), b'\xca' + struct.pack('>f', 1.0))
assert_equal(packb(1.0, use_single_float=False), b'\xcb' + struct.pack('>d', 1.0))
if __name__ == '__main__':
main()