IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 44ff8cb1 authored by ralfulrich's avatar ralfulrich
Browse files

added copy and swap particle test cases

parent 4a4ede9a
No related branches found
No related tags found
1 merge request!258Interface change of DoDecay() and DoInteraction()
Pipeline #2171 failed
This commit is part of merge request !254. Comments created here will be created in the context of that merge request.
......@@ -241,10 +241,6 @@ namespace corsika::stack {
data_.Swap(a.GetIndex(), b.GetIndex());
std::swap(deleted_[a.GetIndex()], deleted_[b.GetIndex()]);
}
void Swap(ConstStackIterator a, ConstStackIterator b) {
data_.Swap(a.GetIndex(), b.GetIndex());
std::swap(deleted_[a.GetIndex()], deleted_[b.GetIndex()]);
}
void Copy(StackIterator a, StackIterator b) {
data_.Copy(a.GetIndex(), b.GetIndex());
if (deleted_[b.GetIndex()] && !deleted_[a.GetIndex()]) nDeleted_--;
......
......@@ -162,4 +162,52 @@ TEST_CASE("Stack", "[Stack]") {
CHECK(s.getEntries() == 0);
CHECK(s.IsEmpty());
}
SECTION("swap particle") {
StackTest s;
CHECK(s.getSize() == 0);
CHECK(s.getEntries() == 0);
CHECK(s.IsEmpty());
s.AddParticle(std::tuple{9.888});
s.AddParticle(std::tuple{8.999});
CHECK(s.getSize() == 2);
CHECK(s.getEntries() == 2);
CHECK(!s.IsEmpty());
auto p1 = s.begin();
auto p2 = p1+1;
CHECK(p1.GetData()==9.888);
CHECK(p2.GetData()==8.999);
s.Swap(p1, p2);
CHECK(p1.GetData()==8.999);
CHECK(p2.GetData()==9.888);
}
SECTION("copy particle") {
StackTest s;
CHECK(s.getSize() == 0);
CHECK(s.getEntries() == 0);
CHECK(s.IsEmpty());
s.AddParticle(std::tuple{9.888});
s.AddParticle(std::tuple{8.999});
CHECK(s.getSize() == 2);
CHECK(s.getEntries() == 2);
CHECK(!s.IsEmpty());
auto p1 = s.begin();
auto p2 = p1+1;
CHECK(p1.GetData()==9.888);
CHECK(p2.GetData()==8.999);
s.Copy(p1, p2);
CHECK(p1.GetData()==9.888);
CHECK(p2.GetData()==9.888);
}
}
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