File: parselocator_test.go

package info (click to toggle)
golang-github-pd0mz-go-maidenhead 0.0~git20170221.faa09c2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 84 kB
  • sloc: makefile: 2
file content (35 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package maidenhead

import "testing"

// parsed locator must be translated to the same locator
// using GridSquare()
func TestParseLocator(t *testing.T) {
	var locTests = []string{
		"JN88RT",
		"JN89HF",
		"JN58TD",
		"GF15VC",
		"FM18LW",
		"RE78IR",
	}

	for _, loc := range locTests {

		point, err := ParseLocator(loc)
		if err != nil {
			t.Errorf("%s parsing error: %s", loc, err)
			continue
		}

		l, err := point.GridSquare()
		if err != nil {
			t.Errorf("%s: %v to GridSquare(): %s", loc, point, err)
			continue
		}

		if l != loc {
			t.Errorf("%s: parsed to %v produces %s\n", loc, point, l)
		}
	}
}