Last active
November 13, 2017 07:21
-
-
Save klauszhang/e2f4f64960557cb570a3fba2a7f2a809 to your computer and use it in GitHub Desktop.
a validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1357 just a random number to get thing started | |
const sut = require('./index')(1357); | |
// should have 1000 elements | |
if (sut.size !== 1000) { | |
console.log(sut.size); | |
console.error('something goes wrong...'); | |
} | |
// should have no duplicate numbers | |
[ | |
/11/, | |
/22/, | |
/33/, | |
/44/, | |
/55/, | |
/66/, | |
/77/, | |
/88/, | |
/99/, | |
/00/ | |
].forEach(regex => { | |
sut.forEach(item => { | |
if (regex.test(item)) { | |
console.log(item); | |
console.error('something goes wrong...'); | |
} | |
}); | |
}); | |
// should have no consecutive numbers | |
Array.from(sut).forEach(item => { | |
const numArray = item | |
.toString() | |
.split('') | |
.map(item => parseInt(item)); | |
[0, 1, 2].forEach(index => { | |
if ( | |
numArray[index] === | |
numArray[index + 1] - 1 | |
) { | |
console.log(item); | |
console.error('something goes wrong...'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment