var tests=[
// array(format, test val, test good result)
['%{toto:2}', 'abcdef', 'ab'],
['%{toto:3:-2}', 'abcdef', 'bc'],
['%{toto:1:0}', 'abcdef', 'bcdef'],
['%{toto:-2}', 'abcdef', 'ef'],
['%{toto:-3:2}', 'abcdef', 'de'],
['%{toto:-1}', 'abcdef', 'f'],
['%{toto!}', 'tiTé', 'TITÉ'],
['%{toto_}', 'tiTé', 'tité'],
['%{toto~}', 'tiTé', 'tiTe'],
['%{toto%}', 'tiTé', '<a>tiTé'],
['%{toto!%}', 'tiTé', '<A>TITÉ'],
['%{toto!~}', 'tiTé', 'TITE'],
['%{toto!~%}', 'tiTé', '<A>TITE'],
['%{toto:1!%}', 'tiTé', '<'],
['%{toto:1:0!~}', 'tiTé', 'A>TITE'],
['%{toto:-3!~%}', 'tiTé', 'ITE'],
['%{toto:-3:2!~%}', 'tiTé', 'IT'],
];
var nb_tests = tests.length;
for (i = 0; i < nb_tests; i++) {
var result = getFData(tests[i][0], tests[i][1]);
var ok = 'OK';
if (result != tests[i][2]) {
ok = "\n\t!!!! NOK !!!!";
}
console.log('Test ('+i+') : "'+tests[i][0]+'" ('+tests[i][2]+') : "'+tests[i][1]+'" -> "'+result+'" => '+ok);
}