blob: 4b72a765b2218ff0cf23bcfda99571231a459d3e [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
Chip Boling157c9b92021-04-21 09:58:36 -050028func TestKnownMessageType(t *testing.T) {
Chip Boling6e27b352020-02-14 09:10:01 -060029 for _, msg := range allMessageTypes {
Chip Boling157c9b92021-04-21 09:58:36 -050030 layer, err := omci.MsgTypeToNextLayer(msg, false)
Chip Boling6e27b352020-02-14 09:10:01 -060031 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 Boling157c9b92021-04-21 09:58:36 -050039func TestUnknownMessageType(t *testing.T) {
Chip Boling6e27b352020-02-14 09:10:01 -060040 unknown := omci.MessageType(0xFF)
Chip Boling157c9b92021-04-21 09:58:36 -050041 layer, err := omci.MsgTypeToNextLayer(unknown, false)
Chip Boling6e27b352020-02-14 09:10:01 -060042 assert.Equal(t, layer, gopacket.LayerTypeZero)
43 assert.NotNil(t, err)
44}