source: trip-planner-front/node_modules/buffer-indexof/test/test.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 987 bytes
RevLine 
[6a3a178]1var test = require('tape');
2var bindexOf = require('../');
3
4test("can haz working",function(t){
5
6
7 var newLineBuffer = new Buffer("\n");
8
9 var b = new Buffer("hi\nho\nsilver");
10
11 t.equals(bindexOf(new Buffer('a'), new Buffer('abc')), -1, 'should not match')
12
13
14 t.equals(bindexOf(new Buffer('aaa'), new Buffer('aa'), 2), -1, 'should not match with 2 offset')
15 t.equals(bindexOf(new Buffer('aaa'), new Buffer('aa')), 0, 'should match')
16
17 t.equals(bindexOf(b,newLineBuffer),2,'should find newlines');
18
19 // you can also start from index
20
21 t.equals(bindexOf(b,newLineBuffer,3),5,"should find newlines after offset");
22
23 // no match === -1
24
25 t.equals(bindexOf(b,newLineBuffer,6),-1,"should not find newlines where none are.");
26
27
28 t.end();
29})
30
31
32test("can handle overlapping matches",function(t){
33 console.log(1,'aaaba'.indexOf('aaba'))
34 console.log(2,bindexOf(new Buffer('aaaba'), new Buffer('aaba')))
35 console.log(3,(new Buffer('aaaba')).indexOf(new Buffer('aaba')))
36 t.end()
37})
Note: See TracBrowser for help on using the repository browser.