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/. */
46 { "0x12345678", 4,1, 1,1, 0, { '\022', '\064', '\126', '\170' } },
47 { "0x12345678", 1,1, 4,1, 0, { '\022', '\064', '\126', '\170' } },
48 { "0x12345678", 1,-1, 4,1, 0, { '\022', '\064', '\126', '\170' } },
50 { "0x12345678", 4,-1, 1,-1, 0, { '\170', '\126', '\064', '\022' } },
51 { "0x12345678", 1,1, 4,-1, 0, { '\170', '\126', '\064', '\022' } },
52 { "0x12345678", 1,-1, 4,-1, 0, { '\170', '\126', '\064', '\022' } },
54 { "0x15", 5,1, 1,1, 7, { '\001', '\000', '\001', '\000', '\001' } },
56 { "0x1FFFFFFFFFFF", 3,1, 2,1, 1, {
57 '\177','\377', '\177','\377', '\177','\377' } },
58 { "0x1FFFFFFFFFFF", 3,1, 2,-1, 1, {
59 '\377','\177', '\377','\177', '\377','\177' } },
60 { "0x7", 3,1, 2,1, 15, {
61 '\000','\001', '\000','\001', '\000','\001' } },
62 { "0x7", 3,1, 2,-1, 15, {
63 '\001','\000', '\001','\000', '\001','\000' } },
65 { "0x24", 3,1, 2,1, 14, { '\000','\002', '\000','\001', '\000','\000' }},
66 { "0x24", 3,1, 2,-1, 14, { '\002','\000', '\001','\000', '\000','\000' }},
67 { "0x24", 3,-1, 2,-1, 14, { '\000','\000', '\001','\000', '\002','\000' }},
68 { "0x24", 3,-1, 2,1, 14, { '\000','\000', '\000','\001', '\000','\002' }},
70 { "0x123456789ABC", 3,1, 2,1, 0, {
71 '\022','\064', '\126','\170', '\232','\274' } },
72 { "0x123456789ABC", 3,-1, 2,1, 0, {
73 '\232','\274', '\126','\170', '\022','\064' } },
74 { "0x123456789ABC", 3,1, 2,-1, 0, {
75 '\064','\022', '\170','\126', '\274','\232' } },
76 { "0x123456789ABC", 3,-1, 2,-1, 0, {
77 '\274','\232', '\170','\126', '\064','\022' } },
79 { "0x112233445566778899AABBCC", 3,1, 4,1, 0,
80 { '\021','\042','\063','\104',
81 '\125','\146','\167','\210',
82 '\231','\252','\273','\314' } },
83 { "0x112233445566778899AABBCC", 3,-1, 4,1, 0,
84 { '\231','\252','\273','\314',
85 '\125','\146','\167','\210',
86 '\021','\042','\063','\104' } },
87 { "0x112233445566778899AABBCC", 3,1, 4,-1, 0,
88 { '\104','\063','\042','\021',
89 '\210','\167','\146','\125',
90 '\314','\273','\252','\231' } },
91 { "0x112233445566778899AABBCC", 3,-1, 4,-1, 0,
92 { '\314','\273','\252','\231',
93 '\210','\167','\146','\125',
94 '\104','\063','\042','\021' } },
96 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,1, 8,1, 0,
97 { '\020','\001','\040','\002','\060','\003','\100','\004',
98 '\120','\005','\140','\006','\160','\007','\200','\010',
99 '\220','\011','\240','\012','\260','\013','\300','\014' } },
100 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,-1, 8,1, 0,
101 { '\220','\011','\240','\012','\260','\013','\300','\014',
102 '\120','\005','\140','\006','\160','\007','\200','\010',
103 '\020','\001','\040','\002','\060','\003','\100','\004' } },
104 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,1, 8,-1, 0,
105 { '\004','\100','\003','\060','\002','\040','\001','\020',
106 '\010','\200','\007','\160','\006','\140','\005','\120',
107 '\014','\300','\013','\260','\012','\240','\011','\220' } },
108 { "0x100120023003400450056006700780089009A00AB00BC00C", 3,-1, 8,-1, 0,
109 { '\014','\300','\013','\260','\012','\240','\011','\220',
110 '\010','\200','\007','\160','\006','\140','\005','\120',
111 '\004','\100','\003','\060','\002','\040','\001','\020' } },
113 { "0x155555555555555555555555", 3,1, 4,1, 1,
114 { '\125','\125','\125','\125',
115 '\052','\252','\252','\252',
116 '\125','\125','\125','\125' } },
117 { "0x155555555555555555555555", 3,-1, 4,1, 1,
118 { '\125','\125','\125','\125',
119 '\052','\252','\252','\252',
120 '\125','\125','\125','\125' } },
121 { "0x155555555555555555555555", 3,1, 4,-1, 1,
122 { '\125','\125','\125','\125',
123 '\252','\252','\252','\052',
124 '\125','\125','\125','\125' } },
125 { "0x155555555555555555555555", 3,-1, 4,-1, 1,
126 { '\125','\125','\125','\125',
127 '\252','\252','\252','\052',
128 '\125','\125','\125','\125' } },
131 char buf[sizeof(data[0].src) + sizeof (mp_limb_t) + 128];
134 size_t align, got_count, j;
140 for (i = 0; i < numberof (data); i++)
142 for (align = 0; align < sizeof (mp_limb_t); align++)
144 mpz_set_str_or_abort (src, data[i].src, 0);
145 MPZ_CHECK_FORMAT (src);
146 got_data = buf + align;
148 ASSERT_ALWAYS (data[i].want_count * data[i].size + align
151 memset (got_data, '\0', data[i].want_count * data[i].size);
152 ret = mpz_export (got_data, &got_count, data[i].order,
153 data[i].size, data[i].endian, data[i].nail, src);
157 printf ("return doesn't equal given pointer\n");
160 if (got_count != data[i].want_count)
162 printf ("wrong count\n");
165 if (memcmp (got_data, data[i].want_data, got_count * data[i].size) != 0)
167 printf ("wrong result data\n");
172 printf (" at data[%d] align=%d\n", i, (int) align);
173 printf (" src \"%s\"\n", data[i].src);
174 mpz_trace (" src", src);
175 printf (" order=%d size=%lu endian=%d nail=%u\n",
177 (unsigned long) data[i].size, data[i].endian, data[i].nail);
178 printf (" want count %lu\n", (unsigned long) data[i].want_count);
179 printf (" got count %lu\n", (unsigned long) got_count);
181 for (j = 0; j < data[i].want_count*data[i].size; j++)
182 printf (" 0x%02X,", (unsigned) (unsigned char) data[i].want_data[j]);
185 for (j = 0; j < got_count*data[i].size; j++)
186 printf (" 0x%02X,", (unsigned) (unsigned char) got_data[j]);