Kernel word recovery crack, Mobile themes website for samsung wave 525, Dekha ek khwab sony tv title song, Song zombies on your lawn, Bloody mary nerve endings mp3, Digittrade tv jukebox, Padosan songs mp3, Gold cup series 70 manual, Nieuwste versie van mozilla firefox en, Cant install spotify on mac, Web brute force password cracker, Belkin g peek driver windows 7

Archive for February, 2012

Test Monkey

February 28th, 2012

To test my ongoing projects, or rather to do some test based development, I wrote some simple C++ classes and macros that emulate the Qt testing framework with some differences.

– Testing functions don’t need to be in a Q_OBJECT but are normal C-style functions.
– More information about the location of a failed test, debug/warning/error messages and segmentation faults.
– A QLOGCOMPARE macro that displays a diff of two lists of strings that can be populated by a MonkeyLogger stream.

To illustrate how this works, let me show you a short example.

#include <QCoreApplication>
#include <QStringList>
#include "testmonkey.h"
#include "monkeylogger.h"
void raiseWarning() {
    qWarning("Warning: do not call me !");
void raiseFault() {
    struct Foo { int bar; };
    Foo* foo = 0;
    int a = 5;
    int b = 4;
    QVERIFY(a < 0);
    QCOMPARE(a, b);
    MonkeyLogger result;
    MonkeyLogger expected;
    expected() << "line1";
    expected() << "line2";
    expected() << "line3";
    result() << "line1";
    result() << "bogus";
    result() << "line3";
    QLOGCOMPARE(result.entries(), expected.entries());
//  raiseFault();
    QVERIFY(1 > 0);
    int a = 0;
    int b = 1;
    QVERIFY(a < b);
int main(int argc, char *argv[]) {
    QCoreApplication(argc, argv);
    return 0;

Running this examples yields the following output:

     Test failed at main.cpp:24:
        Expression: a < 0
     Comparison failed at main.cpp:25
        Expression: a
          Expected: "4"
               Got: 5
    Log comparison failed at main.cpp:36
  RESULT                                       EXPECTED                                    
  line1                                        line1                                       
* bogus                                        line2                                       
  line3                                        line3                                       
     -> after main.cpp:36 in test myTest (outside a test macro):
        WARNING: main.cpp:11, void raiseWarning()
            Warning: do not call me !
FAIL myTest (1/4)
OK   allOk
1/2 TESTS SUCCEEDED. (3/6 tests)

If raiseFault() line in the myTest method were to be uncommented, the program would stop with the following message:

     -> after main.cpp:36 in test myTest (outside a test macro):
        SEGFAULT caught

Some random notes:

– In this example the logging functionality is kind of stupid. In reality it is useful to log signals. A monitor object is create that connects to the signals that are to be monitored and logs a textual representation of the signal to a MonkeyLogger. Another MonkeyLogger object is created in the test function, and logs stores the expected signal representations.
– When debug/warning message and segfaults are caught, the last known location in a test function is displayed. This is the location of the last test macro (QCOMPARE, QVERIFY, QLOGCOMPARE) that was called. If the message was not the result of a call from one of these macros, the displayed message is “after file.cpp:line in test Test (outside a test macro)”, which means the error occurred anywhere between that location and the next test macro or the end of the test function.
– The MONKEY_TEST macro registers a function with the TestMonkey framework using a static TestMonkey object. While this is quick and dirty, it also means that registration order is undetermined if you use multiple object files containing testing functions. This can be a source of errors if they use other global objects, so remember to have everything initialized before calling TestMonkey::run().
– As my current projects use C++11 and this testing framework is mostly for myself (but feel free to use), TestMonkey requires C++11.
– The Qt testing macros that handle data sets are not implemented.

Attached Files: