Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | */ |
| 17 | package omci_test |
| 18 | |
| 19 | import ( |
| 20 | "github.com/cboling/omci" |
| 21 | me "github.com/cboling/omci/generated" |
| 22 | "github.com/google/gopacket" |
| 23 | "github.com/stretchr/testify/assert" |
| 24 | "testing" |
| 25 | ) |
| 26 | |
| 27 | // Note: The majority of this file is tested by other unit tests |
| 28 | func TestKnownMessageTytpe(t *testing.T) { |
| 29 | for _, msg := range allMessageTypes { |
| 30 | layer, err := omci.MsgTypeToNextLayer(msg) |
| 31 | assert.NotEqual(t, layer, gopacket.LayerTypeZero) |
| 32 | assert.Nil(t, err) |
| 33 | } |
| 34 | unknown := me.MsgType(0xFF) |
| 35 | strMsg := unknown.String() |
| 36 | assert.NotEqual(t, len(strMsg), 0) |
| 37 | } |
| 38 | |
| 39 | func TestUnknownMessageTytpe(t *testing.T) { |
| 40 | unknown := omci.MessageType(0xFF) |
| 41 | layer, err := omci.MsgTypeToNextLayer(unknown) |
| 42 | assert.Equal(t, layer, gopacket.LayerTypeZero) |
| 43 | assert.NotNil(t, err) |
| 44 | } |