Hi Peter,
We could have the compiler help us in case a new Event is ever added to TrackerReqeust::Event. If TrackerRequestWriter::eventToString() uses a simple switch like that:
[snip]
the compiler will produce a warning that no case exists for the new enum value, which would be a hint for us to fix that! If we forget to change the Writer after a new Event has been added, then the line:return EventsAsStrings[event];
could be troublesome. What do you think?
Yes, I agree. I’ve change the implementation, but I’ve used
...
default:
Q_ASSERT (false && "Unknown event - you most likely forgot to actualize"
"this switch when adding a new event to TrackerRequest::Event.");
return "unknown";
break;
}
instead of a switch without ‘default’ clause - I think this will be better. Do you agree?
Btw. I think the reason for this strange crash of tester is that global PeerIdQueryItemKeyName is not yet initialized by the time const TrackerRequest TrackerRequestSessionTest::ValidTrackerRequest (TrackerRequestSessionTest.cpp:190) is constructed. I remember reading that the order in which static/global variables is undefined so probably we have other situations like this that “just work” with the specific version of gcc we are using but will probably not work with different compilers. We have to think of a solution or a workaround to the problem.
Yes, that was the problem (I overlooked that there is that PeerIdQueryItemKeyName used). Problems are caused by unit tests with static constants (mostly, in our case). I was thinking - could I just create a default ctor for *Test classes? Then I’ll be able to remove the static modifier from constants and initialize them in that ctor. I can’t think of any other idea now…
However, I’ll try to compile and run `./tester` on our student servers that our faculty provides. There are various OS/compilers, so this way we could see whether there are currently more poblems. There are:
CentOS 64bit Linux - GCC (3.3, 3.4, 4.0, 4.1, 4.2), Intel C/C++ Compiler/Debugger 10.0
FreeBSD 6.2 - GCC (3.4)
Solaris 7 - GCC (3.3), Sun C/C++
Regards,
Peter
