1414#include < memory>
1515#include < vector>
1616
17+ #include " absl/log/check.h"
1718#include " absl/status/statusor.h"
1819#include " absl/types/optional.h"
1920#include " absl/types/span.h"
@@ -168,15 +169,14 @@ TEST(XC7ConfigurationTest,
168169 MemoryMapFile (kTestDataBase / " xc7-configuration.debug.bit" );
169170 ASSERT_TRUE (debug_bitstream_status.ok ()) << debug_bitstream_status.status ();
170171 auto &debug_bitstream = debug_bitstream_status.value ();
171- ASSERT_TRUE (debug_bitstream);
172+ CHECK (debug_bitstream);
172173
173174 auto debug_reader =
174175 BitstreamReader<kArch >::InitWithBytes (debug_bitstream->AsBytesView ());
175- ASSERT_TRUE (debug_reader);
176+ CHECK (debug_reader. has_value () );
176177 auto debug_configuration =
177- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
178178 Configuration<kArch >::InitWithPackets (*part, *debug_reader);
179- ASSERT_TRUE (debug_configuration);
179+ CHECK (debug_configuration. has_value () );
180180
181181 absl::StatusOr<std::unique_ptr<MemoryBlock>> perframecrc_bitstream_status =
182182 MemoryMapFile (kTestDataBase / " xc7-configuration.perframecrc.bit" );
@@ -187,18 +187,14 @@ TEST(XC7ConfigurationTest,
187187
188188 auto perframecrc_reader =
189189 BitstreamReader<kArch >::InitWithBytes (perframecrc_bitstream->AsBytesView ());
190- ASSERT_TRUE (perframecrc_reader);
190+ CHECK (perframecrc_reader. has_value () );
191191 auto perframecrc_configuration =
192- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
193192 Configuration<kArch >::InitWithPackets (*part, *perframecrc_reader);
194- ASSERT_TRUE (perframecrc_configuration);
193+ CHECK (perframecrc_configuration. has_value () );
195194
196- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
197195 for (auto debug_frame : debug_configuration->frames ()) {
198196 auto perframecrc_frame =
199- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
200197 perframecrc_configuration->frames ().find (debug_frame.first );
201- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
202198 if (perframecrc_frame == perframecrc_configuration->frames ().end ()) {
203199 ADD_FAILURE () << debug_frame.first
204200 << " : missing in perframecrc bitstream" ;
@@ -210,12 +206,9 @@ TEST(XC7ConfigurationTest,
210206 << debug_frame.first << " : word " << ii;
211207 }
212208 }
213- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
214209 for (auto perframecrc_frame : perframecrc_configuration->frames ()) {
215210 auto debug_frame =
216- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
217211 debug_configuration->frames ().find (perframecrc_frame.first );
218- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
219212 if (debug_frame == debug_configuration->frames ().end ()) {
220213 ADD_FAILURE () << perframecrc_frame.first
221214 << " : unexpectedly present in "
@@ -233,15 +226,14 @@ TEST(XC7ConfigurationTest, DebugAndNormalBitstreamsProduceEqualConfigurations) {
233226 MemoryMapFile (kTestDataBase / " xc7-configuration.debug.bit" );
234227 ASSERT_TRUE (debug_bitstream_status.ok ()) << debug_bitstream_status.status ();
235228 auto &debug_bitstream = debug_bitstream_status.value ();
236- ASSERT_TRUE (debug_bitstream);
229+ CHECK (debug_bitstream);
237230
238231 auto debug_reader =
239232 BitstreamReader<kArch >::InitWithBytes (debug_bitstream->AsBytesView ());
240- ASSERT_TRUE (debug_reader);
233+ CHECK (debug_reader. has_value () );
241234 auto debug_configuration =
242- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
243235 Configuration<kArch >::InitWithPackets (*part, *debug_reader);
244- ASSERT_TRUE (debug_configuration);
236+ CHECK (debug_configuration. has_value () );
245237
246238 absl::StatusOr<std::unique_ptr<MemoryBlock>> normal_bitstream_status =
247239 MemoryMapFile (kTestDataBase / " xc7-configuration.bit" );
@@ -251,16 +243,13 @@ TEST(XC7ConfigurationTest, DebugAndNormalBitstreamsProduceEqualConfigurations) {
251243
252244 auto normal_reader =
253245 BitstreamReader<kArch >::InitWithBytes (normal_bitstream->AsBytesView ());
254- ASSERT_TRUE (normal_reader);
246+ CHECK (normal_reader. has_value () );
255247 auto normal_configuration =
256- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
257248 Configuration<kArch >::InitWithPackets (*part, *normal_reader);
258- ASSERT_TRUE (normal_configuration);
259- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
260- for (auto debug_frame : debug_configuration->frames ()) {
261- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
262- auto normal_frame = normal_configuration->frames ().find (debug_frame.first );
263- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
249+ CHECK (normal_configuration.has_value ());
250+ for (const auto &debug_frame : debug_configuration->frames ()) {
251+ const auto normal_frame =
252+ normal_configuration->frames ().find (debug_frame.first );
264253 if (normal_frame == normal_configuration->frames ().end ()) {
265254 ADD_FAILURE () << debug_frame.first << " : missing in normal bitstream" ;
266255 continue ;
@@ -271,11 +260,8 @@ TEST(XC7ConfigurationTest, DebugAndNormalBitstreamsProduceEqualConfigurations) {
271260 << debug_frame.first << " : word " << ii;
272261 }
273262 }
274- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
275- for (auto normal_frame : normal_configuration->frames ()) {
276- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
263+ for (const auto &normal_frame : normal_configuration->frames ()) {
277264 auto debug_frame = debug_configuration->frames ().find (normal_frame.first );
278- // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
279265 if (debug_frame == debug_configuration->frames ().end ()) {
280266 ADD_FAILURE () << normal_frame.first
281267 << " : unexpectedly present in normal bitstream" ;
@@ -356,13 +342,11 @@ TEST(XC7ConfigurationTest, CheckForPaddingFrames) {
356342
357343 auto test_config =
358344 Configuration<Architecture::kXC7 >::InitWithPackets (*test_part, packets);
359- ASSERT_TRUE (test_config);
360- // NOLINTBEGIN(bugprone-unchecked-optional-access)
345+ CHECK (test_config.has_value ());
361346 ASSERT_EQ (test_config->frames ().size (), 5 );
362347 for (const auto &frame : test_config->frames ()) {
363348 EXPECT_EQ (frame.second , frames.GetFrames ().at (frame.first ));
364349 }
365- // NOLINTEND(bugprone-unchecked-optional-access)
366350}
367351} // namespace
368352} // namespace xilinx
0 commit comments