Closed smhmhmd closed 5 months ago
Hi @smhmhmd Branch 'return true' is unreachable, isn't it? Variables 'i' and 'j' should be '0' for method 'Foobar' not to throw exception (array 'a' contains only one element). So, condition in first 'if' statement evaluates to 'false', but second condition evaluates to 'true', because 'i' and 'j' are equal to '0'.
Hi @MchKosticyn
Branch 'return true' is unreachable, isn't it? You are right.
For this input code:
public bool Foobar(int i, int j)
{
int[] a = { 0, 0 };
if (a[i] > 1 || a[j] > 1) return false;
a[i] = 5;
if (a[j] == 5) return false;
return true;
}
The test is generated correctly
[Test, Category("Generated")]^M
public void FoobarTest1()^M
{^M
// arrange
object thisArg = new Allocator<object>("ConsoleApp2.Class1, ConsoleApp2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null").Object;^M
// act
var result = thisArg.Call("Foobar", 0, 1);^M
// assert
Assert.AreEqual(true, result);^M
}^M
Hi @MchKosticyn
This is from the paper you had mentioned earlier in another issue. Test class:
Here is the generated test class, the last test that asserts the 'return true' should have had parameters as (1, 0) ?