Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Properties, CppUnit and crashing tests

Sign in to follow this  
Staffan E


You'll have to excuse any weird typing today. My head is completely worn down by moving all weekend. I've evacuated my apartment and will be staying with the family for a few weeks. Then it's off to Stavanger, Norway for a two-month internship position. Awesome! [grin]

Integrating the properties
Read about my property system here, and about the Body component here.
I've shifted my efforts towards integrating the new property system together with the new Body component. It may seem dangerous to do several integrations simultaneously, and it is, see below. However the property container is a necessary part of the system the way I see it evolve so putting it off until later will only complicate things.

I'm going to scrap the current way of supplying configuration data to the components by their constructor. Instead I want all such values to be properties that can be set before or after the component has been crated.

The key difference here is that properties belong to the entity and the components just use them. The component must declare in its constructor which properties it will use, and give a fallback value if no such property exists. This way no props will be missing and no config data will be overwritten.

This is the current prop_container interface.
  • T get("name")

  • void set("name", value)

  • require_prop("name", def_value)

  • void set_callback("name", callback_ptr)

The exact operation of require_prop() is to add the property and set the default value only if it doesn't already exist. One can also specify a callback function object that is called every time a property is written to. Such an object must inherit the prop_callback interface and is held through a weak_ptr.

I'd love to post the whole prop_container class source if only I had it checked in, but it's on another computer right now and in a non-functional state. I'll try to remember this later. Some people have shown interest in the property implementation.

Converting test code to CppUnit format
There has been a big problem with my testing code for a while. Namely, the whole test application has not failed, but crashed hard without any helpful debug output.

Up until now I've been using FCTX, Fast C-Testing, xUnit, something. This is obviously a framework suited for C-programs and the main reason I picked it was it is contained in one single header and was darn easy to get running.

However, since FCTX is based on C macros it does not work well with stack trace analysis, so in the end I just ignored the whole thing as the game did run (the very opposite of good conduct).

Now, finally, I've taken on the problem by ditching FCTX and going over to CppUnit instead. It was a crap-load of work converting all the tests (WHY DON'T VISUAL STUDIO SUPPORT MULTILINE SEARCH AND REPLACE!?!). Just want you to know...

Anyway now I can trace the crash down to something in the new property container. Apparently the deepest informative level is the string key comparer in the map that holds the property objects. It's not solved yet but at least I'm getting closer.

CppUnit is nice too. Now I don't have to hack my way around testing the exception handling. And without the macro-orgy VS intellisense actually knows what's going on. The poor thing.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!