Skip to content

Commit

Permalink
Merge pull request #10 from stefanb/build-test-workflow
Browse files Browse the repository at this point in the history
Go build & test workflow
  • Loading branch information
wroge authored Jul 16, 2024
2 parents fcbe27a + b35f785 commit 5fb8989
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/go.yml
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
9 changes: 5 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches:
- master
- main
- v2
pull_request:
permissions:
contents: read
Expand All @@ -17,9 +18,9 @@ jobs:
runs-on: ubuntu-latest
environment: CI
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21
- uses: actions/checkout@v3
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
42 changes: 42 additions & 0 deletions wgs84_test.go
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)
}
})
}
}

0 comments on commit 5fb8989

Please sign in to comment.