utestMorton.cpp 2.02 KB
Newer Older
1
// See LICENCE file at project root
2 3
#include "FUTester.hpp"

BRAMAS Berenger's avatar
BRAMAS Berenger committed
4
#include "Containers/FTreeCoordinate.hpp"
5 6 7 8 9 10 11 12 13 14 15 16 17 18

// compile by g++ utestMorton.cpp -o utestMorton.exe

/**
* This file is a unit test for the FTreeCoordinate class
*/


/** this class test the list container */
class TestMorton : public FUTester<TestMorton> {
        void Morton(){
            {
                FTreeCoordinate pos(5,1,7);
                FTreeCoordinate cp;
19
                cp.setPositionFromMorton(pos.getMortonIndex());
20
                uassert(pos == cp);
21
                uassert(cp.getMortonIndex() == pos.getMortonIndex());
22 23 24 25
            }
            {
                FTreeCoordinate pos(2,8,3);
                FTreeCoordinate cp;
26
                cp.setPositionFromMorton(pos.getMortonIndex());
27
                uassert(pos == cp);
28
                uassert(cp.getMortonIndex() == pos.getMortonIndex());
29 30 31 32
            }
            {
                FTreeCoordinate pos(51,11,47);
                FTreeCoordinate cp;
33
                cp.setPositionFromMorton(pos.getMortonIndex());
34
                uassert(pos == cp);
35
                uassert(cp.getMortonIndex() == pos.getMortonIndex());
36 37 38 39 40 41
            }
	}

        void Position(){
            {
                FTreeCoordinate pos(0,0,0);
42
                uassert(pos.getMortonIndex() == 0);
43 44 45
            }
            {
                FTreeCoordinate pos(1,1,1);
46
                uassert(pos.getMortonIndex() == 7);
47 48 49
            }
            {
                FTreeCoordinate pos(0,1,1);
50
                uassert(pos.getMortonIndex() == 3);
51 52 53
            }
            {
                FTreeCoordinate pos(2,2,2);
54
                uassert(pos.getMortonIndex() == (7 << 3) );
55 56 57
            }
            {
                FTreeCoordinate pos(1,2,4);
58
                uassert(pos.getMortonIndex() == 84 );// 001 010 100 =>> 001010100 => 84d
59 60
            }
	}
61

62 63 64 65 66 67 68 69 70
	// set test
	void SetTests(){
            AddTest(&TestMorton::Morton,"Test Morton");
            AddTest(&TestMorton::Position,"Test Position");
	}
};

// You must do this
TestClass(TestMorton)