Why is it So Hard to Find a Simple XML Parser for C++?

I spent the last few hours looking for a simple XML parser for C++.  I did find two candidates:  TinyXML and xmlParser.  The latter looks the easiest, but I had to send an e-mail to the developer requesting for the tool.  It’s been a few hours now and I haven’t heard back from him yet, but I did send it quite late on a Friday night.

I know that there are many other XML parsers out there.   Xerces and Expat are quite popular, but they are just too big for what I am trying to do.  If you know your history, Xerces along with his huge Persian army fought against a tiny group of Spartans.  I thought that it would be clever to come up with a tiny XML parser called Sparta.  Well, Eamonn O’Brien-Strain developed an open-source project called Sparta – Lean XML Parser, DOM,, & XPath.  Unfortunately, it’s a Java application–still nice work with the parsing tool and the historical references.  I wish I could have thought of these things first.

Microsoft’s XmlLite showed promise too, but when I looked at the code samples, I quickly realized that I needed to learn some things about C++ COM programming before I could even think about XML.  I then checked out Microsoft’s MSXML.  I found some really great articles, but most them were ten years or older.  It probably works just fine today, but I don’t trust old code on newer Windows operating systems.  I have Win7 64-bit.  This library was written about the same time as Microsoft ME – which, by the way, is still the greatest operating system ever known to mankind.

Once I try TinyXML and xmlParser, I will write something up for you.  Now it’s too late.  Go to hell XML.

References:

http://www.applied-mathematics.net/tools/xmlParser.html

http://sourceforge.net/projects/tinyxml/

http://xerces.apache.org/xerces-c/

http://expat.sourceforge.net/

http://sourceforge.net/projects/sparta-xml/

http://msdn.microsoft.com/en-us/magazine/cc163436.aspx

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged with:  

Con Carne Chair

Mahmoud, the developer, asks Steve, the tester, if he borrowed his chair.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged with:  

Cannot Quit Microsoft Office Excel

I got this information dialog today while using Excel.  I couldn’t quit the application when I tried to exit.  I finally ended up cycling through and closing other open applications on my desktop before I could finally close Excel.  I have never seen this before on XP/Office 2007.

I pretended for a moment that I belonged to the MS Office test team.  How would I report this to a developer?  Would the developer agree that this was a bug or would s/he give me grief about doing something that I wasn’t supposed to be doing?  I don’t know.  I have not been able to repeat this so I will just file it as a WTF sighting for now.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged with:  

Big Mouth Small Talk

Mahmoud, the developer, tells Steve, the developer, he likes Smalltalk.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged with:  

Gear Shifting, Beer Drinking ENUM Testing in C++

C/C++ API testing usually involves testing parameters that are defined as enumerated types or enums.  Developers like to use enums because they make APIs more readable since related data can be easily grouped together and referenced in external documentation.

As test developers, we can take quick advantage of enums as long as they are ordered in logical and predicable ways.  The example I provide below shows the gears of a vehicle as an enum type.  I intentionally space them numerically from low to high.  It seems like the natural thing to do.  We can take advantage of this order when we do parameter testing against the shiftGear() function.  The function takes a GEARS type as a single argument.  We don’t know what is inside the function so we must test all positive cases, REVERSE to FIFTH and all negative cases outside of the valid enum range.

So to take advantage of the order, I created a simple for loop to traverse from REVERSE to FIFTH gear.  You may have noticed that I am using GEARS(int) instead of just using the int in the for loop.  It has to be done this way because although we can assign a GEARS to an int, we can’t assign an int to a GEARS. GEARS(int) allows me to cast the int to an enum.  It’s a little confusing for beginners because the types of GEARS are really just integers, but here is how it goes:

int x = FIRST;  // OK

GEARS y = 1;  // NOT OK

One other interesting aspect of the GEARS(int) syntax is that it allows us to cast values that are not defined in the original GEARS enum structure.  This is really useful for negative, out-of-bounds testing as seen later in this example.  It allows me to break the API rules without breaking compilation rules.

#include <iostream>

using namespace std;

// Valid gears to work with
enum GEARS {
  REVERSE = -1,
  NEUTRAL = 0,
  FIRST = 1,
  SECOND = 2,
  THIRD = 3,
  FOURTH = 4,
  FIFTH = 5 };

// Function API to test
void shiftGear( GEARS gear );

int main(int argc, char **argv)
{
  // It's always safe to start in neutral
  GEARS gear = NEUTRAL;

  // Check within boundary...everything should work
  for ( int i = REVERSE; i <= FIFTH; i++ )
  {
    shiftGear( GEARS(i) );
  }

  // Below expected boundary
  shiftGear( GEARS(-255) );

  // Above expected boundary
  shiftGear ( GEARS(255) );

  return 0;
}
% demo.exe
Shifting gear to -1
Shifting gear to 0
Shifting gear to 1
Shifting gear to 2
Shifting gear to 3
Shifting gear to 4
Shifting gear to 5
Not Shifting gear to -255 because not allowed
Shifting gear to 255 ahhhhh, transmission blown, die!

The pretend bug here is that the 255 case is not caught by the function, so the transmission blows up.  As I mentioned before, the logic has to make sense to test it this way.  What happens if we change the order of the positive tests?  What if we decide to shift straight from FIFTH to REVERSE?  It’s allowed in real life and probably here, but is this a smart thing to do?  This is where you get into an argument with the developer who says that although it will destroy the transmission, the specification allows for it; therefore, this is not a real bug.  Maybe so, I don’t know.  Factory recalls can be very expensive though.

There one other danger regarding the enum-based parameter testing.  There is nothing stopping developers from removing, adding, or reordering elements in enum structures.  Not a good idea, but it does happen.  If it does happen, regression tests are likely to break.  The effect is like grinding the gears of a transmission that is tongue-frozen to a metal chalkboard covered with someone’s dirty fingernails.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged with:  
Page 3 of 612345...Last »

Random Site Quotes

“Always be testing, never be resting.”
© 2009-2011 TestDeveloper.com
Powered by WordPress
Content provided by John L. Whiteman and his Slam Carrot Long Ears Gang