<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Derek Jones wrote:</div>
<blockquote style="margin-left: 0.8ex; padding-left: 1ex; border-left: 3px solid rgb(200, 200, 200);">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
I have not seen an analysis of MC/DC that involves conditional operators in if-statement conditions</div>
</blockquote>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
We (Rapita Systems) treat conditional operators like this in a Boolean context as MC/DC conditions. This is mentioned in DOT/FAA/AR-06/54 (4.3.2) and has been supported by RapiCover for a long time now.</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
With thanks to my colleague Joe for throwing this through the tool, below are some screenshots from a small example.</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
It would be interesting to run the Sqlite tests through RapiCover, but we have not tried.</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Ian</div>
<div class="elementToProof" style="margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<ol start="1" data-editing-info="{"applyListStyleFromLevel":false,"orderedStyleType":1}" style="list-style-type: decimal;">
<li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<div class="elementToProof">The conditional operator within an "if" gives rise to 2 conditions in the decision and only partial coverage achieved with c=0.</div>
</li></ol>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="text-align: left; text-indent: 0px; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
test_func_1:</div>
<div style="text-align: left; text-indent: 0px; margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<img id="image_0" size="11379" contenttype="image/png" style="height: auto; max-width: 1056px; min-width: auto; min-height: auto; margin: 0px;" data-outlook-trace="F:3|T:3" src="cid:0801db3a-1d18-4818-8542-bd012c7cde5b"></div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<ol start="2" data-editing-info="{"applyListStyleFromLevel":false,"orderedStyleType":1}" style="list-style-type: decimal;">
<li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<div class="elementToProof">The source code (red or yellow shows incomplete MC/DC coverage) for 2 similar functions.</div>
</li></ol>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="direction: ltr; text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<img size="12291" contenttype="image/png" style="height: auto; max-width: 1056px; min-width: auto; min-height: auto; margin: 0px;" data-outlook-trace="F:3|T:3" src="cid:0c2091cd-05d1-4aeb-a2cb-720b8360ff04"></div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
2. <span style="font-size: 12pt;">test_func_2 list of decisions, for comparison.</span></div>
<div class="elementToProof" style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<img size="12321" contenttype="image/png" style="height: auto; max-width: 1056px; min-width: auto; min-height: auto; margin: 0px;" data-outlook-trace="F:3|T:3" src="cid:776869f1-a5a8-4665-9993-2d2ffd6d0f21"><br>
<br>
</div>
<ol start="3" data-editing-info="{"applyListStyleFromLevel":false,"orderedStyleType":1}" style="text-align: left; list-style-type: decimal; flex-direction: column; display: flex;">
<li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); align-self: start; margin-right: 0px; margin-left: 0px;">
<div class="elementToProof" style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin-top: 0px; margin-bottom: 0px;">
Only when we have test cases where c is 0 and non-zero, we can achieve full coverage.</div>
</li></ol>
<div style="text-align: left; text-indent: 0px; background-color: rgb(255, 255, 255); margin: 0px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<img size="15251" contenttype="image/png" style="height: auto; max-width: 1056px; min-width: auto; min-height: auto; margin: 0px;" data-outlook-trace="F:3|T:3" src="cid:0bf35888-ef79-4f67-b016-f568eac779f7"></div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature" class="elementToProof">
<p style="background-color: white; margin: 0cm; font-family: Calibri, sans-serif; font-size: 11pt;">
<span style="font-size: 10pt; color: rgb(33, 33, 33);">-- </span></p>
<p style="text-align: left; background-color: white; margin: 0cm; font-family: Calibri, sans-serif; font-size: 11pt;">
<span style="font-size: 10pt; color: rgb(33, 33, 33);">Dr Ian Broster</span><span style="font-size: 12pt; color: black;"><br>
</span><span style="font-size: 10pt; color: rgb(33, 33, 33);">Chief Operating Officer - Rapita Systems Ltd (UK) / S.L.(Spain)</span></p>
<p style="text-align: left; background-color: white; margin: 0cm; font-family: Calibri, sans-serif; font-size: 11pt;">
<span style="font-size: 10pt; color: rgb(33, 33, 33);">+44 7963 469 090</span></p>
<p style="margin: 0cm; font-family: Calibri, sans-serif; font-size: 11pt;"> </p>
</div>
<div id="appendonsend"></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> systemsafety <systemsafety-bounces@lists.techfak.uni-bielefeld.de> on behalf of Derek M Jones <derek@knosof.co.uk><br>
<b>Sent:</b> Wednesday, October 30, 2024 12:10<br>
<b>To:</b> systemsafety@lists.techfak.uni-bielefeld.de <systemsafety@lists.techfak.uni-bielefeld.de><br>
<b>Subject:</b> [SystemSafety] MC/DC handling of conditional operators</span>
<div> </div>
</div>
<div style="font-size: 11pt;">All,<br>
<br>
I have not seen an analysis of MC/DC that involves<br>
conditional operators in if-statement conditions.<br>
<br>
Why would anybody use conditional operators (also known as<br>
a ternary operator) in this context you ask?<br>
I thought the same until some recent analysis of<br>
if-statement conditions.<br>
<br>
As its name suggests, the conditional operator involves a<br>
condition, and as such looks like it needs to be addressed<br>
by MC/DC (I have added parenthesis to the following examples<br>
to make things clear):<br>
<br>
In: 1+(c!=0 ? x : y)<br>
if c is not equal to zero, the result is 1+x,<br>
otherwise the result is 1+y.<br>
<br>
Now in C, C++ and other languages we can write:<br>
<br>
if (1+(c!=0 ? x : y) == z)<br>
foo=bar;<br>
<br>
or we can write the longer equivalent code<br>
<br>
if (c != 0)<br>
{<br>
if (1+x == z)<br>
foo=bar;<br>
}<br>
else<br>
{<br>
if (1+y == z)<br>
foo=bar;<br>
}<br>
<br>
All the analysis of MC/DC that I have seen only involves<br>
logical AND and logical OR.<br>
<br>
Is the behavior of conditional operator something that gets<br>
ignored?<br>
Is there an unwritten MC/DC rule that conditional operators<br>
not be used in if-statement conditions?<br>
<br>
Shouldn't the conditional operator be part of the MC/DC<br>
analysis, i.e., required to be tested along both arms?<br>
<br>
SQLite says they achieve 100% MC/DC<br>
<a href="https://www.sqlite.org/testing.html#mcdc" id="OWA0ac82bdd-730c-4493-8b66-2b50b588a3a0" class="OWAAutoLink" data-auth="NotApplicable">https://www.sqlite.org/testing.html#mcdc</a><br>
<br>
The SQLite source contains instances of the conditional<br>
operator if if-statement conditions<br>
<a href="https://shape-of-code.com/2024/10/13/if-statement-conditions-some-basic-measurements/" id="OWA869f3582-469c-cbf7-26f0-09878fe0d5e7" class="OWAAutoLink" data-auth="NotApplicable">https://shape-of-code.com/2024/10/13/if-statement-conditions-some-basic-measurements/</a><br>
<br>
Does anybody know how SQLite+MC/DC deals with the<br>
conditional operator?<br>
<br>
--<br>
Derek M. Jones Evidence-based software engineering<br>
blog:https://shape-of-code.com<br>
<br>
_______________________________________________<br>
The System Safety Mailing List<br>
systemsafety@TechFak.Uni-Bielefeld.DE<br>
Manage your subscription: <a href="https://lists.techfak.uni-bielefeld.de/mailman/listinfo/systemsafety" id="OWA06708eb2-c8a3-9ff0-2640-213ada9d9b2f" class="OWAAutoLink" data-auth="NotApplicable">
https://lists.techfak.uni-bielefeld.de/mailman/listinfo/systemsafety</a></div>
-- <br>
<br>
<span style="font-size:12pt;"><a href="https://www.rapitasystems.com/events/do-178c-multicore-person-training-munich?utm_source=rs_email_sig">Book your place for DO-178C Multicore Training taking place on 6 and 7 November in Munich</a></span>
</body>
</html>