title: Explain unit testing please
body: <p>I'm a little confused about unit testing. I see the value in things like automated testing. I think perhaps a good example would be the best way to help me understand. Lets say I have a binary search function I want unit tested. </p>
  
  <p>Now in testing, I would want to know things like: Does the search find the first element, the last element, and other elements? Does the search correctly compare unicode characters. Does the search handle symbols and other "painful" characters. Would unit testing cover this, or am I missing it? How would you write unit tests for my binary search?</p>
  
  <pre><code>function search(collection, value){
   var start = 0, end = collection.length - 1, mid;
   while (start &lt;= end) {
    mid = start + ((end - start) / 2);
    if (value == collection[mid])
     return mid;
    if (collection[mid] &lt; value)
     end = mid - 1;
    else
         start = mid + 1;
   }
   return mid;
  }
  </code></pre>
  
  <p>Psuedo code for unit tests would be lovely.</p>
  
  <p>So, we might have:</p>
  
  <pre><code>function testFirst(){
   var collection = ['a','b','c','x','y','z'],first = 'a', findex = 0;
   assert(seach(collection,first),findex);
  }
  function testLast(){
   var collection = ['a','b','c','x','y','z'], last = 'z', lindex = 5;
   assert(seach(collection,last),lindex);
  }
  </code></pre>