garth
Joined: 14 Feb 2007 Posts: 2
|
Posted: Sat Feb 24, 2007 8:04 pm Post subject: What's wrong with this? |
|
|
Hi all,
x and y are random Values (rand()%8). I want to assert that y is always x+/-3.
However, assert seems to be executed before switch, because it throws me an Assertion-Error. When I comment the assert function and check the output of the debug then y is exactly what I wanted to assert...
Why can't I use the assert function here??
Code: |
void swapVertical(int x, int y) {
switch(x) {
case 0: y = x +3; break;
case 1: y = x +3; break;
case 2: y = x +3; break;
case 6: y = x -3; break;
case 7: y = x -3; break;
case 8: y = x -3; break;
default: if(y >= 3 && y <= 5){
y = x + 3; break;
}
else if(y <= 8 && y >= 4){
y = x - 3;break;}
}
debug writefln("X=%d,Y=%d", x,y);
assert(y == x + 3 || y == x -3);
}
|
Hope I could explain what I meant
Thanks alot, Garth |
|