clean up atoX a little and add testing
This commit is contained in:
Родитель
58a2ec60c6
Коммит
4499c52fca
|
@ -3715,25 +3715,17 @@ LibraryManager.library = {
|
|||
|
||||
atof__deps: ['strtod'],
|
||||
atof: function(ptr) {
|
||||
var str = Pointer_stringify(ptr);
|
||||
return _strtod(ptr, null);
|
||||
},
|
||||
|
||||
atoi__deps: ['strtol'],
|
||||
atoi: function(ptr) {
|
||||
var str = Pointer_stringify(ptr);
|
||||
return _strtol(ptr, null, 10);
|
||||
},
|
||||
|
||||
atol__deps: ['strtol'],
|
||||
atol: function(ptr) {
|
||||
var str = Pointer_stringify(ptr);
|
||||
return _strtol(ptr, null, 10);
|
||||
},
|
||||
atol: 'atoi',
|
||||
|
||||
atoll__deps: ['strtoll'],
|
||||
atoll: function(ptr) {
|
||||
var str = Pointer_stringify(ptr);
|
||||
return _strtoll(ptr, null, 10);
|
||||
},
|
||||
|
||||
|
|
|
@ -4022,7 +4022,9 @@ at function.:blag
|
|||
'''
|
||||
self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
|
||||
|
||||
def test_atoi(self):
|
||||
def test_atoX(self):
|
||||
if Settings.QUANTUM_SIZE != 4: return self.skip('need q4 for atoll')
|
||||
|
||||
src = r'''
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -4039,10 +4041,33 @@ at function.:blag
|
|||
printf("%d*", atoi(" 3 7"));
|
||||
printf("%d*", atoi("9 d"));
|
||||
printf("%d\n", atoi(" 8 e"));
|
||||
printf("%d*", atol(""));
|
||||
printf("%d*", atol("a"));
|
||||
printf("%d*", atol(" b"));
|
||||
printf("%d*", atol(" c "));
|
||||
printf("%d*", atol("6"));
|
||||
printf("%d*", atol(" 5"));
|
||||
printf("%d*", atol("4 "));
|
||||
printf("%d*", atol("3 6"));
|
||||
printf("%d*", atol(" 3 7"));
|
||||
printf("%d*", atol("9 d"));
|
||||
printf("%d\n", atol(" 8 e"));
|
||||
printf("%lld*", atoll("6294967296"));
|
||||
printf("%lld*", atoll(""));
|
||||
printf("%lld*", atoll("a"));
|
||||
printf("%lld*", atoll(" b"));
|
||||
printf("%lld*", atoll(" c "));
|
||||
printf("%lld*", atoll("6"));
|
||||
printf("%lld*", atoll(" 5"));
|
||||
printf("%lld*", atoll("4 "));
|
||||
printf("%lld*", atoll("3 6"));
|
||||
printf("%lld*", atoll(" 3 7"));
|
||||
printf("%lld*", atoll("9 d"));
|
||||
printf("%lld\n", atoll(" 8 e"));
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
self.do_run(src, '0*0*0*0*6*5*4*3*3*9*8')
|
||||
self.do_run(src, '0*0*0*0*6*5*4*3*3*9*8\n0*0*0*0*6*5*4*3*3*9*8\n6294967296*0*0*0*0*6*5*4*3*3*9*8\n')
|
||||
|
||||
def test_strstr(self):
|
||||
src = r'''
|
||||
|
|
Загрузка…
Ссылка в новой задаче