kesavand | 0c06492 | 2020-12-15 15:36:25 +0530 | [diff] [blame^] | 1 | // Copyright 2018 Open Networking Foundation |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | //Package utils gives type conversion helpers |
| 15 | |
| 16 | |
| 17 | package utils |
| 18 | |
| 19 | import ( |
| 20 | "github.com/stretchr/testify/assert" |
| 21 | "testing" |
| 22 | ) |
| 23 | |
| 24 | func TestGetOnuSN(t *testing.T) { |
| 25 | testCases := []struct { |
| 26 | hexFlag bool |
| 27 | input string |
| 28 | expectedOutput string |
| 29 | expectedError string |
| 30 | }{ |
| 31 | { |
| 32 | hexFlag: true, |
| 33 | input: "SCOM00001B6D", |
| 34 | expectedOutput: "53434F4D00001B6D", |
| 35 | }, |
| 36 | |
| 37 | { |
| 38 | hexFlag: false, |
| 39 | input: "SCO00001B6D", |
| 40 | expectedOutput: "SCO00001B6D", |
| 41 | }, |
| 42 | } |
| 43 | |
| 44 | for _, testCase := range testCases { |
| 45 | OnuSNhex = testCase.hexFlag |
| 46 | hexFormat := GetOnuSN(testCase.input) |
| 47 | assert.Equal(t, testCase.expectedOutput, hexFormat) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | |