blob: 2b99278996957099672973fcb81116e3f193834f [file] [log] [blame]
Chip Boling6e27b352020-02-14 09:10:01 -06001/*
2 * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net)
Andrea Campanella7167ebb2020-02-24 09:56:38 +01003 * Copyright 2020-present Open Networking Foundation
4
Chip Boling6e27b352020-02-14 09:10:01 -06005 * 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 Campanella7167ebb2020-02-24 09:56:38 +01008
Chip Boling6e27b352020-02-14 09:10:01 -06009 * http://www.apache.org/licenses/LICENSE-2.0
Andrea Campanella7167ebb2020-02-24 09:56:38 +010010
Chip Boling6e27b352020-02-14 09:10:01 -060011 * 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 Boling6e27b352020-02-14 09:10:01 -060016 */
17package omci_test
18
19import (
David K. Bainbridgeadf422d2021-04-09 16:06:41 +000020 "github.com/google/gopacket"
Andrea Campanella7167ebb2020-02-24 09:56:38 +010021 "github.com/opencord/omci-lib-go"
22 me "github.com/opencord/omci-lib-go/generated"
Chip Boling6e27b352020-02-14 09:10:01 -060023 "github.com/stretchr/testify/assert"
24 "testing"
25)
26
27// Note: The majority of this file is tested by other unit tests
28func 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
39func 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}