Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net) |
Andrea Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 3 | * Copyright 2020-present Open Networking Foundation |
| 4 | |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Andrea Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 8 | |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Andrea Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 10 | |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 16 | */ |
| 17 | package omci_test |
| 18 | |
| 19 | import ( |
David K. Bainbridge | adf422d | 2021-04-09 16:06:41 +0000 | [diff] [blame] | 20 | "github.com/google/gopacket" |
Andrea Campanella | 7167ebb | 2020-02-24 09:56:38 +0100 | [diff] [blame] | 21 | "github.com/opencord/omci-lib-go" |
| 22 | me "github.com/opencord/omci-lib-go/generated" |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 23 | "github.com/stretchr/testify/assert" |
| 24 | "testing" |
| 25 | ) |
| 26 | |
| 27 | // Note: The majority of this file is tested by other unit tests |
Chip Boling | 157c9b9 | 2021-04-21 09:58:36 -0500 | [diff] [blame] | 28 | func TestKnownMessageType(t *testing.T) { |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 29 | for _, msg := range allMessageTypes { |
Chip Boling | 157c9b9 | 2021-04-21 09:58:36 -0500 | [diff] [blame] | 30 | layer, err := omci.MsgTypeToNextLayer(msg, false) |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 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 | |
Chip Boling | 157c9b9 | 2021-04-21 09:58:36 -0500 | [diff] [blame] | 39 | func TestUnknownMessageType(t *testing.T) { |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 40 | unknown := omci.MessageType(0xFF) |
Chip Boling | 157c9b9 | 2021-04-21 09:58:36 -0500 | [diff] [blame] | 41 | layer, err := omci.MsgTypeToNextLayer(unknown, false) |
Chip Boling | 6e27b35 | 2020-02-14 09:10:01 -0600 | [diff] [blame] | 42 | assert.Equal(t, layer, gopacket.LayerTypeZero) |
| 43 | assert.NotNil(t, err) |
| 44 | } |