OOPS
TestVector3D.h
Go to the documentation of this file.
1
/*
2
* (C) Copyright 2020 Met Office UK
3
*
4
* This software is licensed under the terms of the Apache Licence Version 2.0
5
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
*/
7
8
#ifndef TEST_ASSIMILATION_TESTVECTOR3D_H_
9
#define TEST_ASSIMILATION_TESTVECTOR3D_H_
10
11
#include <string>
12
#include <vector>
13
14
#include "eckit/testing/Test.h"
15
16
#include "
oops/../test/TestEnvironment.h
"
17
#include "
oops/runs/Test.h
"
18
#include "oops/util/Expect.h"
19
20
#include "
test/assimilation/Vector3D.h
"
21
22
namespace
test
{
23
24
void
test_Vector3D
()
25
{
26
// Test each function in the Vector3D class
27
28
const
Vector3D
v1(1.0, 2.0, 3.0);
29
const
Vector3D
v2(4.0, 5.0, 6.0);
30
31
Vector3D
vEq = v1;
32
EXPECT(vEq.
x
() == 1.0 && vEq.
y
() == 2.0 && vEq.
z
() == 3.0);
33
34
const
Vector3D
vCopy(v1);
35
EXPECT(vCopy.
x
() == 1.0 && vCopy.
y
() == 2.0 && vCopy.
z
() == 3.0);
36
37
Vector3D
vAdd = v1;
38
vAdd += v2;
39
EXPECT(vAdd.
x
() == 5.0 && vAdd.
y
() == 7.0 && vAdd.
z
() == 9.0);
40
41
Vector3D
vSub = v2;
42
vSub -= v1;
43
EXPECT(vSub.
x
() == 3.0 && vSub.
y
() == 3.0 && vSub.
z
() == 3.0);
44
45
Vector3D
vMult = v1;
46
vMult *= 2.0;
47
EXPECT(vMult.
x
() == 2.0 && vMult.
y
() == 4.0 && vMult.
z
() == 6.0);
48
49
Vector3D
vMultV = v1;
50
vMultV *= v2;
51
EXPECT(vMultV.
x
() == 4.0 && vMultV.
y
() == 10.0 && vMultV.
z
() == 18.0);
52
53
Vector3D
vDivV = v2;
54
vDivV /= v1;
55
EXPECT(vDivV.
x
() == 4.0 && vDivV.
y
() == 2.5 && vDivV.
z
() == 2.0);
56
57
Vector3D
vAxpy = v1;
58
vAxpy.
axpy
(3, v2);
59
EXPECT(vAxpy.
x
() == 13.0 && vAxpy.
y
() == 17.0 && vAxpy.
z
() == 21.0);
60
61
const
double
dotprod = v1.
dot_product_with
(v2);
62
EXPECT(dotprod == 32.0);
63
}
64
65
CASE
(
"assimilation/TestVector3D/Vector3D"
) {
66
test_Vector3D
();
67
}
68
69
class
TestVector3D
:
public
oops::Test
{
70
private
:
71
std::string
testid
()
const override
{
return
"test::TestVector3D"
;}
72
void
register_tests
()
const override
{}
73
void
clear
()
const override
{}
74
};
75
76
}
// namespace test
77
78
#endif // TEST_ASSIMILATION_TESTVECTOR3D_H_
test::Vector3D::y
double y() const
Definition:
Vector3D.h:31
test::Vector3D::z
double z() const
Definition:
Vector3D.h:32
test::Vector3D::axpy
void axpy(const double, const Vector3D &)
x -> x + mult * rhs
Definition:
Vector3D.cc:74
test::Vector3D::dot_product_with
double dot_product_with(const Vector3D &) const
Definition:
Vector3D.cc:81
test::CASE
CASE("test_linearmodelparameterswrapper_valid_name")
Definition:
LinearModelFactory.cc:22
test::Vector3D
Definition:
Vector3D.h:15
test
Definition:
LinearModelFactory.cc:20
test::TestVector3D
Definition:
TestVector3D.h:69
Test.h
test::test_Vector3D
void test_Vector3D()
Definition:
TestVector3D.h:24
TestEnvironment.h
test::TestVector3D::testid
std::string testid() const override
Definition:
TestVector3D.h:71
Vector3D.h
test::TestVector3D::register_tests
void register_tests() const override
Definition:
TestVector3D.h:72
oops::Test
Definition:
Test.h:39
test::Vector3D::x
double x() const
Definition:
Vector3D.h:30
test::TestVector3D::clear
void clear() const override
Definition:
TestVector3D.h:73
fv3-bundle
oops
src
test
assimilation
TestVector3D.h
Generated on Sun Oct 25 2020 12:42:59 for OOPS by
1.8.18