github.com/la5nta/wl2k-go@v0.11.8/fbb/handshake_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 (
     8  	"fmt"
     9  	"io"
    10  	"reflect"
    11  	"testing"
    12  )
    13  
    14  func TestParseFW(t *testing.T) {
    15  	tests := map[string][]Address{
    16  		";FW: LA5NTA":       []Address{AddressFromString("LA5NTA")},
    17  		";FW: LE1OF":        []Address{AddressFromString("LE1OF")},
    18  		";FW: LE1OF LA5NTA": []Address{AddressFromString("LE1OF"), AddressFromString("LA5NTA")},
    19  		";FW: la4tta":       []Address{{Addr: "LA4TTA"}},
    20  	}
    21  
    22  	for input, expected := range tests {
    23  		got, err := parseFW(input)
    24  		if err != nil {
    25  			t.Errorf("Got unexpected error while parsing '%s': %s", input, err)
    26  		} else if !reflect.DeepEqual(got, expected) {
    27  			t.Errorf("Expected %s, got %s", expected, got)
    28  		}
    29  	}
    30  }
    31  
    32  func TestIsLoginFailure(t *testing.T) {
    33  	tests := map[error]bool{
    34  		fmt.Errorf("[1] Secure login failed - account password does not match. - Disconnecting (88.90.2.192)"): true,
    35  		io.EOF:              false,
    36  		io.ErrUnexpectedEOF: false,
    37  	}
    38  
    39  	for err, expect := range tests {
    40  		if got := IsLoginFailure(err); got != expect {
    41  			t.Errorf("'%s' - Expected %t got %t", err.Error(), expect, got)
    42  		}
    43  	}
    44  }