File: b2f_test.go

package info (click to toggle)
golang-github-la5nta-wl2k-go 0.11.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,856 kB
  • sloc: ansic: 14; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
// Copyright 2015 Martin Hebnes Pedersen (LA5NTA). All rights reserved.
// Use of this source code is governed by the MIT-license that can be
// found in the LICENSE file.

package fbb

import "testing"

func TestParseProposalAnswer(t *testing.T) {
	tests := map[string][]*Proposal{
		"FS YLA3350RH": []*Proposal{
			&Proposal{answer: Accept}, // Y
			&Proposal{answer: Defer},  // L
			&Proposal{
				answer: Accept,
				offset: 3350,
			}, // A3350
			&Proposal{answer: Reject}, // R
			&Proposal{answer: Defer},  // H
		},
		"FS +=!3350-+": []*Proposal{
			&Proposal{answer: Accept}, // +
			&Proposal{answer: Defer},  // =
			&Proposal{
				answer: Accept,
				offset: 3350,
			}, // !3350
			&Proposal{answer: Reject}, // -
			&Proposal{answer: Accept}, // +
		},
	}

	for input, expected := range tests {
		got := []*Proposal{&Proposal{}, &Proposal{}, &Proposal{}, &Proposal{}, &Proposal{}}

		if err := parseProposalAnswer(input, got, nil); err != nil {
			t.Fatalf("Got error from parser func: %s", err)
		}
		for i, exp := range expected {
			if exp.answer != got[i].answer {
				t.Errorf("Test %d: expected %c got %c", i, exp.answer, got[i].answer)
			}
		}
	}
}