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

Function TEST_F

lib/mdflib/mdflib_test/src/testwrite.cpp:146–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146TEST_F(TestWrite, Mdf3WriteTest1) {
147 if (kSkipTest) {
148 GTEST_SKIP();
149 }
150 path mdf_file(kTestDir);
151 mdf_file.append("test1.mf3");
152 auto writer = MdfFactory::CreateMdfWriter(MdfWriterType::Mdf3Basic);
153
154 writer->Init(mdf_file.string());
155
156 auto* header = writer->Header();
157 ASSERT_TRUE(header != nullptr);
158 header->Author("Ingemar Hedvall");
159 header->Department("Home Alone");
160 header->Description("Testing Sample");
161 header->Project("Mdf3WriteHD");
162 header->StartTime(TimeStampToNs());
163 header->Subject("PXY");
164
165 auto* dg3 = writer->CreateDataGroup();
166 auto* cg3 = mdf::MdfWriter::CreateChannelGroup(dg3);
167 for (size_t cn_index = 0; cn_index < 3; ++cn_index) {
168 auto* cn3 = mdf::MdfWriter::CreateChannel(cg3);
169 ASSERT_TRUE(cn3 != nullptr);
170 std::ostringstream name;
171 name << "Channel_" << cn_index + 1;
172 cn3->Name(name.str());
173 cn3->Description("Channel description");
174 cn3->Type(cn_index == 0 ? ChannelType::Master : ChannelType::FixedLength);
175 cn3->DataType(ChannelDataType::FloatBe);
176 cn3->DataBytes(4);
177 cn3->Unit("s");
178 }
179
180 writer->InitMeasurement();
181
182 writer->StartMeasurement(TimeStampToNs());
183 for (size_t sample = 0; sample < 100; ++sample) {
184 auto cn_list = cg3->Channels();
185 double value = 0.01 * static_cast<double>(sample);
186 for(auto* channel : cn_list) {
187 channel->SetChannelValue(value);
188 }
189 writer->SaveSample(*cg3, TimeStampToNs());
190 sleep_for(10ms);
191 }
192 writer->StopMeasurement(TimeStampToNs());
193 writer->FinalizeMeasurement();
194}
195
196TEST_F(TestWrite, Mdf3WriteTestValueType) {
197 if (kSkipTest) {

Callers

nothing calls this directly

Calls 15

TimeStampToNsFunction · 0.85
TimeMethod · 0.80
ToolNameMethod · 0.80
XmlSnippetMethod · 0.80
emptyMethod · 0.80
GetLogFileMethod · 0.80
IsEmbeddedMethod · 0.80
IsCompressedMethod · 0.80
FileTypeMethod · 0.80
Md5Method · 0.80
GroupNameMethod · 0.80

Tested by

no test coverage detected