Skip to content
Snippets Groups Projects
Commit e1a8b461 authored by Owen Arnold's avatar Owen Arnold
Browse files

OrientedLattice operator== and operator!=

parent c1866aa4
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,9 @@ public: ...@@ -67,6 +67,9 @@ public:
static bool GetABC(const Kernel::DblMatrix &UB, Kernel::V3D &a_dir, static bool GetABC(const Kernel::DblMatrix &UB, Kernel::V3D &a_dir,
Kernel::V3D &b_dir, Kernel::V3D &c_dir); Kernel::V3D &b_dir, Kernel::V3D &c_dir);
bool operator==(const OrientedLattice &other) const;
bool operator!=(const OrientedLattice &other) const;
private: private:
Kernel::DblMatrix U; Kernel::DblMatrix U;
Kernel::DblMatrix UB; Kernel::DblMatrix UB;
...@@ -79,4 +82,4 @@ private: ...@@ -79,4 +82,4 @@ private:
void recalculate() override; void recalculate() override;
}; };
} // namespace Geometry } // namespace Geometry
} // namespace Mantid } // namespace Mantid
\ No newline at end of file
...@@ -344,5 +344,11 @@ void OrientedLattice::recalculate() { ...@@ -344,5 +344,11 @@ void OrientedLattice::recalculate() {
UnitCell::recalculate(); UnitCell::recalculate();
UB = U * getB(); UB = U * getB();
} }
bool OrientedLattice::operator==(const OrientedLattice &other) const {
return UB == other.UB;
}
bool OrientedLattice::operator!=(const OrientedLattice &other) const {
return UB != other.UB;
}
} // Namespace Geometry } // Namespace Geometry
} // Namespace Mantid } // Namespace Mantid
...@@ -300,4 +300,29 @@ public: ...@@ -300,4 +300,29 @@ public:
TSM_ASSERT_EQUALS(" should be along the y direction", V3D(0, 1, 0), ey); TSM_ASSERT_EQUALS(" should be along the y direction", V3D(0, 1, 0), ey);
TSM_ASSERT_EQUALS("y direction is", V3D(0, -1, 0), eyPrime); TSM_ASSERT_EQUALS("y direction is", V3D(0, -1, 0), eyPrime);
} }
void test_equals_when_orientedlattice_identical() {
OrientedLattice a(1.0, 2.0, 3.0, 90.0, 90.0,
90.0); // create via lattice parameters
OrientedLattice b{a};
TS_ASSERT_EQUALS(a, b);
TS_ASSERT(!(a != b));
}
void test_not_equals_when_orientedlattice_different_b() {
OrientedLattice a(1.0, 2.0, 3.0, 90.0, 90.0,
90.0); // create via lattice parameters
OrientedLattice b{a};
b.seta(10); // Results in B change
TS_ASSERT_DIFFERS(a, b);
TS_ASSERT(!(a == b));
}
void test_not_equals_when_orientedlattice_different_u() {
OrientedLattice a(1.0, 2.0, 3.0, 90.0, 90.0,
90.0); // create via lattice parameters
OrientedLattice b{a};
b.setUFromVectors(V3D(0, 1, 0), V3D(1, 0, 0)); // Different U
TS_ASSERT_DIFFERS(a, b);
TS_ASSERT(!(a == b));
}
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment