2 // MonoTests.Mono.Math.BitwiseTest.cs
7 // Copyright (c) 2003 Ben Maurer. All rights reserved
12 using NUnit
.Framework
;
14 namespace MonoTests
.Mono
.Math
{
16 public abstract class Bitwise_Base
: BigIntegerTestSet
{
18 BigInteger N
, expectedNls
, expectedNrs
;
24 N
= new BigInteger(n
);
25 expectedNls
= new BigInteger(ExpectedNLeftShift
);
26 expectedNrs
= new BigInteger(ExpectedNRightShift
);
27 shiftAmount
= ShiftAmount
;
30 public abstract uint[] n
{
34 public abstract int ShiftAmount
{
38 public abstract uint[] ExpectedNLeftShift
{
42 public abstract uint[] ExpectedNRightShift
{
47 public void ShiftLeft()
49 Expect( N
<< shiftAmount
, expectedNls
);
53 public void ShiftRight()
55 Expect( N
>> shiftAmount
, expectedNrs
);
59 public class Bitwise_Rand512n
: Bitwise_Base
{
61 public override uint[] n
{
64 0xb29696b0, 0x8a8674b9, 0xabf0f8b7, 0xb873579f, 0x88d90993, 0x697c9290,
65 0xbb70f64c, 0x77f4c616, 0x60bab197, 0x39884b0d, 0x37e83131, 0x8de30d79,
66 0xae47b2e2, 0x67718497, 0x23559359, 0xc4c9259c
71 public override int ShiftAmount
{
77 public override uint[] ExpectedNLeftShift
{
80 0xb29, 0x696b08a8, 0x674b9abf, 0x0f8b7b87, 0x3579f88d, 0x90993697,
81 0xc9290bb7, 0x0f64c77f, 0x4c61660b, 0xab197398, 0x84b0d37e, 0x831318de,
82 0x30d79ae4, 0x7b2e2677, 0x18497235, 0x59359c4c, 0x9259c000
86 public override uint[] ExpectedNRightShift
{
89 0xb2969, 0x6b08a867, 0x4b9abf0f, 0x8b7b8735, 0x79f88d90, 0x993697c9,
90 0x290bb70f, 0x64c77f4c, 0x61660bab, 0x19739884, 0xb0d37e83, 0x1318de30,
91 0xd79ae47b, 0x2e267718, 0x49723559, 0x359c4c92
97 public class Bitwise_Rand2048n
: Bitwise_Base
{
99 public override uint[] n
{
102 0x27dd8385, 0xf44cf2f6, 0x2fba638e, 0x23151ade, 0xc4366886, 0x86d5ea9e,
103 0xd8c92f09, 0x326fd166, 0xc466ab65, 0xe163db79, 0xcc6eb808, 0xce262b4c,
104 0x7317b66b, 0x360c9746, 0x0464d7c2, 0x37709a34, 0x2ee973fc, 0x04c90896,
105 0x60790e40, 0xff5247f8, 0x864d5f5b, 0xcf8e8567, 0x59782b43, 0x27cfbb82,
106 0x0dc53a89, 0x8072e526, 0xcf44d0d1, 0x4eeac325, 0xcb1c91aa, 0x8d09c910,
107 0xe13ab08e, 0x656235ef, 0xb553255c, 0x8709557a, 0x7f809100, 0xf47c7acf,
108 0x9c70a17f, 0x8c1b2aa3, 0x1d6f0cec, 0x9c1ca046, 0xaac3c552, 0xd04318fc,
109 0x5c217295, 0x8deb3c73, 0xaa039583, 0x72ccfbc6, 0x91783ee6, 0xe3257194,
110 0x70e54a12, 0x0b29e5b9, 0x0b4c883c, 0xaf2fe460, 0x21f86d3b, 0x35ce8fc7,
111 0x9f336fc8, 0x3e0e1aa0, 0xed8ec9f1, 0xc10572d9, 0x26fb856e, 0x96f425c2,
112 0xf73f62f4, 0xa0690bb7, 0x35875324, 0x513e84b7
117 public override int ShiftAmount
{
123 public override uint[] ExpectedNLeftShift
{
126 0x27dd, 0x8385f44c, 0xf2f62fba, 0x638e2315, 0x1adec436, 0x688686d5,
127 0xea9ed8c9, 0x2f09326f, 0xd166c466, 0xab65e163, 0xdb79cc6e, 0xb808ce26,
128 0x2b4c7317, 0xb66b360c, 0x97460464, 0xd7c23770, 0x9a342ee9, 0x73fc04c9,
129 0x08966079, 0x0e40ff52, 0x47f8864d, 0x5f5bcf8e, 0x85675978, 0x2b4327cf,
130 0xbb820dc5, 0x3a898072, 0xe526cf44, 0xd0d14eea, 0xc325cb1c, 0x91aa8d09,
131 0xc910e13a, 0xb08e6562, 0x35efb553, 0x255c8709, 0x557a7f80, 0x9100f47c,
132 0x7acf9c70, 0xa17f8c1b, 0x2aa31d6f, 0x0cec9c1c, 0xa046aac3, 0xc552d043,
133 0x18fc5c21, 0x72958deb, 0x3c73aa03, 0x958372cc, 0xfbc69178, 0x3ee6e325,
134 0x719470e5, 0x4a120b29, 0xe5b90b4c, 0x883caf2f, 0xe46021f8, 0x6d3b35ce,
135 0x8fc79f33, 0x6fc83e0e, 0x1aa0ed8e, 0xc9f1c105, 0x72d926fb, 0x856e96f4,
136 0x25c2f73f, 0x62f4a069, 0x0bb73587, 0x5324513e, 0x84b70000, 0x00000000
141 public override uint[] ExpectedNRightShift
{
144 0x27dd, 0x8385f44c, 0xf2f62fba, 0x638e2315, 0x1adec436, 0x688686d5,
145 0xea9ed8c9, 0x2f09326f, 0xd166c466, 0xab65e163, 0xdb79cc6e, 0xb808ce26,
146 0x2b4c7317, 0xb66b360c, 0x97460464, 0xd7c23770, 0x9a342ee9, 0x73fc04c9,
147 0x08966079, 0x0e40ff52, 0x47f8864d, 0x5f5bcf8e, 0x85675978, 0x2b4327cf,
148 0xbb820dc5, 0x3a898072, 0xe526cf44, 0xd0d14eea, 0xc325cb1c, 0x91aa8d09,
149 0xc910e13a, 0xb08e6562, 0x35efb553, 0x255c8709, 0x557a7f80, 0x9100f47c,
150 0x7acf9c70, 0xa17f8c1b, 0x2aa31d6f, 0x0cec9c1c, 0xa046aac3, 0xc552d043,
151 0x18fc5c21, 0x72958deb, 0x3c73aa03, 0x958372cc, 0xfbc69178, 0x3ee6e325,
152 0x719470e5, 0x4a120b29, 0xe5b90b4c, 0x883caf2f, 0xe46021f8, 0x6d3b35ce,
153 0x8fc79f33, 0x6fc83e0e, 0x1aa0ed8e, 0xc9f1c105, 0x72d926fb, 0x856e96f4,
154 0x25c2f73f, 0x62f4a069, 0x0bb73587