MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / TEST

Function TEST

lib/mdflib/mdflib_test/src/testhdcomment.cpp:17–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace mdf::test {
16
17TEST(TestHdComment, Properties) {
18 HdComment comment;
19
20 constexpr std::string_view kAuthor = "Road Runner";
21 comment.Author(std::string(kAuthor));
22 EXPECT_EQ(comment.Author(), kAuthor);
23
24 constexpr std::string_view kDepartment = "ACME Ltd";
25 comment.Department(std::string(kDepartment));
26 EXPECT_EQ(comment.Department(), kDepartment);
27
28 constexpr std::string_view kProject = "Exploding MDF";
29 comment.Project(std::string(kProject));
30 EXPECT_EQ(comment.Project(), kProject);
31
32 constexpr std::string_view kSubject = "Instant Success";
33 comment.Subject(std::string(kSubject));
34 EXPECT_EQ(comment.Subject(), kSubject);
35
36 constexpr std::string_view kMeasUuid = "&789";
37 comment.MeasurementUuid(std::string(kMeasUuid));
38 EXPECT_EQ(comment.MeasurementUuid(), kMeasUuid);
39
40 constexpr std::string_view kRecorderUuid = "1234";
41 comment.RecorderUuid(std::string(kRecorderUuid));
42 EXPECT_EQ(comment.RecorderUuid(), kRecorderUuid);
43
44 constexpr int64_t kRecorderFileIndex = 112;
45 comment.RecorderFileIndex(kRecorderFileIndex);
46 EXPECT_EQ(comment.RecorderFileIndex(), kRecorderFileIndex);
47
48 constexpr std::string_view kTimeSource = "PC Computer";
49 comment.TimeSource(MdString(kTimeSource));
50 EXPECT_EQ(comment.TimeSource(), kTimeSource);
51
52 constexpr double kPi = 3.14;
53 comment.AddConstant(MdString("PI"), std::to_string(kPi) );
54 EXPECT_EQ(comment.Constants().size(), 1);
55
56 auto& unit_spec = comment.UnitSpecification();
57 constexpr std::string_view kKiloMeter = "km";
58 HoUnit unit;
59 unit.Identity(std::string(kKiloMeter));
60 unit.ShortName(std::string(kKiloMeter));
61 unit_spec.AddUnit(unit);
62
63 std::string xml_snippet = comment.ToXml();
64
65 HdComment comment1;
66 comment1.FromXml(xml_snippet);
67
68 EXPECT_EQ(comment1.TimeSource(), comment.TimeSource());
69 EXPECT_EQ(comment1.Constants().size(), 1);
70 for ( const auto& [name, expression] : comment1.Constants()) {
71 EXPECT_EQ(name.Text(), std::string("PI"));
72 EXPECT_DOUBLE_EQ(std::stod(expression), 3.14);
73 }
74

Callers

nothing calls this directly

Calls 15

MdStringClass · 0.85
MeasurementUuidMethod · 0.80
RecorderUuidMethod · 0.80
RecorderFileIndexMethod · 0.80
TimeSourceMethod · 0.80
AddConstantMethod · 0.80
AddUnitMethod · 0.80
TeamMemberReferenceMethod · 0.80
RevisionLabelMethod · 0.80
DateNsMethod · 0.80
AddCompanyRevisionMethod · 0.80
AddModificationMethod · 0.80

Tested by

no test coverage detected