Skip to content

Commit

Permalink
Test IDs and actually compare strings in serialization test
Browse files Browse the repository at this point in the history
  • Loading branch information
austinschneider committed Feb 1, 2024
1 parent 7cd64b7 commit ce06479
Showing 1 changed file with 86 additions and 1 deletion.
87 changes: 86 additions & 1 deletion projects/dataclasses/private/test/InteractionRecord_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ TEST(Comparison, Comparison_equal)
B.signature.secondary_types.push_back(Particle::ParticleType::EMinus);
EXPECT_TRUE(A == B);

A.primary_id = ParticleID(1, 1);
EXPECT_FALSE(A == B);
B.primary_id = ParticleID(1, 1);
EXPECT_TRUE(A == B);

A.primary_initial_position = {1.0, 2.0, 3.0};
EXPECT_FALSE(A == B);
B.primary_initial_position = {1.0, 2.0, 3.0};
Expand Down Expand Up @@ -144,6 +149,14 @@ TEST(Comparison, LessThan)
EXPECT_FALSE(A < B);
EXPECT_FALSE(B < A);

A.primary_id = ParticleID(1, 1);
EXPECT_FALSE(A < B);
EXPECT_TRUE(B < A);

B.primary_id = ParticleID(1, 1);
EXPECT_FALSE(A < B);
EXPECT_FALSE(B < A);

A.primary_initial_position = {1.0, 2.0, 3.0};
EXPECT_FALSE(A < B);
EXPECT_TRUE(B < A);
Expand Down Expand Up @@ -255,6 +268,8 @@ TEST(Serialization, Save)
record.signature.primary_type = Particle::ParticleType::EMinus;
record.signature.target_type = Particle::ParticleType::PPlus;
record.signature.secondary_types.push_back(Particle::ParticleType::EMinus);
record.primary_id = ParticleID(1, 1);
record.primary_initial_position = {1.0, 2.0, 3.0};
record.primary_mass = 1.0;
record.primary_momentum = {1.0, 2.0, 3.0, 4.0};
record.primary_helicity = 1.0;
Expand All @@ -274,7 +289,77 @@ TEST(Serialization, Save)
oarchive(record);
}

std::string expected = "{\n \"cereal_class_version\": 0,\n \"InteractionSignature\": {\n \"cereal_class_version\": 0,\n \"PrimaryType\": -11,\n \"TargetType\": 2212,\n \"SecondaryTypes\": [\n -11\n ]\n },\n \"PrimaryInitialPosition\": [\n 1,\n 2,\n 3\n ],\n \"PrimaryMass\": 1,\n \"PrimaryMomentum\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"PrimaryHelicity\": 1,\n \"TargetMass\": 1,\n \"TargetMomentum\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"TargetHelicity\": 1,\n \"InteractionVertex\": [\n 1,\n 2,\n 3\n ],\n \"SecondaryMasses\": [\n 1\n ],\n \"SecondaryMomenta\": [\n [\n 1,\n 2,\n 3,\n 4\n ]\n ],\n \"SecondaryHelicity\": [\n 1\n ],\n \"InteractionParameters\": {\n \"test\": 1\n }\n}";
std::string expected = "{\n\
\"value0\": {\n\
\"cereal_class_version\": 0,\n\
\"InteractionSignature\": {\n\
\"cereal_class_version\": 0,\n\
\"PrimaryType\": 11,\n\
\"TargetType\": 2212,\n\
\"SecondaryTypes\": [\n\
11\n\
]\n\
},\n\
\"PrimaryID\": {\n\
\"cereal_class_version\": 0,\n\
\"MajorID\": 1,\n\
\"MinorID\": 1\n\
},\n\
\"PrimaryInitialPosition\": [\n\
1.0,\n\
2.0,\n\
3.0\n\
],\n\
\"PrimaryMass\": 1.0,\n\
\"PrimaryMomentum\": [\n\
1.0,\n\
2.0,\n\
3.0,\n\
4.0\n\
],\n\
\"PrimaryHelicity\": 1.0,\n\
\"TargetID\": {\n\
\"MajorID\": 0,\n\
\"MinorID\": 0\n\
},\n\
\"TargetMass\": 1.0,\n\
\"TargetMomentum\": [\n\
1.0,\n\
2.0,\n\
3.0,\n\
4.0\n\
],\n\
\"TargetHelicity\": 1.0,\n\
\"InteractionVertex\": [\n\
1.0,\n\
2.0,\n\
3.0\n\
],\n\
\"SecondaryIDs\": [],\n\
\"SecondaryMasses\": [\n\
1.0\n\
],\n\
\"SecondaryMomenta\": [\n\
[\n\
1.0,\n\
2.0,\n\
3.0,\n\
4.0\n\
]\n\
],\n\
\"SecondaryHelicity\": [\n\
1.0\n\
],\n\
\"InteractionParameters\": [\n\
{\n\
\"key\": \"test\",\n\
\"value\": 1.0\n\
}\n\
]\n\
}\n\
}";

EXPECT_EQ(ss.str(), expected);
}

int main(int argc, char** argv)
Expand Down

0 comments on commit ce06479

Please sign in to comment.