Hello gamedev.net,
while I set the tag as C++, it is more about a general question and beside this specific example, I would be thankful for any resource or explanation of more complex cases of unit-testing.
Is TDD something that I should focus on when I do unit-testing?
How would I test the unit of a tile-map class? What am I looking for?
I read through quite easy examples, where I check values of variables to contain a certain value related to a bank account example.
On the other hand, there seems to be a lot to test during this class, did I construct it too complex already?
The class itself is like this:
There are not many variables: A vertex-array variable and a variable for the tile-map-file.
1. It has an empty constructor.
2. There is a map-loader function
It receives a const char* which will be used to load the file containing all the needed tile-map-information.
Is this already a moment where I would have to unit-test if the const char is empty?
If that is the case, why is not testing if it is null enough without using the unit-test framework?
The map-loader starts to iterate through that information-file. It will look for an entry of a tile-map-image-path first.
Next would be starting to look at all the tile-coordinates which stand in relation to the tile-map.
Would I have to test whether these are even valid coordinates on the image file (for example not outside of the canvas size).
The rest is defining the quads of the vertex, repeating this until the file reached an end.
3. Draw the tile-map function
All it does is opening up the vertex array and starting to draw the tile-map.
This is all the class does and can do.
Still I'm not really sure what to test exactly.
Moreover, would an integration test be a good thing to be added on here, too?
There are so many ways of testing, it gets really overwhelming at first, so I would be happy if someone could clear things up for me : )
Thanks a lot for taking your time to read this, if something is unclear, I will give my best to explain further details or to simplify explanation.