Software developer blog

Unit test framework for C++ in about a 100 lines

Those who know me well are also aware of the fact, that I'm a very strong proponent of test automation and test driven development. Unfortunately there are times in our lives when installing an existing framework is not an option. So when I've been challenged to write a test framework that is so simple one can memorize it, and flush it out of their brain anytime needed, I was up to the task. The entire framework is 113 lines of C++ code, and using it is just as simple as using google test. Of course it doesn't come with all the features, it's fragile and has a good number of limitations, but it's good enough if you have absolutely no other option.

Here is how to use it, along with a sample output:

#include "TestBase.hpp"
 
class TestGroup : public TestBase {
};
 
TEST_F(TestGroup,PassingTest)
{
	EXPECT_TRUE(true);
	EXPECT_TRUE(true);
}
 
TEST_F(TestGroup,FailingTest)
{
	EXPECT_TRUE(true);
	EXPECT_TRUE(false);
	EXPECT_TRUE(true);
}
 
TEST_F(TestGroup,SecondPassingTest)
{
	EXPECT_TRUE(true);
	EXPECT_TRUE(true);
}
Sample output

Sample output of a simple unit test framework

Universal custom keyboard layout

In a perfect world everyone would speak the same language. Wouldn't that just be wonderful? Everyone would understand everyone else, and there were no need for localization at all. But things are not so nice, and to make things worse people developed separate keyboard layouts for each language. Now that becomes a real problem when you are blind typing on more than one languages, which of course happens a lot, when your first language is not English, and happen to have a grand mother who speaks a third language. To make things even more challenging, typewriter designers had the strange habit of moving special characters around on the keyboard for each new language, making it a nightmare to write source code while switching back and forth between languages.

@ //

Remote editing

To achieve maximal productivity it is very important to choose the right tools for editing your code, and find the configuration that works best for you. When coding on a remote server one has several choices, but each has it's drawbacks. Let's sum up the possibilities.

@ //

Moving your PuTTY config

The general stereotype is, that geeky programmers don't like windows, and to be honest it really is like an annoying aunt: you hate her, but got to put up with her sometimes. Although one must acknowledge windows' virtues, and I'd find it inconvenient to get along without my windows box at home. Not because of windows, but because of software that is only available for windows and don't run on Wine. However when it comes to coding I inevitably find myself opening an SSH connection to my Linux based server. So not surprisingly PuTTY is among the first 3 or 4 applications I install on a fresh windows.

One of the most convenient features of Linux is that configurations are stored in simple files allowing you to just copy them to your new home directory without much trouble. On windows however configurations are hidden deep into the registry making it a real pain to re customize your windows desktop once you replaced your old PC with a new one. Not that if windows was so highly customizable, but it still takes like a day to get all of my settings right. Today was such a day...

@ //