Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : Boolean.js
const {Boolean, uint8, DecodeStream, EncodeStream} = require('../');
const should = require('chai').should();
const concat = require('concat-stream');

describe('Boolean', function() {
  describe('decode', function() {
    it('should decode 0 as false', function() {
      const stream = new DecodeStream(Buffer.from([0]));
      const boolean = new Boolean(uint8);
      return boolean.decode(stream).should.equal(false);
    });

    return it('should decode 1 as true', function() {
      const stream = new DecodeStream(Buffer.from([1]));
      const boolean = new Boolean(uint8);
      return boolean.decode(stream).should.equal(true);
    });
  });

  describe('size', () =>
    it('should return given type size', function() {
      const stream = new DecodeStream(Buffer.from([0]));
      const boolean = new Boolean(uint8);
      return boolean.size().should.equal(1);
    })
  );

  return describe('encode', function() {
    it('should encode false as 0', function(done) {
      const stream = new EncodeStream;
      const boolean = new Boolean(uint8);
      stream.pipe(concat(function(buf) {
        buf.should.deep.equal(Buffer.from([0]));
        return done();
      })
      );

      boolean.encode(stream, false);
      return stream.end();
    });

    return it('should encode true as 1', function(done) {
      const stream = new EncodeStream;
      const boolean = new Boolean(uint8);
      stream.pipe(concat(function(buf) {
        buf.should.deep.equal(Buffer.from([1]));
        return done();
      })
      );

      boolean.encode(stream, true);
      return stream.end();
    });
  });
});
© 2026 GrazzMean