| 1 | /** |
| 2 | * Copyright (C) 2004-2006 Brad Hards <bradh@frogmouth.net> |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include <QTest> |
| 27 | #include <QtCrypto> |
| 28 | |
| 29 | #ifdef QT_STATICPLUGIN |
| 30 | #include "import_plugins.h" |
| 31 | #endif |
| 32 | |
| 33 | class BigIntUnitTest : public QObject |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | private Q_SLOTS: |
| 38 | void initTestCase(); |
| 39 | void cleanupTestCase(); |
| 40 | void allTests(); |
| 41 | |
| 42 | private: |
| 43 | QCA::Initializer *m_init; |
| 44 | }; |
| 45 | |
| 46 | void BigIntUnitTest::initTestCase() |
| 47 | { |
| 48 | m_init = new QCA::Initializer; |
| 49 | } |
| 50 | |
| 51 | void BigIntUnitTest::cleanupTestCase() |
| 52 | { |
| 53 | delete m_init; |
| 54 | } |
| 55 | |
| 56 | void BigIntUnitTest::allTests() |
| 57 | { |
| 58 | QCA::BigInteger result; |
| 59 | |
| 60 | // Some string conversion tests |
| 61 | QCOMPARE(QCA::BigInteger("255" ).toString(), QCA::BigInteger(255).toString()); |
| 62 | QCOMPARE(QCA::BigInteger("-255" ).toString(), QCA::BigInteger(-255).toString()); |
| 63 | QCOMPARE(QCA::BigInteger("255" ).toString(), QStringLiteral("255" )); |
| 64 | QCOMPARE(QCA::BigInteger("-255" ).toString(), QStringLiteral("-255" )); |
| 65 | QCOMPARE(QCA::BigInteger("255" ), QCA::BigInteger(QCA::BigInteger(255).toArray())); |
| 66 | QCOMPARE(QCA::BigInteger("-255" ), QCA::BigInteger(QCA::BigInteger(-255).toArray())); |
| 67 | |
| 68 | // Some operator tests |
| 69 | QCOMPARE(QCA::BigInteger("255" ) == QCA::BigInteger(255), true); |
| 70 | QCOMPARE(QCA::BigInteger("-255" ) == QCA::BigInteger(-255), true); |
| 71 | QCOMPARE(QCA::BigInteger("256" ) != QCA::BigInteger(255), true); |
| 72 | QCOMPARE(QCA::BigInteger("-256" ) != QCA::BigInteger(-255), true); |
| 73 | |
| 74 | // Some comparison tests |
| 75 | QCA::BigInteger a("4000000000000" ); |
| 76 | QCA::BigInteger b("-4000000000000" ); |
| 77 | QCA::BigInteger c("2000000000000" ); |
| 78 | QCOMPARE(a < b, false); |
| 79 | QCOMPARE(a <= b, false); |
| 80 | QCOMPARE(a.compare(b), 1); |
| 81 | QCOMPARE(a > b, true); |
| 82 | QCOMPARE(a >= b, true); |
| 83 | QCOMPARE(a > c, true); |
| 84 | QCOMPARE(c.compare(b), 1); |
| 85 | QCOMPARE(c.compare(a), -1); |
| 86 | |
| 87 | // Check if the stream operator is any good |
| 88 | QString testString; |
| 89 | QTextStream ts(&testString, QIODevice::WriteOnly); |
| 90 | ts << a << b << c << Qt::endl; |
| 91 | QCOMPARE(testString, QStringLiteral("4000000000000-40000000000002000000000000\n" )); |
| 92 | |
| 93 | // Botan's addition tests |
| 94 | QCOMPARE(QCA::BigInteger(255) += QCA::BigInteger(1), QCA::BigInteger(256)); |
| 95 | result = QCA::BigInteger(255) += QCA::BigInteger(1); |
| 96 | QCOMPARE(result.toString(), QCA::BigInteger(256).toString()); |
| 97 | |
| 98 | result = QCA::BigInteger("65535" ) += QCA::BigInteger("1" ); |
| 99 | QCOMPARE(result.toString(), QStringLiteral("65536" )); |
| 100 | QCOMPARE(result, QCA::BigInteger("65536" )); |
| 101 | |
| 102 | result = QCA::BigInteger("4294967295" ) += QCA::BigInteger(1); |
| 103 | QCOMPARE(result.toString(), QStringLiteral("4294967296" )); |
| 104 | QCOMPARE(result, QCA::BigInteger("4294967296" )); |
| 105 | |
| 106 | result = QCA::BigInteger("18446744073709551615" ) += QCA::BigInteger(1); |
| 107 | QCOMPARE(result.toString(), QStringLiteral("18446744073709551616" )); |
| 108 | QCOMPARE(result, QCA::BigInteger("18446744073709551616" )); |
| 109 | |
| 110 | result = QCA::BigInteger("124536363637272472" ) += QCA::BigInteger("124536363637272472" ); |
| 111 | QCOMPARE(result.toString(), QStringLiteral("249072727274544944" )); |
| 112 | QCOMPARE(result, QCA::BigInteger("249072727274544944" )); |
| 113 | |
| 114 | result = QCA::BigInteger("9223372036854775807" ) += QCA::BigInteger("281474976710655" ); |
| 115 | QCOMPARE(result.toString(), QStringLiteral("9223653511831486462" )); |
| 116 | QCOMPARE(result, QCA::BigInteger("9223653511831486462" )); |
| 117 | |
| 118 | result = QCA::BigInteger("9223372036854775807" ) += QCA::BigInteger("137438953471" ); |
| 119 | QCOMPARE(result.toString(), QStringLiteral("9223372174293729278" )); |
| 120 | QCOMPARE(result, QCA::BigInteger("9223372174293729278" )); |
| 121 | |
| 122 | // Botan's carry tests |
| 123 | result = QCA::BigInteger("340282366920938463463374607431768211455" ) += |
| 124 | QCA::BigInteger("340282366920938463463374607431768211455" ); |
| 125 | QCOMPARE(result.toString(), QStringLiteral("680564733841876926926749214863536422910" )); |
| 126 | QCOMPARE(result, QCA::BigInteger("680564733841876926926749214863536422910" )); |
| 127 | |
| 128 | result = QCA::BigInteger("340282366920938463463374607431768211455" ) += |
| 129 | QCA::BigInteger("340282366920938463463374607431768211450" ); |
| 130 | QCOMPARE(result.toString(), QStringLiteral("680564733841876926926749214863536422905" )); |
| 131 | QCOMPARE(result, QCA::BigInteger("680564733841876926926749214863536422905" )); |
| 132 | |
| 133 | result = QCA::BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639935" ) += |
| 134 | QCA::BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639935" ); |
| 135 | QCOMPARE(result.toString(), |
| 136 | QStringLiteral("231584178474632390847141970017375815706539969331281128078915168015826259279870" )); |
| 137 | QCOMPARE(result, QCA::BigInteger("231584178474632390847141970017375815706539969331281128078915168015826259279870" )); |
| 138 | |
| 139 | result = QCA::BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639935" ) += |
| 140 | QCA::BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639919" ); |
| 141 | QCOMPARE(result.toString(), |
| 142 | QStringLiteral("231584178474632390847141970017375815706539969331281128078915168015826259279854" )); |
| 143 | QCOMPARE(result, QCA::BigInteger("231584178474632390847141970017375815706539969331281128078915168015826259279854" )); |
| 144 | |
| 145 | result = QCA::BigInteger( |
| 146 | "13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858" |
| 147 | "186486050853753882811946569946433649006084095" ) += QCA::BigInteger("18446744073709551616" ); |
| 148 | QCOMPARE(result.toString(), |
| 149 | QStringLiteral("134078079299425970995740249982058461274793658205923933777235614437217640300735469768018742" |
| 150 | "98166903427690031858186486050853753882811946588393177722715635711" )); |
| 151 | QCOMPARE(result, |
| 152 | QCA::BigInteger("13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874" |
| 153 | "298166903427690031858186486050853753882811946588393177722715635711" )); |
| 154 | |
| 155 | result = QCA::BigInteger( |
| 156 | "13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858" |
| 157 | "186486050853753882811946569946433649006084095" ) += QCA::BigInteger("1" ); |
| 158 | QCOMPARE(result.toString(), |
| 159 | QStringLiteral("134078079299425970995740249982058461274793658205923933777235614437217640300735469768018742" |
| 160 | "98166903427690031858186486050853753882811946569946433649006084096" )); |
| 161 | QCOMPARE(result, |
| 162 | QCA::BigInteger("13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874" |
| 163 | "298166903427690031858186486050853753882811946569946433649006084096" )); |
| 164 | |
| 165 | result = QCA::BigInteger( |
| 166 | "-3979427001391940661083482696042714676976618976483847341650296529192053560111268857919862747528477749805933030" |
| 167 | "6128763345008528325994574657552726381901" ) += QCA::BigInteger("-342238655038" ); |
| 168 | QCOMPARE(result.toString(), |
| 169 | QStringLiteral("-39794270013919406610834826960427146769766189764838473416502965291920535601112688579198627" |
| 170 | "475284777498059330306128763345008528325994574657894965036939" )); |
| 171 | QCOMPARE(result, |
| 172 | QCA::BigInteger("-3979427001391940661083482696042714676976618976483847341650296529192053560111268857919862" |
| 173 | "7475284777498059330306128763345008528325994574657894965036939" )); |
| 174 | |
| 175 | result = QCA::BigInteger( |
| 176 | "25110291853498940831251897922987678157346336093292373576945426289097725034326735312448621015537884914" ) += |
| 177 | QCA::BigInteger("-36551081154398645734533965739979697527373251608055056627686956281114038842935173436543461" ); |
| 178 | QCOMPARE( |
| 179 | result.toString(), |
| 180 | QStringLiteral( |
| 181 | "25110291853462389750097499277253144191606356395765000325337371232470038078045621273605685842101341453" )); |
| 182 | QCOMPARE( |
| 183 | result, |
| 184 | QCA::BigInteger( |
| 185 | "25110291853462389750097499277253144191606356395765000325337371232470038078045621273605685842101341453" )); |
| 186 | |
| 187 | result = QCA::BigInteger("27802650352" ) += QCA::BigInteger("660736146705288303126411072388564329913778942" ); |
| 188 | QCOMPARE(result.toString(), QStringLiteral("660736146705288303126411072388564357716429294" )); |
| 189 | QCOMPARE(result, QCA::BigInteger("660736146705288303126411072388564357716429294" )); |
| 190 | |
| 191 | result = QCA::BigInteger( |
| 192 | "-1348245899955041864800954463709881466231496038216683608715424566397833766910915722793041224478985289" ) += |
| 193 | QCA::BigInteger( |
| 194 | "1151714952286618235856515264359526625702022859705853911311473221800833298790436145729926116122727676438617" |
| 195 | "3666571334749062651694592291882972" ); |
| 196 | QCOMPARE(result.toString(), |
| 197 | QStringLiteral("115171495228661823585651526435952662570188803511585840712499312635446231064381299612610444" |
| 198 | "77618561339819775832804423833339858653367812897683" )); |
| 199 | QCOMPARE(result, |
| 200 | QCA::BigInteger("11517149522866182358565152643595266257018880351158584071249931263544623106438129961261044" |
| 201 | "477618561339819775832804423833339858653367812897683" )); |
| 202 | |
| 203 | result = QCA::BigInteger( |
| 204 | "-17540530441681616962868251635133601915039026254996886583618243914226325157426408929602625346567256761818" ) += |
| 205 | QCA::BigInteger("865200427983527245206901810160356641402419461642082623179544681519016990" ); |
| 206 | QCOMPARE(result.toString(), |
| 207 | QStringLiteral("-17540530441681616962868251635132736714611042727751679681808083557584922737964766846979445" |
| 208 | "801885737744828" )); |
| 209 | QCOMPARE(result, |
| 210 | QCA::BigInteger("-1754053044168161696286825163513273671461104272775167968180808355758492273796476684697944" |
| 211 | "5801885737744828" )); |
| 212 | |
| 213 | result = QCA::BigInteger("128844776074298261556398714096948603458177018275051329218555498374" ) += QCA::BigInteger( |
| 214 | "44381631382915087636205223513461060322054892810769796122995361187369527639191715091334647906024675972047519364" |
| 215 | "8" ); |
| 216 | QCOMPARE(result.toString(), |
| 217 | QStringLiteral("443816313829150876362052235134610603220548928236542737304251873430093990488865754371523497" |
| 218 | "335298088939030692022" )); |
| 219 | QCOMPARE(result, |
| 220 | QCA::BigInteger("44381631382915087636205223513461060322054892823654273730425187343009399048886575437152349" |
| 221 | "7335298088939030692022" )); |
| 222 | |
| 223 | result = QCA::BigInteger("1709484189262457846620911889502097055085989595277300243221975568275935717696463" ) += |
| 224 | QCA::BigInteger("-1646592344139809206374540620411514484579951199941360" ); |
| 225 | QCOMPARE(result.toString(), |
| 226 | QStringLiteral("1709484189262457846620911887855504710946180388902759622810461083695984517755103" )); |
| 227 | QCOMPARE(result, |
| 228 | QCA::BigInteger("1709484189262457846620911887855504710946180388902759622810461083695984517755103" )); |
| 229 | |
| 230 | result = QCA::BigInteger( |
| 231 | "32017586542963717616570934157618710254018062780641801520492877117023353895132395250905592913967322327352806288" |
| 232 | "3083030595199153877335714942842" ) += |
| 233 | QCA::BigInteger( |
| 234 | "-2828241696960736089879965882386687935938570856545481227619497640844399275054327390050478930503975773972" ); |
| 235 | QCOMPARE(result.toString(), |
| 236 | QStringLiteral("320175865429637176165709341576187102537352386109457279115048805287846851015385381652510447" |
| 237 | "912053725632683663608028703205148674946831739168870" )); |
| 238 | QCOMPARE(result, |
| 239 | QCA::BigInteger("32017586542963717616570934157618710253735238610945727911504880528784685101538538165251044" |
| 240 | "7912053725632683663608028703205148674946831739168870" )); |
| 241 | |
| 242 | result = QCA::BigInteger( |
| 243 | "-4035398360542181725908295312107496142105415014744259439963377204111754181625695349185753326709217" ) += |
| 244 | QCA::BigInteger("85450213703789913646546187382091037800" ); |
| 245 | QCOMPARE(result.toString(), |
| 246 | QStringLiteral( |
| 247 | "-4035398360542181725908295312107496142105415014744259439963291753898050391712048802998371235671417" )); |
| 248 | QCOMPARE(result, |
| 249 | QCA::BigInteger( |
| 250 | "-4035398360542181725908295312107496142105415014744259439963291753898050391712048802998371235671417" )); |
| 251 | |
| 252 | result = QCA::BigInteger( |
| 253 | "-1292166446073479876801522363382357887431657639184151284775525387363973852756087726243671676713861533673009088" |
| 254 | "319851" ) += |
| 255 | QCA::BigInteger( |
| 256 | "8045388958745181755374994252823750582362455317985903504033438417669555720706432671419456956248951093302427" |
| 257 | "49935754739434394691714971" ); |
| 258 | QCOMPARE(result.toString(), |
| 259 | QStringLiteral("804538895874518174245332979208895181434723168416232462971686202582804287295117879777971842" |
| 260 | "868807383086571073221893205761385603395120" )); |
| 261 | QCOMPARE(result, |
| 262 | QCA::BigInteger("80453889587451817424533297920889518143472316841623246297168620258280428729511787977797184" |
| 263 | "2868807383086571073221893205761385603395120" )); |
| 264 | |
| 265 | result = QCA::BigInteger( |
| 266 | "-4519865887009263094594517568520056973794810149560079685292342518849465226829012150220864325970243240622408355" |
| 267 | "64200177389" ) += QCA::BigInteger("15762983479" ); |
| 268 | QCOMPARE(result.toString(), |
| 269 | QStringLiteral("-45198658870092630945945175685200569737948101495600796852923425188494652268290121502208643" |
| 270 | "2597024324062240835548437193910" )); |
| 271 | QCOMPARE(result, |
| 272 | QCA::BigInteger("-4519865887009263094594517568520056973794810149560079685292342518849465226829012150220864" |
| 273 | "32597024324062240835548437193910" )); |
| 274 | |
| 275 | result = QCA::BigInteger( |
| 276 | "-3907475412115728816974567022055278374116794025624287474334038831885743634200801846649105209920908153587891040" |
| 277 | "882946582394429615396962188674594744360388466" ) += |
| 278 | QCA::BigInteger("193893611236537854694879677478106237157079207398283117392998175454362643521031390" ); |
| 279 | QCOMPARE(result.toString(), |
| 280 | QStringLiteral("-39074754121157288169745670220552783741167940256242874743340388318857436340069082354125673" |
| 281 | "55226028476109784803725867374996146498003964013220232100839357076" )); |
| 282 | QCOMPARE(result, |
| 283 | QCA::BigInteger("-3907475412115728816974567022055278374116794025624287474334038831885743634006908235412567" |
| 284 | "355226028476109784803725867374996146498003964013220232100839357076" )); |
| 285 | |
| 286 | result = QCA::BigInteger("-72603710637966201224690926289" ) += |
| 287 | QCA::BigInteger("-13618442642298533261581255034923612640512507150728017106768861506299813289801666559564532" ); |
| 288 | QCOMPARE( |
| 289 | result.toString(), |
| 290 | QStringLiteral("-13618442642298533261581255034923612640512507150728017106768934110010451256002891250490821" )); |
| 291 | QCOMPARE( |
| 292 | result, |
| 293 | QCA::BigInteger("-13618442642298533261581255034923612640512507150728017106768934110010451256002891250490821" )); |
| 294 | |
| 295 | result = QCA::BigInteger( |
| 296 | "56077960835713056831402948406790747107889446769357509759472207603483968107693997028111823994257399379783658853" |
| 297 | "302692762256851623103019589392739" ) += |
| 298 | QCA::BigInteger("-427057313888431079237360487703561848638868677065083968842" ); |
| 299 | QCOMPARE(result.toString(), |
| 300 | QStringLiteral("560779608357130568314029484067907471078894467693575097594722076034839681076939970281113969" |
| 301 | "36943510948704421492814989200408212754425954505423897" )); |
| 302 | QCOMPARE(result, |
| 303 | QCA::BigInteger("56077960835713056831402948406790747107889446769357509759472207603483968107693997028111396" |
| 304 | "936943510948704421492814989200408212754425954505423897" )); |
| 305 | |
| 306 | result = QCA::BigInteger("-2209800838508504443494783762534800337712101405156784708782197580824527899758308" ) += |
| 307 | QCA::BigInteger( |
| 308 | "4284407650303949586450021392583759850781770841835415277411207859644308960659857039623581632798746339397171" |
| 309 | "0495985285591895096794994387176281079" ); |
| 310 | QCOMPARE(result.toString(), |
| 311 | QStringLiteral("428440765030394958645002139258375985078177084183541527741120785942332887680900659527410325" |
| 312 | "65452663056259609090828500883112899214169859276522771" )); |
| 313 | QCOMPARE(result, |
| 314 | QCA::BigInteger("42844076503039495864500213925837598507817708418354152774112078594233288768090065952741032" |
| 315 | "565452663056259609090828500883112899214169859276522771" )); |
| 316 | |
| 317 | result = QCA::BigInteger( |
| 318 | "33887767308809826842417841176152232321272231788338404526859019370507113927387984766381329515371768224976188337" |
| 319 | "692" ) += QCA::BigInteger("349484339542971517481628970179002500341" ); |
| 320 | QCOMPARE(result.toString(), |
| 321 | QStringLiteral("338877673088098268424178411761522323212722317883384045268590193705071139277374691059243010" |
| 322 | "32853397195155190838033" )); |
| 323 | QCOMPARE(result, |
| 324 | QCA::BigInteger("33887767308809826842417841176152232321272231788338404526859019370507113927737469105924301" |
| 325 | "032853397195155190838033" )); |
| 326 | |
| 327 | result = QCA::BigInteger( |
| 328 | "85748089639858660722587321621536298082690707526412426951630101551228144063151688592419555048867068162" ) += |
| 329 | QCA::BigInteger("-383634567691961960211191292397062452265352651123492760493087381707279" ); |
| 330 | QCOMPARE( |
| 331 | result.toString(), |
| 332 | QStringLiteral( |
| 333 | "85748089639858660722587321621535914448123015564452215760337704488775878710500565099659061961485360883" )); |
| 334 | QCOMPARE( |
| 335 | result, |
| 336 | QCA::BigInteger( |
| 337 | "85748089639858660722587321621535914448123015564452215760337704488775878710500565099659061961485360883" )); |
| 338 | |
| 339 | result = QCA::BigInteger("23889807888563742283608049816129153552608399262924421832404872043475" ) += |
| 340 | QCA::BigInteger("995" ); |
| 341 | QCOMPARE(result.toString(), QStringLiteral("23889807888563742283608049816129153552608399262924421832404872044470" )); |
| 342 | QCOMPARE(result, QCA::BigInteger("23889807888563742283608049816129153552608399262924421832404872044470" )); |
| 343 | |
| 344 | result = QCA::BigInteger( |
| 345 | "-6547869258334748646692309625826942226114726807018592624664656062396549960483067839575496977812718292577743295" |
| 346 | "38985" ) += QCA::BigInteger("-276137507159648540503039013089014674747" ); |
| 347 | QCOMPARE(result.toString(), |
| 348 | QStringLiteral("-65478692583347486466923096258269422261147268070185926246646560623965499604858292146470934" |
| 349 | "6321774868270863344213732" )); |
| 350 | QCOMPARE(result, |
| 351 | QCA::BigInteger("-6547869258334748646692309625826942226114726807018592624664656062396549960485829214647093" |
| 352 | "46321774868270863344213732" )); |
| 353 | |
| 354 | result = QCA::BigInteger("50463316268089933" ) += QCA::BigInteger( |
| 355 | "-1405915834634318069210003494981352875890054233189278509478942429953101385694731575213124136524392343244191305" |
| 356 | "27702899917161307657443381774866237429" ); |
| 357 | QCOMPARE(result.toString(), |
| 358 | QStringLiteral("-14059158346343180692100034949813528758900542331892785094789424299531013856947315752131241" |
| 359 | "3652439234324419130527702899917161307657392918458598147496" )); |
| 360 | QCOMPARE(result, |
| 361 | QCA::BigInteger("-1405915834634318069210003494981352875890054233189278509478942429953101385694731575213124" |
| 362 | "13652439234324419130527702899917161307657392918458598147496" )); |
| 363 | |
| 364 | result = QCA::BigInteger( |
| 365 | "1339015021665554488163337105187026760232395594198925052890859936\ |
| 366 | 418304234254229440059229155546157793544192" ) += |
| 367 | QCA::BigInteger( |
| 368 | "6294037420283433712414743361937677483761554699961644450461297486224793278823004487175687771163597590566132" |
| 369 | "592591599249970281125781761944353272" ); |
| 370 | QCOMPARE(result.toString(), |
| 371 | QStringLiteral("629403742028343371241474336193767748510056972162719893862463459141182003905540008137461282" |
| 372 | "4054457526984436826845828690029510281327919737897464" )); |
| 373 | QCOMPARE(result, |
| 374 | QCA::BigInteger("62940374202834337124147433619376774851005697216271989386246345914118200390554000813746128" |
| 375 | "24054457526984436826845828690029510281327919737897464" )); |
| 376 | |
| 377 | result = QCA::BigInteger("-241446683" ) += QCA::BigInteger( |
| 378 | "-282671163032866994488211995758272717472259277760825940523445628\ |
| 379 | 442206062910449311538519756165635175664610569214430918184214" ); |
| 380 | QCOMPARE(result.toString(), |
| 381 | QStringLiteral("-28267116303286699448821199575827271747225927776082594052344562844220606291044931153851975" |
| 382 | "6165635175664610569214431159630897" )); |
| 383 | QCOMPARE(result, |
| 384 | QCA::BigInteger("-2826711630328669944882119957582727174722592777608259405234456284422060629104493115385197" |
| 385 | "56165635175664610569214431159630897" )); |
| 386 | |
| 387 | result = QCA::BigInteger( |
| 388 | "23586055033034526379960814219020565159517446117183831284424451195057397075503263789123424483550462390668969955" |
| 389 | "63581" ) += |
| 390 | QCA::BigInteger("-3830437229145325165273364525551261440648845791949681661260946956860463720730123941973615" ); |
| 391 | QCOMPARE(result.toString(), |
| 392 | QStringLiteral("235860550330345263799608141807161928680641944644501860289118367885689391560064471765139549" |
| 393 | "1494582518336773053589966" )); |
| 394 | QCOMPARE(result, |
| 395 | QCA::BigInteger("23586055033034526379960814180716192868064194464450186028911836788568939156006447176513954" |
| 396 | "91494582518336773053589966" )); |
| 397 | |
| 398 | result = QCA::BigInteger("1860794367587960058388097846258490" ) += |
| 399 | QCA::BigInteger("-237344494507203983863096991896035366478949095337787603280" ); |
| 400 | QCOMPARE(result.toString(), QStringLiteral("-237344494507203983863095131101667778518890707239941344790" )); |
| 401 | QCOMPARE(result, QCA::BigInteger("-237344494507203983863095131101667778518890707239941344790" )); |
| 402 | |
| 403 | result = QCA::BigInteger("-286399096802321907543674770412181810379003627366516307780436082546" ) += |
| 404 | QCA::BigInteger("6433131620680089024037442172197761714707480582555136398379812339597187475099646442833150194" ); |
| 405 | QCOMPARE( |
| 406 | result.toString(), |
| 407 | QStringLiteral("6433131620680089024037441885798664912385573038880365986198001960593560108583338662397067648" )); |
| 408 | QCOMPARE( |
| 409 | result, |
| 410 | QCA::BigInteger("6433131620680089024037441885798664912385573038880365986198001960593560108583338662397067648" )); |
| 411 | |
| 412 | result = QCA::BigInteger( |
| 413 | "18118033907710236955953781758362789478332280418185972957475244257214680056902377349016498752054120312533829578" |
| 414 | "5763244283224569259250011493" ) += |
| 415 | QCA::BigInteger( |
| 416 | "-119912766577350317025030707802803587547945939765717835695952624506754949712992302334818793328075301820498" |
| 417 | "3010837846725666878521137637491" ); |
| 418 | QCOMPARE(result.toString(), |
| 419 | QStringLiteral("179981211411328866389287510505599858907843344784202551217792916327079251071893850466816799" |
| 420 | "587260450107133312774925397557557690738112374002" )); |
| 421 | QCOMPARE(result, |
| 422 | QCA::BigInteger("17998121141132886638928751050559985890784334478420255121779291632707925107189385046681679" |
| 423 | "9587260450107133312774925397557557690738112374002" )); |
| 424 | |
| 425 | result = QCA::BigInteger( |
| 426 | "-6414020139555553381140864289162018465205127581107592617628203214491558550345077676836677565241902214951203461" |
| 427 | "1311149858695307750874152" ) += QCA::BigInteger("174441039" ); |
| 428 | QCOMPARE(result.toString(), |
| 429 | QStringLiteral("-64140201395555533811408642891620184652051275811075926176282032144915585503450776768366775" |
| 430 | "652419022149512034611311149858695307576433113" )); |
| 431 | QCOMPARE(result, |
| 432 | QCA::BigInteger("-6414020139555553381140864289162018465205127581107592617628203214491558550345077676836677" |
| 433 | "5652419022149512034611311149858695307576433113" )); |
| 434 | |
| 435 | result = QCA::BigInteger( |
| 436 | "12727579443088358572080378780185073375305574454222304955616346165037244198775127175123602392596401935136013522" |
| 437 | "02821462208896049331599624285621" ) += |
| 438 | QCA::BigInteger( |
| 439 | "7326562354017884140300121264633612334070903165496641915889499701\ |
| 440 | 38457507491850467631029977010" ); |
| 441 | QCOMPARE(result.toString(), |
| 442 | QStringLiteral("127275794430883585720803787801850733753055744542296315179703640491775443200397607874576732" |
| 443 | "9576189857705190302172959919716387899799230654262631" )); |
| 444 | QCOMPARE(result, |
| 445 | QCA::BigInteger("12727579443088358572080378780185073375305574454229631517970364049177544320039760787457673" |
| 446 | "29576189857705190302172959919716387899799230654262631" )); |
| 447 | |
| 448 | result = QCA::BigInteger("-296171972628230" ) += QCA::BigInteger( |
| 449 | "-8295766099121843219000823699362222865173820102569731517716391727126741710202086962877467940292139" ); |
| 450 | QCOMPARE(result.toString(), |
| 451 | QStringLiteral( |
| 452 | "-8295766099121843219000823699362222865173820102569731517716391727126741710202086963173639912920369" )); |
| 453 | QCOMPARE(result, |
| 454 | QCA::BigInteger( |
| 455 | "-8295766099121843219000823699362222865173820102569731517716391727126741710202086963173639912920369" )); |
| 456 | |
| 457 | result = QCA::BigInteger("746985914068199510024843682108839444828414222769191520615967632362127522466922882591" ) += |
| 458 | QCA::BigInteger("-20487191102299831461877807785745372724903547246374023" ); |
| 459 | QCOMPARE(result.toString(), |
| 460 | QStringLiteral("746985914068199510024843682108818957637311922937729642808181886989402618919676508568" )); |
| 461 | QCOMPARE(result, |
| 462 | QCA::BigInteger("746985914068199510024843682108818957637311922937729642808181886989402618919676508568" )); |
| 463 | |
| 464 | result = QCA::BigInteger("-4" ) += |
| 465 | QCA::BigInteger("-2344390090753264806043234960981151613122271366762590006930318876906455201397017135" ); |
| 466 | QCOMPARE(result.toString(), |
| 467 | QStringLiteral("-2344390090753264806043234960981151613122271366762590006930318876906455201397017139" )); |
| 468 | QCOMPARE(result, |
| 469 | QCA::BigInteger("-2344390090753264806043234960981151613122271366762590006930318876906455201397017139" )); |
| 470 | |
| 471 | result = QCA::BigInteger("-44876180273995737337769331875058141129678736711749946388832275767882143882764" ) += |
| 472 | QCA::BigInteger("20982187786" ); |
| 473 | QCOMPARE(result.toString(), |
| 474 | QStringLiteral("-44876180273995737337769331875058141129678736711749946388832275767861161694978" )); |
| 475 | QCOMPARE(result, QCA::BigInteger("-44876180273995737337769331875058141129678736711749946388832275767861161694978" )); |
| 476 | |
| 477 | result = QCA::BigInteger( |
| 478 | "-601944008264824351134005823298148744369561537910415436895793990789678217920719566630222862549689727198849" |
| 479 | "4" ) += |
| 480 | QCA::BigInteger( |
| 481 | "532566302499155416003316607801593784583652720754079760364736422291735917382015688217276924340984564880" ); |
| 482 | QCOMPARE(result.toString(), |
| 483 | QStringLiteral("-60189075163457443559240549163736858499110317263834002891975751714744904432898136506140113" |
| 484 | "48572556287423614" )); |
| 485 | QCOMPARE(result, |
| 486 | QCA::BigInteger("-6018907516345744355924054916373685849911031726383400289197575171474490443289813650614011" |
| 487 | "348572556287423614" )); |
| 488 | |
| 489 | result = QCA::BigInteger( |
| 490 | "-7375547156361602684772634935716753083385095966292105905292822923781472871944886871927821129478599825311797681" |
| 491 | "2683153264088230182865250970217610487" ) += |
| 492 | QCA::BigInteger("-30100016097092378349958946184353117306134810372681" ); |
| 493 | QCOMPARE(result.toString(), |
| 494 | QStringLiteral("-73755471563616026847726349357167530833850959662921059052928229237814728719448868719278211" |
| 495 | "294786028353134073905061503223034414535982557105027983168" )); |
| 496 | QCOMPARE(result, |
| 497 | QCA::BigInteger("-7375547156361602684772634935716753083385095966292105905292822923781472871944886871927821" |
| 498 | "1294786028353134073905061503223034414535982557105027983168" )); |
| 499 | |
| 500 | result = QCA::BigInteger( |
| 501 | "-2211177066689704345686852756638946306674958952044447080285364283965878599873864667094550865713828159912" ) += |
| 502 | QCA::BigInteger( |
| 503 | "-536556043937245689200756579876160678199726920153847573681478030051738396345585808165230823703346036004092" |
| 504 | "1820049494698892905680307378540208" ); |
| 505 | QCOMPARE(result.toString(), |
| 506 | QStringLiteral("-53655604393724568920075657987616067842084462682281800825016330571563302701308170336967553" |
| 507 | "17318824644006800419923359365987456546021206700120" )); |
| 508 | QCOMPARE(result, |
| 509 | QCA::BigInteger("-5365560439372456892007565798761606784208446268228180082501633057156330270130817033696755" |
| 510 | "317318824644006800419923359365987456546021206700120" )); |
| 511 | |
| 512 | result = QCA::BigInteger( |
| 513 | "60741225123371088419685216490350768416336915742544171041442859708190687151580370231498672521465704184848502349" |
| 514 | "79838064249373816163440" ) += QCA::BigInteger("301843614094506325875637699" ); |
| 515 | QCOMPARE(result.toString(), |
| 516 | QStringLiteral("607412251233710884196852164903507684163369157425441710414428597081906871515803702314986725" |
| 517 | "2146570418484850536823452158755699691801139" )); |
| 518 | QCOMPARE(result, |
| 519 | QCA::BigInteger("60741225123371088419685216490350768416336915742544171041442859708190687151580370231498672" |
| 520 | "52146570418484850536823452158755699691801139" )); |
| 521 | |
| 522 | result = QCA::BigInteger( |
| 523 | "-5182147769311581499087713405643489820105439851080650534792191527346598920424997741288096547136515478330872068" |
| 524 | "93256740737426200715673766732196603988" ) += |
| 525 | QCA::BigInteger( |
| 526 | "-2983517255774769372611552588738613700467454531142255734565888403876035392822615770224917521828071895197" |
| 527 | "9" ); |
| 528 | QCOMPARE(result.toString(), |
| 529 | QStringLiteral("-51821477693115814990877134056434898201054401494323761122691287885018577942863677880335496" |
| 530 | "6136208893491971245653610668963583902964848985012915555967" )); |
| 531 | QCOMPARE(result, |
| 532 | QCA::BigInteger("-5182147769311581499087713405643489820105440149432376112269128788501857794286367788033549" |
| 533 | "66136208893491971245653610668963583902964848985012915555967" )); |
| 534 | |
| 535 | result = QCA::BigInteger("15937412249227240968245047444122" ) += QCA::BigInteger( |
| 536 | "186214680376169426108822450700978827886569053440254258585576645530381613666540347032550716844628275956253" ); |
| 537 | QCOMPARE(result.toString(), |
| 538 | QStringLiteral("186214680376169426108822450700978827886569053440254258585576645530381613682477759281777957" |
| 539 | "812873323400375" )); |
| 540 | QCOMPARE(result, |
| 541 | QCA::BigInteger("18621468037616942610882245070097882788656905344025425858557664553038161368247775928177795" |
| 542 | "7812873323400375" )); |
| 543 | |
| 544 | result = QCA::BigInteger( |
| 545 | "-1252801011625868585504750425292810762392310545870176170791196952700385571348584614055110796749581358409708177" |
| 546 | "7160" ) += |
| 547 | QCA::BigInteger( |
| 548 | "-539986280927242338236008809854961759996986302156061552378097160849129372827386927545686899193598721998757" |
| 549 | "419572890" ); |
| 550 | QCOMPARE(result.toString(), |
| 551 | QStringLiteral("-55251429104350102409105631410788986762090940761476331408600913037613322854087277368623800" |
| 552 | "7161094535582854501350050" )); |
| 553 | QCOMPARE(result, |
| 554 | QCA::BigInteger("-5525142910435010240910563141078898676209094076147633140860091303761332285408727736862380" |
| 555 | "07161094535582854501350050" )); |
| 556 | |
| 557 | result = QCA::BigInteger("-2454746908" ) += QCA::BigInteger( |
| 558 | "-3822957127889394780055242156360370187075592078655552376050604679934415014573879513870030211860839641756441626" |
| 559 | "913419699098985245833920954444218" ); |
| 560 | QCOMPARE(result.toString(), |
| 561 | QStringLiteral("-38229571278893947800552421563603701870755920786555523760506046799344150145738795138700302" |
| 562 | "11860839641756441626913419699098985245833923409191126" )); |
| 563 | QCOMPARE(result, |
| 564 | QCA::BigInteger("-3822957127889394780055242156360370187075592078655552376050604679934415014573879513870030" |
| 565 | "211860839641756441626913419699098985245833923409191126" )); |
| 566 | |
| 567 | result = QCA::BigInteger("-54288706131860071583318409080596095357980447323635" ) += QCA::BigInteger( |
| 568 | "-4253394105560156310989737429933273230514384568190270696062942611579402976432972405594521244327792021815897638" |
| 569 | "74" ); |
| 570 | QCOMPARE(result.toString(), |
| 571 | QStringLiteral("-42533941055601563109897374299332732305143845681902706960629431544664642950336882387786120" |
| 572 | "5028874560162037087509" )); |
| 573 | QCOMPARE(result, |
| 574 | QCA::BigInteger("-4253394105560156310989737429933273230514384568190270696062943154466464295033688238778612" |
| 575 | "05028874560162037087509" )); |
| 576 | |
| 577 | result = QCA::BigInteger( |
| 578 | "1418766894051319870818496026367686195459604395660119754151922014257535705077512233275240217434104" ) += |
| 579 | QCA::BigInteger("-111987390206074845527" ); |
| 580 | QCOMPARE(result.toString(), |
| 581 | QStringLiteral( |
| 582 | "1418766894051319870818496026367686195459604395660119754151922014257535705077400245885034142588577" )); |
| 583 | QCOMPARE(result, |
| 584 | QCA::BigInteger( |
| 585 | "1418766894051319870818496026367686195459604395660119754151922014257535705077400245885034142588577" )); |
| 586 | |
| 587 | result = QCA::BigInteger( |
| 588 | "-6904101318604104774561038575945435154096774792428336186348093024529626004763532868225501682312348541164651530" |
| 589 | "78845744722987447719420052500874721214723" ) += |
| 590 | QCA::BigInteger( |
| 591 | "-258469037743394674731135699243278836145549479106673938483740960989738710973653960062315588091814633168127" |
| 592 | "2708396146283818299" ); |
| 593 | QCOMPARE(result.toString(), |
| 594 | QStringLiteral("-69041013186041047745610386017923389284362422655419061106759766390845739154309267165995977" |
| 595 | "8128621963853004753702001625641133779400692760897021005033022" )); |
| 596 | QCOMPARE(result, |
| 597 | QCA::BigInteger("-6904101318604104774561038601792338928436242265541906110675976639084573915430926716599597" |
| 598 | "78128621963853004753702001625641133779400692760897021005033022" )); |
| 599 | |
| 600 | result = QCA::BigInteger("-2326153002179462643778624079324592172489363679671158" ) += |
| 601 | QCA::BigInteger("-109819757548464054181938329012610459679" ); |
| 602 | QCOMPARE(result.toString(), QStringLiteral("-2326153002179572463536172543378774110818376290130837" )); |
| 603 | QCOMPARE(result, QCA::BigInteger("-2326153002179572463536172543378774110818376290130837" )); |
| 604 | |
| 605 | result = QCA::BigInteger( |
| 606 | "-4428752250566525488353857709194941742993785578807911414016959206453045495320705299466107784149485981354180907" |
| 607 | "411034982168391" ) += |
| 608 | QCA::BigInteger( |
| 609 | "-39247778259374215325521768005388007526581235832446540589720560855741992694947322437679214611686905696" ); |
| 610 | QCOMPARE(result.toString(), |
| 611 | QStringLiteral("-44287522505665254883538969569732011172091111005759168020244857876888779418612950200269635" |
| 612 | "26142180928676618586625646669074087" )); |
| 613 | QCOMPARE(result, |
| 614 | QCA::BigInteger("-4428752250566525488353896956973201117209111100575916802024485787688877941861295020026963" |
| 615 | "526142180928676618586625646669074087" )); |
| 616 | |
| 617 | result = QCA::BigInteger("3047" ) += QCA::BigInteger( |
| 618 | "-7356458785031315352377693216371961073343377689039020461804017379719600010085607082927794304834315616579528230" |
| 619 | "7508135277641315214" ); |
| 620 | QCOMPARE(result.toString(), |
| 621 | QStringLiteral("-73564587850313153523776932163719610733433776890390204618040173797196000100856070829277943" |
| 622 | "048343156165795282307508135277641312167" )); |
| 623 | QCOMPARE(result, |
| 624 | QCA::BigInteger("-7356458785031315352377693216371961073343377689039020461804017379719600010085607082927794" |
| 625 | "3048343156165795282307508135277641312167" )); |
| 626 | |
| 627 | result = QCA::BigInteger( |
| 628 | "71397189765381049110362731262243394989390499523719445987286843598407339615555456955143712741779487184644001767" |
| 629 | "776382991377987516772847242986" ) += |
| 630 | QCA::BigInteger("-5821969555717973232123574849275726788359152255219972775831" ); |
| 631 | QCOMPARE(result.toString(), |
| 632 | QStringLiteral("713971897653810491103627312622433949893904995237194459872868435984073396155554569493217431" |
| 633 | "86061513952520426918500656203018835261552874467155" )); |
| 634 | QCOMPARE(result, |
| 635 | QCA::BigInteger("71397189765381049110362731262243394989390499523719445987286843598407339615555456949321743" |
| 636 | "186061513952520426918500656203018835261552874467155" )); |
| 637 | |
| 638 | result = QCA::BigInteger( |
| 639 | "-1814097526566131387779640926359093790218263603909606471867269911652274001767668314665411600499352055079190702" |
| 640 | "33410228328274" ) += |
| 641 | QCA::BigInteger( |
| 642 | "-523301382154855044703947051892202646490840761177533623732372519689918420769842424772676407501350528096714" |
| 643 | "904915297347684247802773107355881667545916901" ); |
| 644 | QCOMPARE(result.toString(), |
| 645 | QStringLiteral("-52330138215485504470394705207361239914745389995549771636828189871174478116080307195940339" |
| 646 | "8666577928273481736381838507734183008281026426115077774245175" )); |
| 647 | QCOMPARE(result, |
| 648 | QCA::BigInteger("-5233013821548550447039470520736123991474538999554977163682818987117447811608030719594033" |
| 649 | "98666577928273481736381838507734183008281026426115077774245175" )); |
| 650 | |
| 651 | result = QCA::BigInteger("6858961373707073067" ) += QCA::BigInteger( |
| 652 | "-3340515089338930614338442797642711071819749062833649913099030776499716064369180713270728698264719460945945941" |
| 653 | "15614990907" ); |
| 654 | QCOMPARE(result.toString(), |
| 655 | QStringLiteral("-33405150893389306143384427976427110718197490628336499130990307764997160643691807132707286" |
| 656 | "9826471946087735632741907917840" )); |
| 657 | QCOMPARE(result, |
| 658 | QCA::BigInteger("-3340515089338930614338442797642711071819749062833649913099030776499716064369180713270728" |
| 659 | "69826471946087735632741907917840" )); |
| 660 | |
| 661 | result = QCA::BigInteger( |
| 662 | "-23635098930374569407171906960429616870908424281519944658490940109956689534874971218650241680916564611" ) += |
| 663 | QCA::BigInteger( |
| 664 | "-189589178757795228335995891331428279524485393011427187469792714438466702359827437934396866267364281985416" |
| 665 | "47202983677887505430060922528525205" ); |
| 666 | QCOMPARE(result.toString(), |
| 667 | QStringLiteral("-18958917875779522833599589133142827952472174400073093316386443350807099852853652217721206" |
| 668 | "571394919138651603892518552858724080302603445089816" )); |
| 669 | QCOMPARE(result, |
| 670 | QCA::BigInteger("-1895891787577952283359958913314282795247217440007309331638644335080709985285365221772120" |
| 671 | "6571394919138651603892518552858724080302603445089816" )); |
| 672 | |
| 673 | // Botan's subtraction tests |
| 674 | result = QCA::BigInteger("0" ) -= QCA::BigInteger("0" ); |
| 675 | QCOMPARE(result.toString(), QStringLiteral("0" )); |
| 676 | QCOMPARE(result, QCA::BigInteger("0" )); |
| 677 | |
| 678 | result = QCA::BigInteger("0" ) -= QCA::BigInteger("1" ); |
| 679 | QCOMPARE(result.toString(), QStringLiteral("-1" )); |
| 680 | QCOMPARE(result, QCA::BigInteger("-1" )); |
| 681 | |
| 682 | result = QCA::BigInteger("0" ) -= QCA::BigInteger("4294967296" ); |
| 683 | QCOMPARE(result.toString(), QStringLiteral("-4294967296" )); |
| 684 | QCOMPARE(result, QCA::BigInteger("-4294967296" )); |
| 685 | |
| 686 | // Next test is labelled # 2^512 - 1 |
| 687 | result = QCA::BigInteger( |
| 688 | "13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858" |
| 689 | "186486050853753882811946569946433649006084095" ) -= QCA::BigInteger("1" ); |
| 690 | QCOMPARE(result.toString(), |
| 691 | QStringLiteral("134078079299425970995740249982058461274793658205923933777235614437217640300735469768018742" |
| 692 | "98166903427690031858186486050853753882811946569946433649006084094" )); |
| 693 | QCOMPARE(result, |
| 694 | QCA::BigInteger("13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874" |
| 695 | "298166903427690031858186486050853753882811946569946433649006084094" )); |
| 696 | |
| 697 | result = QCA::BigInteger("89094716573076464980713547115099137014719483620102078148320806773871083148864" ) -= |
| 698 | QCA::BigInteger("49505213825110728957828173754776257356620450607893971553289366249708672306581" ); |
| 699 | QCOMPARE(result.toString(), |
| 700 | QStringLiteral("39589502747965736022885373360322879658099033012208106595031440524162410842283" )); |
| 701 | QCOMPARE(result, QCA::BigInteger("39589502747965736022885373360322879658099033012208106595031440524162410842283" )); |
| 702 | |
| 703 | result = QCA::BigInteger("65894747009896006767807716946835412110318548717263922395390971078905789585431" ) -= |
| 704 | QCA::BigInteger("3884269741925508225990715416862047284194603799902650748631039608684367281358" ); |
| 705 | QCOMPARE(result.toString(), |
| 706 | QStringLiteral("62010477267970498541817001529973364826123944917361271646759931470221422304073" )); |
| 707 | QCOMPARE(result, QCA::BigInteger("62010477267970498541817001529973364826123944917361271646759931470221422304073" )); |
| 708 | |
| 709 | result = QCA::BigInteger( |
| 710 | "59501963964519775669021213017070542183647171968931013600114917777619522537369647091659626133477106071641786829" |
| 711 | "87783755894811024288429224592316636383" ) -= |
| 712 | QCA::BigInteger( |
| 713 | "8750653273562160761286422180115618621879821429145276197424652349306577311499807887070429373153777028581165" |
| 714 | "316131683348567" ); |
| 715 | QCOMPARE(result.toString(), |
| 716 | QStringLiteral("595019639645197756690212129295640094480255643560667917989587315588213082459168851174131026" |
| 717 | "4041133295664370795917354382741033995707263908460633287816" )); |
| 718 | QCOMPARE(result, |
| 719 | QCA::BigInteger("59501963964519775669021212929564009448025564356066791798958731558821308245916885117413102" |
| 720 | "64041133295664370795917354382741033995707263908460633287816" )); |
| 721 | |
| 722 | result = QCA::BigInteger("9815262808265519920770782360080149146267723690" ) -= QCA::BigInteger( |
| 723 | "14067005768891609281364919358115291341352189918255780397560060748765650205261663193732434161580120817" ); |
| 724 | QCOMPARE( |
| 725 | result.toString(), |
| 726 | QStringLiteral( |
| 727 | "-14067005768891609281364919358115291341352189918255780387744797940500130284490880833652285015312397127" )); |
| 728 | QCOMPARE( |
| 729 | result, |
| 730 | QCA::BigInteger( |
| 731 | "-14067005768891609281364919358115291341352189918255780387744797940500130284490880833652285015312397127" )); |
| 732 | |
| 733 | result = QCA::BigInteger( |
| 734 | "-3901491029419486215684797223469406667043760137344853438401542216058534125031549938788864908670209347775308945" |
| 735 | "93416337175399865065870417717658815158195790" ) -= |
| 736 | QCA::BigInteger("1456031684988128870809574635750149625240648487837308" ); |
| 737 | QCOMPARE(result.toString(), |
| 738 | QStringLiteral("-39014910294194862156847972234694066670437601373448534384015422160585341250315499387888649" |
| 739 | "0867020934778986926278404466046209439701620567342899463646033098" )); |
| 740 | QCOMPARE(result, |
| 741 | QCA::BigInteger("-3901491029419486215684797223469406667043760137344853438401542216058534125031549938788864" |
| 742 | "90867020934778986926278404466046209439701620567342899463646033098" )); |
| 743 | |
| 744 | result = QCA::BigInteger("7473774301764883450943" ) -= |
| 745 | QCA::BigInteger("-26256369859367890755157372820052387483402723790185562908491933812453" ); |
| 746 | QCOMPARE(result.toString(), QStringLiteral("26256369859367890755157372820052387483402723797659337210256817263396" )); |
| 747 | QCOMPARE(result, QCA::BigInteger("26256369859367890755157372820052387483402723797659337210256817263396" )); |
| 748 | |
| 749 | result = QCA::BigInteger( |
| 750 | "36246343251214922024139186757009148849295485593397952003237349660142296147421019916619944353877490544706223768" |
| 751 | "684758263065399016597969" ) -= |
| 752 | QCA::BigInteger( |
| 753 | "2574427901445527995149185461475228850098549655325125750771680756403104624569522792792597223218143154924988" |
| 754 | "199562355517064962665954307425375180" ); |
| 755 | QCOMPARE(result.toString(), |
| 756 | QStringLiteral("-25744278651991847439342634373360420930894008060296401573737287531657549644272266453715773" |
| 757 | "06598198801047497654856131748380204402888908408777211" )); |
| 758 | QCOMPARE(result, |
| 759 | QCA::BigInteger("-2574427865199184743934263437336042093089400806029640157373728753165754964427226645371577" |
| 760 | "306598198801047497654856131748380204402888908408777211" )); |
| 761 | |
| 762 | result = QCA::BigInteger("30129746266682790628283889040897642317014108334116727" ) -= |
| 763 | QCA::BigInteger("-1580480523895398762563721715474380903630073871362143915864398724834897608423" ); |
| 764 | QCOMPARE(result.toString(), |
| 765 | QStringLiteral("1580480523895398762563751845220647586420702155251184813506715738943231725150" )); |
| 766 | QCOMPARE(result, QCA::BigInteger("1580480523895398762563751845220647586420702155251184813506715738943231725150" )); |
| 767 | |
| 768 | result = QCA::BigInteger("-4614735863800137951667138933166372061" ) -= |
| 769 | QCA::BigInteger("87175694379075561307234146162193190462135078700346746992273" ); |
| 770 | QCOMPARE(result.toString(), QStringLiteral("-87175694379075561307238760898056990600086745839279913364334" )); |
| 771 | QCOMPARE(result, QCA::BigInteger("-87175694379075561307238760898056990600086745839279913364334" )); |
| 772 | |
| 773 | result = QCA::BigInteger("-3753904" ) -= QCA::BigInteger("-11269137783745339515071988205310702154422777729974" ); |
| 774 | QCOMPARE(result.toString(), QStringLiteral("11269137783745339515071988205310702154422773976070" )); |
| 775 | QCOMPARE(result, QCA::BigInteger("11269137783745339515071988205310702154422773976070" )); |
| 776 | |
| 777 | result = QCA::BigInteger( |
| 778 | "59252394849537944008202127973817008840291885845547005014065278717183005886493293990079450595543785692690297587" |
| 779 | "0288" ) -= QCA::BigInteger("-205854658295495452479104108497931263758143158076949293929661651111" ); |
| 780 | QCOMPARE(result.toString(), |
| 781 | QStringLiteral("592523948495379440082021279738170088402918858455675904798948282624309162973430871164552649" |
| 782 | "113514806220832637521399" )); |
| 783 | QCOMPARE(result, |
| 784 | QCA::BigInteger("59252394849537944008202127973817008840291885845567590479894828262430916297343087116455264" |
| 785 | "9113514806220832637521399" )); |
| 786 | |
| 787 | result = QCA::BigInteger("-33993701617495591491176844355" ) -= QCA::BigInteger( |
| 788 | "3438065097398894672826284379125235190693300918673662774192379185002391232383325160416036963599856704698280" ); |
| 789 | QCOMPARE(result.toString(), |
| 790 | QStringLiteral("-34380650973988946728262843791252351906933009186736627741923791850023912323833591541176544" |
| 791 | "59191347881542635" )); |
| 792 | QCOMPARE(result, |
| 793 | QCA::BigInteger("-3438065097398894672826284379125235190693300918673662774192379185002391232383359154117654" |
| 794 | "459191347881542635" )); |
| 795 | |
| 796 | result = QCA::BigInteger("26876428790838270949718735111909136008255051776703" ) -= QCA::BigInteger( |
| 797 | "-1781128112966810373286192008831149275546995635268767241859967609117529616872536681035700534316457543887601645" |
| 798 | "022" ); |
| 799 | QCOMPARE(result.toString(), |
| 800 | QStringLiteral("178112811296681037328619200883114927554699563526876724185996763599395840771080763075443564" |
| 801 | "6225593552142653421725" )); |
| 802 | QCOMPARE(result, |
| 803 | QCA::BigInteger("17811281129668103732861920088311492755469956352687672418599676359939584077108076307544356" |
| 804 | "46225593552142653421725" )); |
| 805 | |
| 806 | result = QCA::BigInteger( |
| 807 | "2059771092932179758019770618974659367350250375647433386639519387\ |
| 808 | 69317693429941871882153770641334267205446421916220398066553188" ) -= |
| 809 | QCA::BigInteger("3342500267594994347156312297990633112620923791590960237694328174171473763026" ); |
| 810 | QCOMPARE(result.toString(), |
| 811 | QStringLiteral("205977109293217975801977061897465936735025037564739996163684343774970537117643881249041149" |
| 812 | "717542676245208727588046226592790162" )); |
| 813 | QCOMPARE(result, |
| 814 | QCA::BigInteger("20597710929321797580197706189746593673502503756473999616368434377497053711764388124904114" |
| 815 | "9717542676245208727588046226592790162" )); |
| 816 | |
| 817 | result = QCA::BigInteger("5545520403000578843599072515870982842927227412121917598877293331575380404618111609" ) -= |
| 818 | QCA::BigInteger("5991287327241003718821424770352575362437680738923552868139860461945460339860477495902" ); |
| 819 | QCOMPARE(result.toString(), |
| 820 | QStringLiteral("-5985741806838003139977825697836704379594753511511430950540983168613884959455859384293" )); |
| 821 | QCOMPARE(result, |
| 822 | QCA::BigInteger("-5985741806838003139977825697836704379594753511511430950540983168613884959455859384293" )); |
| 823 | |
| 824 | result = QCA::BigInteger("248039029608125071340" ) -= QCA::BigInteger("3664608673" ); |
| 825 | QCOMPARE(result.toString(), QStringLiteral("248039029604460462667" )); |
| 826 | QCOMPARE(result, QCA::BigInteger("248039029604460462667" )); |
| 827 | |
| 828 | result = QCA::BigInteger("15425705711415937103627" ) -= QCA::BigInteger( |
| 829 | "-1435504065517745703440045276868982910754081405474123003767554211132837427846963435621523810229738262235546179" |
| 830 | "779885824" ); |
| 831 | QCOMPARE(result.toString(), |
| 832 | QStringLiteral("143550406551774570344004527686898291075408140547412300376755421113283742784696343562152381" |
| 833 | "0229753687941257595716989451" )); |
| 834 | QCOMPARE(result, |
| 835 | QCA::BigInteger("14355040655177457034400452768689829107540814054741230037675542111328374278469634356215238" |
| 836 | "10229753687941257595716989451" )); |
| 837 | |
| 838 | result = QCA::BigInteger("50882847205108645607281568922683652688671738236030732914347600821086" ) -= |
| 839 | QCA::BigInteger("12176160963158" ); |
| 840 | QCOMPARE(result.toString(), QStringLiteral("50882847205108645607281568922683652688671738236030732902171439857928" )); |
| 841 | QCOMPARE(result, QCA::BigInteger("50882847205108645607281568922683652688671738236030732902171439857928" )); |
| 842 | |
| 843 | result = QCA::BigInteger( |
| 844 | "-3542651856598581894767004787703302288554217246197356622850977105341631254320181588119095376220762923216041205" |
| 845 | "8300173038824256783171761132" ) -= |
| 846 | QCA::BigInteger("-4864862607366468843184694353123830534588538011093812418208808135799" ); |
| 847 | QCOMPARE(result.toString(), |
| 848 | QStringLiteral("-35426518565985818947670047877033022885542172461973566228509771053416307678339208514722110" |
| 849 | "577513276108329877469762161945011838574363625333" )); |
| 850 | QCOMPARE(result, |
| 851 | QCA::BigInteger("-3542651856598581894767004787703302288554217246197356622850977105341630767833920851472211" |
| 852 | "0577513276108329877469762161945011838574363625333" )); |
| 853 | |
| 854 | result = QCA::BigInteger( |
| 855 | "-1428596214712268310382144828171384812520179141608121870013556402879770424002218157546599921571184" ) -= |
| 856 | QCA::BigInteger("-4054101" ); |
| 857 | QCOMPARE(result.toString(), |
| 858 | QStringLiteral( |
| 859 | "-1428596214712268310382144828171384812520179141608121870013556402879770424002218157546599917517083" )); |
| 860 | QCOMPARE(result, |
| 861 | QCA::BigInteger( |
| 862 | "-1428596214712268310382144828171384812520179141608121870013556402879770424002218157546599917517083" )); |
| 863 | |
| 864 | result = QCA::BigInteger("-200931" ) -= QCA::BigInteger( |
| 865 | "-4455880246013049575948283291316071779115178672557051947544960765970517168228311149083493083504573514296684748" |
| 866 | "3009157514950177565952218520297258834187372" ); |
| 867 | QCOMPARE(result.toString(), |
| 868 | QStringLiteral("445588024601304957594828329131607177911517867255705194754496076597051716822831114908349308" |
| 869 | "35045735142966847483009157514950177565952218520297258833986441" )); |
| 870 | QCOMPARE(result, |
| 871 | QCA::BigInteger("44558802460130495759482832913160717791151786725570519475449607659705171682283111490834930" |
| 872 | "835045735142966847483009157514950177565952218520297258833986441" )); |
| 873 | |
| 874 | result = QCA::BigInteger("105704314890799915321259" ) -= QCA::BigInteger( |
| 875 | "82792354594507641557491243849916981441456306687749410083165776119049069747385436947778487411878749535140554980" |
| 876 | "3329615347120938123226038208" ); |
| 877 | QCOMPARE(result.toString(), |
| 878 | QStringLiteral("-82792354594507641557491243849916981441456306687749410083165776119049069747385436947778487" |
| 879 | "4118787495351405549803329509642806047323310716949" )); |
| 880 | QCOMPARE(result, |
| 881 | QCA::BigInteger("-8279235459450764155749124384991698144145630668774941008316577611904906974738543694777848" |
| 882 | "74118787495351405549803329509642806047323310716949" )); |
| 883 | |
| 884 | result = QCA::BigInteger("1448979433940064018828919290452280235308901982649341" ) -= |
| 885 | QCA::BigInteger("303926827425887072291878308433008512899006711759770318009" ); |
| 886 | QCOMPARE(result.toString(), QStringLiteral("-303925378446453132227859479513718060618771402857787668668" )); |
| 887 | QCOMPARE(result, QCA::BigInteger("-303925378446453132227859479513718060618771402857787668668" )); |
| 888 | |
| 889 | result = QCA::BigInteger("-243237595290235750457450892290434789864" ) -= QCA::BigInteger( |
| 890 | "19817702076334276402981273067417321098467533300947463865383702005126562800253466403934608765512316565811954342" |
| 891 | "319565128573969" ); |
| 892 | QCOMPARE(result.toString(), |
| 893 | QStringLiteral("-19817702076334276402981273067417321098467533300947463865383702005126562800253466403934852" |
| 894 | "003107606801562411793211855563363833" )); |
| 895 | QCOMPARE(result, |
| 896 | QCA::BigInteger("-1981770207633427640298127306741732109846753330094746386538370200512656280025346640393485" |
| 897 | "2003107606801562411793211855563363833" )); |
| 898 | |
| 899 | result = QCA::BigInteger("294037338365659932242802023634" ) -= |
| 900 | QCA::BigInteger("4401245995535867764294876849802142926077599828776505639975554254356763769548465" ); |
| 901 | QCOMPARE(result.toString(), |
| 902 | QStringLiteral("-4401245995535867764294876849802142926077599828776211602637188594424520967524831" )); |
| 903 | QCOMPARE(result, |
| 904 | QCA::BigInteger("-4401245995535867764294876849802142926077599828776211602637188594424520967524831" )); |
| 905 | |
| 906 | result = QCA::BigInteger("7303853946195223307036710881687367004566538357189824031021831088365362" ) -= |
| 907 | QCA::BigInteger("119286025999378935715794641163321741" ); |
| 908 | QCOMPARE(result.toString(), |
| 909 | QStringLiteral("7303853946195223307036710881687366885280512357810888315227189925043621" )); |
| 910 | QCOMPARE(result, QCA::BigInteger("7303853946195223307036710881687366885280512357810888315227189925043621" )); |
| 911 | |
| 912 | result = |
| 913 | QCA::BigInteger("571167355343287235687602610714110416067426289363505412908804940696550592413192300554016875" ) -= |
| 914 | QCA::BigInteger("15872188842802631759540597" ); |
| 915 | QCOMPARE( |
| 916 | result.toString(), |
| 917 | QStringLiteral("571167355343287235687602610714110416067426289363505412908804940680678403570389668794476278" )); |
| 918 | QCOMPARE( |
| 919 | result, |
| 920 | QCA::BigInteger("571167355343287235687602610714110416067426289363505412908804940680678403570389668794476278" )); |
| 921 | |
| 922 | result = QCA::BigInteger("1002240129784524388754179399598974973256811336031329881209395070412702275169416754240" ) -= |
| 923 | QCA::BigInteger( |
| 924 | "5942948247886059134314539354042003351647830595287234900671578947794647475365720680007051520796770907993342" |
| 925 | "0746952" ); |
| 926 | QCOMPARE(result.toString(), |
| 927 | QStringLiteral("-59429482478860591343145393539417793386693781564118169607116814504689663417625876918861120" |
| 928 | "137555006804764003992712" )); |
| 929 | QCOMPARE(result, |
| 930 | QCA::BigInteger("-5942948247886059134314539353941779338669378156411816960711681450468966341762587691886112" |
| 931 | "0137555006804764003992712" )); |
| 932 | |
| 933 | result = QCA::BigInteger( |
| 934 | "1370431648825444838359719050380239722263203134555431526491525074601463042144798545817957389" ) -= |
| 935 | QCA::BigInteger("3473869878" ); |
| 936 | QCOMPARE( |
| 937 | result.toString(), |
| 938 | QStringLiteral("1370431648825444838359719050380239722263203134555431526491525074601463042144798542344087511" )); |
| 939 | QCOMPARE( |
| 940 | result, |
| 941 | QCA::BigInteger("1370431648825444838359719050380239722263203134555431526491525074601463042144798542344087511" )); |
| 942 | |
| 943 | result = QCA::BigInteger("8548280229254726209" ) -= |
| 944 | QCA::BigInteger("33066125035269904981849320434016892734943145935582141989968280846973981913056248918" ); |
| 945 | QCOMPARE(result.toString(), |
| 946 | QStringLiteral("-33066125035269904981849320434016892734943145935582141989968280838425701683801522709" )); |
| 947 | QCOMPARE(result, |
| 948 | QCA::BigInteger("-33066125035269904981849320434016892734943145935582141989968280838425701683801522709" )); |
| 949 | |
| 950 | result = QCA::BigInteger( |
| 951 | "-1902355883268750648950815079596633217599012996302992895858417011175963029327693964733408210016910253836443785" |
| 952 | "9846398095065171936899503" ) -= |
| 953 | QCA::BigInteger( |
| 954 | "2489927112752354534228346876280965340763863196622012469575197689419310377944305084304077119122752284308807" |
| 955 | "9031762445684377195650493065096847292797" ); |
| 956 | QCOMPARE(result.toString(), |
| 957 | QStringLiteral("-24899271127542568901116156269299161558434598298396114825715006823151687949554810473334048" |
| 958 | "130874856925188248134300810122237042048588130268784192300" )); |
| 959 | QCOMPARE(result, |
| 960 | QCA::BigInteger("-2489927112754256890111615626929916155843459829839611482571500682315168794955481047333404" |
| 961 | "8130874856925188248134300810122237042048588130268784192300" )); |
| 962 | |
| 963 | result = QCA::BigInteger( |
| 964 | "-1800353575522706389288305623797196690530870204356722928042061228497437075035917720399302198953687023" ) -= |
| 965 | QCA::BigInteger( |
| 966 | "-118756682615304660537085387309407764121711064830726245327571774713841280164583325446427884047654699244961" |
| 967 | "27460164" ); |
| 968 | QCOMPARE(result.toString(), |
| 969 | QStringLiteral("118756682615286657001330160245514881065473092863820936625528207484560859552298351075677524" |
| 970 | "87045070622297173773141" )); |
| 971 | QCOMPARE(result, |
| 972 | QCA::BigInteger("11875668261528665700133016024551488106547309286382093662552820748456085955229835107567752" |
| 973 | "487045070622297173773141" )); |
| 974 | |
| 975 | result = QCA::BigInteger("-29861551039945217879" ) -= QCA::BigInteger( |
| 976 | "11134730259168556423534561466475429305816690823484096396972829608778892265003199963808382325823762328728689476" |
| 977 | "24793789212829885934" ); |
| 978 | QCOMPARE(result.toString(), |
| 979 | QStringLiteral("-11134730259168556423534561466475429305816690823484096396972829608778892265003199963808382" |
| 980 | "32582376232872868947654655340252775103813" )); |
| 981 | QCOMPARE(result, |
| 982 | QCA::BigInteger("-1113473025916855642353456146647542930581669082348409639697282960877889226500319996380838" |
| 983 | "232582376232872868947654655340252775103813" )); |
| 984 | |
| 985 | result = QCA::BigInteger( |
| 986 | "56553296365676115383821827756495791765870729764975792067630330165532810366551228779710851013983764350649164198" |
| 987 | "7188791892506290" ) -= QCA::BigInteger("-2188105671531473889939411772533707" ); |
| 988 | QCOMPARE(result.toString(), |
| 989 | QStringLiteral("565532963656761153838218277564957917658707297649757920676303301655328103665512287797108510" |
| 990 | "142025749178023115877128203665039997" )); |
| 991 | QCOMPARE(result, |
| 992 | QCA::BigInteger("56553296365676115383821827756495791765870729764975792067630330165532810366551228779710851" |
| 993 | "0142025749178023115877128203665039997" )); |
| 994 | |
| 995 | result = QCA::BigInteger("-349535960680522202843083381184496349093812380954435872337802226" ) -= |
| 996 | QCA::BigInteger("-1829600726218222026679938" ); |
| 997 | QCOMPARE(result.toString(), QStringLiteral("-349535960680522202843083381184496349091982780228217650311122288" )); |
| 998 | QCOMPARE(result, QCA::BigInteger("-349535960680522202843083381184496349091982780228217650311122288" )); |
| 999 | |
| 1000 | result = QCA::BigInteger("-1" ) -= QCA::BigInteger("-6726974989587128275" ); |
| 1001 | QCOMPARE(result.toString(), QStringLiteral("6726974989587128274" )); |
| 1002 | QCOMPARE(result, QCA::BigInteger("6726974989587128274" )); |
| 1003 | |
| 1004 | result = QCA::BigInteger("-107142709838121196902389095205618516687047338619382145236348309762148611647954748824" ) -= |
| 1005 | QCA::BigInteger("42484103615491" ); |
| 1006 | QCOMPARE(result.toString(), |
| 1007 | QStringLiteral("-107142709838121196902389095205618516687047338619382145236348309762148654132058364315" )); |
| 1008 | QCOMPARE(result, |
| 1009 | QCA::BigInteger("-107142709838121196902389095205618516687047338619382145236348309762148654132058364315" )); |
| 1010 | |
| 1011 | result = |
| 1012 | QCA::BigInteger("-90546630430085769764839607528116121381848878494574360812027599640018921358040178215575723" ) -= |
| 1013 | QCA::BigInteger( |
| 1014 | "-118922408531468986902800063237122125617455464103913195171141030774109638861272017660698580914239435114280" |
| 1015 | "434761425243" ); |
| 1016 | QCOMPARE(result.toString(), |
| 1017 | QStringLiteral("118922408531468986902800063146575495187369694339073587643024909392260760366697656848670981" |
| 1018 | "274220513756240256545849520" )); |
| 1019 | QCOMPARE(result, |
| 1020 | QCA::BigInteger("11892240853146898690280006314657549518736969433907358764302490939226076036669765684867098" |
| 1021 | "1274220513756240256545849520" )); |
| 1022 | |
| 1023 | result = QCA::BigInteger( |
| 1024 | "-5545044667082427128801726416727657360001588430113578182850657573063241939882570324573086267287272360432363387" |
| 1025 | "213743735507218270373633222520429" ) -= QCA::BigInteger("-151423255459028627628896755237194376177115" ); |
| 1026 | QCOMPARE(result.toString(), |
| 1027 | QStringLiteral("-55450446670824271288017264167276573600015884301135781828506575730632419398825703245730862" |
| 1028 | "67287272360280940131754715107878321515136438846343314" )); |
| 1029 | QCOMPARE(result, |
| 1030 | QCA::BigInteger("-5545044667082427128801726416727657360001588430113578182850657573063241939882570324573086" |
| 1031 | "267287272360280940131754715107878321515136438846343314" )); |
| 1032 | |
| 1033 | result = QCA::BigInteger("-5247636471953421659649611318164848102069" ) -= |
| 1034 | QCA::BigInteger("-4024324110573096565232590473170599175885004" ); |
| 1035 | QCOMPARE(result.toString(), QStringLiteral("4019076474101143143572940861852434327782935" )); |
| 1036 | QCOMPARE(result, QCA::BigInteger("4019076474101143143572940861852434327782935" )); |
| 1037 | |
| 1038 | result = QCA::BigInteger("39412892606015043322484854253879371723186457838590224795040178472832" ) -= |
| 1039 | QCA::BigInteger("-5038321321957452145034687815432890684825466579123474921848465393400312" ); |
| 1040 | QCOMPARE(result.toString(), |
| 1041 | QStringLiteral("5077734214563467188357172669686770056548653036962065146643505571873144" )); |
| 1042 | QCOMPARE(result, QCA::BigInteger("5077734214563467188357172669686770056548653036962065146643505571873144" )); |
| 1043 | |
| 1044 | result = QCA::BigInteger( |
| 1045 | "-5597941458800922703568362450520876675318746972779964027720427420784331758329273633391278382952827027264258300" |
| 1046 | "4969175230274821" ) -= |
| 1047 | QCA::BigInteger( |
| 1048 | "-109633110576212669339535976775635762395927171313557427036242111476016398579345366908401334025571265714128" |
| 1049 | "108308032073779442181369365924213118258269679" ); |
| 1050 | QCOMPARE(result.toString(), |
| 1051 | QStringLiteral("109633110576212669339535920796221174386700135629932921827475358288546670779705089704127126" |
| 1052 | "182253682421391774395248244251171908726782919243943027994858" )); |
| 1053 | QCOMPARE(result, |
| 1054 | QCA::BigInteger("10963311057621266933953592079622117438670013562993292182747535828854667077970508970412712" |
| 1055 | "6182253682421391774395248244251171908726782919243943027994858" )); |
| 1056 | |
| 1057 | result = |
| 1058 | QCA::BigInteger("-38752353898173389347479216285772999906325286421302866854350737050533204094183249691110" ) -= |
| 1059 | QCA::BigInteger( |
| 1060 | "2428819407377764342156426895396654728835493564788997075896393065230009911546390816091652653701035085361" ); |
| 1061 | QCOMPARE(result.toString(), |
| 1062 | QStringLiteral("-24288194073777643809087807935700440763147098505619969822216794865328767658971278666248567" |
| 1063 | "47884284776471" )); |
| 1064 | QCOMPARE(result, |
| 1065 | QCA::BigInteger("-2428819407377764380908780793570044076314709850561996982221679486532876765897127866624856" |
| 1066 | "747884284776471" )); |
| 1067 | |
| 1068 | result = QCA::BigInteger("-2784579005241382005249492720344" ) -= |
| 1069 | QCA::BigInteger("-164204542616919252351131740123094674" ); |
| 1070 | QCOMPARE(result.toString(), QStringLiteral("164201758037914010969126490630374330" )); |
| 1071 | QCOMPARE(result, QCA::BigInteger("164201758037914010969126490630374330" )); |
| 1072 | |
| 1073 | result = QCA::BigInteger("200948857420871544747808060972375039052401280822505804851732868100" ) -= |
| 1074 | QCA::BigInteger("-795957177479360455258269298038670876462147576765875895105714" ); |
| 1075 | QCOMPARE(result.toString(), QStringLiteral("200949653378049024108263319241673077723277742970082570727627973814" )); |
| 1076 | QCOMPARE(result, QCA::BigInteger("200949653378049024108263319241673077723277742970082570727627973814" )); |
| 1077 | |
| 1078 | result = QCA::BigInteger("217570540819" ) -= QCA::BigInteger( |
| 1079 | "121955083597720420983384282166693307394185530431368476834980748302158718406063500763434561937200696970170700" ); |
| 1080 | QCOMPARE(result.toString(), |
| 1081 | QStringLiteral("-12195508359772042098338428216669330739418553043136847683498074830215871840606350076343456" |
| 1082 | "1937200479399629881" )); |
| 1083 | QCOMPARE(result, |
| 1084 | QCA::BigInteger(QStringLiteral("-1219550835977204209833842821666933073941855304313684768349807483021587184" |
| 1085 | "06063500763434561937200479399629881" ))); |
| 1086 | |
| 1087 | result = QCA::BigInteger(QStringLiteral("2335319252198456765380587281374076367944" )) -= |
| 1088 | QCA::BigInteger(QStringLiteral("-4500271" )); |
| 1089 | QCOMPARE(result, QCA::BigInteger(QStringLiteral("2335319252198456765380587281374080868215" ))); |
| 1090 | |
| 1091 | result = QCA::BigInteger( |
| 1092 | QStringLiteral("-393694614027544181700073367147249369966344727230221941008713805434207925307052598" )) -= |
| 1093 | QCA::BigInteger(QStringLiteral("-153972676737062409261153899615588515236137907791841623991260363840680295565313" |
| 1094 | "157972489168132345521780658007459602823125797806770" )); |
| 1095 | QCOMPARE(result.toString(), |
| 1096 | QStringLiteral("153972676737062409261153899615588515236137907791447929377232819658980222198165908602522823" |
| 1097 | "405115299839649293654168615200490754172" )); |
| 1098 | QCOMPARE(result, |
| 1099 | QCA::BigInteger(QStringLiteral("15397267673706240926115389961558851523613790779144792937723281965898022219" |
| 1100 | "8165908602522823405115299839649293654168615200490754172" ))); |
| 1101 | |
| 1102 | result = QCA::BigInteger(QStringLiteral("114832549702862263167" )) -= |
| 1103 | QCA::BigInteger(QStringLiteral("1292186490722995955874527641883028787538667360089228102228659716577356947303995" |
| 1104 | "3984775959232814911435097412913078625" )); |
| 1105 | QCOMPARE(result.toString(), |
| 1106 | QStringLiteral("-12921864907229959558745276418830287875386673600892281022286597165773569473039953984775959" |
| 1107 | "232814796602547710050815458" )); |
| 1108 | QCOMPARE(result, |
| 1109 | QCA::BigInteger(QStringLiteral("-1292186490722995955874527641883028787538667360089228102228659716577356947" |
| 1110 | "3039953984775959232814796602547710050815458" ))); |
| 1111 | |
| 1112 | result = |
| 1113 | QCA::BigInteger(QStringLiteral("6489502346837936889305337487724547956628371915228387374094443896266362105931065" |
| 1114 | "153072983425911767580294076594078932835008494777866083" )) -= |
| 1115 | QCA::BigInteger(QStringLiteral("1099205476533612407829257935144627350486541654788267826664706620630745291371323" |
| 1116 | "154513322608446957760026881954001581" )); |
| 1117 | QCOMPARE(result.toString(), |
| 1118 | QStringLiteral("648950234683793688820613201119093554879911398008376002360790224147809427926635853244223813" |
| 1119 | "4540444425780753985631975074981612823864502" )); |
| 1120 | QCOMPARE(result, |
| 1121 | QCA::BigInteger(QStringLiteral("64895023468379368882061320111909355487991139800837600236079022414780942792" |
| 1122 | "66358532442238134540444425780753985631975074981612823864502" ))); |
| 1123 | |
| 1124 | result = |
| 1125 | QCA::BigInteger(QStringLiteral("1699911441239587542538013131736629773378508702733583789516405216010771529944743" |
| 1126 | "40806917796870911557233689087716056557" )) -= |
| 1127 | QCA::BigInteger(QStringLiteral("-15409167" )); |
| 1128 | QCOMPARE(result.toString(), |
| 1129 | QStringLiteral("169991144123958754253801313173662977337850870273358378951640521601077152994474340806917796" |
| 1130 | "870911557233689087731465724" )); |
| 1131 | QCOMPARE(result, |
| 1132 | QCA::BigInteger(QStringLiteral("16999114412395875425380131317366297733785087027335837895164052160107715299" |
| 1133 | "4474340806917796870911557233689087731465724" ))); |
| 1134 | } |
| 1135 | |
| 1136 | QTEST_MAIN(BigIntUnitTest) |
| 1137 | |
| 1138 | #include "bigintunittest.moc" |
| 1139 | |