clintbellanger/flare — pull request #277 by Sevis (2012-01-05 11:10:22+00:00)
Title: Unit tests, smart surfaces, and a few minor bugfixes

I added two unit test suites and modified CMakeLists.txt so that a buildscript for the tests would be generated, but they would not be built by default. The unit tests depend on boost and can be built with `make flare-tests`, then run with `./flare-tests`. To ensure that the unit tests worked, I modified a function in `UtilsParsing`.

I also created the `SmartSurface` and `ScopedPtr` classes. `SmartSurface` wraps an `SDL_Surface*` and calls `SDL_FreeSurface` on it when it goes out of scope, and `ScopedPtr` wraps a `T*` and deletes it when it goes out of scope. I rewrote `TileSet` to use `SmartSurface` as an example.

Finally, I fixed things that looked like bugs to me:
- Looked for places where the state of an input stream was checked before reads, not after them, and moved the checks appropriately.
- Fixed "conditional jump depends on uninitialised value" errors that valgrind was giving (see `~PowerManager()`).
- Made the size of the array `TileSet` has a named constant.