Ignore:
File:
1 edited

Legend:

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

    r952f38 rbcf653  
     1/*
     2 * Project: MoleCuilder
     3 * Description: creates and alters molecular systems
     4 * Copyright (C)  2010 University of Bonn. All rights reserved.
     5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
     6 */
     7
    18/*
    29 * unittest.cpp
     
    613 */
    714
     15// include config.h
     16#ifdef HAVE_CONFIG_H
     17#include <config.h>
     18#endif
    819
    920using namespace std;
     
    1627#include "Helpers/Log.hpp"
    1728#include "LinearAlgebra/Vector.hpp"
    18 #include "vector_ops.hpp"
     29#include "LinearAlgebra/vector_ops.hpp"
    1930#include "vectorunittest.hpp"
    2031#include "LinearAlgebra/Plane.hpp"
     
    5263  errorLogger::purgeInstance();
    5364};
     65
     66/** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne().
     67 */
     68void VectorTest::AssignmentTest()
     69{
     70  // test with zero
     71  zero.at(0) = 0;
     72  zero.at(1) = 0;
     73  zero.at(2) = 0;
     74  double zero_array[3] = {0., 0., 0.};
     75
     76  CPPUNIT_ASSERT_EQUAL( zero, Vector(0,0,0));
     77  CPPUNIT_ASSERT_EQUAL( zero, Vector(0.,0.,0.));
     78  CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array[0], zero_array[1], zero_array[2]));
     79  CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array));
     80
     81  // test with unit
     82  unit.at(0) = 1;
     83  unit.at(1) = 0;
     84  unit.at(2) = 0;
     85  double unit_array[3] = {1., 0., 0.};
     86
     87  CPPUNIT_ASSERT_EQUAL( unit, Vector(1,0,0));
     88  CPPUNIT_ASSERT_EQUAL( unit, Vector(1.,0.,0.));
     89  CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array[0], unit_array[1], unit_array[2]));
     90  CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array));
     91
     92  // test with two
     93  two.at(0) = 2;
     94  two.at(1) = 1;
     95  two.at(2) = 0;
     96  double two_array[3] = {2., 1., 0.};
     97
     98  CPPUNIT_ASSERT_EQUAL( two, Vector(2,1,0));
     99  CPPUNIT_ASSERT_EQUAL( two, Vector(2.,1.,0.));
     100  CPPUNIT_ASSERT_EQUAL( two, Vector(two_array[0], two_array[1], two_array[2]));
     101  CPPUNIT_ASSERT_EQUAL( two, Vector(two_array));
     102
     103  // test with three
     104  three.at(0) = 1;
     105  three.at(1) = 2;
     106  three.at(2) = 3;
     107  double three_array[3] = {1., 2., 3.};
     108
     109  CPPUNIT_ASSERT_EQUAL( three, Vector(1,2,3));
     110  CPPUNIT_ASSERT_EQUAL( three, Vector(1.,2.,3.));
     111  CPPUNIT_ASSERT_EQUAL( three, Vector(three_array[0], three_array[1], three_array[2]));
     112  CPPUNIT_ASSERT_EQUAL( three, Vector(three_array));
     113}
    54114
    55115/** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne().
Note: See TracChangeset for help on using the changeset viewer.