@Test
public void testScalingIfNeed() throws Exception {

    Mat img1 = makeRandomImage(0, 0, 1);
    Mat img2 = makeRandomImage(0, 0, 3);
    int w1 = 60, h1 = 110, ch1 = 1;
    NativeImageLoader loader1 = new NativeImageLoader(h1, w1, ch1);
    Mat scaled1 = loader1.scalingIfNeed(img1);
    assertEquals(h1, scaled1.rows());
    assertEquals(w1, scaled1.cols());
    assertEquals(img1.channels(), scaled1.channels());
    Mat scaled2 = loader1.scalingIfNeed(img2);
    assertEquals(h1, scaled2.rows());
    assertEquals(w1, scaled2.cols());
    assertEquals(img2.channels(), scaled2.channels());
    int w2 = 70, h2 = 120, ch2 = 3;
    NativeImageLoader loader2 = new NativeImageLoader(h2, w2, ch2);
    Mat scaled3 = loader2.scalingIfNeed(img1);
    assertEquals(h2, scaled3.rows());
    assertEquals(w2, scaled3.cols());
    assertEquals(img1.channels(), scaled3.channels());
    Mat scaled4 = loader2.scalingIfNeed(img2);
    assertEquals(h2, scaled4.rows());
    assertEquals(w2, scaled4.cols());
    assertEquals(img2.channels(), scaled4.channels());
}