source: git/factory/test.cc @ 1dc25bf

fieker-DuValspielwiese
Last change on this file since 1dc25bf was 8f26a44, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Assure that config.h was generated on 'compatible' cpu (same size of long)
  • Property mode set to 100644
File size: 3.2 KB
Line 
1#include <factory/factory.h>
2#include <resources/feFopen.h>
3#include "cf_assert.h"
4
5int mmInit(void) {
6#ifdef SINGULAR
7// this is a hack to make linker baheave on Mac OS X 10.6.8 / 64 bit
8// since otherwise both debug and release DYNAMIC tests failed there with:
9/*
10dyld: lazy symbol binding failed: Symbol not found: __Z7feFopenPKcS0_
11Referenced from: ...BUILDDIR/factory/.libs/libfactory_g-3.1.3.dylib
12Expected in: flat namespace
13   
14dyld: Symbol not found: __Z7feFopenPKcS0_
15Referenced from: ...BUILDDIR/factory/.libs/libfactory_g-3.1.3.dylib
16Expected in: flat namespace
17*/
18const int f = (int)(long)(void*)feFopen;
19return (f ^ f) + 1; 
20#else
21return 1; 
22#endif
23}
24
25int test2 (int p)
26{
27  int ret = 1;
28  setCharacteristic (p);
29  printf ("p: %d, i: %d", p, 0);
30  CanonicalForm d1= Variable (1) + Variable (2) + 1;
31  CanonicalForm f1= Variable (1) - Variable (2) - 2;
32  CanonicalForm g1= Variable (1) + Variable (2) + 2;
33  CanonicalForm d= power (d1, 2);
34  CanonicalForm f= d* power (f1, 2);
35  CanonicalForm g= d* power (g1, 2);
36  CanonicalForm h= gcd (f,g);
37  h /= Lc (h);
38  printf (", h==d? %d\n", (h == d));
39  if (h != d)
40    ret = -1;
41  for (int i= 3; i <= 11; i++)
42  {
43    printf ("p: %d, i: %d", p, i);
44    d1 += power (Variable (i), i);
45    f1 -= power (Variable (i), i);
46    g1 += power (Variable (i), i);
47    d= power (d1, 2);
48    f= d*power (f1, 2);
49    g= d*power (g1, 2);
50    h= gcd (f,g);
51    h /= Lc (h);
52    printf (", h==d? %d\n", (h == d));
53    if (h != d)
54      ret = -1;
55  }
56  return ret;
57}
58
59/*int test5 (int p)
60{
61  setCharacteristic (p);
62  Variable x= Variable (1);
63  CanonicalForm d1= x + 1;
64  CanonicalForm d2= Variable (2) + 1;
65  CanonicalForm f1= x - 2;
66  CanonicalForm f2= Variable (2) - 2;
67  CanonicalForm g1= x + 2;
68  CanonicalForm g2= Variable (2) + 2;
69  CanonicalForm d= d1*d2 - 2;
70  CanonicalForm f= f1*f2 + 2;
71  CanonicalForm g= g1*g2 - 2;
72  f *= d;
73  g *= d;
74  CanonicalForm h= gcd (f, g);
75  h /= Lc (h);
76  if (h != d)
77    return - 1;
78  printf ("h==d? %d\n", (h == d));
79  for (int i= 3; i <= 11; i++)
80  {
81    d2 *= power (Variable (i), i) + 1;
82    f2 *= power (Variable (i), i) - 2;
83    g2 *= power (Variable (i), i) + 2;
84
85    d= d1*d2 - 2;
86    f= f1*f2 + 2;
87    g= g1*g2 - 2;
88    f *= d;
89    g *= d;
90    h= gcd (f, g);
91    h /= Lc (h);
92    if (h != d)
93      return -1;
94    printf ("h==d? %d\n", (h == d));
95  }
96  return 1;
97}*/
98
99extern void feInitResources(const char* argv0 = NULL);
100
101int main( int, char *argv[] )
102{
103  int ret = 0;
104
105  ASSERT( sizeof(long) == SIZEOF_LONG, "Bad config.h: wrong size of long!"  );
106
107  if( sizeof(long) != SIZEOF_LONG )
108  {
109    printf("Bad config.h: wrong size of long!");
110
111    return(1);
112  }
113   
114  feInitResources(argv[0]);
115
116//  On (SW_USE_EZGCD); On (SW_USE_EZGCD_P); // TODO&NOTE: these switches lead to failed tests (with nonzero p)!
117
118  Off (SW_USE_EZGCD);
119  Off (SW_USE_CHINREM_GCD);
120
121  int t= test2 (0);
122  if (t < 0)
123    ret = t;
124  /*t= test5 (0);
125  if (t < 0)
126    return t;
127  t= test5 (3);
128  if (t < 0)
129    return t;
130  t= test5 (101);
131  if (t < 0)
132    return t;
133  t= test5 (43051);
134  if (t < 0)
135    return t;*/
136  t= test2 (3);
137  if (t < 0)
138    ret += t;
139 
140  t= test2 (101);
141  if (t < 0)
142    ret += t;
143 
144  t= test2 (43051);
145  if (t < 0)
146    ret += t;
147 
148  return ret;
149}
Note: See TracBrowser for help on using the repository browser.