CMarkup Test

With CMarkup release 10.1, the cross-platform CMarkupTest class allows you to run regression tests and walk through the 70+ CMarkup regression tests and examples on many platforms and compilers. It also has a performance readout. It is tested on Ubuntu Linux, Mac OS X, VC++ 6.0, VC++ 2008 Express, and even cygwin.

Building a command line CMarkup test program

Results from the CMarkupTest are displayed in the Windows CMarkup test dialog, but you can also use CMarkupTest on many platforms in a command line program main.cpp as follows:

#include <stdio.h>
#include "MarkupTest.h"

int main()
	CMarkupTest test;
#if defined(MARKUP_WCHAR)
	wprintf( MCD_T("%ls"), MCD_2PCSZ(test.m_strResult) );
	printf( MCD_T("%s"), MCD_2PCSZ(test.m_strResult) );
	return 0;

On Linux you can compile this as follows:

g++ main.cpp Markup.cpp MarkupTest.cpp

On OS X you may need to specify the iconv library:

g++ main.cpp Markup.cpp MarkupTest.cpp -liconv

On cygwin you must use Windows conversion:

g++ main.cpp Markup.cpp MarkupTest.cpp -DMARKUP_WINCONV


The RunTest method performs diagnostics to test CMarkup in the context of the particular build options that have been selected. This is a big routine built out of all of the regression tests devised through the years of CMarkup development, newly moved from MarkupDlg.cpp to MarkupTest.cpp with CMarkup release 10.1. The RunTest function runs a set of checks. The number of checks is different for the different builds due to certain builds being specifically targeted or excluded from the tests.

You can step through the RunTest to see a lot of examples of how to use CMarkup. The test.m_strResult output displays the build version and RunTest results. For example:

3083 checks, create 9377b/ms, parse 39232b/ms, writer 8533b/ms, reader 11153b/ms

Performance measure

To give a rough idea of how fast CMarkup is in the given build configuration, sample document create and parse commands are timed.

Update March 24, 2009: With CMarkup release 11.0 developer version you get additional writer and reader speeds for a file write mode measure (see C++ XML writer) and a file read mode measure (C++ XML reader) unless File I/O tests (see below) are skipped.

Speeds are now expressed in b/ms (bytes per millisecond) and w/ms (words per millisecond). In an MBCS or WCHAR build, the reader and writer speeds include the conversion between the in-memory character set and UTF-8 in the files.

File I/O Tests

If it finds the CMarkupRunTest.xml file in the current directory, it will do read/write tests. Otherwise, if the CMarkupRunTest.xml file is not found, it will say "File I/O Tests Skipped." This is because when you run Markup.exe right out of the zip file you don't want it writing the sample XML file to disk; only if you unzip to a folder do you want it to read and write.

The CMarkupRunTest.xml file is mainly just an indicator. Most of the file I/O tests are done by reading and writing CMarkupReadWriteTest.xml. Many of the tests have to do with saving and loading files in different character sets, and byte order marks.