Skip to content

Commit

Permalink
fixed split tests b00tc4mp#185
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos committed Sep 12, 2024
1 parent bc79788 commit 4295197
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 79 deletions.
58 changes: 0 additions & 58 deletions staff/carlos-bock/chain-characters/slice2.js

This file was deleted.

38 changes: 17 additions & 21 deletions staff/carlos-bock/chain-characters/split.test.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@

const ChainCharacters = require("./");

function compare(array1, array2) {
let result = true;
let i = 0;
if (array1.length !== array2.length) return false;
while (i < array1.length) {
if (array1[i].value !== array2[i]) {
result = false;
}
i++;
function compare(arr1, arr2) {
if (arr1.length !== arr2.length) return false;
let result = true;
let i = 0;
while (i < arr1.length && result === false) {
if (arr1[i] !== arr2[i]) {
result = false;
}
return result;
i++;
}
return result;
}


//const str = 'Esta es una oración que tiene que estar split.';
const str = 'Esta es una oración que tiene que estar split.';
const pattern = "";
const pattern2 = " ";
const pattern3 = "q";
const pattern4 = "e";

//const result1 = split(str, pattern);
//const result2 = split(str, pattern2);
//const result3 = split(str, pattern3);
//const result4 = split(str, pattern4);


const result1 = new ChainCharacters('Esta es una oración que tiene que estar split.').split(pattern);
console.assert(compare(result1, 'Esta es una oración que tiene que estar split.'.split(pattern)),{
const result1 = new ChainCharacters(str).split(pattern);
console.assert(compare(result1, str.split(pattern)),{
result: result1,
message: "Test 1 No pasado ",
});

/*
const result2 = new ChainCharacters(str).split(pattern2);
console.assert(compare(result2, str.split(pattern2)),{
result: result2,
message: "Test 2 No pasado ",
});

const result3 = new ChainCharacters(str).split(pattern3)
console.assert(compare(result3, str.split(pattern3)),{
result: result3,
message: "Test 3 No pasado ",
});

const result4 = new ChainCharacters(str).split(pattern4)
console.assert(compare(result4, str.split(pattern4)),{
result: result4,
message: "Test 3 No pasado ",
});
*/

0 comments on commit 4295197

Please sign in to comment.