github.com/pavlo67/common@v0.5.3/common/geolib/bearing_test.go (about)

     1  package geolib
     2  
     3  import (
     4  	"math"
     5  	"testing"
     6  
     7  	"github.com/pavlo67/common/common/mathlib"
     8  )
     9  
    10  func TestDegrees_DMS(t *testing.T) {
    11  	tests := []struct {
    12  		name    string
    13  		degrees Degrees
    14  		want    DMS
    15  	}{
    16  		{
    17  			name:    "",
    18  			degrees: 10.5,
    19  			want:    DMS{10, 30, 0},
    20  		},
    21  		{
    22  			name:    "",
    23  			degrees: 10.55,
    24  			want:    DMS{10, 33, 0},
    25  		},
    26  		{
    27  			name:    "",
    28  			degrees: 10.555,
    29  			want:    DMS{10, 33, 18},
    30  		},
    31  	}
    32  	for _, tt := range tests {
    33  		t.Run(tt.name, func(t *testing.T) {
    34  			if got := tt.degrees.DMS(); !(got.D == tt.want.D && got.M == tt.want.M && math.Abs(got.S-tt.want.S) <= mathlib.Eps) {
    35  				t.Errorf("DMS() = %v, want %v", got, tt.want)
    36  			}
    37  		})
    38  	}
    39  }