Пример #1
0
Location* addNavigationWithColors(enum TeamColor teamColor, Navigation* navigation, char* name, float x, float y) {
    LocationList* locationList = navigation->locationList;
    if (teamColor == TEAM_COLOR_2018_ORANGE) {
        y = GAMEBOARD_HEIGHT - y;
    }
    Location* result = addNamedLocation(locationList, name, x, y);
    return result;
}
Пример #2
0
void locationListTest(void) {
    initLocationList(&locationList, (Location(*)[]) &locationListArray, LOCATION_LIST_ARRAY_TEST);

    Location* locationA;
    Location* locationB;
    Location* locationC;
    Location* locationD;
    Location* locationE;
    Location* tmpLocation;
    // Location* tmpLocation2;

    // Emtpy Test
    bool isEmpty = isEmptyLocationList(&locationList);
    TEST_ASSERT_TRUE(isEmpty);

    locationA = addNamedLocation(&locationList, "A", 20, 20);
    locationB = addNamedLocation(&locationList, "B", 10, 30);
    locationC = addNamedLocation(&locationList, "C", -1, 2);
    locationD = addNamedLocation(&locationList, "D", -100, 200);
    locationE = addNamedLocation(&locationList, "E", -10, -50);

    isEmpty = isEmptyLocationList(&locationList);
    TEST_ASSERT_FALSE(isEmpty);


    // getLocationCount
    unsigned locationCount = getLocationCount(&locationList);
    TEST_ASSERT_EQUAL(5, locationCount);

    // findLocationByName
    tmpLocation = findLocationByStringName(&locationList, "C");
    TEST_ASSERT_EQUAL(locationC, tmpLocation);

    // locationEquals
    bool actual = locationEquals(locationA, locationA);
    TEST_ASSERT_TRUE(actual);
    actual = locationEquals(locationA, locationC);
    TEST_ASSERT_FALSE(actual);

    // getNearestLocation
    tmpLocation = getNearestLocation(&locationList, -120, 180);
    TEST_ASSERT_EQUAL(locationD, tmpLocation);
}