* ExplodeDefault Test * * ExplodeDefault test given a single 5x5 input cube with 2 bands. * * The output cube is verified by checking the histogram statistics * for each band. * * INPUT: testCube from DefaultCube fixture resized to 5x5x1 * * OUTPUT: 1) explodeOut.band0001.cub * 2) explodeOut.band0002.cub */
| 27 | * 2) explodeOut.band0002.cub |
| 28 | */ |
| 29 | TEST_F(DefaultCube, FunctionalTestExplodeDefault) { |
| 30 | |
| 31 | // reduce test cube size and create two bands |
| 32 | resizeCube(5, 5, 2); |
| 33 | |
| 34 | // close and reopen test cube to ensure dn buffer is available |
| 35 | testCube->reopen("r"); |
| 36 | |
| 37 | // run explode |
| 38 | QVector<QString> args = {"to=" + tempDir.path() + "/explodeOut"}; |
| 39 | UserInterface ui(APP_XML, args); |
| 40 | |
| 41 | try { |
| 42 | explode(testCube, ui); |
| 43 | } |
| 44 | catch(IException &e) { |
| 45 | FAIL() << e.toString().toStdString().c_str() << std::endl; |
| 46 | } |
| 47 | |
| 48 | // validate band 1 output cube |
| 49 | Cube outCube1(tempDir.path() + "/explodeOut.band0001.cub"); |
| 50 | |
| 51 | ASSERT_EQ(outCube1.sampleCount(), 5); |
| 52 | ASSERT_EQ(outCube1.lineCount(), 5); |
| 53 | ASSERT_EQ(outCube1.bandCount(), 1); |
| 54 | |
| 55 | std::unique_ptr<Histogram> inCubeBand1Hist (testCube->histogram(1)); |
| 56 | std::unique_ptr<Histogram> outCube1Hist (outCube1.histogram(1)); |
| 57 | |
| 58 | EXPECT_NEAR(outCube1Hist->Average(), inCubeBand1Hist->Average(), .000001); |
| 59 | EXPECT_NEAR(outCube1Hist->Sum(), inCubeBand1Hist->Sum(), .000001); |
| 60 | EXPECT_EQ(outCube1Hist->ValidPixels(), inCubeBand1Hist->ValidPixels()); |
| 61 | EXPECT_EQ(outCube1Hist->TotalPixels(), inCubeBand1Hist->TotalPixels()); |
| 62 | EXPECT_NEAR(outCube1Hist->StandardDeviation(), inCubeBand1Hist->StandardDeviation(), .000001); |
| 63 | |
| 64 | // validate band 2 output cube |
| 65 | Cube outCube2(tempDir.path() + "/explodeOut.band0002.cub"); |
| 66 | |
| 67 | ASSERT_EQ(outCube2.sampleCount(), 5); |
| 68 | ASSERT_EQ(outCube2.lineCount(), 5); |
| 69 | ASSERT_EQ(outCube2.bandCount(), 1); |
| 70 | |
| 71 | std::unique_ptr<Histogram> inCubeBand2Hist (testCube->histogram(2)); |
| 72 | std::unique_ptr<Histogram> outCube2Hist (outCube2.histogram(1)); |
| 73 | |
| 74 | EXPECT_NEAR(outCube2Hist->Average(), inCubeBand2Hist->Average(), .000001); |
| 75 | EXPECT_NEAR(outCube2Hist->Sum(), inCubeBand2Hist->Sum(), .000001); |
| 76 | EXPECT_EQ(outCube2Hist->ValidPixels(), inCubeBand2Hist->ValidPixels()); |
| 77 | EXPECT_EQ(outCube2Hist->TotalPixels(), inCubeBand2Hist->TotalPixels()); |
| 78 | EXPECT_NEAR(outCube2Hist->StandardDeviation(), inCubeBand2Hist->StandardDeviation(), .000001); |
| 79 | } |
| 80 |
nothing calls this directly
no test coverage detected