All files / src/codec/ber/decoder/primitive ReadBoolean.ts

85.71% Statements 6/7
83.33% Branches 5/6
100% Functions 1/1
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13    1x 5x 1x   4x     4x 4x    
import {CursorDataView} from '../../../../CursorDataView';
 
export function readBoolean(cdv: CursorDataView, length: number) {
  if (length === 0) {
    return null;
  }
  Iif (length !== 1) {
    throw new Error('length must be 1');
  }
  const v = cdv.read();
  return v === 0x00 ? false : true;
}