diff --git a/general/g.proj/output.c b/general/g.proj/output.c index 365578ab527..33b7b6042d9 100644 --- a/general/g.proj/output.c +++ b/general/g.proj/output.c @@ -22,6 +22,10 @@ #include #include +#ifdef HAVE_OGR +#include +#endif + #include "local_proto.h" static int check_xy(int shell); @@ -274,7 +278,7 @@ void print_wkt(int esristyle, int dontprettify) if (outwkt != NULL) { fprintf(stdout, "%s\n", outwkt); - G_free(outwkt); + CPLFree(outwkt); } else G_warning(_("Unable to convert to WKT")); diff --git a/general/g.proj/testsuite/test_g_proj.py b/general/g.proj/testsuite/test_g_proj.py new file mode 100644 index 00000000000..4ef67e5781b --- /dev/null +++ b/general/g.proj/testsuite/test_g_proj.py @@ -0,0 +1,27 @@ +"""g.proj tests + +(C) 2023 by the GRASS Development Team +This program is free software under the GNU General Public +License (>=v2). Read the file COPYING that comes with GRASS +for details. + +:author: Anna Petrasova +""" + +from grass.gunittest.case import TestCase +from grass.gunittest.main import test +from grass.gunittest.gmodules import SimpleModule + + +class GProjWKTTestCase(TestCase): + """Test g.proj with WKT output""" + + def test_wkt_output(self): + """Test if g.proj returns WKT""" + module = SimpleModule("g.proj", flags="w") + self.assertModule(module) + self.assertIn("PROJCRS", module.outputs.stdout) + + +if __name__ == "__main__": + test()