Skip to content

Commit

Permalink
Added longoption translation tests for gmt{defaults,get,info,logo,mat…
Browse files Browse the repository at this point in the history
…h,regress}. (#8042)
  • Loading branch information
rbdavis authored Nov 15, 2023
1 parent d1fd975 commit 1318d26
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/longopt/gmtregress_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static struct GMT_KEYWORD_DICTIONARY module_kw[] = {
{ 0, 'N', "norm",
"1,2,r,w", "mean_absolute,mean_squared,lms|LMS,rms|RMS",
"", "" },
{ 0, 'S', "skip_outliers|restrict_outliners",
{ 0, 'S', "skip_outliers|restrict_outliers",
"r", "reverse",
"", "" },
{ 0, 'T', "range|series",
Expand Down
20 changes: 20 additions & 0 deletions test/gmtdefaults/gmtdefaults-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Test gmtdefaults longopts translation.

m=gmtdefaults
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -D -Du -Du
--l2stranstest -Ds -Ds
EOF

# module-specific longopts
gmt $m $l2s --defaults --defaults=us --defaults=US >> $b
gmt $m $l2s --defaults=si --defaults=SI >> $b

diff $a $b --strip-trailing-cr > fail
28 changes: 28 additions & 0 deletions test/gmtget/gmtget-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# Test gmtget longopts translation.

m=gmtget
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -Ddata=earth -Dcache
--l2stranstest -G/some/gmt.conf
--l2stranstest -I1m
--l2stranstest -L
--l2stranstest -N
--l2stranstest -Q -Q
EOF

# module-specific longopts
gmt $m $l2s --data=data=earth --dataset=cache >> $b
gmt $m $l2s --gmtconf=/some/gmt.conf >> $b
gmt $m $l2s --increment=1m >> $b
gmt $m $l2s --lines >> $b
gmt $m $l2s --no_convert >> $b
gmt $m $l2s --list --no_download >> $b

diff $a $b --strip-trailing-cr > fail
40 changes: 40 additions & 0 deletions test/gmtinfo/gmtinfo-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# Test gmtinfo longopts translation.

m=gmtinfo
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -Aa -At -As
--l2stranstest -C -C
--l2stranstest -D0.15/0.25
--l2stranstest -El -EL5
--l2stranstest -Eh0 -EH9
--l2stranstest -F -Fi -Fd
--l2stranstest -Ft
--l2stranstest -Ib1/2/3+e4/3 -Ie6+r0.1
--l2stranstest -If4/2+R2 -Ip4/2
--l2stranstest -Is1+r2/1
--l2stranstest -L
--l2stranstest -T4w+c3
EOF

# module-specific longopts
gmt $m $l2s --report=all --report=per_table --report=per_segment >> $b
gmt $m $l2s --columns --numeric >> $b
gmt $m $l2s --center=0.15/0.25 >> $b
gmt $m $l2s --get_record=min --get_record=minabs:5 >> $b
gmt $m $l2s --get_record=max:0 --get_record=maxabs:9 >> $b
gmt $m $l2s --counts --counts=totals --counts=segments >> $b
gmt $m $l2s --counts=segments_reset >> $b
gmt $m $l2s --inc=box:1/2/3+extend_box:4/3 --spacing=exact:6+adjust:0.1 >> $b
gmt $m $l2s --increment=fft:4/2+extend_region:2 --increment=override:4/2 >> $b
gmt $m $l2s --increment=surface:1+adjust:2/1 >> $b
gmt $m $l2s --common_limits >> $b
gmt $m $l2s --nearest_multiple=4w+column:3 >> $b

diff $a $b --strip-trailing-cr > fail
30 changes: 30 additions & 0 deletions test/gmtlogo/gmtlogo-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# Test gmtlogo longopts translation.

m=gmtlogo
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -Dg10/20+w5 -Dg1/2+h2
--l2stranstest -DjTR+jBL -DJTR
--l2stranstest -Dn0.5/0.4+o1/2
--l2stranstest -Dx3/4+jBL
--l2stranstest -F+c0.1 -F+gred -F+i1
--l2stranstest -F+p2p -F+r0.5 -F+s1/1/green
--l2stranstest -Sl -Sn -Su
EOF

# module-specific longopts
gmt $m $l2s --position=user:10/20+width:5 --position=map:1/2+height:2 >> $b
gmt $m $l2s --position=justify:TR+justify:BL --position=mirror:TR >> $b
gmt $m $l2s --position=normalize:0.5/0.4+offset:1/2 >> $b
gmt $m $l2s --position=plot:3/4+justify:BL >> $b
gmt $m $l2s --border+clearance:0.1 --box+fill:red --box+inner:1 >> $b
gmt $m $l2s --border+pen:2p --border+radius:0.5 --box+shade:1/1/green >> $b
gmt $m $l2s --label=standard --style=none --style=url >> $b

diff $a $b --strip-trailing-cr > fail
42 changes: 42 additions & 0 deletions test/gmtmath/gmtmath-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
#
# Test gmtmath longopts translation.

m=gmtmath
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -A/some/file+e -A/some/file+r
--l2stranstest -A/some/file+s -A/some/file+w
--l2stranstest -C -C1,3-5,7 -Cx -Cy
--l2stranstest -C0 -Ca -Cr
--l2stranstest -E1e-8
--l2stranstest -I -I
--l2stranstest -N8/1
--l2stranstest -Qc -Qc
--l2stranstest -Qi -Qp -Qn
--l2stranstest -S -Sf -Sl
--l2stranstest -T10/20/0.5+b -T10/20/0.5+l
--l2stranstest -T10/20/0.5+i -T10/20/0.5+n
--l2stranstest -T/some/file
EOF

# module-specific longopts
gmt $m $l2s --init=/some/file+evaluate --matrix=/some/file+no_left >> $b
gmt $m $l2s --init=/some/file+sigma --init=/some/file+weights >> $b
gmt $m $l2s --columns --columns=1,3-5,7 --columns=x --columns=y >> $b
gmt $m $l2s --columns=0 --columns=a --columns=r >> $b
gmt $m $l2s --eigen=1e-8 >> $b
gmt $m $l2s --invert --reverse >> $b
gmt $m $l2s --ncolumns=8/1 >> $b
gmt $m $l2s --quick=cm --quick=centimeter >> $b
gmt $m $l2s --quick=inch --quick=point --quick=none >> $b
gmt $m $l2s --output --output=first --output=last >> $b
gmt $m $l2s --range=10/20/0.5+log2 --range=10/20/0.5+log10 >> $b
gmt $m $l2s --series=10/20/0.5+inverse --series=10/20/0.5+number >> $b
gmt $m $l2s --series=/some/file >> $b

diff $a $b --strip-trailing-cr > fail
40 changes: 40 additions & 0 deletions test/gmtregress/gmtregress-l2s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# Test gmtregress longopts translation.

m=gmtregress
l2s='--l2stranstest'
a=$m-l2s-a.txt
b=$m-l2s-b.txt
rm -f $a $b ; touch $b

cat << EOF > $a
--l2stranstest -A-20/20/1+fn -A-5/20/2+fp
--l2stranstest -C80 -C90
--l2stranstest -Ex -Ey -Eo
--l2stranstest -Eo -Er
--l2stranstest -Fxrc -Fwry
--l2stranstest -N1 -N2 -Nr
--l2stranstest -Nr -Nw -Nw
--l2stranstest -S -Sr
--l2stranstest -T5/100/2+i -T5+n
--l2stranstest -T/some/file
--l2stranstest -Wxy
--l2stranstest -Z+5 -Z-5
EOF

# module-specific longopts
gmt $m $l2s --angles=-20/20/1+force:n --slopes=-5/20/2+force:p >> $b
gmt $m $l2s --confidence=80 --confidence_level=90 >> $b
gmt $m $l2s --regression=x_on_y --regression=y_on_x --regression=ortho >> $b
gmt $m $l2s --regression_type=orthogonal --regression_type=reduced >> $b
gmt $m $l2s --columns=xrc --column_combination=wry >> $b
gmt $m $l2s --norm=mean_absolute --norm=mean_squared --norm=lms >> $b
gmt $m $l2s --norm=LMS --norm=rms --norm=RMS >> $b
gmt $m $l2s --skip_outliers --restrict_outliers=reverse >> $b
gmt $m $l2s --range=5/100/2+inverse --range=5+number >> $b
gmt $m $l2s --series=/some/file >> $b
gmt $m $l2s --weighted=xy >> $b
gmt $m $l2s --limit=+5 --limit=-5 >> $b

diff $a $b --strip-trailing-cr > fail

0 comments on commit 1318d26

Please sign in to comment.