Subversion Repositories gelsvn

Rev

Rev 667 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 667 Rev 680
Line 2... Line 2...
2
#include <cmath>
2
#include <cmath>
3
#include <ctime>
3
#include <ctime>
4
#include <cstdlib>
4
#include <cstdlib>
5
#include <climits>
5
#include <climits>
6
 
6
 
7
#include "CGLA/Vec2d.h"
7
#include <GEL/CGLA/Vec2d.h>
8
#include "CGLA/Vec2f.h"
8
#include <GEL/CGLA/Vec2f.h>
9
#include "CGLA/Vec2i.h"
9
#include <GEL/CGLA/Vec2i.h>
10
#include "CGLA/Vec3i.h"
10
#include <GEL/CGLA/Vec3i.h>
11
#include "CGLA/Vec3f.h" 
11
#include <GEL/CGLA/Vec3f.h> 
12
#include "CGLA/Vec3d.h" 
12
#include <GEL/CGLA/Vec3d.h> 
13
#include "CGLA/Vec3Hf.h" // next
13
#include <GEL/CGLA/Vec3Hf.h> // next
14
#include "CGLA/Vec3uc.h"
14
#include <GEL/CGLA/Vec3uc.h>
15
#include "CGLA/Vec3usi.h"
15
#include <GEL/CGLA/Vec3usi.h>
16
#include "CGLA/Vec4f.h"
16
#include <GEL/CGLA/Vec4f.h>
17
#include "CGLA/Vec4d.h"
17
#include <GEL/CGLA/Vec4d.h>
18
#include "CGLA/Vec4uc.h"
18
#include <GEL/CGLA/Vec4uc.h>
19
#include "CGLA/Quatf.h"
19
#include <GEL/CGLA/Quatf.h>
20
#include "CGLA/Quatd.h"
20
#include <GEL/CGLA/Quatd.h>
21
#include "Util/Timer.h"
21
#include <GEL/Util/Timer.h>
22
 
22
 
23
using namespace std;
23
using namespace std;
24
using namespace CGLA;
24
using namespace CGLA;
25
using namespace Util;
25
using namespace Util;
26
 
26
 
Line 34... Line 34...
34
}
34
}
35
 
35
 
36
/* This is a non-exhaustive test program for CGLA */
36
/* This is a non-exhaustive test program for CGLA */
37
int main()
37
int main()
38
{
38
{
-
 
39
    cout << "Note that some of these tests appear to fail although everything works," << endl;
-
 
40
    cout << "e.g. because floating point to double conversion and back does not yield original number" << endl;
39
  int success = 0;
41
  int success = 0;
40
  Timer t;
42
  Timer t;
41
 
43
 
42
  gel_srand(time(0));
44
  gel_srand(time(0));
43
 
45
 
Line 373... Line 375...
373
 
375
 
374
    int xii1 = gel_rand(), xii2 = gel_rand();
376
    int xii1 = gel_rand(), xii2 = gel_rand();
375
    Vec2i i1(xii1, xii2);
377
    Vec2i i1(xii1, xii2);
376
    Vec2f x3(i1);
378
    Vec2f x3(i1);
377
    success += x3[0] == xii1 && x3[1] == xii2;
379
    success += x3[0] == xii1 && x3[1] == xii2;
378
 
380
      
-
 
381
 // Doubles and floats cannot represent exactly the same numbers.
379
    double xiii1 = my_random(), xiii2 = my_random();
382
//    double xiii1 = my_random(), xiii2 = my_random();
380
    Vec2d d1(xiii1, xiii2);
383
//    Vec2d d1(xiii1, xiii2);
381
    Vec2f x4(d1);
384
//    Vec2f x4(d1);
382
    success += x4[0] == xiii1 && x4[1] == xiii2;
385
//    success += x4[0] == xiii1 && x4[1] == xiii2;
383
 
386
 
384
    float xiiii = my_random();
387
    float xiiii = my_random();
385
    Vec2f x5(xiiii);
388
    Vec2f x5(xiiii);
386
    success += x5[0] == xiiii && x5[1] == xiiii;
389
    success += x5[0] == xiiii && x5[1] == xiiii;
387
  }
390
  }
388
  if(success != 5)
391
  if(success != 4)
389
  {
392
  {
390
    cout << "Failure in test of Vec2f Constructors";
393
    cout << "Failure in test of Vec2f Constructors";
391
    system ("pause");
394
    system ("pause");
392
    return 1;
395
    return 1;
393
  }
396
  }
Line 1256... Line 1259...
1256
 
1259
 
1257
    float xiiii = my_random();
1260
    float xiiii = my_random();
1258
    Vec3f x3(xiiii);
1261
    Vec3f x3(xiiii);
1259
    success += x3[0] == xiiii && x3[1] == xiiii && x3[2] == xiiii;
1262
    success += x3[0] == xiiii && x3[1] == xiiii && x3[2] == xiiii;
1260
 
1263
 
-
 
1264
      // Doubles and floats cannot represent exactly the same numbers.
1261
    double xii1 = my_random(), xii2 = my_random(), xii3 = my_random();
1265
//    double xii1 = my_random(), xii2 = my_random(), xii3 = my_random();
1262
    Vec3d d1(xii1, xii2, xii3);
1266
//    Vec3d d1(xii1, xii2, xii3);
1263
    Vec3f x4(d1);
1267
//    Vec3f x4(d1);
1264
    success += x4[0] == xii1 && x4[1] == xii2 && x4[2] == xii3;
1268
//    success += x4[0] == xii1 && x4[1] == xii2 && x4[2] == xii3;
1265
 
1269
 
1266
    int xiii1 = gel_rand(), xiii2 = gel_rand(), xiii3 = gel_rand();
1270
    int xiii1 = gel_rand(), xiii2 = gel_rand(), xiii3 = gel_rand();
1267
    Vec3i i1(xiii1, xiii2, xiii3);
1271
    Vec3i i1(xiii1, xiii2, xiii3);
1268
    Vec3f x5(i1);
1272
    Vec3f x5(i1);
1269
    success += x5[0] == xiii1 && x5[1] == xiii2 && x5[2] == xiii3;
1273
    success += x5[0] == xiii1 && x5[1] == xiii2 && x5[2] == xiii3;