# Copyright 2012 Colin Scott
# Copyright 2012 James McCauley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest
import sys
import os.path
from pox.lib.addresses import *
from copy import copy

class MockEthAddrTest(unittest.TestCase):
  def test_basic(self):
    self.assertEqual("00:11:22:33:44:55", str(EthAddr("00:11:22:33:44:55")), "str(eth) doesn't match original string")

#  def test_int_ctor(self):
#    int_val = EthAddr("00:00:00:00:01:00").toInt()
#    self.assertEqual(int_val, 1<<8)
#    with_int_ctor = EthAddr(int_val)
#    self.assertEqual(int_val, with_int_ctor.toInt())
#    self.assertEqual(str(with_int_ctor), "00:00:00:00:01:00")

class MockIPAddrTest (unittest.TestCase):
  def test_in_network (self):
    self.assertTrue(IPAddr("192.168.1.1").inNetwork("192.168.1.0/24"))


@@ -38,16 +38,21 @@
 ght 2012
+,2013
  James M
@@ -704,16 +704,142 @@
 t copy%0A%0A
+try:%0A  import nose%0A  _fail_decorator = nose.tools.raises(RuntimeError)%0Aexcept:%0A  _fail_decorator = unittest.expectedFailure%0A%0A%0A
 class Mo
@@ -972,16 +972,24 @@
 4:55%22)),
+%0A       
  %22str(et
@@ -1441,8 +1441,447 @@
 /24%22))%0A%0A
+  def test_multicast (self):%0A    self.assertTrue(str(IPAddr(%22224.0.0.9%22).multicast_ethernet_address)%0A        == %2201:00:5e:00:00:09%22)%0A%0A  @_fail_decorator%0A  def test_bad_cidr_fail (self):%0A    parse_cidr(%22192.168.1.0/16%22, infer=False, allow_host=False)%0A%0A  def test_bad_cidr_succeed (self):%0A    a,b=parse_cidr(%22192.168.1.0/255.255.255.0%22, infer=False, allow_host=False)%0A    self.assertEqual(a,IPAddr(%22192.168.1.0%22))%0A    self.assertEqual(b,24)%0A

Improve lib.addresses tests