You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases, it is possible to have functions with code paths which are never executed.
For example, such as following:
publicstaticlongDoSomething(nintx){switch(Unsafe.SizeOf<nint>()){case4:// do something for 32bit environmentreturnResultFor32;case8:// do something for 64bit environmentreturnResultFor64;default:thrownewNotSupportedException();}}
Because size of nint in every dotnet runtime must be 4 or 8, therefore default path of switch can never be run.
This method aims for high performance using JIT optimization, so it is not possible to refactor this conditional branch into any design pattern.
However I want test the case of Unsafe.SizeOf<nint>() == 4 and Unsafe.SizeOf<nint>() == 8.
In such a case, is there a way to avoid to measure coverage only the specified code path?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello.
In some cases, it is possible to have functions with code paths which are never executed.
For example, such as following:
Because size of
nint
in every dotnet runtime must be 4 or 8, therefore default path of switch can never be run.This method aims for high performance using JIT optimization, so it is not possible to refactor this conditional branch into any design pattern.
However I want test the case of
Unsafe.SizeOf<nint>() == 4
andUnsafe.SizeOf<nint>() == 8
.In such a case, is there a way to avoid to measure coverage only the specified code path?
Beta Was this translation helpful? Give feedback.
All reactions