-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from stefanb/build-test-workflow
Go build & test workflow
- Loading branch information
Showing
3 changed files
with
75 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ "v2" ] | ||
pull_request: | ||
branches: [ "v2" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v -race ./... -cover |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package wgs84 | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestTransform(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
fromEpsg int | ||
inA float64 | ||
inB float64 | ||
inC float64 | ||
toEpsg int | ||
wantA float64 | ||
wantB float64 | ||
wantC float64 | ||
}{ | ||
{"Web Mercator: EPSG(4326) to EPSG(3857)", 4326, 10, 50, 0, 3857, 1.113194908e+06, 6.446275841e+06, 0}, | ||
{"OSGB: EPSG(4326) to EPSG(27700)", 4326, -2.25, 52.25, 0, 27700, 383029.296, 261341.615, 0}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
fromEPSG := EPSG(tt.fromEpsg) | ||
toEPSG := EPSG(tt.toEpsg) | ||
|
||
transform := Transform(fromEPSG, toEPSG).Round(3) | ||
|
||
gotA, gotB, gotC := transform(tt.inA, tt.inB, tt.inC) | ||
|
||
if gotA != tt.wantA { | ||
t.Errorf("Transform() A = %v, want %v", gotA, tt.wantA) | ||
} | ||
if gotB != tt.wantB { | ||
t.Errorf("Transform() B = %v, want %v", gotB, tt.wantB) | ||
} | ||
if gotC != tt.wantC { | ||
t.Errorf("Transform() C = %v, want %v", gotC, tt.wantC) | ||
} | ||
}) | ||
} | ||
} |