github.com/la5nta/wl2k-go@v0.11.8/fbb/b2f_test.go (about)

     1  // Copyright 2015 Martin Hebnes Pedersen (LA5NTA). All rights reserved.
     2  // Use of this source code is governed by the MIT-license that can be
     3  // found in the LICENSE file.
     4  
     5  package fbb
     6  
     7  import "testing"
     8  
     9  func TestParseProposalAnswer(t *testing.T) {
    10  	tests := map[string][]*Proposal{
    11  		"FS YLA3350RH": []*Proposal{
    12  			&Proposal{answer: Accept}, // Y
    13  			&Proposal{answer: Defer},  // L
    14  			&Proposal{
    15  				answer: Accept,
    16  				offset: 3350,
    17  			}, // A3350
    18  			&Proposal{answer: Reject}, // R
    19  			&Proposal{answer: Defer},  // H
    20  		},
    21  		"FS +=!3350-+": []*Proposal{
    22  			&Proposal{answer: Accept}, // +
    23  			&Proposal{answer: Defer},  // =
    24  			&Proposal{
    25  				answer: Accept,
    26  				offset: 3350,
    27  			}, // !3350
    28  			&Proposal{answer: Reject}, // -
    29  			&Proposal{answer: Accept}, // +
    30  		},
    31  	}
    32  
    33  	for input, expected := range tests {
    34  		got := []*Proposal{&Proposal{}, &Proposal{}, &Proposal{}, &Proposal{}, &Proposal{}}
    35  
    36  		if err := parseProposalAnswer(input, got, nil); err != nil {
    37  			t.Fatalf("Got error from parser func: %s", err)
    38  		}
    39  		for i, exp := range expected {
    40  			if exp.answer != got[i].answer {
    41  				t.Errorf("Test %d: expected %c got %c", i, exp.answer, got[i].answer)
    42  			}
    43  		}
    44  	}
    45  }