Skip to content

Commit

Permalink
Add tests for BINARY_NUMBER_RE
Browse files Browse the repository at this point in the history
  • Loading branch information
sourrust committed Apr 18, 2015
1 parent 2509a2e commit 378fc6d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ describe('hljs', function() {
require('./regex/underscoreIdent');
require('./regex/number');
require('./regex/cNumber');
require('./regex/binaryNumber');
});
25 changes: 25 additions & 0 deletions test/regex/binaryNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

var hljs = require('../../build');

var pattern = new RegExp(hljs.BINARY_NUMBER_RE + '$');

describe('.BINARY_NUMBER_RE', function() {
it('should match binary numbers', function() {
var numbers = [ '0b0101', '0b1100', '0b1001'
, '0b11110101', '0b11001111'
, '0b1010111111000001'
];

numbers.should.matchEach(pattern);
});

it('should not match binary numbers greater than 2', function() {
var numbers = [ '0b2101', '0b1130', '0b1041'
, '0b11150101', '0b11061111'
, '0b1010111117000001'
];

numbers.should.not.matchEach(pattern);
});
});

0 comments on commit 378fc6d

Please sign in to comment.