#include <math.h>
#include <boost/test/unit_test.hpp>

#include "test_lid.hpp"

#define ERR_NONE 0

using namespace std;

BOOST_AUTO_TEST_SUITE(test_lid_toolkitapi_fixture)

    // Testing Results Getters (During Simulation) BC
    BOOST_FIXTURE_TEST_CASE(result_check_LID_BC, Fixture_LID_Results)
    {
        open_swmm_model(0);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        char chr_value;

        vector<double> revised_subcatchment_runoff;

        string lid = string("BC");
        string subcatch = string("wBC");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Surface layer
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, 6);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, 0.25);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);

        // Soil layer
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_POROSITY, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, 0.2);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSLOPE, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_SUCTION, 3.5);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

        // Storage layer
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, 0.75);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.75, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Drain layer
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_COEFF, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_EXPON, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_OFFSET, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_DELAY, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HOPEN, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 50.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 100);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);
            error = swmm_getLidCOverflow(lid_index, &chr_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_EQUAL(chr_value, 0);

            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.75, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 100);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

    // Testing Results Getters (During Simulation) GR
    BOOST_FIXTURE_TEST_CASE(result_check_LID_GR, Fixture_LID_Results)
    {
        open_swmm_model(1);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        char chr_value;
        vector<double> revised_subcatchment_runoff;

        string lid = string("GR");
        string subcatch = string("wGR");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Surface layer
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, 6);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, 0.25);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);

        // Soil layer
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_POROSITY, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, 0.2);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSLOPE, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_SUCTION, 3.5);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

        // Drainmat layer get/set
        error = swmm_setLidCParam(lid_index, SM_DRAINMAT, SM_THICKNESS, 3);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAINMAT, SM_VOIDFRAC, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAINMAT, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 3, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49 - 0, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 50.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 100);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);
            error = swmm_getLidCOverflow(lid_index, &chr_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_EQUAL(chr_value, 0);

            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 3, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAINMAT, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49 - 0, 0.0001);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 100);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);

            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

    // Testing Results Getters (During Simulation) IT
    BOOST_FIXTURE_TEST_CASE(result_check_LID_IT, Fixture_LID_Results)
    {
        open_swmm_model(2);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        char chr_value;
        vector<double> revised_subcatchment_runoff;

        string lid = string("IT");
        string subcatch = string("wIT");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Surface layer
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, 6);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, 0.25);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);

        // Storage layer
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, 0.75);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.75, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Drain layer
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_COEFF, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_EXPON, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_OFFSET, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_DELAY, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HOPEN, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 50.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 100);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);
            error = swmm_getLidCOverflow(lid_index, &chr_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_EQUAL(chr_value, 0);

            error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.75, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 100);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);

            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

    // Testing Results Getters (During Simulation) PP
    BOOST_FIXTURE_TEST_CASE(result_check_LID_PP, Fixture_LID_Results)
    {
        open_swmm_model(3);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        char chr_value;
        vector<double> revised_subcatchment_runoff;

        string lid = string("PP");
        string subcatch = string("wPP");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Surface layer
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, 6);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, 0.25);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);

        // Pavement layer get/set check
        error = swmm_setLidCParam(lid_index, SM_PAVE, SM_THICKNESS, 6);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_PAVE, SM_VOIDFRAC, 0.15);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_PAVE, SM_IMPERVFRAC, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_PAVE, SM_KSAT, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_PAVE, SM_CLOGFACTOR, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_PAVE, SM_REGENDAYS, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_PAVE, SM_REGENDEGREE, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_PAVE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_PAVE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.15, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_PAVE, SM_IMPERVFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_PAVE, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 100, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_PAVE, SM_CLOGFACTOR, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_PAVE, SM_REGENDAYS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_PAVE, SM_REGENDEGREE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Soil layer
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_POROSITY, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, 0.2);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSLOPE, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_SUCTION, 3.5);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

        // Storage layer
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, 0.75);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.75, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Drain layer
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_COEFF, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_EXPON, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_OFFSET, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_DELAY, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HOPEN, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 50.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 100);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);
            error = swmm_getLidCOverflow(lid_index, &chr_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_EQUAL(chr_value, 0);

            error = swmm_getLidCParam(lid_index, SM_PAVE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_PAVE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.15, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_PAVE, SM_IMPERVFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_PAVE, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 100, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_PAVE, SM_CLOGFACTOR, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_PAVE, SM_REGENDAYS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_PAVE, SM_REGENDEGREE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.75, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 100);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);

            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

    // Testing Results Getters (During Simulation) RB
    BOOST_FIXTURE_TEST_CASE(result_check_LID_RB, Fixture_LID_Results)
    {
        open_swmm_model(4);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        vector<double> revised_subcatchment_runoff;

        string lid = string("RB");
        string subcatch = string("wRB");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Storage layer
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_THICKNESS, 48);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, 0.75);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 48, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Drain layer
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_COEFF, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_EXPON, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_OFFSET, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_DELAY, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HOPEN, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 12.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 100);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 48, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 100);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);

            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

    // Testing Results Getters (During Simulation) RG
    BOOST_FIXTURE_TEST_CASE(result_check_LID_RG, Fixture_LID_Results)
    {
        open_swmm_model(5);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        char chr_value;
        vector<double> revised_subcatchment_runoff;

        string lid = string("RG");
        string subcatch = string("wRG");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Surface layer
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, 6);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, 0.25);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);

        // Soil layer
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_POROSITY, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, 0.2);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_KSLOPE, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SOIL, SM_SUCTION, 3.5);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

        // Storage layer
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_THICKNESS, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, 0.75);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_KSAT, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        // storage layer thickness was originally zero
        // void frac is default 1.0
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 50.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 100);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);
            error = swmm_getLidCOverflow(lid_index, &chr_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_EQUAL(chr_value, 0);

            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_POROSITY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_FIELDCAP, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.2, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_WILTPOINT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_KSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SOIL, SM_SUCTION, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 3.5, 0.0001);

            error = swmm_getLidCParam(lid_index, SM_STOR, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            // storage layer thickness was originally zero
            // void frac is default 1.0
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_KSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_STOR, SM_CLOGFACTOR, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0., 0.0001);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 100);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);

            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

    // Testing Results Getters (During Simulation) SWALE
    BOOST_FIXTURE_TEST_CASE(result_check_LID_SWALE, Fixture_LID_Results)
    {
        open_swmm_model(6);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        char chr_value;
        vector<double> revised_subcatchment_runoff;

        string lid = string("SWALE");
        string subcatch = string("wSWALE");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Surface layer
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, 12);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, 0.25);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SIDESLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 12, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SIDESLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 10);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 500.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 100.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 10);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 500.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 100.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 12, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SIDESLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);
            // always true for veg. swale
            error = swmm_getLidCOverflow(lid_index, &chr_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_EQUAL(chr_value, 1);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 10);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 500.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 100.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);

            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

    // Testing Results Getters (During Simulation) RD
    BOOST_FIXTURE_TEST_CASE(result_check_LID_RD, Fixture_LID_Results)
    {
        open_swmm_model(7);
        int error, sub_index, lid_index;
        double elapsed_time = 0.0;
        int int_value = 0;
        double db_value = 0.0;
        char chr_value;
        vector<double> revised_subcatchment_runoff;

        string lid = string("RD");
        string subcatch = string("wRD");

        lid_index = swmm_getObjectIndex(SM_LID, (char *)lid.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        sub_index = swmm_getObjectIndex(SM_SUBCATCH, (char *)subcatch.c_str(), &error);
        BOOST_REQUIRE(error == ERR_NONE);

        // Lid Control
        // Surface layer
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, 6);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, 0.25);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, 0.1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, 1.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);

        // Drain layer
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_COEFF, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_EXPON, 0.5);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_OFFSET, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_DELAY, 6.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HOPEN, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
        // if storage thickness is zero (no storage layer since it is roof disconnection)
        // the offset is changed to zero
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        // Lid Unit
        error = swmm_setLidUOption(sub_index, 0, SM_NUMBER, 100);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUOption(sub_index, 0, SM_TOPERV, 1);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_UNITAREA, 50.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FWIDTH, 10.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_INITSAT, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMIMPERV, 25.0);
        BOOST_REQUIRE(error == ERR_NONE);
        error = swmm_setLidUParam(sub_index, 0, SM_FROMPERV, 0.0);
        BOOST_REQUIRE(error == ERR_NONE);

        error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 100);
        error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_REQUIRE(int_value == 1);
        error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
        error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
        BOOST_REQUIRE(error == ERR_NONE);
        BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

        swmm_start(0);
        do
        {
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_THICKNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_VOIDFRAC, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.25, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ROUGHNESS, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.1, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_SURFSLOPE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_SURFACE, SM_ALPHA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 1.49, 0.0001);
            error = swmm_getLidCOverflow(lid_index, &chr_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_EQUAL(chr_value, 0);

            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_COEFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_EXPON, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.5, 0.0001);
            // if storage thickness is zero (no storage layer since it is roof disconnection)
            // the offset is changed to zero
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_OFFSET, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_DELAY, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 6.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HOPEN, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidCParam(lid_index, SM_DRAIN, SM_HCLOSE, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_getLidUOption(sub_index, 0, SM_NUMBER, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 100);
            error = swmm_getLidUOption(sub_index, 0, SM_TOPERV, &int_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_REQUIRE(int_value == 1);
            error = swmm_getLidUParam(sub_index, 0, SM_UNITAREA, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 50.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FWIDTH, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 10.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_INITSAT, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMIMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 25.0, 0.0001);
            error = swmm_getLidUParam(sub_index, 0, SM_FROMPERV, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);
            BOOST_CHECK_SMALL(db_value - 0.0, 0.0001);

            error = swmm_step(&elapsed_time);
            BOOST_REQUIRE(error == ERR_NONE);
            error = swmm_getSubcatchResult(sub_index, SM_SUBCRUNOFF, &db_value);
            BOOST_REQUIRE(error == ERR_NONE);

            revised_subcatchment_runoff.push_back(round(db_value * 100000.0) / 100000.0);
        }while (elapsed_time != 0 && !error);
        BOOST_CHECK_EQUAL(0, error);
        swmm_end();

        BOOST_CHECK_EQUAL_COLLECTIONS(revised_subcatchment_runoff.begin(), revised_subcatchment_runoff.end(),
                              subcatchment_runoff.begin(), subcatchment_runoff.end());
    }

BOOST_AUTO_TEST_SUITE_END()


#ifndef TEST_UNIT_TORSTEN_ONECPT_NON_AUTONOMOUS_TEST_FIXTURE
#define TEST_UNIT_TORSTEN_ONECPT_NON_AUTONOMOUS_TEST_FIXTURE

#include <stan/math/rev/core/recover_memory.hpp>
#include <gtest/gtest.h>
#include <boost/numeric/odeint.hpp>
#include <stan/math/torsten/test/unit/test_fixture_model.hpp>
#include <stan/math/torsten/pmx_ode_model.hpp>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>

template <typename T0, typename T1, typename T2, typename T3>
Eigen::Matrix<typename stan::return_type_t<T0, T1, T2, T3>, -1, 1>
onecpt_abstime(const T0& t,
                       const Eigen::Matrix<T1, -1, 1>& x,
                       std::ostream* pstream__,
                       const std::vector<T2>& parms,
                       const std::vector<T3>& x_r,
                       const std::vector<int>& x_i) {
  typedef typename stan::return_type_t<T0, T1, T2, T3> scalar;

  scalar CL0 = parms[0], V1 = parms[1], ka = parms[2], CLSS = parms[3],
    K = parms[4];

  scalar CL = CL0 + (CLSS - CL0) * (1 - stan::math::exp(-K * t));
  scalar k10 = CL / V1;

  Eigen::Matrix<scalar, -1, 1> y(2);

  y[0] = -ka * x[0];
  y[1] = ka * x[0] - k10 * x[1];

  return y;
}

struct onecpt_abstime_functor {
  template <typename T0, typename T1, typename T2, typename T3>
  Eigen::Matrix<typename stan::return_type_t<T0, T1, T2, T3>, -1, 1>
  operator()(const T0& t,
             const Eigen::Matrix<T1, -1, 1>& x,
             std::ostream* pstream__,
             const std::vector<T2>& parms,
             const std::vector<T3>& x_r,
             const std::vector<int>& x_i) const {
    return onecpt_abstime(t, x, pstream__, parms, x_r, x_i);
  }
};

template<typename T>
struct test_onecpt_non_autonomous : public TorstenPMXTest<test_onecpt_non_autonomous<T> > {
  test_onecpt_non_autonomous() {
    this -> ncmt = 2;

    this -> reset_events(10);

    this -> theta.resize(1);
    this -> theta[0] = {10, 80, 1.2, 2, 1}; // CL0, VC, ka, CLSS, K
    this -> biovar.resize(1);
    this -> biovar[0] = {1, 1};
    this -> tlag.resize(1);
    this -> tlag[0] = {0, 0};

    for(int i = 0; i < this -> nt; i++) {
      this -> time[i] = i * 0.25;
    }
    this -> time[this -> nt - 1] = 4.0;

    this -> amt[0] = 1000.0;
    this -> cmt[0] = 1;
    this -> evid[0] = 1;
    this -> ii[0] = 12;
    this -> addl[0] = 14;
  }
};

#endif