Skip to content

Commit

Permalink
Adding failing unit test to GeneralizedSuffixArray
Browse files Browse the repository at this point in the history
Related to #196
  • Loading branch information
Yomguithereal committed Oct 4, 2022
1 parent 7c043c2 commit cffb94c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion suffix-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function convert(target) {
}

// Padding the array
for (; i < paddingOffset; i++)
for (i = length; i < length + paddingOffset; i++)
array[i] = 0;

return array;
Expand Down
23 changes: 23 additions & 0 deletions test/suffix-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,27 @@ describe('GeneralizedSuffixArray', function() {
['the', 'mouse']
);
});

it.skip('should work with int values (issue #196).', function() {
var suffixArray = new GeneralizedSuffixArray([
'1234',
'234',
'1234'
]);

var result = suffixArray.longestCommonSubsequence();

assert.deepStrictEqual(result, '234');

// TODO: fix sentinel to be lower than anything else in the token case
suffixArray = new GeneralizedSuffixArray([
[1, 2, 3, 4],
[2, 3, 4],
[1, 2, 3, 4]
]);

result = suffixArray.longestCommonSubsequence();

assert.deepStrictEqual(result, [2, 3, 4]);
});
});

0 comments on commit cffb94c

Please sign in to comment.