-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bug fix * remove old comment * fix error string * added `ShowSource` flag * implemented app & tests * added -inverse test * update tests
- Loading branch information
Showing
7 changed files
with
209 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,74 @@ | ||
package main_test | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
|
||
main "github.com/go-spatial/proj/cmd/proj" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestXYZZY(t *testing.T) { | ||
func TestCmd(t *testing.T) { | ||
assert := assert.New(t) | ||
assert.True(true) | ||
|
||
type testcase struct { | ||
args string | ||
input []float64 | ||
output []float64 | ||
} | ||
|
||
testcases := []testcase{ | ||
{ | ||
"proj -epsg 9999", | ||
[]float64{0.0, 0.0}, | ||
nil, | ||
}, { | ||
"proj -epsg 9999 proj=merc", | ||
[]float64{0.0, 0.0}, | ||
nil, | ||
}, { | ||
"proj-epsg 9999 -inverse", | ||
[]float64{0.0, 0.0}, | ||
nil, | ||
}, { | ||
"proj -epsg 3395", | ||
[]float64{-77.625583, 38.833846}, | ||
[]float64{-8641240.37, 4671101.60}, | ||
}, { | ||
"proj +proj=utm +zone=32 +ellps=GRS80", | ||
[]float64{12.0, 55.0}, | ||
[]float64{691875.63, 6098907.83}, | ||
}, { | ||
"proj -inverse +proj=utm +zone=32 +ellps=GRS80", | ||
[]float64{691875.63, 6098907.83}, | ||
[]float64{12.0, 55.0}, | ||
}, | ||
} | ||
|
||
for _, tc := range testcases { | ||
|
||
s := fmt.Sprintf("%f %f", tc.input[0], tc.input[1]) | ||
inBuf := bytes.NewBuffer([]byte(s)) | ||
outBuf := &bytes.Buffer{} | ||
|
||
err := main.Main(inBuf, outBuf, strings.Fields(tc.args)) | ||
|
||
if tc.output == nil { | ||
assert.Error(err, tc.args) | ||
} else { | ||
assert.NoError(err, tc.args) | ||
|
||
tokens := strings.Fields(string(outBuf.Bytes())) | ||
assert.Len(tokens, 2, tc.args) | ||
actual0, err := strconv.ParseFloat(tokens[0], 64) | ||
assert.NoError(err, tc.args) | ||
assert.InDelta(tc.output[0], actual0, 1.0e-2, tc.args) | ||
actual1, err := strconv.ParseFloat(tokens[1], 64) | ||
assert.NoError(err, tc.args) | ||
assert.InDelta(tc.output[1], actual1, 1.0e-2, tc.args) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters