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

Added tests for issue #53, followup to PR #57. #65

Closed
wants to merge 15 commits into from

Conversation

fpl
Copy link
Contributor

@fpl fpl commented Nov 15, 2023

Hi,

Here I added a few tests for issue #53, still missing a test for OCTTransformBounds because I honestly did not understand the use and context of that API function. Without PR 57, those tests should cause a failure due to wrong type of arguments (double[] instead of double*) i.e. argument type not a reference to scalar.
.

If you try to force the use of double *, that should cause a segfault in the Perl interpreter.

Cheers

PS: note that this PR does not include the fix proposed in #57, so the obvious failures indicated above are expected and present in the CI failures.

@shawnlaffan
Copy link
Collaborator

It is probably cleaner to append these changes to PR #57?

@fpl
Copy link
Contributor Author

fpl commented Nov 17, 2023

It is probably cleaner to append these changes to PR #57?

I merged the previous PR #57 into this one for coherence and see t/transform.t needs a little fix in one of its calls

@shawnlaffan
Copy link
Collaborator

Thank you for combining the commits. It seems, though, that something has happened to the commit authors of several commits in the merge process.

It might be necessary to rebase your commits onto the master branch and then force push the PR. If it all gets too messy then a new PR might be simpler. And if that's too complex (as rebasing can be) then I can also cherry-pick your commits onto a new PR.

@shawnlaffan
Copy link
Collaborator

Although the authors seem correct when pulling the changes locally so perhaps don't worry about the rebase.

@@ -210,6 +210,11 @@ if(1){
is($p, $ogc_wkt, "Set/get projection string");
my $transform = [10,2,0,20,0,3];
$ds->SetGeoTransform($transform);
my $inv = [0,0,0,0,0,0];
ok(Geo::GDAL::FFI::GDALInvGeoTransform($transform, $inv) && "@$inv" eq "-5 0.5 0 -6.66666666666667 0 0.333333333333333", "Invert geotransform");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be split into two tests? Store the result of the transform call into a scalar variable. It can be checked using the is function. Then use an is_deeply test to check the expected array values.

my @y = ($ul[1], $lr[1], $ur[1], $ll[1]);
my $z = undef;
ok(Geo::GDAL::FFI::OCTTransform($ct, 4, \@x, \@y, \@$z), "Coordinate transformation 3D worked");
ok(qq/@x @y/ eq $result, "Resulting coordinates");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also better done using is_deeply.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for similar cases below.

ok(qq/@x @y/ eq $result, "Resulting coordinates");
@ps = (0,0,0,0);
ok(Geo::GDAL::FFI::OCTTransform4D($ct, 4, \@x, \@y, \@$z, \@$t, \@ps), "Coordinate transformation 4D worked");
ok(qq/@x @y/ eq $result && qq/@ps/ eq qq/1 1 1 1/, "Resulting coordinates");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better written using is_deeply.

my $exp_results = [...];  #  set up expected values
is_deeply ([@x, @y], $exp_result, "Resulting coordinates match");
is_deeply (\@ps, [qw/1 1 1 1/], "Resulting coordinates match, (ps array)");

The is and is_deeply type tests give better feedback when a test fails, i.e they say what was found and was was expected. ok just says there was a failure.

@shawnlaffan
Copy link
Collaborator

@fpl - I added some comments a while ago but it seems one has to publish them so they are visible to others. I have just done that so now you should hopefully be able to see them. If you don't have time then I can clean them up in a later commit.

@fpl
Copy link
Contributor Author

fpl commented Dec 15, 2023

@fpl - I added some comments a while ago but it seems one has to publish them so they are visible to others. I have just done that so now you should hopefully be able to see them. If you don't have time then I can clean them up in a later commit.

Yep, I can change the test code as suggested.

@shawnlaffan
Copy link
Collaborator

Yep, I can change the test code as suggested.

Thanks @fpl. If you can rebase the changes on latest master then that would be useful. If it causes problems then don't worry about it.

@fpl
Copy link
Contributor Author

fpl commented Dec 19, 2023

I'm closing because this is obsoleted by PR #68

@fpl fpl closed this Dec 19, 2023
shawnlaffan added a commit that referenced this pull request Jun 12, 2024
Closes #53 with simple tests (this obsoletes PR #57 and PR #65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants