utestBoolArray.cpp 2.81 KB
Newer Older
1
// ===================================================================================
2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.  
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info". 
// "http://www.gnu.org/licenses".
15
// ===================================================================================
16 17
#include "FUTester.hpp"

BRAMAS Berenger's avatar
BRAMAS Berenger committed
18
#include "Containers/FBoolArray.hpp"
19 20 21 22 23 24 25 26 27 28 29


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


/** this class test the bool array container */
class TestArray : public FUTester<TestArray> {

        void TestGetSet(){
30 31
                FBoolArray array(500);
                for(int idx = 0 ; idx < 500 ; ++idx){
32
                    uassert(!array.get(idx));
33 34
                }

35
                for(int idx = 0 ; idx < 500 ; ++idx){
36
                    array.set(idx, true);
37
                    uassert(array.get(idx));
38
                    array.set(idx, false);
39
                    uassert(!array.get(idx));
40 41 42 43 44 45 46
                }

                for(int idx = 0 ; idx < 500 ; ++idx){
                    array.set(idx, true);
                }
                array.setToZeros();
                for(int idx = 0 ; idx < 500 ; ++idx){
47
                    uassert(!array.get(idx));
48 49 50 51
                }
	}

        void TestGetSet2(){
52
                FBoolArray array(100);
53

54
                for(int idx = 0 ; idx < 100 ; ++idx){
55 56
                    if(idx%3){
                        array.set(idx, true);
57
                        uassert(array.get(idx));
58 59
                    }
                    else{
60
                        uassert(!array.get(idx));
61 62 63 64 65 66 67 68 69
                    }
                }
        }

        void TestEqual(){
                FBoolArray array1(10);
                FBoolArray array2(10);


70
                uassert(array1 == array2);
71 72

                array1.set(1, true);
73
                uassert(array1 != array2);
74 75

                array2.set(1, true);
76
                uassert(array1 == array2);
77 78 79

                array1.set(5, true);
                array2 = array1;
80
                uassert(array1 == array2);
81 82 83 84 85 86 87 88 89 90 91 92 93 94
        }
		
	// set test
	void SetTests(){
            AddTest(&TestArray::TestGetSet,"Test Get & Set");
            AddTest(&TestArray::TestGetSet2,"Test Get & Set 2");
            AddTest(&TestArray::TestEqual,"Test Equal");
	}
};

// You must do this
TestClass(TestArray)