]> git.treefish.org Git - phys/latlib.git/blob - neigh_test.cpp
Made c++11 standard dependency obsolete.
[phys/latlib.git] / neigh_test.cpp
1 #include "neigh.h"
2 #include <time.h>
3 #include <stdlib.h>
4 #include <iostream>
5
6 using namespace std;
7
8 int main()
9 {
10   neigh *n;
11   srand(time(NULL));
12
13   while( true )
14     {
15       int l[] = { rand()%10 + 1, rand()%10 + 1, rand()%10 + 1 , rand()%10 + 1 };
16
17       n = new neigh(4,l[0],l[1],l[2],l[3]);
18
19       cout << l[0] << "x" << l[1] << "x" << l[2] << "x" << l[3] << endl; 
20
21       for(int itry=0; itry<100000; itry++)
22         {
23           int dir0 = rand()%4;
24           int dir1 = rand()%3;
25           if(dir0 <= dir1) dir1++;
26
27           int l0 = rand()%(3*l[dir0]);
28           int l1 = rand()%(3*l[dir1]);
29
30           int startpos = rand()%l[0] + (rand()%l[1])*l[0] + (rand()%l[2])*l[0]*l[1] + (rand()%l[3])*l[0]*l[1]*l[2];
31
32           int pos = startpos;
33
34           for(int istep=0; istep<l0; istep++) pos = (*n)[pos*8+dir0];     
35           for(int istep=0; istep<l1; istep++) pos = (*n)[pos*8+dir1];
36           for(int istep=0; istep<l0; istep++) pos = (*n)[pos*8+dir0+4];
37           for(int istep=0; istep<l1; istep++) pos = (*n)[pos*8+dir1+4];
38
39           if( pos != startpos ) {
40             cout << "OHOH!!!" << endl;
41             exit(1);
42           }
43         }
44
45       delete n;
46     }
47
48   return 0;
49 }