remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
remix-project/remix-lib/test/util.js

31 lines
784 B

'use strict'
var tape = require('tape')
var util = require('../src/util')
tape('Util', function (t) {
t.test('lowerbound', function (st) {
st.plan(7)
var array = [2, 5, 8, 9, 45, 56, 78]
var lowerBound = util.findLowerBound(10, array)
st.equal(lowerBound, 3)
lowerBound = util.findLowerBound(3, array)
st.equal(lowerBound, 0)
lowerBound = util.findLowerBound(100, array)
st.equal(lowerBound, 6)
lowerBound = util.findLowerBound(1, array)
st.equal(lowerBound, -1)
lowerBound = util.findLowerBound(45, array)
st.equal(lowerBound, 4)
array = [2, 5, 8, 9, 9, 45, 56, 78]
lowerBound = util.findLowerBound(9, array)
st.equal(lowerBound, 4)
lowerBound = util.findLowerBound(9, [])
st.equal(lowerBound, -1)
})
})