Exhaustive Enumeration Case

Is this Enterprise only?

The stackoverflow answer was from 2016.

delphi - Function result as enumerated type - how to proof all of variants are in case section - Stack Overflow https://share.google/4Z9cSRGqZRRYPCRsO

(In fact, saying ‘Switch’ .. maybe it refers to C++ ?)

QA audits were removed in Florence. Prior to that the enum case audit was only available in Enterprise (Professional only included some basic metrics).

I routinely use this pattern for case statements:

  case EnumVar of
    TEnumType.One: ...;
    TEnumType.Two: ...;
  else
    raise Exception.Create('Unhandled enum type = ' + Spring.TEnum.GetName<TEnumType>(EnumVar));
  end;

Obviously that is not possible in a function that has more complex conditions. You may be able to use AI to perform an audit, otherwise add sufficient unit tests and make sure that they are kept up to date with any changes to the enum type :slight_smile:

One AI answer mentioned tying the cases into interface methods .. but I’m working and haven’t had time to think about it or digest that idea.

I do the same. It’s not perfect but it’s saved me a few times over the years.