<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -122,6 +122,10 @@ class IPAllocator
         if candidate_block.contains?(allocated_block)
           break false
         end
+
+        if allocated_block.contains?(candidate_block)
+          break false
+        end
       end
     end
 </diff>
      <filename>ip_allocator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,5 +52,60 @@ describe IPAllocator do
         @allocator.available(20).should == []
       end
     end
+  
+    describe &quot;first_unused()&quot; do
+      describe &quot;with generic use cases&quot; do
+        it &quot;should not return a /30 contained within any other allocated block&quot; do
+          @supernet  = NetAddr::CIDR.create('208.79.89.128/25')
+          @allocated = [NetAddr::CIDR.create('208.79.89.0/27'), 
+                        NetAddr::CIDR.create('208.79.89.32/28'), 
+                        NetAddr::CIDR.create('208.79.89.64/26'), 
+                        NetAddr::CIDR.create('208.79.89.128/28'), 
+                        NetAddr::CIDR.create('208.79.89.144/29')]
+
+          @allocator = IPAllocator.new(@supernet, @allocated)
+
+          @first_unused = @allocator.first_unused(30).to_s
+
+          @first_unused.should_not == '208.79.89.0/30'
+          @first_unused.should_not == '208.79.89.4/30'
+          @first_unused.should_not == '208.79.89.8/30'
+          @first_unused.should_not == '208.79.89.12/30'
+          @first_unused.should_not == '208.79.89.16/30'
+          @first_unused.should_not == '208.79.89.20/30'
+          @first_unused.should_not == '208.79.89.24/30'
+          @first_unused.should_not == '208.79.89.28/30'
+          @first_unused.should_not == '208.79.89.32/30'
+          @first_unused.should_not == '208.79.89.36/30'
+          @first_unused.should_not == '208.79.89.40/30'
+          @first_unused.should_not == '208.79.89.44/30'
+
+          @first_unused.should_not == '208.79.89.64/30'
+          @first_unused.should_not == '208.79.89.68/30'
+          @first_unused.should_not == '208.79.89.72/30'
+          @first_unused.should_not == '208.79.89.76/30'
+          @first_unused.should_not == '208.79.89.80/30'
+          @first_unused.should_not == '208.79.89.84/30'
+          @first_unused.should_not == '208.79.89.88/30'
+          @first_unused.should_not == '208.79.89.92/30'
+          @first_unused.should_not == '208.79.89.96/30'
+          @first_unused.should_not == '208.79.89.100/30'
+          @first_unused.should_not == '208.79.89.104/30'
+          @first_unused.should_not == '208.79.89.108/30'
+          @first_unused.should_not == '208.79.89.112/30'
+          @first_unused.should_not == '208.79.89.116/30'
+          @first_unused.should_not == '208.79.89.120/30'
+          @first_unused.should_not == '208.79.89.124/30'
+
+          @first_unused.should_not == '208.79.89.128/30'
+          @first_unused.should_not == '208.79.89.132/30'
+          @first_unused.should_not == '208.79.89.136/30'
+          @first_unused.should_not == '208.79.89.140/30'
+
+          @first_unused.should_not == '208.79.89.144/30'
+          @first_unused.should_not == '208.79.89.148/30'
+        end
+      end
+    end
   end
 end</diff>
      <filename>ip_allocator_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b6465bfc8ba2ad0b1b1924b92fba992b59e78502</id>
    </parent>
  </parents>
  <author>
    <name>Garry Dolley</name>
    <email>gdolley@arpnetworks.com</email>
  </author>
  <url>http://github.com/up_the_irons/ip_allocator/commit/db8a6447c5ae9e6962808b5766524dc03ce10dae</url>
  <id>db8a6447c5ae9e6962808b5766524dc03ce10dae</id>
  <committed-date>2009-03-04T13:09:44-08:00</committed-date>
  <authored-date>2009-03-04T13:05:33-08:00</authored-date>
  <message>BUG FIX: Don't return blocks that are contained within other allocated blocks

Not sure how I missed this one; a very obvious use case that wasn't covered,
now fixed.

I deserve a http://mattcbr.files.wordpress.com/2008/04/facepalmbq8.jpg</message>
  <tree>fb9cc70533ceecb11642b28597dfb4fab0deb200</tree>
  <committer>
    <name>Garry Dolley</name>
    <email>gdolley@arpnetworks.com</email>
  </committer>
</commit>
