Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // checks our test conditions
- // @param - condition (function) test to run
- // @param - ref (string) to display for result
- assert = function (condition, ref){
- if(condition){
- console.log("+ Passed: " + ref);
- } else {
- console.log("- Failed: " + ref, 'warn');
- }
- };
- // tests that special characters \r, \n have been
- // removed from a string
- testsRemoveSpecialCharactersFromString = function (){
- var specialString = '\rI am \nreally\n\rspecial\r\n dont_you_think_so? maybe-not';
- assert(specialString.indexOf('_') > -1, '_ in string');
- assert(specialString.indexOf('?') > -1, '? in string');
- assert(specialString.indexOf('-') > -1, '- in string');
- assert(specialString.indexOf('\r') > -1, '\\r in string');
- assert(specialString.indexOf('\n') > -1, '\\n in string');
- assert(specialString.removeSpecialCharacters().indexOf('?') == -1, '\? removed from string');
- assert(specialString.removeSpecialCharacters().indexOf('-') == -1, '\- removed from string');
- assert(specialString.removeSpecialCharacters().indexOf('_') == -1, '\_ removed from string');
- assert(specialString.removeSpecialCharacters().indexOf('\r') == -1, '\\r removed from string');
- assert(specialString.removeSpecialCharacters().indexOf('\n') == -1, '\\n removed from string');
- };
Add Comment
Please, Sign In to add comment