|
| 1 | +/********************************************************************* |
| 2 | + * Copyright (c) Intel Corporation 2023 |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + **********************************************************************/ |
| 5 | + |
| 6 | +package http |
| 7 | + |
| 8 | +import ( |
| 9 | + "testing" |
| 10 | +) |
| 11 | + |
| 12 | +func TestInfoFormat_String(t *testing.T) { |
| 13 | + tests := []struct { |
| 14 | + state InfoFormat |
| 15 | + expected string |
| 16 | + }{ |
| 17 | + {InfoFormatIPv4, "IPv4 Address"}, |
| 18 | + {InfoFormatIPv6, "IPv6 Address"}, |
| 19 | + {InfoFormatFQDN, "FQDN"}, |
| 20 | + {InfoFormat(999), "Value not found in map"}, |
| 21 | + } |
| 22 | + |
| 23 | + for _, test := range tests { |
| 24 | + result := test.state.String() |
| 25 | + if result != test.expected { |
| 26 | + t.Errorf("Expected %s, but got %s", test.expected, result) |
| 27 | + } |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +func TestGetReturnValueString(t *testing.T) { |
| 32 | + tests := []struct { |
| 33 | + returnValue int |
| 34 | + expected string |
| 35 | + }{ |
| 36 | + {PTStatusSuccess, "PT_STATUS_SUCCESS"}, |
| 37 | + {PTStatusInternalError, "PT_STATUS_INTERNAL_ERROR"}, |
| 38 | + {PTStatusNotPermitted, "PT_STATUS_NOT_PERMITTED"}, |
| 39 | + {PTStatusMaxLimitReached, "PT_STATUS_MAX_LIMIT_REACHED"}, |
| 40 | + {PTStatusInvalidParameter, "PT_STATUS_INVALID_PARAMETER"}, |
| 41 | + {PTStatusDuplicate, "PT_STATUS_DUPLICATE"}, |
| 42 | + {999, "Value not found in map"}, |
| 43 | + } |
| 44 | + |
| 45 | + for _, test := range tests { |
| 46 | + result := GetReturnValueString(test.returnValue) |
| 47 | + if result != test.expected { |
| 48 | + t.Errorf("Expected %s, but got %s", test.expected, result) |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments