[Proj] Testing framework
Even Rouault
even.rouault at spatialys.com
Wed May 30 14:59:23 EST 2018
On mercredi 30 mai 2018 11:36:06 CEST Kurt Schwehr wrote:
> So... Just to state my preference. I think Google
> Test(gtest/gmock/microbenchmark) would be great if PROJ decides to go that
> way. It's been run through the ringer with hundreds of millions of lines
> of tests written with it and it covers most use cases without being to
> heavy weight. And I would be happy to contribute my tests to PROJ
> (switching them to the PROJ license) and drop them from gdal-autotest2.
>
> I really don't know Catch2 so I don't really have an opinion on how well it
> works.
>
> Either way, I will keep on doing PROJ/GEOS/GDAL testing in gtest for my own
> work.
I'm pretty sure for our basic needs whatever modern unit testing framework would do. catch2 with
its single header was just easier to integrate, and thus passed the least effort principle.
Just as an exercice, I've created a fake "gunit.h" that redirects to catch2:
{{{
#include "catch.hpp"
#define STR(x) #x
#define CONCAT(x,y) STR(x ## _ ## y)
#define TEST(x,y) TEST_CASE(CONCAT(x,y))
#define ASSERT_EQ(x,y) CHECK( (x) == (y) )
#define EXPECT_DOUBLE_EQ(x,y) CHECK( (x) == (y) )
#define EXPECT_TRUE(x) CHECK(x)
#define EXPECT_NEAR(x,y,tolerance) CHECK( (x) == Approx(y).margin(tolerance) )
}}}
and with that, I could integrate
https://github.com/schwehr/gdal-autotest2/blob/master/cpp/third_party/proj/
PJ_geos_test.cc
pj_phi2_test.cc
geodesic_test.cc
completely unmodified ([1]) and
"""
All tests passed (347 assertions in 7 test cases)
"""
See:
https://github.com/OSGeo/proj.4/commit/1e42254017c118c082bd79a6d63136d459c7d934
Interestingly there seems to be a slight precision issue on Mac on 2 steps.
See https://travis-ci.org/rouault/proj.4/builds/385859941
Even
[1] except an issue with isnan in pj_phi2_test.cpp, unrelated to the testing framework
https://github.com/rouault/proj.4/commit/ba4ef84f2be6b8532af527f1380e6071430165cd
probably using std::isnan instead of the macro hack would be better.
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the Proj
mailing list