Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to comments of test_SW_Flow_lib_temp #222

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion googletest
Submodule googletest updated 52 files
+2 −2 README.md
+5 −0 appveyor.yml
+8 −8 googlemock/README.md
+2 −2 googlemock/docs/CheatSheet.md
+1 −1 googlemock/docs/CookBook.md
+1 −1 googlemock/docs/ForDummies.md
+0 −1 googlemock/docs/FrequentlyAskedQuestions.md
+4 −4 googlemock/include/gmock/gmock-matchers.h
+4 −5 googlemock/scripts/generator/README
+2 −4 googlemock/test/gmock-matchers_test.cc
+1 −1 googlemock/test/gmock_link2_test.cc
+1 −1 googlemock/test/gmock_link_test.cc
+1 −1 googlemock/test/gmock_test_utils.py
+168 −187 googletest/README.md
+0 −16 googletest/docs/Documentation.md
+3 −3 googletest/docs/advanced.md
+43 −43 googletest/docs/faq.md
+5 −5 googletest/docs/primer.md
+0 −0 googletest/docs/samples.md
+1 −1 googletest/include/gtest/gtest-death-test.h
+1 −1 googletest/include/gtest/gtest-message.h
+1 −1 googletest/include/gtest/gtest-param-test.h
+1 −1 googletest/include/gtest/gtest-param-test.h.pump
+5 −1 googletest/include/gtest/gtest-printers.h
+1 −1 googletest/include/gtest/gtest.h
+1 −1 googletest/include/gtest/gtest_prod.h
+0 −5 googletest/include/gtest/internal/custom/gtest-port.h
+1 −1 googletest/include/gtest/internal/gtest-death-test-internal.h
+1 −1 googletest/include/gtest/internal/gtest-internal.h
+1 −1 googletest/include/gtest/internal/gtest-port-arch.h
+1 −1 googletest/include/gtest/internal/gtest-port.h
+1 −1 googletest/include/gtest/internal/gtest-string.h
+17 −1 googletest/include/gtest/internal/gtest-type-util.h
+17 −1 googletest/include/gtest/internal/gtest-type-util.h.pump
+1 −1 googletest/scripts/fuse_gtest_files.py
+1 −1 googletest/src/gtest-all.cc
+24 −25 googletest/src/gtest-death-test.cc
+1 −1 googletest/src/gtest-printers.cc
+1 −1 googletest/src/gtest-test-part.cc
+9 −8 googletest/src/gtest.cc
+16 −0 googletest/test/BUILD.bazel
+1 −1 googletest/test/gtest-listener_test.cc
+1 −1 googletest/test/gtest-param-test_test.h
+7 −1 googletest/test/gtest-printers_test.cc
+1 −1 googletest/test/gtest-unittest-api_test.cc
+1 −1 googletest/test/gtest_all_test.cc
+1 −1 googletest/test/gtest_help_test.py
+1 −1 googletest/test/gtest_output_test.py
+1 −1 googletest/test/gtest_test_utils.py
+65 −0 googletest/test/gtest_testbridge_test.py
+44 −0 googletest/test/gtest_testbridge_test_.cc
+25 −0 googletest/test/gtest_unittest.cc
67 changes: 40 additions & 27 deletions test/test_SW_Flow_lib_temp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ namespace {

tSoilAvg = surface_temperature_under_snow(airTempAvg, snow);

EXPECT_EQ(0, tSoilAvg); // When there is snow, the return is 0
EXPECT_EQ(0, tSoilAvg); // When there is snow, the return of tSoilAvg is 0


// test when snow is > 0 and airTempAvg is >= 0
snow = 1, airTempAvg = 0;

tSoilAvg = surface_temperature_under_snow(airTempAvg, snow);

EXPECT_EQ(-2.0, tSoilAvg); // When there is snow and airTemp >= 0, the return is -2.0
EXPECT_EQ(-2.0, tSoilAvg); // When there is snow and airTemp >= 0, the return of tSoilAvg is -2.0

// test when snow > 0 and airTempAvg < 0
snow = 1, airTempAvg = -10;

tSoilAvg = surface_temperature_under_snow(airTempAvg, snow);

EXPECT_EQ(-4.55, tSoilAvg); // When there snow == 1 airTempAvg = -10
EXPECT_EQ(-4.55, tSoilAvg); // When snow == 1 and airTempAvg = -10, tSoilAvg = -4.55

//
snow = 6.7, airTempAvg = 0;
Expand Down Expand Up @@ -118,8 +118,8 @@ namespace {
}

// Other init test
EXPECT_EQ(stValues.depths[nlyrs - 1], 20); // sum of inputs width = maximum depth; in my example 20
EXPECT_EQ((stValues.depthsR[nRgr]/deltaX) - 1, nRgr); // nRgr = (MaxDepth/deltaX) - 1
EXPECT_EQ(stValues.depths[nlyrs - 1], 20); // sum of input width should = maximum depth; in my example 20
EXPECT_EQ((stValues.depthsR[nRgr]/deltaX) - 1, nRgr); // The nRgr should = (MaxDepth/deltaX) - 1

// Reset to previous global state
Reset_SOILWAT2_after_UnitTest();
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace {
}

// Other init test
EXPECT_EQ(stValues.depths[nlyrs - 1], 295); // sum of inputs width = maximum depth; in my example 295
EXPECT_EQ(stValues.depths[nlyrs - 1], 295); // sum of input width should = maximum depth; in my example 295
EXPECT_EQ((stValues.depthsR[nRgr]/deltaX) - 1, nRgr); // nRgr = (MaxDepth/deltaX) - 1

// Reset to previous global state
Expand Down Expand Up @@ -220,7 +220,7 @@ namespace {
}

for (i = ceil(stValues.depths[nlyrs - 1]/deltaX) + 1; i < nRgr + 1; i++) {
//The TempLayer values that are at depths greater than the max SoilLayer depth should be uniform
//The TempLayeR values that are at depths greater than the max SoilLayer depth should be uniform
EXPECT_EQ(stValues.bDensityR[i], stValues.bDensityR[i - 1]);
EXPECT_EQ(stValues.fcR[i], stValues.fcR[i - 1]);
EXPECT_EQ(stValues.wpR[i], stValues.wpR[i - 1]);
Expand Down Expand Up @@ -265,7 +265,7 @@ namespace {
}

for (i = ceil(stValues.depths[nlyrs - 1]/deltaX) + 1; i < nRgr + 1; i++) {
//The TempLayer values that are at depths greater than the max SoilLayer depth should be uniform
//The TempLayeR values that are at depths greater than the max SoilLayer depth should be uniform
EXPECT_EQ(stValues.bDensityR[i], stValues.bDensityR[i - 1]);
EXPECT_EQ(stValues.fcR[i], stValues.fcR[i - 1]);
EXPECT_EQ(stValues.wpR[i], stValues.wpR[i - 1]);
Expand Down Expand Up @@ -298,15 +298,15 @@ namespace {

set_frozen_unfrozen(nlyrs, sTemp, swc, swc_sat, width);

EXPECT_EQ(1,stValues.lyrFrozen[0]); // Soil should freeze when sTemp is <= -1
EXPECT_EQ(1,stValues.lyrFrozen[0]); // Soil should freeze (= 1) when sTemp is <= -1
// AND swc is > swc_sat - width * .13

/// ***** Test that soil does not freeze ***** ///
double sTemp2[] = {0};

set_frozen_unfrozen(nlyrs, sTemp2, swc, swc_sat, width);

EXPECT_EQ(0,stValues.lyrFrozen[0]); // Soil should NOT freeze when sTemp is > -1
EXPECT_EQ(0,stValues.lyrFrozen[0]); // Soil should NOT freeze ( = 0) when sTemp is > -1

// Reset to previous global state
Reset_SOILWAT2_after_UnitTest();
Expand All @@ -322,14 +322,14 @@ namespace {
sTemp4[i] = 0;
swc2[i] = 5; // set swc to a high value so will be > swc_sat - width * .13
swc_sat2[i] = 1;
// run
// Run
set_frozen_unfrozen(nlyrs, sTemp3, swc2, swc_sat2, width2);
// Test
EXPECT_EQ(1,stValues.lyrFrozen[i]);
EXPECT_EQ(1,stValues.lyrFrozen[i]); // when sTemp3 < 0 , we expect the layers to be frozen (1)
// run
set_frozen_unfrozen(nlyrs, sTemp4, swc2, swc_sat2, width2);
// Test
EXPECT_EQ(0,stValues.lyrFrozen[i]);
EXPECT_EQ(0,stValues.lyrFrozen[i]); // when sTemp4 > 0, we expect the layers NOT to be fronze (0)
}

// Reset to previous global state
Expand Down Expand Up @@ -365,17 +365,17 @@ namespace {
vwcR, wpR, fcR, bDensityR, csParam1, csParam2, shParam, &ptr_stError);

// Check that values that are set, are set right.
EXPECT_EQ(sTempR[0], T1);
EXPECT_EQ(sTempR[nRgr + 1], sTconst);
EXPECT_EQ(sTempR[0], T1); // The first layer of sTempR should be equal to T1
EXPECT_EQ(sTempR[nRgr + 1], sTconst); // The last layer of sTempR should be equal to sTconst

//Check that ptr_stError is FALSE
EXPECT_EQ(ptr_stError, 0);
EXPECT_EQ(ptr_stError, 0); // There should be no errors.

//Check that when ptr_stError is FALSE, sTempR values are realisitic and pass check in code (between -100 and 100)
for (i = 0; i <= nRgr + 1; i++)
{
EXPECT_LT(sTempR[i], 100);
EXPECT_GT(sTempR[i], -100);
EXPECT_LT(sTempR[i], 100); // Temp values in any layer should always be < 100
EXPECT_GT(sTempR[i], -100); // Temp values in any layer should always be > -100
}

// test that the ptr_stError is FALSE when it is supposed to
Expand All @@ -391,7 +391,7 @@ namespace {
vwcR, wpR, fcR, bDensityR, csParam1, csParam2, shParam, &ptr_stError);

//Check that ptr_stError is TRUE
EXPECT_EQ(ptr_stError, 1);
EXPECT_EQ(ptr_stError, 1); // An error (ptr_stError = 1) should be documented when soil temperature values are incredibly high

// Reset to previous global state
Reset_SOILWAT2_after_UnitTest();
Expand Down Expand Up @@ -423,6 +423,7 @@ namespace {


// Expect that surface temp equals surface_temperature_under_snow() because snow > 0
// Should not equal other two formula options
EXPECT_EQ(surfaceTemp[Today], surface_temperature_under_snow(airTemp, snow));
EXPECT_NE(surfaceTemp[Today], airTemp + ((t1Param2 * (biomass - bmLimiter)) / t1Param3));
EXPECT_NE(surfaceTemp[Today], airTemp + (t1Param1 * pet * (1. - (aet / pet)) * (1. - (biomass / bmLimiter))));
Expand All @@ -435,6 +436,8 @@ namespace {
t1Param3, csParam1, csParam2, shParam, snowdepth, sTconst, deltaX, theMaxDepth,
nRgr, snow, &ptr_stError);

// Expect that surface temp equals Form 1 because snow = 0 & biomass < blimiter
// Should not equal other two options
EXPECT_EQ(surfaceTemp[Today], airTemp + (t1Param1 * pet * (1. - (aet / pet)) * (1. - (biomass / bmLimiter))));
EXPECT_NE(surfaceTemp[Today], airTemp + ((t1Param2 * (biomass - bmLimiter)) / t1Param3));
EXPECT_NE(surfaceTemp[Today], surface_temperature_under_snow(airTemp, snow));
Expand All @@ -447,6 +450,8 @@ namespace {
t1Param3, csParam1, csParam2, shParam, snowdepth, sTconst, deltaX, theMaxDepth,
nRgr, snow, &ptr_stError);

// Expect that surface temp equals Form 2 because snow = 0 & biomass > blimiter
// Should not equal other two options
EXPECT_EQ(surfaceTemp[Today], airTemp + ((t1Param2 * (biomass - bmLimiter)) / t1Param3));
EXPECT_NE(surfaceTemp[Today], airTemp + (t1Param1 * pet * (1. - (aet / pet)) * (1. - (biomass / bmLimiter))));
EXPECT_NE(surfaceTemp[Today], surface_temperature_under_snow(airTemp, snow));
Expand All @@ -458,17 +463,15 @@ namespace {
EXPECT_LT(sTemp[0], 100); // Sense check
EXPECT_EQ(0, ptr_stError); // ptr_stError should be FALSE

// Expect that oldsTempR is updated to sTempR for the next day
for (k = 0; k <= nRgr + 1; k++)
{
//swprintf("\n k %u, newoldtempR %f", k, stValues.oldsTempR[k]);
// Expect that oldsTempR is updated to sTempR for the next day (should not be missing)
EXPECT_NE(stValues.oldsTempR[k], SW_MISSING);
}

//Reset to global state
Reset_SOILWAT2_after_UnitTest();


// ptr_stError should be set to TRUE if soil_temperature_today fails (i.e. unrealistic temp values)
double sTemp2[nlyrs], oldsTemp2[nlyrs];
for (i = 0; i < nlyrs; i++)
Expand Down Expand Up @@ -516,9 +519,9 @@ namespace {
fc2[i] = fmaxf(RandNorm(1.5, 0.5), 0.1); // greater than 0.1
swc_sat2[i] = fc2[i] + 0.2; //swc_sat > fc2
swc2[i] = fmax(swc_sat2[i] - 0.3, 0.01); // swc_sat > swc > 0
wp2[i] = fmaxf(fc2[i] - 0.6, 0.1); // wp < fc
//swprintf("\n i %u, bDensity %f, swc_sat %f, fc %f, swc %f, wp %f",
// i, bDensity2[i], swc_sat2[i], fc2[i], swc2[i], wp2[i] );
wp2[i] = fmaxf(fc2[i] - 0.6, 0.1); // 0 < wp < fc
swprintf("\n i %u, bDensity %f, swc_sat %f, fc %f, swc %f, wp %f",
i, bDensity2[i], swc_sat2[i], fc2[i], swc2[i], wp2[i] );
}

// Test surface temp equals surface_temperature_under_snow() because snow > 0
Expand All @@ -529,6 +532,8 @@ namespace {
t1Param3, csParam1, csParam2, shParam, snowdepth, sTconst, deltaX, theMaxDepth,
nRgr, snow, &ptr_stError);

// Expect that surface temp equals surface_temperature_under_snow() because snow > 0
// Should not equal other two formula options
EXPECT_EQ(surfaceTemp[Today], surface_temperature_under_snow(airTemp, snow));
EXPECT_NE(surfaceTemp[Today], airTemp + ((t1Param2 * (biomass - bmLimiter)) / t1Param3));
EXPECT_NE(surfaceTemp[Today], airTemp + (t1Param1 * pet * (1. - (aet / pet)) * (1. - (biomass / bmLimiter))));
Expand All @@ -542,6 +547,8 @@ namespace {
t1Param3, csParam1, csParam2, shParam, snowdepth, sTconst, deltaX, theMaxDepth,
nRgr, snow, &ptr_stError);

// Expect that surface temp equals Form 1 because snow = 0 & biomass < blimiter
// Should not equal other two options
EXPECT_EQ(surfaceTemp[Today], airTemp + (t1Param1 * pet * (1. - (aet / pet)) * (1. - (biomass / bmLimiter))));
EXPECT_NE(surfaceTemp[Today], airTemp + ((t1Param2 * (biomass - bmLimiter)) / t1Param3));
EXPECT_NE(surfaceTemp[Today], surface_temperature_under_snow(airTemp, snow));
Expand All @@ -554,6 +561,8 @@ namespace {
t1Param3, csParam1, csParam2, shParam, snowdepth, sTconst, deltaX, theMaxDepth,
nRgr, snow, &ptr_stError);

// Expect that surface temp equals Form 2 because snow = 0 & biomass > blimiter
// Should not equal other two options
EXPECT_EQ(surfaceTemp[Today], airTemp + ((t1Param2 * (biomass - bmLimiter)) / t1Param3));
EXPECT_NE(surfaceTemp[Today], airTemp + (t1Param1 * pet * (1. - (aet / pet)) * (1. - (biomass / bmLimiter))));
EXPECT_NE(surfaceTemp[Today], surface_temperature_under_snow(airTemp, snow));
Expand All @@ -564,12 +573,12 @@ namespace {

for (k = 0; k < nlyrs2; k++)
{
//swprintf("\n k %u, sTemp3 %f", k, sTemp3[k]);
swprintf("\n k %u, sTemp3 %f", k, sTemp3[k]);
EXPECT_GT(sTemp3[k], -100); // Sense check
EXPECT_LT(sTemp3[k], 100); // Sense check
}

// Expect that oldsTempR is updated to sTempR for the next day
// Expect that oldsTempR is updated to sTempR for the next day (should not be missing)
for (k = 0; k <= nRgr + 1; k++)
{
//swprintf("\n k %u, newoldtempR %f", k, stValues.oldsTempR[k]);
Expand Down Expand Up @@ -605,6 +614,10 @@ namespace {
swc_sat[i] = fc[i] + 0.2; //swc_sat > fc2
swc[i] = swc_sat[i] - 0.3; // swc_sat > swc
wp[i] = fmaxf(fc[i] - 0.6, 0.1); // wp < fc

swprintf("\n i %u, bDensity %f, swc_sat %f, fc %f, swc %f, wp %f",
i, bDensity[i], swc_sat[i], fc[i], swc[i], wp[i] );

}

// Should fail when soil_temperature_init fails - i.e. when theMaxDepth < depth of nlyrs
Expand Down