Wednesday, December 30, 2009

CppUnit 1.12.1 Installation Guide for Visual Studio 2008

I am sure- Scratch that. I know for a fact that this topic has been covered before, but extensive research (15 minutes with teh Googler) reveals that previous coverage has SUCKED. People just don't know how to write good instructions. Sure, all of the info is out there, but it is scattered all over the web in bits and pieces. Most posts start in noble fashion and then end mid way with cryptic notes about hurdles that require more than a cryptic note to overcome. I suspect the authors either just get tired of typing or they can't remember how they got around certain problems so they skim over them in their posts. Anyway, here goes...

Compile CppUnit
  1. Extract the CppUnit archive to the desired folder, hereafter refered to as %SRCROOT%. For example: C:\src
  2. Open %SRCROOT%\cppunit-1.12.1\src\CppUnitLibraries.dsw in Visual Studio.
  3. When prompted, convert each project to the ‘current Visual C++ project format’.
  4. In the Solution Explorer open TestRunner -> UserInterface -> MsDevCallerListCtrl.cpp and change the version on line 67 from “7.0” to “9.0”. Save the file.
  5. Select Build -> Batch Build… from the menu.
  6. In the Batch Build dialog click the Select All button.
  7. De-select (uncheck) all of the DSPlugIn projects in the list.
  8. Click Build.
Add CppUnit to a Project
  1. In the Solution Explorer right click on your existing solution and select Add -> New Project…
  2. In the Add New Project dialog Select Visual C++ -> Win32 from the Project types tree.
  3. Select Win32 Console Application from the Templates.
  4. Enter a Name for the unit test project. For example, if your main project is called “MyProject” a suitable name for this project would be “MyProjectTest”.
  5. Click OK.
  6. In the Win32 Application Wizard click Next >.
  7. Select Console application under Application type.
  8. Select Empty project under Additional options.
  9. Click Finish.
  10. In the Solution Explorer right click the Source Files folder under your new unit test project and select Add -> New Item...
  11. In the Add New Item dialog select Visual C++ -> Code in the Categories tree and C++ File (.cpp) under Templates.
  12. Give the new file a Name (e.g. testrunner.cpp) and click OK.
  13. Copy the test runner source code (see below) into your new source file and save it.
  14. In the Solution Explorer right click on the new unit test project (e.g. “MyProjectTest”) and select Properties.
  15. In the Project Property Pages dialog select Configuration Properties -> C/C++ -> General and add the follow path to the Additional Include Directories: %SRCROOT%\cppunit-1.12.1\include\cppunit
  16. Select Configuration Properties -> C/C++ -> Linker and add the follow path to the Additional Library Directories: %SRCROOT%\cppunit-1.12.1\lib
  17. Select Configuration Properties -> C/C++ -> Linker -> Input and add cppunitd.lib to the Additional Dependencies.
  18. Select Configuration Properties -> Build Events -> Post-Build Event and enter $(TargetPath) in the Command Line field and Unit testing… in the Description field.
  19. Click OK.
  20. In the Solution Explorer right click on the top-level solution and select Properties.
  21. In the Solution Property Pages dialog select Common Properties -> Project Dependencies.
  22. Select the unit test project from the Project list and select (check) the main project in the Depends on list.
  23. Click OK.
You are now ready to add CppUnit test classes to your unit test project! When you build the solution the test runner will output its test results in Visual Studio’s Output window.

Test Runner Source Code

Adapted from: http://cppunit.sourceforge.net/doc/lastest/money_example.html

#include <iostream>
#include "cppunit/CompilerOutputter.h"
#include "cppunit/extensions/TestFactoryRegistry.h"
#include "cppunit/ui/text/TestRunner.h"

int main(int argc, char* argv[])
{

std::cout << "--------------- BEGIN CPPUNIT TEST ---------------" << std::endl;

// Get the top level suite from the registry
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();

// Adds the test to the list of test to run
CppUnit::TextUi::TestRunner runner;
runner.addTest( suite );

// Change the default outputter to a compiler error format outputter
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
std::cerr ) );
// Run the tests.
bool wasSucessful = runner.run();

std::cout << "--------------- END CPPUNIT TEST ---------------" << << std::endl

// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}

Tuesday, September 8, 2009

Real Estate 101



So, I spent one day this weekend doing the real estate hunt thing. As usual, the hunt went something like, go to umpteenzillion houses and try to keep them straight somehow-someway. I tend to do that by taking my own pictures of the house as the pictures on the listing somehow, nearly without fail, just SUCK (Don't believe me? http://lovelylisting.com). Not that mine are really great pictures, but if I take enough of them, I can remember the floorplan and the size of the rooms.

Today, I get a call from my real estate agent sounding all sheepish. I'm trying to figure out what is going on and then he tells me that one of the houses we saw didn't want pictures taken of their house and asked they be deleted! They were there when we were with the dog out back, so umm, wtf didn't they say something then? And who won't let you take pictures of the house they are trying to sell?!

People are nuts.

Friday, June 13, 2008

Confronting Your Addiction... To Solar Power

A friend of mine writes:

Over lunch, something was mentioned about gas prices, etc. Leading to alternative fuels discussion, etc. So Alfred says, "John, have you seen the latest interventions in solar panels?" As Alfred talked on I realized he meant "INventions", not "INTERventions" (something about being the size of a thumbnail?) but I had this mental image of a bunch of solar panels standing around one poor solar panel, having an intervention, and it was all I could do to keep a straight face. Although you know I can't draw, I had to try to share my mental "cartoon" with you...

Tuesday, October 16, 2007

rm -rf /* Windows Style

As geeks, we've all heard the horror stories of some n00b killing a Unix box with a single command run as root:

rm -rf /*

But surely such things don't happen in the real world, right?

Today a coworker, Bob, asked me what a certain "clean.bat" DOS script was supposed to do. Imagine my surprise (and horror) when I opened the script in an editor:

del /S *.pdb
del /S *.ilk
del /S *.exe
del /S *.obj
del /S *.dll
del /S *.lib
del /S *.exp
del /S *.dep
del /S *.idb
del /S *.manifest
del /S *.res
del /S *.htm
del /S *.tlh
del /S *.tli

It turned out that another developer on my team, Derrik, had managed to slip this little devil into CM amongst the header files we ship with our product. When run from Derrik's sandbox the script helpfully deletes all of the intermediate files left behind by Visual Studio, thus allowing Derrik to do a nice clean recompile.

If the script is accidentally double clicked, however, the little beast runs on the C: drive and deletes all of those pesky applications you have installed. Then it deletes a good portion of Windows itself. Eventually it deletes something it depends on and dies. So does your PC.

Bob found this out the hard way. :(

Tuesday, July 31, 2007

WYSIWTF - the Inspiration

To understand WYSIWTF, one must first understand WYSIWYG - more here.

WYSIWTF was first used, as far as I know, here.

After showing this to a number of friends and co-workers, we decided we needed to create a blog by this very acronym. We instantly knew, too, that it would be dedicated to presenting and discussing the wealth and dearth of user interfaces, with a sure to be too large hall of shame and a not large enough hall of fame.

Seeing as how we're all engineering types, we'll probably be coming from a more technical slant than some other usability/interaction design discussions. But we're still discussing what we actually want to do ... so check back regularly while collect our thoughts about how to move forward. Hopefully good (and bad) things are to come to soon.