| 383 | } |
| 384 | |
| 385 | void regressionTestSqlFile(const std::string& name, double netSiteEnergy, double firstVal, double lastVal) { |
| 386 | openstudio::path fromPath = resourcesPath() / toPath("utilities/SqlFile") / toPath(name); |
| 387 | openstudio::path path = toPath(name); |
| 388 | |
| 389 | if (openstudio::filesystem::exists(path)) { |
| 390 | openstudio::filesystem::remove(path); |
| 391 | } |
| 392 | ASSERT_FALSE(openstudio::filesystem::exists(path)); |
| 393 | ASSERT_TRUE(openstudio::filesystem::exists(fromPath)) << toString(fromPath); |
| 394 | openstudio::filesystem::copy(fromPath, path); |
| 395 | ASSERT_TRUE(openstudio::filesystem::exists(path)); |
| 396 | |
| 397 | boost::optional<SqlFile> sqlFile; |
| 398 | EXPECT_NO_THROW(sqlFile = SqlFile(path)); |
| 399 | ASSERT_TRUE(sqlFile); |
| 400 | |
| 401 | // Capture the version (1st group) |
| 402 | boost::regex re("1ZoneEvapCooler-V(.*)\\.sql"); |
| 403 | boost::smatch m; |
| 404 | ASSERT_TRUE(boost::regex_match(name, m, re)); |
| 405 | VersionString expected(m[1]); |
| 406 | VersionString actual(sqlFile->energyPlusVersion()); |
| 407 | EXPECT_EQ(expected.major(), actual.major()); |
| 408 | EXPECT_EQ(expected.minor(), actual.minor()); |
| 409 | EXPECT_EQ(expected.patch().get(), actual.patch().get()); |
| 410 | |
| 411 | // Check if the SqlFile has the 'Year' field |
| 412 | if (expected >= VersionString(9, 0)) { |
| 413 | EXPECT_TRUE(sqlFile->hasYear()); |
| 414 | } else if (expected < VersionString(8, 9)) { |
| 415 | EXPECT_FALSE(sqlFile->hasYear()); |
| 416 | } else { |
| 417 | // For 8.9.0, seems that it has the 'Year' field but it's always zero... |
| 418 | EXPECT_FALSE(sqlFile->hasYear()) << "Failed for " << name; |
| 419 | } |
| 420 | |
| 421 | // Check if the SqlFile has the 'Year' field for IlluminanceMap, which was added later in 9.2.0 |
| 422 | if (expected < VersionString(9, 2)) { |
| 423 | EXPECT_FALSE(sqlFile->hasIlluminanceMapYear()); |
| 424 | } else { |
| 425 | EXPECT_TRUE(sqlFile->hasIlluminanceMapYear()); |
| 426 | } |
| 427 | |
| 428 | ASSERT_TRUE(sqlFile->hoursSimulated()); |
| 429 | EXPECT_EQ(8760.0, sqlFile->hoursSimulated().get()) << name; |
| 430 | ASSERT_TRUE(sqlFile->netSiteEnergy()); |
| 431 | EXPECT_NEAR(netSiteEnergy, sqlFile->netSiteEnergy().get(), 0.1) << name; |
| 432 | |
| 433 | std::vector<std::string> availableEnvPeriods = sqlFile->availableEnvPeriods(); |
| 434 | ASSERT_FALSE(availableEnvPeriods.empty()); |
| 435 | EXPECT_EQ(static_cast<unsigned>(3), availableEnvPeriods.size()); |
| 436 | std::string availableEnvPeriod; |
| 437 | for (size_t i = 0; i < availableEnvPeriods.size(); i++) { |
| 438 | if (availableEnvPeriods[i].find("CONDNS") == std::string::npos) { |
| 439 | availableEnvPeriod = availableEnvPeriods[i]; |
| 440 | } |
| 441 | } |
| 442 |
no test coverage detected