blob: c41cc2ae7759687f96a694820990de6106cbff7a [file] [log] [blame]
Matteo Scandolo90d08f62020-10-29 12:06:55 -07001/*
Joey Armstrong3881b732022-12-27 07:55:37 -05002 * Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
Matteo Scandolo90d08f62020-10-29 12:06:55 -07003
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package dhcp
18
19import (
20 "gotest.tools/assert"
21 "net"
22 "testing"
23)
24
25func TestCreateIpFromMacAddress(t *testing.T) {
26 dhcpServer := NewDHCPServer()
27
28 mac1 := net.HardwareAddr{0x2e, 0x60, 0x00, 0x0c, 0x0f, 0x02}
29 ip1 := dhcpServer.createIpFromMacAddress(mac1)
30 assert.Equal(t, "10.12.15.2", ip1.String())
31
32 mac2 := net.HardwareAddr{0x2e, 0x60, 0x00, 0x00, 0x00, 0x00}
33 ip2 := dhcpServer.createIpFromMacAddress(mac2)
34 assert.Equal(t, "10.0.0.0", ip2.String())
35}