Question: I'm trying to understand how unit testing works. So far i understand you're testing the output of functions based on what you put in. Ok. Does that mean if your function has the only possibility of returning one datatype you only have to write one test for it? So say i write a function that only has the possibility of returning TRUE or FALSE, does that mean i would just be checking if the response is boolean? 

And then also say i have a function that is pulling posts from a blog from a database. Say have the function set to: if number of rows = 0 return FALSE, else return the results. So i now i have the possibility of a function that could return a boolean value or an array. How the heck do you test that? The function now doesn't rely solely on the input, it relies on what's in the database.

Answer: 
Unit testing just means that you're getting the outputs you expect. Write a test for every conceivable, unique state your program could be in and ensure the output of your function is what you expect.

For example, you could test in the case that your database is empty, a few rows, or full.

Then for each state, give different inputs (a couple invalid, a couple valid).

Unit testing just breaks up your programs into units and makes sure each unit works as expected.

EDIT:

Wikipedia has a great article on [unit testing](http://en.wikipedia.org/wiki/Unit_testing).
If you allow me a suggestion, take this book: **THE ART OF UNIT TESTING**, by Roy Osherove. <http://amzn.com/1933988274>. It's not a huge weapon-massive-like book.

I had never read anything about UnitTesting prior to this book, but now it's very clear how UnitTest works.

Hope it helps!