-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
40 lines (36 loc) · 835 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict'
var test = require('tape')
var nextLine = require('./')
var strings = [
'a\nb\nc\nd\n\ne',
'a\rb\rc\rd\r\re',
'a\r\nb\r\nc\r\nd\r\n\r\ne',
'a\r\nb\nc\rd\r\n\ne',
'a\r\nb\rc\nd\r\n\re'
]
strings.forEach(function (str, index) {
test('string ' + index, function (t) {
var next = nextLine(str)
t.equal(next(), 'a')
t.equal(next(), 'b')
t.equal(next(), 'c')
t.equal(next(), 'd')
t.equal(next(), '')
t.equal(next(), 'e')
t.equal(next(), null)
t.end()
})
})
strings.forEach(function (str, index) {
test('buffer ' + index, function (t) {
var next = nextLine(new Buffer(str))
t.equal(next(), 'a')
t.equal(next(), 'b')
t.equal(next(), 'c')
t.equal(next(), 'd')
t.equal(next(), '')
t.equal(next(), 'e')
t.equal(next(), null)
t.end()
})
})