Hi Martin, Then its better if we can include scenarios in test case(like using RenderedImage) to actually verify this behaviour(non-zero grid offsets) instead of just having BufferedImage.
Thanks, Jay > On 17-Apr-2020, at 6:58 PM, Martin Desruisseaux > <martin.desruisse...@geomatys.com> wrote: > > Hello Jay > > Le 17/04/2020 à 12:58, Jayathirth D v a écrit : > >> I have a question regarding test case. Why test has to check whether we are >> getting negative value or not and then calculate whether the tileGridOffset >> is 0. From different function's specification in BufferedImage I see that >> there are no multiple tiles support. I went through mail thread related to >> how we are comparing it to JAI’s implementation. But I think we can still >> keep the test case to be minimal and just check for 0 grid offset values. >> > It is true that just testing that grid offset values are 0 would be > sufficient. But doing so does not explain why it needs to be zero (except > because the specification said so). The purpose of the first part of the > test, which is computing tileX and tileY, is to illustrate why grid offsets > need to be zero. The idea is to said "Suppose that we don't know that this > image has only one tile. Let's calculate tile indices the way we would do for > an arbitrary RenderedImage. Do we get consistent results?". > > In other words the two tests are redundant. But the first test requiring > (tileX == 0 && tileY == 0) takes the perspective of checking if the values > are mathematically consistent, while the other tests requiring > (tileGridXOffset == 0 && tileGridXOffset == 0) are basically the same tests > but from the perspective of checking compliance with specification. The first > test about mathematical consistency is a kind of documentation, but > addresses the problem which was the reason for this patch request. > > The comment about negative value is because the formulas used in the test — > tileX = (x - tileGridXOffset) / image.getTileWidth() — is not quite exact. > The division should be replaced by a call to Math.floorDiv(int, int). I > though that it was not necessary for this test since the two formulas will > differ only if (x - tileGridXOffset) is negative, which is not the case in > this test, and that a comment would be simpler. But maybe it would be less > confusing to remove the comment and use Math.floorDiv(int, int) instead. > > Regards, > Martin > > >