Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/unittests/vectorunittest.cpp

    r952f38 rbf3817  
    66 */
    77
     8// include config.h
     9#ifdef HAVE_CONFIG_H
     10#include <config.h>
     11#endif
    812
    913using namespace std;
     
    1620#include "Helpers/Log.hpp"
    1721#include "LinearAlgebra/Vector.hpp"
    18 #include "vector_ops.hpp"
     22#include "LinearAlgebra/vector_ops.hpp"
    1923#include "vectorunittest.hpp"
    2024#include "LinearAlgebra/Plane.hpp"
     
    5256  errorLogger::purgeInstance();
    5357};
     58
     59/** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne().
     60 */
     61void VectorTest::AssignmentTest()
     62{
     63  // test with zero
     64  zero.at(0) = 0;
     65  zero.at(1) = 0;
     66  zero.at(2) = 0;
     67  double zero_array[3] = {0., 0., 0.};
     68
     69  CPPUNIT_ASSERT_EQUAL( zero, Vector(0,0,0));
     70  CPPUNIT_ASSERT_EQUAL( zero, Vector(0.,0.,0.));
     71  CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array[0], zero_array[1], zero_array[2]));
     72  CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array));
     73
     74  // test with unit
     75  unit.at(0) = 1;
     76  unit.at(1) = 0;
     77  unit.at(2) = 0;
     78  double unit_array[3] = {1., 0., 0.};
     79
     80  CPPUNIT_ASSERT_EQUAL( unit, Vector(1,0,0));
     81  CPPUNIT_ASSERT_EQUAL( unit, Vector(1.,0.,0.));
     82  CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array[0], unit_array[1], unit_array[2]));
     83  CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array));
     84
     85  // test with two
     86  two.at(0) = 2;
     87  two.at(1) = 1;
     88  two.at(2) = 0;
     89  double two_array[3] = {2., 1., 0.};
     90
     91  CPPUNIT_ASSERT_EQUAL( two, Vector(2,1,0));
     92  CPPUNIT_ASSERT_EQUAL( two, Vector(2.,1.,0.));
     93  CPPUNIT_ASSERT_EQUAL( two, Vector(two_array[0], two_array[1], two_array[2]));
     94  CPPUNIT_ASSERT_EQUAL( two, Vector(two_array));
     95
     96  // test with three
     97  three.at(0) = 1;
     98  three.at(1) = 2;
     99  three.at(2) = 3;
     100  double three_array[3] = {1., 2., 3.};
     101
     102  CPPUNIT_ASSERT_EQUAL( three, Vector(1,2,3));
     103  CPPUNIT_ASSERT_EQUAL( three, Vector(1.,2.,3.));
     104  CPPUNIT_ASSERT_EQUAL( three, Vector(three_array[0], three_array[1], three_array[2]));
     105  CPPUNIT_ASSERT_EQUAL( three, Vector(three_array));
     106}
    54107
    55108/** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne().
Note: See TracChangeset for help on using the changeset viewer.