More tests
This commit is contained in:
parent
41ab0cf4ac
commit
23a52719b9
|
@ -40,4 +40,8 @@ b5c5767469746c656476706572736f6e12757468696e6711416559426c61636b77656c6cb4746461
|
|||
c411121314
|
||||
c41e1f1011
|
||||
c75568656c6c6f75746865726565776f726c64c0d00100
|
||||
ce0000000000000000000000000000
|
||||
cf0f000000000000000000000000000000
|
||||
cf6400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
cfc8010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
e8716111516201c31112136163e27a66697273742d6e616d6559456c697a6162657468e2777375726e616d6559426c61636b77656c6c
|
||||
|
|
|
@ -28,6 +28,12 @@ describe('hex samples', () => {
|
|||
.filter((h) => h)
|
||||
.map((h) => Buffer.from(h, 'hex'));
|
||||
|
||||
function manyFalses(n) {
|
||||
return List().withMutations((l) => {
|
||||
for (let i = 0; i < n; i++) { l.push(false); }
|
||||
});
|
||||
}
|
||||
|
||||
// As new samples are added to samples.txt, we will need to update this list:
|
||||
const samplesExpected = [
|
||||
{ expected: new Single(1), },
|
||||
|
@ -43,7 +49,7 @@ describe('hex samples', () => {
|
|||
{ expected: Buffer.from("hello"), encodesTo: '6568656c6c6f', },
|
||||
{ expected: Buffer.from("hello"), encodesTo: '6568656c6c6f', },
|
||||
{ expected: Buffer.from("hello"), encodesTo: '6568656c6c6f', },
|
||||
{ expected: List([1, 2, 3, 4]), encodesTo: 'c411121314', },
|
||||
{ expected: Immutable.Seq([1, 2, 3, 4]), },
|
||||
{ expected: fromJS([["a", 1], ["b", 2], ["c", 3]]), encodesTo: 'c3c2516111c2516212c2516313', },
|
||||
{ expected: 13, },
|
||||
{ expected: 127, },
|
||||
|
@ -75,6 +81,10 @@ describe('hex samples', () => {
|
|||
{ expected: List([-2, -1, 0, 1]), },
|
||||
{ expected:
|
||||
fromJS(["hello", Symbol.for('there'), Buffer.from('world'), [], Set(), true, false]), },
|
||||
{ expected: manyFalses(14), },
|
||||
{ expected: manyFalses(15), },
|
||||
{ expected: manyFalses(100), },
|
||||
{ expected: manyFalses(200), },
|
||||
{ expected:
|
||||
Map()
|
||||
.set(Symbol.for('a'), 1)
|
|
@ -191,3 +191,11 @@ class CodecTests(unittest.TestCase):
|
|||
bs = _e(d.items())
|
||||
self.assertRegex(_hex(bs), r)
|
||||
self.assertEqual(sorted(_d(bs)), [(u'a', 1), (u'b', 2), (u'c', 3)])
|
||||
|
||||
def test_long_sequence(self):
|
||||
# Short enough to not need a varint:
|
||||
self._roundtrip((False,) * 14, _buf(0xCE, b'\x00' * 14))
|
||||
# Varint-needing:
|
||||
self._roundtrip((False,) * 15, _buf(0xCF, 0x0F, b'\x00' * 15))
|
||||
self._roundtrip((False,) * 100, _buf(0xCF, 0x64, b'\x00' * 100))
|
||||
self._roundtrip((False,) * 200, _buf(0xCF, 0xC8, 0x01, b'\x00' * 200))
|
||||
|
|
Loading…
Reference in New Issue