1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
// Copyright INRIA
//test format %i %d
if sscanf('123','%i')<>123 then bugmes();quit;end
if sscanf(' 123','%i')<>123 then bugmes();quit;end
if sscanf('123','%2i')<>12 then bugmes();quit;end
if sscanf('123','%0i')<>123 then bugmes();quit;end
if sscanf('123','%5i')<>123 then bugmes();quit;end
//test format %u
if sscanf('+123','%u')<>123 then bugmes();quit;end
if sscanf(' 123','%2u')<>12 then bugmes();quit;end
if sscanf('123','%0u')<>123 then bugmes();quit;end
if sscanf('+123','%5u')<>123 then bugmes();quit;end
//test format %e %f %g
if sscanf('123','%e')<>123 then bugmes();quit;end
if sscanf(' 123','%e')<>123 then bugmes();quit;end
if sscanf('123','%2e')<>12 then bugmes();quit;end
if sscanf('123','%0e')<>123 then bugmes();quit;end
if sscanf('123','%5e')<>123 then bugmes();quit;end
//test format %s
if sscanf('123','%s')<>'123' then bugmes();quit;end
if sscanf(' 123','%s')<>'123' then bugmes();quit;end
if sscanf('123','%2s')<>'12' then bugmes();quit;end
if sscanf('123','%0s')<>'123' then bugmes();quit;end
if sscanf('123','%5s')<>'123' then bugmes();quit;end
//test format %o
if sscanf('123','%o')<>83 then bugmes();quit;end
if sscanf(' 123','%o')<>83 then bugmes();quit;end
if sscanf('123','%2o')<>10 then bugmes();quit;end
if sscanf('123','%0o')<>83 then bugmes();quit;end
if sscanf('123','%5o')<>83 then bugmes();quit;end
//test format %x
if sscanf('123','%x')<>291 then bugmes();quit;end
if sscanf(' 123','%x')<>291 then bugmes();quit;end
if sscanf('123','%2x')<>18 then bugmes();quit;end
if sscanf('123','%0x')<>291 then bugmes();quit;end
if sscanf('123','%5x')<>291 then bugmes();quit;end
//test format %c
if sscanf('123','%c')<>'1' then bugmes();quit;end
if sscanf(' 123','%c')<>' ' then bugmes();quit;end
if sscanf('123','%0c')<>'1' then bugmes();quit;end
//test des format complexes
if sscanf('123 4','%*s%s')<>'4' then bugmes();quit;end
if sscanf('123 4','123%e')<>4 then bugmes();quit;end
[a,b,c]=sscanf('xxxxx 4 test 23.45','xxxxx%i%s%e')
c =
23.45
b =
test
a =
4.
if a<>4|b<>'test'|c<>23.45 then bugmes();quit;end
[a,b]=sscanf('123\n456','%e%e')
b =
456.
a =
123.
if a<>123|b<>456 then bugmes();quit;end
|