Ejemplo n.º 1
0
static char *teams_t_read__ShouldRetrieveMatchingRecord_GivenTheTeamId()
{
     team_s expected = { 0 };

     /**/    expected.team_id         = 123;
     strcpy( expected.name,            "TeamName1" );
     strcpy( expected.location,        "Location1" );
     /**/    expected.primary_color   = cl_Blue;
     /**/    expected.secondary_color = cl_Gold;

     insert_a_team( &expected );

     team_s actual = { 0 };

     actual.team_id = expected.team_id;

     assertEquals( SQLITE_OK, teams_t_read( db, &actual ) );

     assertEqualsInt( expected.team_id,         actual.team_id         );
     assertEqualsStr( expected.name,            actual.name            );
     assertEqualsStr( expected.location,        actual.location        );
     assertEqualsInt( expected.primary_color,   actual.primary_color   );
     assertEqualsInt( expected.secondary_color, actual.secondary_color );

     sqlite3_exec( db, "delete from teams_t", NULL, NULL, NULL );

     return NULL;
}
Ejemplo n.º 2
0
static char *teams_t_update__ShouldModifyMatchingRecord_GivenTheTeamId()
{
     team_s expected = { 0 };

     /**/    expected.team_id         = 123;
     strcpy( expected.name,            "TeamName1" );
     strcpy( expected.location,        "Location1" );
     /**/    expected.primary_color   = cl_Blue;
     /**/    expected.secondary_color = cl_Gold;

     insert_a_team( &expected );

     strcpy( expected.name,            "TeamName2" );
     strcpy( expected.location,        "Location2" );
     /**/    expected.primary_color   = cl_Red;
     /**/    expected.secondary_color = cl_Black;

     assertEquals( SQLITE_OK, teams_t_update( db, &expected ) );

     team_s *actual = get_a_team( expected.team_id );

     assertEqualsInt( expected.team_id,         actual->team_id         );
     assertEqualsStr( expected.name,            actual->name            );
     assertEqualsStr( expected.location,        actual->location        );
     assertEqualsInt( expected.primary_color,   actual->primary_color   );
     assertEqualsInt( expected.secondary_color, actual->secondary_color );

     sqlite3_exec( db, "delete from teams_t", NULL, NULL, NULL );

     return NULL;
}
Ejemplo n.º 3
0
char *_compareTeamAccolades( team_accolade_s *expected, team_accolade_s *actual )
{
     assertEqualsInt( expected->team_id,  actual->team_id  );
     assertEqualsInt( expected->season,   actual->season   );
     assertEqualsInt( expected->accolade, actual->accolade );

     return NULL;
}
char *_comparePlayerKickingRatings( player_kicking_ratings_s *expected, player_kicking_ratings_s *actual )
{
     assertEqualsInt( expected->player_id,        actual->player_id        );
     assertEqualsInt( expected->kicking_ability,  actual->kicking_ability  );
     assertEqualsInt( expected->avoid_kick_block, actual->avoid_kick_block );

     return NULL;
}
unsigned test_directionMachine() {
    unsigned char testsEnErreur = 0;
    EvenementEtValeur ev = {LECTURE_RC_GAUCHE_DROITE, 0};

    DIRECTION_machine(&ev);
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsBas.valeur, 65535 - 40000 + 2000, "DIRM11");
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsHaut.valeur, 65535 - 2000, "DIRM11");

    return testsEnErreur;
}
TIMED_TEST(StackTests, hashCodeTest_Stack, TEST_TIMEOUT_DEFAULT) {
    Stack<int> stack;
    stack.add(69);
    stack.add(42);
    assertEqualsInt("hashcode of self Stack", hashCode(stack), hashCode(stack));

    Stack<int> copy = stack;
    assertEqualsInt("hashcode of copy Stack", hashCode(stack), hashCode(copy));

    Stack<int> empty;
    HashSet<Stack<int> > hashstack {stack, copy, empty, empty};
    assertEqualsInt("hashset of Stack size", 2, hashstack.size());
}
TIMED_TEST(GridTests, hashCodeTest_Grid, TEST_TIMEOUT_DEFAULT) {
    Grid<int> grid(2, 3);
    grid.fill(42);
    assertEqualsInt("hashcode of self Grid", hashCode(grid), hashCode(grid));

    Grid<int> copy = grid;
    assertEqualsInt("hashcode of copy Grid", hashCode(grid), hashCode(copy));

    Grid<int> empty;   // empty
    HashSet<Grid<int> > hashgrid {grid, copy, empty, empty};

    assertEqualsInt("hashset of Grid size", 2, hashgrid.size());
}
TIMED_TEST(MapTests, hashCodeTest_Map, TEST_TIMEOUT_DEFAULT) {
    Map<int, int> map;
    map.add(69, 96);
    map.add(42, 24);
    assertEqualsInt("hashcode of self Map", hashCode(map), hashCode(map));

    Map<int, int> copy = map;
    assertEqualsInt("hashcode of copy Map", hashCode(map), hashCode(copy));

    Map<int, int> empty;

    HashSet<Map<int, int> > hashmap {map, copy, empty, empty};
    assertEqualsInt("hashset of Map size", 2, hashmap.size());
}
TIMED_TEST(DawgLexiconTests, hashCodeTest_DawgLexicon, TEST_TIMEOUT_DEFAULT) {
    DawgLexicon dlex;
    dlex.add("a");
    dlex.add("abc");
    assertEqualsInt("hashcode of self dawglexicon", hashCode(dlex), hashCode(dlex));

    DawgLexicon copy = dlex;
    assertEqualsInt("hashcode of copy dawglexicon", hashCode(dlex), hashCode(copy));

    DawgLexicon dlex2;   // empty

    // shouldn't add two copies of same lexicon
    HashSet<DawgLexicon> hashdawg {dlex, copy, dlex2};
    assertEqualsInt("hashset of dawglexicon size", 2, hashdawg.size());
}
char *_comparePlayerGameReturnsStats( player_game_returns_stats_s *expected, player_game_returns_stats_s *actual )
{
     assertEqualsInt( expected->player_id,              actual->player_id              );
     assertEqualsInt( expected->season,                 actual->season                 );
     assertEqualsInt( expected->week,                   actual->week                   );
     assertEqualsInt( expected->game,                   actual->game                   );
     assertEqualsInt( expected->kick_returns,           actual->kick_returns           );
     assertEqualsInt( expected->kick_return_yards,      actual->kick_return_yards      );
     assertEqualsInt( expected->kick_return_touchdowns, actual->kick_return_touchdowns );
     assertEqualsInt( expected->punt_returns,           actual->punt_returns           );
     assertEqualsInt( expected->punt_return_yards,      actual->punt_return_yards      );
     assertEqualsInt( expected->punt_return_touchdowns, actual->punt_return_touchdowns );

     return NULL;
}
TIMED_TEST(LexiconTests, hashCodeTest_Lexicon, TEST_TIMEOUT_DEFAULT) {
    Lexicon lex;
    lex.add("a");
    lex.add("bc");
    assertEqualsInt("hashcode of self lexicon", hashCode(lex), hashCode(lex));

    Lexicon copy = lex;
    assertEqualsInt("hashcode of copy lexicon", hashCode(lex), hashCode(copy));

    Lexicon lex2;   // empty

    // shouldn't add two copies of same lexicon
    HashSet<Lexicon> hashlex {lex, copy, lex2};
    assertEqualsInt("hashset of lexicon size", 2, hashlex.size());
}
TIMED_TEST(GridTests, initializerListTest_Grid, TEST_TIMEOUT_DEFAULT) {
    Grid<int> grid {{10, 20, 30}, {40, 50, 60}};
    assertEqualsInt("init list Grid numRows", 2, grid.numRows());
    assertEqualsInt("init list Grid numCols", 3, grid.numCols());
    assertEqualsInt("init list Grid size", 6, grid.size());
    assertEqualsInt("init list Grid[0][0]", 10, grid[0][0]);
    assertEqualsInt("init list Grid[0][1]", 20, grid[0][1]);
    assertEqualsInt("init list Grid[0][2]", 30, grid[0][2]);
    assertEqualsInt("init list Grid[1][0]", 40, grid[1][0]);
    assertEqualsInt("init list Grid[1][1]", 50, grid[1][1]);
    assertEqualsInt("init list Grid[1][2]", 60, grid[1][2]);
}
TIMED_TEST(LexiconTests, initializerListTest_Lexicon, TEST_TIMEOUT_DEFAULT) {
    std::initializer_list<std::string> lexlist = {"sixty", "seventy"};
    std::initializer_list<std::string> lexallwords = {
        "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy"
    };

    Lexicon lex {"ten", "twenty", "thirty"};
    assertEqualsString("init list Lexicon", "{\"ten\", \"thirty\", \"twenty\"}", lex.toString());
    assertEqualsInt("init list Lexicon size", 3, lex.size());
    assertTrue("init list Lexicon contains ten", lex.contains("ten"));
    assertTrue("init list Lexicon contains twenty", lex.contains("twenty"));
    assertTrue("init list Lexicon contains thirty", lex.contains("thirty"));
    assertFalse("init list Lexicon contains forty", lex.contains("forty"));
    assertFalse("init list Lexicon contains fifty", lex.contains("fifty"));

    lex += {"forty", "fifty"};
    assertEqualsString("after += Lexicon", "{\"fifty\", \"forty\", \"ten\", \"thirty\", \"twenty\"}", lex.toString());
    assertEqualsInt("after += Lexicon size", 5, lex.size());
    assertTrue("init list Lexicon contains ten", lex.contains("ten"));
    assertTrue("init list Lexicon contains twenty", lex.contains("twenty"));
    assertTrue("init list Lexicon contains thirty", lex.contains("thirty"));
    assertTrue("init list Lexicon contains forty", lex.contains("forty"));
    assertTrue("init list Lexicon contains fifty", lex.contains("fifty"));
    assertFalse("init list Lexicon contains sixty", lex.contains("sixty"));
    assertFalse("init list Lexicon contains seventy", lex.contains("seventy"));

    Lexicon lex2 = (lex + lexlist);
    assertEqualsString("after += Lexicon", "{\"fifty\", \"forty\", \"ten\", \"thirty\", \"twenty\"}", lex.toString());
    assertEqualsInt("after + Lexicon size", 5, lex.size());
    assertTrue("init list Lexicon contains ten", lex.contains("ten"));
    assertTrue("init list Lexicon contains twenty", lex.contains("twenty"));
    assertTrue("init list Lexicon contains thirty", lex.contains("thirty"));
    assertTrue("init list Lexicon contains forty", lex.contains("forty"));
    assertTrue("init list Lexicon contains fifty", lex.contains("fifty"));
    assertFalse("init list Lexicon contains sixty", lex.contains("sixty"));
    assertFalse("init list Lexicon contains seventy", lex.contains("seventy"));

    assertEqualsString("after + Lexicon 2", "{\"fifty\", \"forty\", \"seventy\", \"sixty\", \"ten\", \"thirty\", \"twenty\"}", lex2.toString());
    assertEqualsInt("after + Lexicon 2 size", 7, lex2.size());
    assertTrue("init list Lexicon contains ten", lex2.contains("ten"));
    assertTrue("init list Lexicon contains twenty", lex2.contains("twenty"));
    assertTrue("init list Lexicon contains thirty", lex2.contains("thirty"));
    assertTrue("init list Lexicon contains forty", lex2.contains("forty"));
    assertTrue("init list Lexicon contains fifty", lex2.contains("fifty"));
    assertTrue("init list Lexicon contains sixty", lex2.contains("sixty"));
    assertTrue("init list Lexicon contains seventy", lex2.contains("seventy"));
}
TIMED_TEST(LinkedHashSetTests, forEachTest_LinkedHashSet, TEST_TIMEOUT_DEFAULT) {
    LinkedHashSet<int> lhset {30, 10, 40, 66, -1, 42, 99};
    Queue<int> expected {30, 10, 40, 66, -1, 42, 99};
    for (int n : lhset) {
        int exp = expected.dequeue();
        assertEqualsInt("LinkedHashSet foreach", exp, n);
    }
}
TIMED_TEST(LinkedHashSetTests, hashcodeTest_LinkedHashSet, TEST_TIMEOUT_DEFAULT) {
    LinkedHashSet<int> hset;
    hset.add(69);
    hset.add(42);
    assertEqualsInt("hashcode of self LinkedHashSet", hashCode(hset), hashCode(hset));

    LinkedHashSet<int> hset2;
    hset2.add(42);
    hset2.add(69);
    assertEqualsInt("hashcode of LinkedHashSet other order", hashCode(hset), hashCode(hset2));

    LinkedHashSet<int> copy = hset;
    assertEqualsInt("hashcode of copy LinkedHashSet", hashCode(hset), hashCode(copy));

    LinkedHashSet<int> empty;
    HashSet<LinkedHashSet<int> > hashhashset {hset, copy, hset2, empty, empty};
    assertEqualsInt("hashset of LinkedHashset size", 2, hashhashset.size());
}
TIMED_TEST(GridTests, forEachTest_Grid, TEST_TIMEOUT_DEFAULT) {
    Grid<int> grid(4, 2);
    grid.fill(42);
    grid[2][0] = 17;
    grid[3][1] = 0;
    Queue<int> expected {42, 42, 42, 42, 17, 42, 42, 0};
    for (int n : grid) {
        int exp = expected.dequeue();
        assertEqualsInt("Grid foreach", exp, n);
    }
}
TIMED_TEST(MapTests, initializerListTest_Map, TEST_TIMEOUT_DEFAULT) {
    std::initializer_list<std::pair<const std::string, int>> pairlist = {{"k", 60}, {"t", 70}};
    std::initializer_list<std::pair<const std::string, int>> pairlist2 = {{"b", 20}, {"e", 50}};
    std::initializer_list<std::pair<const std::string, int>> expected;

    Map<std::string, int> map {{"a", 10}, {"b", 20}, {"c", 30}};
    assertEqualsInt("init list Map get a", 10, map.get("a"));
    assertEqualsInt("init list Map get b", 20, map.get("b"));
    assertEqualsInt("init list Map get c", 30, map.get("c"));
    assertEqualsInt("init list Map size", 3, map.size());

    map += {{"d", 40}, {"e", 50}};
    expected = {{"a", 10}, {"b", 20}, {"c", 30}, {"d", 40}, {"e", 50}};
    assertMap("after +=", expected, map);

    Map<std::string, int> copy = map + pairlist;
    expected = {{"a", 10}, {"b", 20}, {"c", 30}, {"d", 40}, {"e", 50}};
    assertMap("after + (shouldn't modify)", expected, map);
    expected = {{"a", 10}, {"b", 20}, {"c", 30}, {"d", 40}, {"e", 50}, {"k", 60}, {"t", 70}};
    // assertMap("after + copy", expected, copy);

    copy = map - pairlist2;
    expected = {{"a", 10}, {"b", 20}, {"c", 30}, {"d", 40}, {"e", 50}};
    assertMap("after - (shouldn't modify)", expected, map);
    expected = {{"a", 10}, {"c", 30}, {"d", 40}};
    assertMap("after - copy", expected, copy);

    copy = map * pairlist2;
    expected = {{"a", 10}, {"b", 20}, {"c", 30}, {"d", 40}, {"e", 50}};
    assertMap("after * (shouldn't modify)", expected, map);
    expected = {{"b", 20}, {"e", 50}};
    assertMap("after * copy", expected, copy);

    map -= {{"d", 40}, {"e", 50}};
    expected = {{"a", 10}, {"b", 20}, {"c", 30}};
    assertMap("after -=", expected, map);

    map *= pairlist2;
    expected = {{"b", 20}};
    assertMap("after *=", expected, map);
}
Ejemplo n.º 18
0
static char *convertDivisions_ShouldReturnDivisionsWithTeams_GivenALeagueFileDataParksDataAndLeagueId()
{
     org_data_s org_data = { 0 };

     org_data.league_data  = buildFileLeagName();
     org_data.parks_data   = buildFileParks();
     org_data.players_data = buildFilePlayers();
     org_data.records      = buildRecords( org_data.league_data, 1, sp_Regular );

     fileleagname_s    *league_data      = org_data.league_data;
     fileparks_s       *parks_data       = org_data.parks_data;
     league_division_s *league_divisions = convertDivisions( &org_data, 1, 0 );

     for ( int i = 0; i < DIVISIONS_PER_LEAGUE; ++i )
     {
          assertNotNull( league_divisions[i].division );

          division_team_s *division_teams = league_divisions[i].division->teams;

          assertNotNull( division_teams );

          for ( int j = 0; j < TEAMS_PER_DIVISION; ++j )
          {
               int idx      = (i * TEAMS_PER_DIVISION) + j;
               int park_idx = byte2int( league_data->teams[idx].stadium );

               assertNotNull(                                                     division_teams[j].team                  );
               assertEqualsInt(           i + 1,                                  division_teams[j].division_id           );
               assertEqualsInt( byte2int( league_data->teams[idx].team_id ),      division_teams[j].team_id               );
               assertEqualsInt( byte2int( league_data->teams[idx].team_id ),      division_teams[j].team->team_id         );
               assertEqualsStr(           league_data->teams[idx].name,           division_teams[j].team->name            );
               assertEqualsStr(           parks_data->park_names[park_idx].text,  division_teams[j].team->location        );
               assertEqualsInt( byte2int( league_data->teams[idx].color ),        division_teams[j].team->primary_color   );
               assertEqualsInt( byte2int( league_data->teams[idx].color ),        division_teams[j].team->secondary_color );
          }
     }

     free_league_divisions( league_divisions );

     return NULL;
}
Ejemplo n.º 19
0
static char *teams_t_create__ShouldInsertRecordsInTheTeamsTTable()
{
     team_s expected = { 0 };

     /**/    expected.team_id         = 123;
     strcpy( expected.name,            "TeamName1" );
     strcpy( expected.location,        "Location1" );
     /**/    expected.primary_color   = cl_Blue;
     /**/    expected.secondary_color = cl_Gold;

     assertEquals( SQLITE_OK, teams_t_create( db, &expected ) );

     team_s *actual = get_a_team( expected.team_id );

     assertEqualsInt( expected.team_id,         actual->team_id         );
     assertEqualsStr( expected.name,            actual->name            );
     assertEqualsStr( expected.location,        actual->location        );
     assertEqualsInt( expected.primary_color,   actual->primary_color   );
     assertEqualsInt( expected.secondary_color, actual->secondary_color );

     sqlite3_exec( db, "delete from teams_t", NULL, NULL, NULL );

     return NULL;
}
Ejemplo n.º 20
0
static char *get_division__ShouldReturnTheMatchingDivisionObject_GivenADivisionId()
{
     division_s expected = { 0 };

     /**/    expected.division_id = 1;
     strcpy( expected.name,        "DivisionName1" );

     assertEquals( SQLITE_OK, divisions_t_create( db, &expected ) );

     division_s *actual = get_division( db, expected.division_id );

     assertEqualsInt( expected.division_id, actual->division_id );
     assertEqualsStr( expected.name,        actual->name        );

     free_division( actual );

     assertEquals( SQLITE_OK, divisions_t_delete( db, &expected ) );

     return NULL;
}
Ejemplo n.º 21
0
static char *save_division__ShouldPersistTheDivisionInTheDatabase_GivenADivisionObject()
{
     division_s expected = { 0 };

     /**/    expected.division_id = 1;
     strcpy( expected.name,        "DivisionName1" );

     assertEquals( SQLITE_OK, save_division( db, &expected ) );

     division_s actual = { 0 };

     actual.division_id = expected.division_id;

     assertEquals( SQLITE_OK, divisions_t_read( db, &actual ) );

     assertEqualsInt( expected.division_id, actual.division_id );
     assertEqualsStr( expected.name,        actual.name        );

     assertEquals( SQLITE_OK, divisions_t_delete( db, &expected ) );

     return NULL;
}
unsigned test_calculePwmServoRouesAvant() {
    unsigned char testsEnErreur = 0;
    
    calculePwmServoRouesAvant(128);
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsBas.valeur, 65535 - 40000 + 3024, "DIR01");
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsHaut.valeur, 65535 - 3024, "DIR01");

    calculePwmServoRouesAvant(0);
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsBas.valeur, 65535 - 40000 + 2000, "DIR11");
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsHaut.valeur, 65535 - 2000, "DIR11");

    calculePwmServoRouesAvant(255);
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsBas.valeur, 65535 - 40000 + 4040, "DIR21");
    assertEqualsInt(tableauDeBord.positionRouesAvant.tempsHaut.valeur, 65535 - 4040, "DIR21");

    return testsEnErreur;
}
Ejemplo n.º 23
0
static char *convertDivisions_ShouldReturnAListOfLeagueDivisions_GivenALeagueFileDataAndLeagueId()
{
     org_data_s org_data = { 0 };

     org_data.league_data  = buildFileLeagName();
     org_data.parks_data   = buildFileParks();
     org_data.players_data = buildFilePlayers();
     org_data.records      = buildRecords( org_data.league_data, 1, sp_Regular );

     fileleagname_s    *league_data      = org_data.league_data;
     league_division_s *league_divisions = convertDivisions( &org_data, 1, 0 );

     assertNotNull( league_divisions );

     assertNotNull(                                   league_divisions[0].division              );
     assertEqualsInt( 1,                              league_divisions[0].league_id             );
     assertEqualsInt( 1,                              league_divisions[0].division_id           );
     assertEqualsInt( 1,                              league_divisions[0].division->division_id );
     assertEqualsStr( league_data->divisions[0].name, league_divisions[0].division->name        );

     assertNotNull(                                   league_divisions[1].division              );
     assertEqualsInt( 1,                              league_divisions[1].league_id             );
     assertEqualsInt( 2,                              league_divisions[1].division_id           );
     assertEqualsInt( 2,                              league_divisions[1].division->division_id );
     assertEqualsStr( league_data->divisions[1].name, league_divisions[1].division->name        );

     assertNull( league_divisions[2].division );

     free_league_divisions( league_divisions );

     league_divisions = convertDivisions( &org_data, 2, 1 );

     assertNotNull( league_divisions );

     assertNotNull(                                   league_divisions[0].division              );
     assertEqualsInt( 2,                              league_divisions[0].league_id             );
     assertEqualsInt( 3,                              league_divisions[0].division_id           );
     assertEqualsInt( 3,                              league_divisions[0].division->division_id );
     assertEqualsStr( league_data->divisions[2].name, league_divisions[0].division->name        );

     assertNotNull(                                   league_divisions[1].division              );
     assertEqualsInt( 2,                              league_divisions[1].league_id             );
     assertEqualsInt( 4,                              league_divisions[1].division_id           );
     assertEqualsInt( 4,                              league_divisions[1].division->division_id );
     assertEqualsStr( league_data->divisions[3].name, league_divisions[1].division->name        );

     assertNull( league_divisions[2].division );

     free_league_divisions( league_divisions );

     return NULL;
}
Ejemplo n.º 24
0
static char *save_division__ShouldUpdateRecordsIfTheyExistAndInsertIfTheyDont_GivenADivision()
{
     division_s          expected                   = { 0 };
     division_team_s     expected_division_teams[3] = { 0 };
     division_stats_s    expected_stats[3]          = { 0 };
     division_accolade_s expected_accolades[3]      = { 0 };

     /**/    expected.division_id = 1;
     strcpy( expected.name,        "DivisionName1" );

     expected_division_teams[0].division_id = 1;
     expected_division_teams[0].team_id     = 2;

     expected_division_teams[1].division_id = 1;
     expected_division_teams[1].team_id     = 5;

     expected_division_teams[2] = division_team_sentinel;

     expected_stats[0].division_id   = 1;
     expected_stats[0].season        = 1;
     expected_stats[0].season_phase  = sp_Regular;
     expected_stats[0].wins          = 388;
     expected_stats[0].losses        = 380;
     expected_stats[0].home_wins     = 205;
     expected_stats[0].home_losses   = 179;
     expected_stats[0].road_wins     = 166;
     expected_stats[0].road_losses   = 218;
     expected_stats[0].league_wins   = 135;
     expected_stats[0].league_losses = 121;
     expected_stats[0].runs_scored   = 2642;
     expected_stats[0].runs_allowed  = 2619;

     expected_stats[1].division_id   = 1;
     expected_stats[1].season        = 2;
     expected_stats[1].season_phase  = sp_Regular;
     expected_stats[1].wins          = 392;
     expected_stats[1].losses        = 376;
     expected_stats[1].home_wins     = 195;
     expected_stats[1].home_losses   = 189;
     expected_stats[1].road_wins     = 167;
     expected_stats[1].road_losses   = 217;
     expected_stats[1].league_wins   = 138;
     expected_stats[1].league_losses = 118;
     expected_stats[1].runs_scored   = 2698;
     expected_stats[1].runs_allowed  = 2703;

     expected_stats[2] = division_stats_sentinel;

     expected_accolades[0].division_id = 1;
     expected_accolades[0].season      = 1;
     expected_accolades[0].accolade    = dacc_League_Title;

     expected_accolades[1].division_id = 1;
     expected_accolades[1].season      = 2;
     expected_accolades[1].accolade    = dacc_Best_Record;

     expected_accolades[2] = division_accolade_sentinel;

     assertEquals( SQLITE_OK, divisions_t_create( db, &expected ) );
     assertEquals( SQLITE_OK, division_teams_t_create( db, &expected_division_teams[0] ) );
     assertEquals( SQLITE_OK, division_stats_t_create( db, &expected_stats[0] ) );
     assertEquals( SQLITE_OK, division_accolades_t_create( db, &expected_accolades[0] ) );

     strcpy( expected.name, "DivisionName2" );

     expected_stats[0].wins          = 390;
     expected_stats[0].losses        = 378;

     expected.teams     = expected_division_teams;
     expected.stats     = expected_stats;
     expected.accolades = expected_accolades;

     assertEquals( SQLITE_OK, save_division( db, &expected ) );

     division_s actual = { 0 };

     actual.division_id = expected.division_id;

     assertEquals( SQLITE_OK, divisions_t_read( db, &actual ) );

     assertEqualsInt( expected.division_id, actual.division_id );
     assertEqualsStr( expected.name,        actual.name        );

     data_list_s division_teams_list = { 0 };

     assertEquals( SQLITE_OK, division_teams_t_read_by_division( db, expected.division_id, &division_teams_list ) );

     assertEquals( 2, division_teams_list.count );

     division_team_s *actual_division_teams = division_teams_list.data;

     assertNotNull( actual_division_teams );

     assertEquals( expected_division_teams[0].division_id, actual_division_teams[0].division_id );
     assertEquals( expected_division_teams[0].team_id,     actual_division_teams[0].team_id     );

     assertEquals( expected_division_teams[1].division_id, actual_division_teams[1].division_id );
     assertEquals( expected_division_teams[1].team_id,     actual_division_teams[1].team_id     );

     data_list_s division_stats_list = { 0 };

     assertEquals( SQLITE_OK, division_stats_t_read_by_division( db, expected.division_id, &division_stats_list ) );

     assertEquals( 2, division_stats_list.count );

     division_stats_s *actual_division_stats = division_stats_list.data;

     assertNotNull( actual_division_stats );

     assertEquals( expected_stats[0].division_id,   actual_division_stats[0].division_id     );
     assertEquals( expected_stats[0].season,        actual_division_stats[0].season          );
     assertEquals( expected_stats[0].season_phase,  actual_division_stats[0].season_phase    );
     assertEquals( expected_stats[0].wins,          actual_division_stats[0].wins            );
     assertEquals( expected_stats[0].losses,        actual_division_stats[0].losses          );
     assertEquals( expected_stats[0].home_wins,     actual_division_stats[0].home_wins       );
     assertEquals( expected_stats[0].home_losses,   actual_division_stats[0].home_losses     );
     assertEquals( expected_stats[0].road_wins,     actual_division_stats[0].road_wins       );
     assertEquals( expected_stats[0].road_losses,   actual_division_stats[0].road_losses     );
     assertEquals( expected_stats[0].league_wins,   actual_division_stats[0].league_wins     );
     assertEquals( expected_stats[0].league_losses, actual_division_stats[0].league_losses   );
     assertEquals( expected_stats[0].runs_scored,   actual_division_stats[0].runs_scored     );
     assertEquals( expected_stats[0].runs_allowed,  actual_division_stats[0].runs_allowed    );

     assertEquals( expected_stats[1].division_id,   actual_division_stats[1].division_id     );
     assertEquals( expected_stats[1].season,        actual_division_stats[1].season          );
     assertEquals( expected_stats[1].season_phase,  actual_division_stats[1].season_phase    );
     assertEquals( expected_stats[1].wins,          actual_division_stats[1].wins            );
     assertEquals( expected_stats[1].losses,        actual_division_stats[1].losses          );
     assertEquals( expected_stats[1].home_wins,     actual_division_stats[1].home_wins       );
     assertEquals( expected_stats[1].home_losses,   actual_division_stats[1].home_losses     );
     assertEquals( expected_stats[1].road_wins,     actual_division_stats[1].road_wins       );
     assertEquals( expected_stats[1].road_losses,   actual_division_stats[1].road_losses     );
     assertEquals( expected_stats[1].league_wins,   actual_division_stats[1].league_wins     );
     assertEquals( expected_stats[1].league_losses, actual_division_stats[1].league_losses   );
     assertEquals( expected_stats[1].runs_scored,   actual_division_stats[1].runs_scored     );
     assertEquals( expected_stats[1].runs_allowed,  actual_division_stats[1].runs_allowed    );

     data_list_s division_accolades_list = { 0 };

     assertEquals( SQLITE_OK, division_accolades_t_read_by_division( db, expected.division_id, &division_accolades_list ) );

     assertEquals( 2, division_accolades_list.count );

     division_accolade_s *actual_division_accolades = division_accolades_list.data;

     assertNotNull( actual_division_accolades );

     assertEquals( expected_accolades[0].division_id, actual_division_accolades[0].division_id );
     assertEquals( expected_accolades[0].season,      actual_division_accolades[0].season      );
     assertEquals( expected_accolades[0].accolade,    actual_division_accolades[0].accolade    );

     assertEquals( expected_accolades[1].division_id, actual_division_accolades[1].division_id );
     assertEquals( expected_accolades[1].season,      actual_division_accolades[1].season      );
     assertEquals( expected_accolades[1].accolade,    actual_division_accolades[1].accolade    );

     free( actual_division_teams     );
     free( actual_division_stats     );
     free( actual_division_accolades );

     assertEquals( SQLITE_OK, divisions_t_delete( db, &expected ) );
     assertEquals( SQLITE_OK, division_teams_t_delete( db, &expected_division_teams[0] ) );
     assertEquals( SQLITE_OK, division_teams_t_delete( db, &expected_division_teams[1] ) );
     assertEquals( SQLITE_OK, division_stats_t_delete( db, &expected_stats[0] ) );
     assertEquals( SQLITE_OK, division_stats_t_delete( db, &expected_stats[1] ) );
     assertEquals( SQLITE_OK, division_accolades_t_delete( db, &expected_accolades[0] ) );
     assertEquals( SQLITE_OK, division_accolades_t_delete( db, &expected_accolades[1] ) );

     return NULL;
}
Ejemplo n.º 25
0
char *_compareTeamStats( team_stats_s *expected, team_stats_s *actual )
{
     assertEqualsInt( expected->team_id,        actual->team_id        );
     assertEqualsInt( expected->season,         actual->season         );
     assertEqualsInt( expected->bowl_game,      actual->bowl_game      );
     assertEqualsInt( expected->wins,           actual->wins           );
     assertEqualsInt( expected->losses,         actual->losses         );
     assertEqualsInt( expected->ties,           actual->ties           );
     assertEqualsInt( expected->home_wins,      actual->home_wins      );
     assertEqualsInt( expected->home_losses,    actual->home_losses    );
     assertEqualsInt( expected->home_ties,      actual->home_ties      );
     assertEqualsInt( expected->road_wins,      actual->road_wins      );
     assertEqualsInt( expected->road_losses,    actual->road_losses    );
     assertEqualsInt( expected->road_ties,      actual->road_ties      );
     assertEqualsInt( expected->points_scored,  actual->points_scored  );
     assertEqualsInt( expected->points_allowed, actual->points_allowed );

     return NULL;
}
Ejemplo n.º 26
0
TIMED_TEST(StringTests, stringToIntegerTest, TEST_TIMEOUT_DEFAULT) {
    assertEqualsInt("base-10", 234, stringToInteger("234"));
    assertEqualsInt("base-8", 156, stringToInteger("234", /* radix */ 8));
    assertEqualsInt("base-16", 564, stringToInteger("234", /* radix */ 16));
}
TIMED_TEST(GridTests, frontBackTest_Grid, TEST_TIMEOUT_DEFAULT) {
    Grid<int> grid {{10, 20, 30}, {40, 50, 60}};
    assertEqualsInt("Grid front", 10, grid.front());
    assertEqualsInt("Grid back",  60, grid.back());
}