UNPKG

@fusioncharts/datatable

Version:

In memory tabular data storage

1 lines 2.08 kB
"use strict";var _sortedSearch=require("./sorted-search");var data=[1,1,2,2,2,4,4,5,6,7,7,7,7,7,7,9,9,9,9,11,12,12,13,16];describe("Search utility on sorted data",(function(){it("Search 6 with leftMostExactOrGreater - should be 8",(function(){expect((0,_sortedSearch.leftMostExactOrGreater)(6,data,(function(a,b){return a-b}),0,data.length)).toBe(8)}));it("Search 6 with rightMostExactOrLesser - should be 8",(function(){expect((0,_sortedSearch.rightMostExactOrLesser)(6,data,(function(a,b){return a-b}),0,data.length)).toBe(8)}));it("Search 7 with leftMostExactOrGreater - should be 9",(function(){expect((0,_sortedSearch.leftMostExactOrGreater)(7,data,(function(a,b){return a-b}),0,data.length)).toBe(9)}));it("Search 7 with rightMostExactOrLesser - should be 14",(function(){expect((0,_sortedSearch.rightMostExactOrLesser)(7,data,(function(a,b){return a-b}),0,data.length)).toBe(14)}));it("Search 3 with leftMostExactOrGreater - should be 5",(function(){expect((0,_sortedSearch.leftMostExactOrGreater)(3,data,(function(a,b){return a-b}),0,data.length)).toBe(5)}));it("Search 3 with rightMostExactOrLesser - should be 4",(function(){expect((0,_sortedSearch.rightMostExactOrLesser)(3,data,(function(a,b){return a-b}),0,data.length)).toBe(4)}));var compositeObject=[["buick skylark 320",15,8,350,165,3693,11.5,"1970-01-01","USA"],["buick skylark 320",15,8,350,165,3693,11.5,"1970-01-01","USA"],["amc rebel sst",16,8,304,150,3433,12,"1970-01-01","USA"],["amc rebel sst",16,8,304,150,3433,12,"1970-01-01","USA"],["ford torino",17,8,302,140,3449,10.5,"1970-01-01","USA"],["ford torino",17,8,302,140,3449,10.5,"1970-01-01","USA"],["chevrolet chevelle malibu",18,8,307,130,3504,12,"1970-01-01","USA"],["plymouth satellite",18,8,318,150,3436,11,"1970-01-01","USA"],["chevrolet chevelle malibu",18,8,307,130,3504,12,"1970-01-01","USA"],["plymouth satellite",18,8,318,150,3436,11,"1970-01-01","USA"]];it("Check the position of 18",(function(){expect((0,_sortedSearch.rightMostExactOrLesser)(18,compositeObject,(function(a,b){return a[1]-b[1]}),2,compositeObject.length)).toBe(9)}))}));