const ExceptionLocation Exception::getLocation( const size_t& index) const throw() { if (index < 0 || index>=getLocationCount()) { return ExceptionLocation(); } else { return locations[index]; } }
void Exception::dump(ostream& s) const throw() { int i; for (i=0; i<getTextCount(); i++) { s << "text " << i << ":" << this->getText(i) << endl; } for (i=0; i<getLocationCount(); i++) { s << "location " << i << ":" << getLocation(i).what() << endl; } }
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); }