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

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