3 Copyright 2002, 2003 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 The GNU MP Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
45 { "0x12345678", 4,1, 1,1, 0, { '\22', '\64', '\126', '\170' } },
46 { "0x12345678", 1,1, 4,1, 0, { '\22', '\64', '\126', '\170' } },
47 { "0x12345678", 1,-1, 4,1, 0, { '\22', '\64', '\126', '\170' } },
49 { "0x12345678", 4,-1, 1,-1, 0, { '\170', '\126', '\064', '\22' } },
50 { "0x12345678", 1,1, 4,-1, 0, { '\170', '\126', '\064', '\22' } },
51 { "0x12345678", 1,-1, 4,-1, 0, { '\170', '\126', '\064', '\22' } },
53 { "0", 5,1, 1,1, 7, { '\376', '\376', '\376', '\376', '\376' } },
54 { "0", 5,-1, 1,1, 7, { '\376', '\376', '\376', '\376', '\376' } },
55 { "0x15", 5,1, 1,1, 7, { '\377', '\376', '\377', '\376', '\377' } },
57 { "0", 3,1, 2,1, 1, { '\200','\000', '\200','\000', '\200','\000' }},
58 { "0", 3,1, 2,-1, 1, { '\000','\200', '\000','\200', '\000','\200' }},
59 { "0", 3,1, 2,1, 15, { '\377','\376', '\377','\376', '\377','\376' }},
61 { "0x2A", 3,1, 2,1, 14, { '\377','\376', '\377','\376', '\377','\376' } },
62 { "0x06", 3,1, 2,1, 14, { '\377','\374', '\377','\375', '\377','\376' } },
63 { "0x24", 3,-1, 2,1, 14, { '\377','\374', '\377','\375', '\377','\376' } },
65 { "0x123456789ABC", 3,1, 2,1, 0, {
66 '\022','\064', '\126','\170', '\232','\274' } },
67 { "0x123456789ABC", 3,-1, 2,1, 0, {
68 '\232','\274', '\126','\170', '\022','\064' } },
69 { "0x123456789ABC", 3,1, 2,-1, 0, {
70 '\064','\022', '\170','\126', '\274','\232' } },
71 { "0x123456789ABC", 3,-1, 2,-1, 0, {
72 '\274','\232', '\170','\126', '\064','\022' } },
74 { "0x112233445566778899AABBCC", 3,1, 4,1, 0,
75 { '\021','\042','\063','\104',
76 '\125','\146','\167','\210',
77 '\231','\252','\273','\314' } },
78 { "0x112233445566778899AABBCC", 3,-1, 4,1, 0,
79 { '\231','\252','\273','\314',
80 '\125','\146','\167','\210',
81 '\021','\042','\063','\104' } },
82 { "0x112233445566778899AABBCC", 3,1, 4,-1, 0,
83 { '\104','\063','\042','\021',
84 '\210','\167','\146','\125',
85 '\314','\273','\252','\231' } },
86 { "0x112233445566778899AABBCC", 3,-1, 4,-1, 0,
87 { '\314','\273','\252','\231',
88 '\210','\167','\146','\125',
89 '\104','\063','\042','\021' } },
91 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,1, 8,1, 0,
92 { '\020','\001','\040','\002','\060','\003','\100','\004',
93 '\120','\005','\140','\006','\160','\007','\200','\010',
94 '\220','\011','\240','\012','\260','\013','\300','\014' } },
95 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,-1, 8,1, 0,
96 { '\220','\011','\240','\012','\260','\013','\300','\014',
97 '\120','\005','\140','\006','\160','\007','\200','\010',
98 '\020','\001','\040','\002','\060','\003','\100','\004' } },
99 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,1, 8,-1, 0,
100 { '\004','\100','\003','\060','\002','\040','\001','\020',
101 '\010','\200','\007','\160','\006','\140','\005','\120',
102 '\014','\300','\013','\260','\012','\240','\011','\220' } },
103 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,-1, 8,-1, 0,
104 { '\014','\300','\013','\260','\012','\240','\011','\220',
105 '\010','\200','\007','\160','\006','\140','\005','\120',
106 '\004','\100','\003','\060','\002','\040','\001','\020' } },
108 { "0x155555555555555555555555", 3,1, 4,1, 1,
109 { '\325','\125','\125','\125',
110 '\252','\252','\252','\252',
111 '\325','\125','\125','\125' } },
112 { "0x155555555555555555555555", 3,-1, 4,1, 1,
113 { '\325','\125','\125','\125',
114 '\252','\252','\252','\252',
115 '\325','\125','\125','\125' } },
116 { "0x155555555555555555555555", 3,1, 4,-1, 1,
117 { '\125','\125','\125','\325',
118 '\252','\252','\252','\252',
119 '\125','\125','\125','\325' } },
120 { "0x155555555555555555555555", 3,-1, 4,-1, 1,
121 { '\125','\125','\125','\325',
122 '\252','\252','\252','\252',
123 '\125','\125','\125','\325' } },
126 char buf[sizeof(data[0].src) + sizeof (mp_limb_t)];
135 for (i = 0; i < numberof (data); i++)
137 for (align = 0; align < sizeof (mp_limb_t); align++)
139 mpz_set_str_or_abort (want, data[i].want, 0);
141 memcpy (src, data[i].src, data[i].count * data[i].size);
143 mpz_set_ui (got, 0L);
144 mpz_import (got, data[i].count, data[i].order,
145 data[i].size, data[i].endian, data[i].nail, src);
147 MPZ_CHECK_FORMAT (got);
148 if (mpz_cmp (got, want) != 0)
150 printf ("wrong at data[%d]\n", i);
151 printf (" count=%lu order=%d size=%lu endian=%d nail=%u align=%lu\n",
152 (unsigned long) data[i].count, data[i].order,
153 (unsigned long) data[i].size, data[i].endian, data[i].nail,
154 (unsigned long) align);
155 mpz_trace (" got ", got);
156 mpz_trace (" want", want);