42 lines
1.8 KiB
Java
42 lines
1.8 KiB
Java
|
public class CovidDatabaseTest {
|
||
|
public static void main (String[] args) {
|
||
|
System.out.println ("Testing starts");
|
||
|
CovidDatabase db = new CovidDatabase() ;
|
||
|
db.readCovidData("covid_data.csv");
|
||
|
// check number of records, total infections, and total deaths
|
||
|
assert db.countRecords() == 10346 : "database should have 10,346";
|
||
|
|
||
|
assert db.getTotalDeaths() == 196696 : "Total deaths should be: 196,696";
|
||
|
assert db.getTotalInfections() == 7032090 : "infections should be: 7,032,090";
|
||
|
// check peak daily deaths for 5/5
|
||
|
CovidEntry mostDeaths = db.peakDailyDeaths(5, 5);
|
||
|
assert mostDeaths.getState().equals("PA") : "State with most deaths for 5/5 is PA";
|
||
|
assert mostDeaths.getDailyDeaths() == 554 : "Deaths for 5/5 is PA: 554";
|
||
|
// test other methods
|
||
|
|
||
|
// Check highest deaths
|
||
|
CovidEntry highestTX = db.peakDailyDeaths("TX");
|
||
|
assert highestTX.getDailyDeaths() == 675 : "Highest texas deaths is: 675";
|
||
|
|
||
|
// Most total deaths
|
||
|
assert db.mostTotalDeaths().getTotalDeaths() == 25456 : "Highest deaths is 25456";
|
||
|
assert db.mostTotalDeaths().getState().equals("NY") : "Highest deaths state: NY";
|
||
|
|
||
|
// Peak daily deaths
|
||
|
assert db.peakDailyDeaths("MI").getDailyDeaths() == 169 : "Highest MI Deaths: 169";
|
||
|
assert db.peakDailyDeaths(5, 5).getDailyDeaths() == 554 : "Highest 5/5 deaths: PA";
|
||
|
|
||
|
// Top ten deaths
|
||
|
assert db.topTenDeaths(5, 5).size() == 10 : "Top ten deaths should be 10";
|
||
|
assert db.topTenDeaths(5, 5).get(0).getState().equals("PA") : "First Top ten deaths should be PA";
|
||
|
|
||
|
// Safe to open
|
||
|
assert db.safeToOpen("MI").get(0).getDailyInfections() == 443 : "First entry should have 443 infections";
|
||
|
|
||
|
//list min daily infections
|
||
|
assert db.listMinimumDailyInfections(6,12,1000).get(0).getState().equals("TX") : "First entry should be TX";
|
||
|
|
||
|
System.out.println ("Testing ends");
|
||
|
}
|
||
|
}
|