Changeset f323dd1 in git for libpolys/tests/coeffs_test.h
- Timestamp:
- Feb 29, 2012, 5:18:58 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 8d8cd944663cf80b3fd163a42279526ce163a5fd
- Parents:
- d8b0f69f9828897dca663d5bb516369b1b0ac64a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/tests/coeffs_test.h
rd8b0f69 rf323dd1 5 5 6 6 #include <reporter/reporter.h> 7 #include < resources/feResource.h>7 #include <findexec/feResource.h> 8 8 9 9 #include <coeffs/coeffs.h> … … 35 35 36 36 const unsigned long ssss = (N * (N+1)) / 2; 37 37 38 38 number sum1 = n_Init(ssss, r); 39 39 clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r); … … 45 45 ndInpMult(s, i, r); 46 46 n_Delete(&i, r); 47 48 clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 49 47 48 clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 49 50 50 i = n_Init(2, r); 51 clog<< "2: "; PrintSized(i, r); 51 clog<< "2: "; PrintSized(i, r); 52 52 53 53 if( !n_IsZero( i, r) ) … … 56 56 TS_ASSERT( n_DivBy(s, i, r) ); 57 57 #endif 58 58 59 59 res = n_Div(s, i, r); 60 60 61 61 clog<< "N*(N+1)/2: "; PrintSized(res, r); 62 62 … … 65 65 TS_ASSERT( n_IsZeroDivisor(d, r) ); 66 66 n_Delete(&d, r); 67 67 68 68 if( n_GetChar(r) == 0 ) 69 69 { … … 73 73 } else 74 74 TS_ASSERT_EQUALS( n_GetChar(r), 2); 75 75 76 76 77 77 n_Delete(&s, r); n_Delete(&i, r); 78 79 n_Delete(&sum1, r); n_Delete(&res, r); 80 78 79 n_Delete(&sum1, r); n_Delete(&res, r); 80 81 81 82 82 s = n_Init(0 , r); … … 89 89 i = n_Neg(i, r); 90 90 ndInpAdd(ss, i, r); // ss -= i 91 92 n_Delete(&i, r); 91 92 n_Delete(&i, r); 93 93 } 94 clog<< "ss: "; PrintSized(ss, r); 94 clog<< "ss: "; PrintSized(ss, r); 95 95 96 96 ss = n_Neg(ss, r); // ss = -ss 97 97 98 98 clog<< "real sum : "; PrintSized(s, r); 99 clog<< "real sum(--): "; PrintSized(ss, r); 99 clog<< "real sum(--): "; PrintSized(ss, r); 100 100 101 101 TS_ASSERT( n_Equal(s, ss, r) ); 102 102 TS_ASSERT( n_Equal(ss, s, r) ); 103 103 104 n_Delete(&s, r); 105 n_Delete(&ss, r); 104 n_Delete(&s, r); 105 n_Delete(&ss, r); 106 106 107 107 clog << ( " >>> TEST DONE!" ); … … 118 118 number two = n_Init(2, r); 119 119 120 number t = n_Init(1, r); 121 ndInpAdd(t, t, r); 120 number t = n_Init(1, r); 121 ndInpAdd(t, t, r); 122 122 TS_ASSERT( n_Equal(two, t, r) ); 123 123 n_Delete(&t, r); 124 124 125 125 if( getCoeffType(r) == n_Q ) 126 126 { 127 number t = n_Init(1, r); 127 number t = n_Init(1, r); 128 128 nlInpAdd(t, t, r); 129 129 TS_ASSERT( n_Equal(two, t, r) ); … … 133 133 134 134 135 135 136 136 const int N = 66666; 137 137 138 138 number a = n_Init(N, r); 139 139 140 140 clog<< "a: "; PrintSized(a, r); 141 141 142 142 143 143 clog<< "two: "; PrintSized(two, r); 144 144 … … 148 148 149 149 clog<< "aa = a + a: "; PrintSized(aa, r); 150 150 151 151 number aa2 = n_Mult(a, two, r); 152 152 … … 154 154 155 155 number aa1 = n_Mult(two, a, r); 156 156 157 157 clog<< "aa1 = 2 * a: "; PrintSized(aa1, r); 158 158 … … 162 162 163 163 a = n_Sub( aa, aa1, r ); 164 164 165 165 clog<< "a = aa - aa1: "; PrintSized(a, r); 166 166 … … 187 187 188 188 189 189 190 190 TS_ASSERT( n_Equal(aa, aa1, r) ); 191 191 TS_ASSERT( n_Equal(aa, aa2, r) ); 192 192 TS_ASSERT( n_Equal(aa1, aa2, r) ); 193 193 194 194 TS_ASSERT( n_Equal(aa0, aa, r) ); 195 195 TS_ASSERT( n_Equal(aa0, aa1, r) ); … … 209 209 210 210 211 211 212 212 213 213 BOOLEAN Test(const n_coeffType type, void* p = NULLp) 214 214 { 215 215 216 216 clog << endl; 217 217 clog << ( "----------------------- Testing coeffs: [" + _2S(type) + ", " + _2S(p) + "]: -----------------------"); … … 230 230 if( r->cfCoeffWrite != NULL ) 231 231 { 232 clog << "Coeff-domain: " << endl; 232 clog << "Coeff-domain: " << endl; 233 233 n_CoeffWrite(r); PrintLn(); 234 234 } … … 239 239 number z = nfPar (0, r); // also any integer instead of 0//? 240 240 clog << "Generator: "; PrintSized(z, r); 241 n_Delete(&z, r); 241 n_Delete(&z, r); 242 242 } 243 243 244 clog << "Char: " << n_GetChar(r) << endl; 245 246 244 clog << "Char: " << n_GetChar(r) << endl; 245 246 247 247 TS_ASSERT_DIFFERS( r, NULLp ); 248 248 nSetChar( r ); … … 262 262 TS_ASSERT_EQUALS( r->cfAdd, nlAdd ); 263 263 TS_ASSERT_EQUALS( r->cfDelete, nlDelete ); 264 264 265 265 TS_ASSERT( nCoeff_is_Q( r )); 266 266 TS_ASSERT( nCoeff_is_Domain( r )); … … 283 283 TS_ASSERT( !nCoeff_is_CF( r )); 284 284 TS_ASSERT( !nCoeff_is_Extension( r )); 285 285 286 286 break; 287 287 } … … 299 299 TS_ASSERT_EQUALS( r->cfWrite, ngcWrite ); 300 300 TS_ASSERT_EQUALS( r->cfAdd, ngcAdd ); 301 TS_ASSERT_EQUALS( r->cfDelete, ngcDelete ); 301 TS_ASSERT_EQUALS( r->cfDelete, ngcDelete ); 302 302 break; 303 303 } … … 362 362 363 363 364 class CoeffsTestSuite : public CxxTest::TestSuite 364 class CoeffsTestSuite : public CxxTest::TestSuite 365 365 { 366 366 public: … … 388 388 #endif 389 389 } 390 390 391 391 void simple(const n_coeffType _type) 392 392 { … … 395 395 TS_ASSERT( Test(type) ); 396 396 } 397 397 398 398 void test_Q() 399 399 { 400 400 simple(n_Q); 401 401 } 402 402 403 403 void test_R() 404 404 { … … 414 414 } 415 415 416 416 417 417 void test_GF_toobig() 418 418 { … … 427 427 TS_ASSERT( !Test(type, (void*) ¶m) ); 428 428 429 // it should not be used by numbers... right? 429 // it should not be used by numbers... right? 430 430 // TODO: what is our policy wrt param-pointer-ownership? 431 431 } … … 445 445 TS_ASSERT( Test(type, (void*) ¶m) ); 446 446 447 // it should not be used by numbers... right? 447 // it should not be used by numbers... right? 448 448 // TODO: what is our policy wrt param-pointer-ownership? 449 449 } 450 450 451 451 452 452 void test_Zn3() … … 472 472 simple(n_long_R); 473 473 } 474 474 475 475 void test_LC() 476 476 { 477 477 simple(n_long_C); 478 478 } 479 479 480 480 void test_Q_special() 481 481 { … … 489 489 if (cf->cfCoeffWrite != NULL ) 490 490 { 491 clog << "Coeff-domain: " << endl; 491 clog << "Coeff-domain: " << endl; 492 492 n_CoeffWrite(cf); PrintLn(); 493 493 } 494 494 495 495 number q1 = n_Init(21, cf); 496 496 number q2 = n_Init(2, cf);
Note: See TracChangeset
for help on using the changeset viewer.