2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / corlib / Test / Mono.Math / PrimeGenerationTest.cs
1 //
2 // MonoTests.Mono.Math.PrimeGenerationTest.cs
3 //
4 // Authors:
5 //      Ben Maurer
6 //
7 // Copyright (c) 2003 Ben Maurer. All rights reserved
8 //
9
10 using System;
11 using Mono.Math;
12 using NUnit.Framework;
13
14 namespace MonoTests.Mono.Math {
15
16         public abstract class PrimeGeneration_Base : BigIntegerTestSet {
17
18                 BigInteger s, e;
19
20                 public PrimeGeneration_Base ()
21                 {
22                         s = new BigInteger (Start);
23                         e = new BigInteger (Expected);
24                 }
25
26                 public abstract uint[] Start {
27                         get;
28                 }
29                 
30                 public abstract uint[] Expected {
31                         get;
32                 }
33                 
34                 [Test]
35                 public void GeneratePrime ()
36                 {
37                         BigInteger r = BigInteger.NextHightestPrime (s);
38                         Expect (r, e);
39                 }
40         }
41         
42         public class PrimeGeneration_Rand1024 : PrimeGeneration_Base {
43
44                 public override uint[] Start {
45                         get {
46                                 return new uint[] {
47                                         0x7eaceb59, 0x344f3bcd, 0xffc5c003, 0xe17e9912, 0x05653294, 0x5383551f,
48                                         0x0f604c65, 0x308f77ec, 0xf86d18d8, 0xad262661, 0x35f021eb, 0x36d3c53c,
49                                         0x5e1ec5a9, 0x1c3dd738, 0x67b49061, 0x294a5a65, 0x0754a346, 0xe9ee0bf2,
50                                         0x181c5e1d, 0x1eb719fa, 0xc4372255, 0x0bdee9bb, 0xbf9cfe74, 0x1b2be7f5,
51                                         0xcf81e022, 0xa43d2698, 0x9c59f568, 0xc45d024d, 0x62eb1a3f, 0x125ad0cf,
52                                         0x11e6834e, 0x09745d93
53                                 };
54                         }
55                 }
56
57                 public override uint[] Expected {
58                         get {
59                                 return new uint[] {
60                                         0x7eaceb59, 0x344f3bcd, 0xffc5c003, 0xe17e9912, 0x05653294, 0x5383551f,
61                                         0x0f604c65, 0x308f77ec, 0xf86d18d8, 0xad262661, 0x35f021eb, 0x36d3c53c,
62                                         0x5e1ec5a9, 0x1c3dd738, 0x67b49061, 0x294a5a65, 0x0754a346, 0xe9ee0bf2,
63                                         0x181c5e1d, 0x1eb719fa, 0xc4372255, 0x0bdee9bb, 0xbf9cfe74, 0x1b2be7f5,
64                                         0xcf81e022, 0xa43d2698, 0x9c59f568, 0xc45d024d, 0x62eb1a3f, 0x125ad0cf,
65                                         0x11e6834e, 0x09745fe9
66                                 };
67                         }
68                 }
69         }
70         
71         public class PrimeGeneration_512 : PrimeGeneration_Base {
72
73                 public override uint[] Start {
74                         get {
75                                 return new uint[] {
76                                         0x5629a00f, 0x3b672419, 0x85891da8, 0x2d63ff0c, 0xd8b91375, 0xfb57f659,
77                                         0x07e2de17, 0x7de561be, 0xc29d6912, 0x198cb7fd, 0x251d33ad, 0x6bc20a0a,
78                                         0xdd1e4060, 0x809d5fb2, 0x20fcd816, 0xafc2ddb2
79                                 };
80                         }
81                 }
82
83                 public override uint[] Expected {
84                         get {
85                                 return new uint[] {
86                                         0x5629a00f, 0x3b672419, 0x85891da8, 0x2d63ff0c, 0xd8b91375, 0xfb57f659,
87                                         0x07e2de17, 0x7de561be, 0xc29d6912, 0x198cb7fd, 0x251d33ad, 0x6bc20a0a,
88                                         0xdd1e4060, 0x809d5fb2, 0x20fcd816, 0xafc2dfd5
89                                 };
90                         }
91                 }
92         }
93 }