Blame view

node_modules/msgpack5/test/booleans.js 761 Bytes
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  'use strict'
  
  var test = require('tape').test
  var msgpack = require('../')
  
  test('encode/decode booleans', function (t) {
    var encoder = msgpack()
  
    t.equal(encoder.encode(true)[0], 0xc3, 'encode true as 0xc3')
    t.equal(encoder.encode(true).length, 1, 'encode true as a buffer of length 1')
    t.equal(encoder.decode(new Buffer([0xc3])), true, 'decode 0xc3 as true')
    t.equal(encoder.decode(encoder.encode(true)), true, 'mirror test true')
  
    t.equal(encoder.encode(false)[0], 0xc2, 'encode false as 0xc2')
    t.equal(encoder.encode(false).length, 1, 'encode false as a buffer of length 1')
    t.equal(encoder.decode(new Buffer([0xc2])), false, 'decode 0xc2 as false')
    t.equal(encoder.decode(encoder.encode(false)), false, 'mirror test false')
  
    t.end()
  })