Skip to content
This repository has been archived by the owner on Aug 4, 2018. It is now read-only.

Commit

Permalink
swego: add Copy method for CalcFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlnetnl committed Aug 6, 2016
1 parent b521a38 commit 5ed7f90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions swego.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ type CalcFlags struct {
FileNameJPL string
}

// Copy returns a copy of the calculation flags fl.
func (fl *CalcFlags) Copy() *CalcFlags {
copy := new(CalcFlags)
*copy = *fl
return copy
}

// Ephemeris represents an ephemeris implemented in the C library.
type Ephemeris int32

Expand Down
12 changes: 11 additions & 1 deletion swego_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,18 @@ func TestNewHSys(t *testing.T) {
}
}

func TestCalcFlags_Copy(t *testing.T) {
fl := new(CalcFlags)
fl.Flags = FlagSpeed
got := fl.Copy()

if got == fl {
t.Errorf("%p = %p, want copy", got, fl)
}
}

func TestCalcFlags_SetEphemeris(t *testing.T) {
fl := CalcFlags{}
fl := new(CalcFlags)
fl.SetEphemeris(JPL)

if fl.Flags != int32(JPL) {
Expand Down

0 comments on commit 5ed7f90

Please sign in to comment.