Skip to content

Commit

Permalink
Add test program testapi_modern.c (#7760)
Browse files Browse the repository at this point in the history
* Add test program testapi_modern.c

This makes sure the issue #4518 is preserved.  The test fails for now (well we need to add an actual testing of the output) but this lets us play in the debugger.

* Add test and PS file in DVC

The C code will make a plot to be compared with the CLI expected plot.
  • Loading branch information
PaulWessel authored Aug 24, 2023
1 parent 30661f2 commit d60a484
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/testapi_modern.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Issue from GitHub: https://github.com/GenericMappingTools/gmt/issues/4518
* Problem seems to be that gmt begin comes after GMT_Create_Session in the
* code so there are orientation and page size issues. In gmt end, the
* psconvert call is missing the -A.
*
* See test script api/apimodern.sh
*/

#include "gmt.h"

int main () {
void *API = NULL;

/* Initialize the GMT session */
if ((API = GMT_Create_Session ("testapi_modern", 2, GMT_SESSION_RUNMODE, NULL)) == NULL)
return EXIT_FAILURE;
GMT_Call_Module(API, "begin", GMT_MODULE_CMD, "apimodern ps");
GMT_Call_Module(API, "basemap", GMT_MODULE_CMD, "-BWESN -Bafg -JM7.27/42.27/16.25c -R5.5/41.425/9.0/43.1+r");
GMT_Call_Module(API, "end", GMT_MODULE_CMD, "show");
/* Destroy session */
if (GMT_Destroy_Session (API))
return EXIT_FAILURE;
}
14 changes: 14 additions & 0 deletions test/api/apimodern.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
#
# Purpose: This is a CLI version of what testapi_modern.c should produce
# Fails until we fix the page size and orientation from the C program.

# This is the fixed baseline DVC plot we will compare with
#gmt begin apimodern ps
# gmt set PS_MEDIA letter
# gmt basemap -BWESN -Bafg -JM7.27/42.27/16.25c -R5.5/41.425/9.0/43.1+r
#gmt end show

# Run the C code to produce apimodern.ps
testapi_modern
ps=apimodern.ps
6 changes: 3 additions & 3 deletions test/baseline/api.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: b985dda50abc7f6dcceb4a8848e0a83a.dir
size: 3041741
nfiles: 16
- md5: b02bb074d97d27aaec4f9d515ebfdc00.dir
size: 3066737
nfiles: 17
path: api

0 comments on commit d60a484

Please sign in to comment.