|
| 1 | +#include <gtest/gtest.h> |
| 2 | +// alias the gtest "testing" namespace |
| 3 | +namespace gtest = ::testing; |
| 4 | + |
| 5 | +#include <iostream> |
| 6 | +#include <nuTens/propagator/pmns-matrix.hpp> |
| 7 | + |
| 8 | +#include <gtest/gtest.h> |
| 9 | + |
| 10 | +using namespace nuTens; |
| 11 | + |
| 12 | +class PMNSmatrixTest :public gtest::TestWithParam<float> { |
| 13 | + |
| 14 | + protected: |
| 15 | + |
| 16 | + float theta12; |
| 17 | + float theta23; |
| 18 | + float theta13; |
| 19 | + float deltaCP; |
| 20 | + |
| 21 | + PMNSmatrix matrix; |
| 22 | + |
| 23 | + Tensor matrixTensor; |
| 24 | + |
| 25 | + // set up common values to use across tests |
| 26 | + void SetUp() { |
| 27 | + |
| 28 | + theta12 = 1.2 * M_PI; |
| 29 | + theta23 = 2.3 * M_PI; |
| 30 | + theta13 = 1.3 * M_PI; |
| 31 | + deltaCP = 0.5 * M_PI; |
| 32 | + |
| 33 | + matrix.setParameterValues(theta12, theta13, theta23, deltaCP); |
| 34 | + |
| 35 | + matrixTensor = matrix.build(); |
| 36 | + |
| 37 | + } |
| 38 | +}; |
| 39 | + |
| 40 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Ue1) { |
| 41 | + |
| 42 | + ASSERT_EQ(matrixTensor.getValue<float>({0,0,0}), std::cos(theta12) * std::cos(theta13)); |
| 43 | + |
| 44 | +} |
| 45 | + |
| 46 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Ue2) { |
| 47 | + |
| 48 | + ASSERT_EQ(matrixTensor.getValue<float>({0,0,1}), std::sin(theta12) * std::cos(theta13)); |
| 49 | + |
| 50 | +} |
| 51 | + |
| 52 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Ue3) { |
| 53 | + |
| 54 | + std::complex<float> Ue3 = std::sin(theta13) * std::exp(std::complex<float>(0.0, -1.0) * deltaCP); |
| 55 | + ASSERT_EQ(matrixTensor.getValue<std::complex<float>>({0,0,2}), Ue3); |
| 56 | + |
| 57 | +} |
| 58 | + |
| 59 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Um1) { |
| 60 | + |
| 61 | + std::complex<float> Um1 = -std::sin(theta12) * std::cos(theta23) - std::cos(theta12) * std::sin(theta23) * std::sin(theta13) * std::exp(std::complex<float>(0.0, 1.0) * deltaCP); |
| 62 | + ASSERT_EQ(matrixTensor.getValue<std::complex<float>>({0,1,0}), Um1); |
| 63 | + |
| 64 | +} |
| 65 | + |
| 66 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Um2) { |
| 67 | + |
| 68 | + std::complex<float> Um2 = std::cos(theta12) * std::cos(theta23) - std::sin(theta12) * std::sin(theta23) * std::sin(theta13) * std::exp(std::complex<float>(0.0, 1.0) * deltaCP); |
| 69 | + ASSERT_EQ(matrixTensor.getValue<std::complex<float>>({0,1,1}), Um2); |
| 70 | + |
| 71 | +} |
| 72 | + |
| 73 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Um3) { |
| 74 | + |
| 75 | + ASSERT_EQ(matrixTensor.getValue<float>({0,1,2}), std::sin(theta23) * std::cos(theta13)); |
| 76 | + |
| 77 | +} |
| 78 | + |
| 79 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Ut1) { |
| 80 | + |
| 81 | + std::complex<float> Ut1 = std::sin(theta12) * std::sin(theta23) - std::cos(theta12) * std::cos(theta23) * std::sin(theta13) * std::exp(std::complex<float>(0.0, 1.0) * deltaCP); |
| 82 | + ASSERT_EQ(matrixTensor.getValue<std::complex<float>>({0,2,0}), Ut1); |
| 83 | + |
| 84 | +} |
| 85 | + |
| 86 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Ut2) { |
| 87 | + |
| 88 | + std::complex<float> Ut2 = -std::cos(theta12) * std::sin(theta23) - std::sin(theta12) * std::cos(theta23) * std::sin(theta13) * std::exp(std::complex<float>(0.0, 1.0) * deltaCP); |
| 89 | + ASSERT_EQ(matrixTensor.getValue<std::complex<float>>({0,2,1}), Ut2); |
| 90 | + |
| 91 | +} |
| 92 | + |
| 93 | +TEST_F(PMNSmatrixTest, FixedValuesTest_Ut3) { |
| 94 | + |
| 95 | + ASSERT_EQ(matrixTensor.getValue<float>({0,2,2}), std::cos(theta23) * std::cos(theta13)); |
| 96 | + |
| 97 | +} |
0 commit comments