I have a number of signals that can be true, false or invalid, but only one of them can be true, otherwise it will be a mistake.
I want to know if there is a way to test this easily and not make a big if statement
enum sig_type
{
sig_invalid, sig_true, sig_false
};
sig_type sig1 = GetSignal("sig1");
sig_type sig2 = GetSignal("sig1");
sig_type sig3 = GetSignal("sig1");
sig_type sig4 = GetSignal("sig1");
if (sig1 == sig_true)
{
if (sig2 == sig_true || sig3 == sig_true || sig4 == sig_true)
{
// Error
}
}
else if (sig2 == sig_true)
{
if (sig1 == sig_true || sig3 == sig_true || sig4 == sig_true)
{
// Error
}
}
etc ... which is a significant amount of code and only increases when I add signals, so in this state it will be uncontrollable
source
share