int main() { int x0; CREST_int(x0); if ( 4 * x0 * x0 == 64 ) //x0 = 4 { printf("Solved the if at depth 1.\n"); if ( 1 * x0 * x0 == 16 ) //x0 = 4 { printf("Solved the if at depth 2.\n"); if ( 3 * x0 * x0 == 48 ) //x0 = 4 { printf("Solved the if at depth 3.\n"); if ( 4 * x0 * x0 == 64 ) //x0 = 4 { printf("Solved the if at depth 4.\n"); } } } } }
int main (){ int l1; CREST_int(l1); //CREST_int(l2); //in l1 , l2 ; //int t1[10] ; //, t2[10] , t3[20]; //CREST_array(t1 , 10); //CREST_int(t2); //CREST_int(t3); int A[] = {0 , 1 , 2, 3 , 4 , 5}; if(l1 < 5){ if(A[l1] == 3) printf("Bazinga\n"); else printf("Badumtss"); } }
int main() { int x; int A[] = { 0, 1, 2, 3, 4, 5}; CREST_int(x); if ( x > 0 ) { if ( x - ( x / 3 * 3) == 0) { printf("c1: x % 3 == 0 \n"); } else { printf("c2: x % 3 != 0 \n"); } #if 1 if ( A[x] == 2 ) { printf("c3: x>0 && A[x] == 2\n"); } else { printf("c4: x>0 && A[x] != 2\n"); } #endif } else { printf("c0: x < 0 \n"); } }
int main() { int side1,side2,side3; CREST_int(side1); CREST_int(side2); CREST_int(side3); if(side1<0 || side2<0 || side3<0) printf("Illegal arguments !! \n"); else { int triang = 0; if(side1 == side2) triang = triang+1; else printf("not equal side1 and side2 \n"); if(side2 == side3) triang = triang+2; else printf("not equal side2 and side3 \n"); if(side1 == side3) triang = triang+3; else printf("not equal side1 and side3 \n"); printf("side1=%d, side2=%d, side3=%d, triang = %d\n", side1,side2,side3,triang); if(triang == 0) { if((side1 + side2 < side3) || (side2 + side3 < side1) || (side1 + side2 < side3)) printf("Illegal arguments !! \n"); else printf("Scalene triangle \n"); } else { if(triang > 3) printf("Equilateral triangle \n"); else { if(triang==1 && side1+side2>side3) printf("Isosceles triangle \n"); else { if(triang==2 && side2+side3>side1) printf("Isosceles triangle \n"); else { if(triang==3 && side1 + side3 > side2) printf("Isosceles triangle \n"); else printf("ILLegal !!! \n"); } } } } } return 0; }
int main(void) { int __retres; int A[5]; CREST_int(A); int l; int r; l = 0; r = 1; { int i; i = 0; if (! (i < 5)) { goto unrolling_2_loop; } if (A[l] < A[r]) { l ++; r ++; } else { goto unrolling_2_loop; } i ++; unrolling_7_loop: /* internal */ ; if (! (i < 5)) { goto unrolling_2_loop; } if (A[l] < A[r]) { l ++; r ++; } else { goto unrolling_2_loop; } i ++; unrolling_6_loop: /* internal */ ; if (! (i < 5)) { goto unrolling_2_loop; } if (A[l] < A[r]) { l ++; r ++; } else { goto unrolling_2_loop; } i ++; unrolling_5_loop: /* internal */ ; if (! (i < 5)) { goto unrolling_2_loop; } if (A[l] < A[r]) { l ++; r ++; } else { goto unrolling_2_loop; } i ++; unrolling_4_loop: /* internal */ ; if (! (i < 5)) { goto unrolling_2_loop; } if (A[l] < A[r]) { l ++; r ++; } else { goto unrolling_2_loop; } i ++; unrolling_3_loop: /* internal */ ; while (i < 5) { if (A[l] < A[r]) { l ++; r ++; } else { break; } i ++; } unrolling_2_loop: /* internal */ ; } __retres = 0; return __retres; }
void TestinitializeGame(CuTest* TestCase) { int i, NumberOfPlayers; struct gameState State; int KingdomCards[10] = { adventurer, gardens, laboratory, treasure_map, minion, pawn, cutpurse, sea_hag, tribute, smithy }; int InitCard[3][treasure_map+1] = { { 10, 8, 8, 8, 46, 40, 30, 10, 10, 10, 10, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 20, 12, 12, 12, 39, 40, 30, 10, 10, 10, 10, 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 10, 12, 12, 12, 32, 40, 30, 10, 10, 10, 10, 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 } }; CREST_int(NumberOfPlayers); CREST_int(KingdomCards[0]); int ExpectedSupply[treasure_map+1]; memset(ExpectedSupply, -1, sizeof(int) * treasure_map); for(i = 0; i < 10; ++i) ExpectedSupply[KingdomCards[i]] = InitCard[NumberOfPlayers-2][KingdomCards[i]]; int Result = initializeGame(NumberOfPlayers, KingdomCards, TestSeed, &State); // Validate the gamestate int ValidGame = 1; if(NumberOfPlayers > 1 && NumberOfPlayers < 5) { for(i = 0; i < 10; ++i) { if(!isKingdomCard(KingdomCards[i])) ValidGame = 0; } if(!ValidGame) CuAssertIntEquals(TestCase, FAILURE, Result); else { CuAssertIntEquals(TestCase, SUCCESS, Result); CuAssertIntEquals(TestCase, NumberOfPlayers, State.numPlayers); CuAssertIntArraysAreEqual(TestCase, ExpectedSupply, State.supplyCount, treasure_map); CuAssertIntEquals(TestCase, 0, State.costDiff); CuAssertIntEquals(TestCase, 0, State.copperBonus); CuAssertIntEquals(TestCase, 0, State.whoseTurn); CuAssertIntEquals(TestCase, 0, State.phase); CuAssertIntEquals(TestCase, 0, State.numActions); CuAssertIntEquals(TestCase, 0, State.coins); CuAssertIntEquals(TestCase, 1, State.numBuys); for(i = 0; i < NumberOfPlayers; ++i) CuAssertIntEquals(TestCase, 5, State.handCount[i]); for(i = 0; i < NumberOfPlayers; ++i) CuAssertIntEquals(TestCase, 5, State.deckCount[i]); for(i = 0; i < NumberOfPlayers; ++i) CuAssertIntEquals(TestCase, 0, State.discardCount); CuAssertIntEquals(TestCase, 0, State.playedCardCount); // int hand[MAX_PLAYERS][MAX_HAND]; // int deck[MAX_PLAYERS][MAX_DECK]; } } }
void TestplayCard(CuTest* TestCase) { int GamePhase; int ActionResult; int ActionPoints; int CardToPlay; int Choice1, Choice2, Choice3; struct gameState State; int FixedHand[] = { smithy, adventurer, copper, estate, pawn }; int KingdomCards[10] = { adventurer, gardens, laboratory, treasure_map, minion, pawn, cutpurse, sea_hag, tribute, smithy }; // Fix initialize game initializeGame(2, KingdomCards, TestSeed, &State); // Randomize the players hand CREST_int(FixedHand[0]); CREST_int(FixedHand[1]); CREST_int(FixedHand[2]); CREST_int(FixedHand[3]); CREST_int(FixedHand[4]); _LoadPlayerHand(&State, 0, FixedHand, sizeof(FixedHand)/sizeof(int)); CREST_int(ActionPoints); CREST_int(GamePhase); CREST_int(CardToPlay); CREST_int(Choice1); CREST_int(Choice2); CREST_int(Choice3); State.numActions = ActionPoints; State.phase = GamePhase; ActionResult = playCard(CardToPlay, Choice1, Choice2, Choice3, &State); if(GamePhase == 1 || ActionPoints < 1 || CardToPlay < 0 || CardToPlay > 5 || !isActionCard(CardToPlay)) CuAssertIntEquals(TestCase, FAILURE, ActionResult); else { CuAssertIntEquals(TestCase, SUCCESS, ActionResult); CuAssertIntEquals(TestCase, ActionPoints-1, State.numActions); CuAssertIntEquals(TestCase, 1, State.playedCardCount); CuAssertIntEquals(TestCase, CardToPlay, State.playedCards[State.playedCardCount-1]); } }