interview assignement

Started by
14 comments, last by ldeej 16 years, 5 months ago
Quote:Original post by yaustar
Tip #3: Use unit checks to test your code.


my problem is i have difficulties to understand some functions description...
how would you use unit testing here?
Advertisement
To answer your questions:

nf_arena appears to be an allocator type, i.e. an abstraction of the memory management functions. This makes it easy to port the code to different platforms or use custom allocators. The only problem with this implementation is that the allocator is a function argument so there's guarantee that the same allocator is used thorughout the lifetime of the string.

size_t is the type that the sizeof operator evaluates to and is used in several standard library functions that require byte counts. It is usually an unsigned int but is compiler specific. It is defined in several header files.

Your unit tests should test what you think the function should do given the description you've been given. Make sure you note any assumptions you make:
Quote:
If you find that any comment for a dstr function does not completely define the functions behaviour, you should decide how to make the function behave and improve the documentation in interview-dstr.h.

Also, make sure you unit tests test failure conditions as well.

Skizz

what does it mean returning "@-1@" for "nf_dstr_init" function?
Looks like their doc tool emphasises anything commented surrounded by '@' signs. Return -1 if an error ocurred.

Good luck!
Are you sure you're up to this job?

This is about as basic as it gets for a programmer. Basic C allocation, string manipulation, documentation.

Just something to consider.
HintXX: For low level stuff like this make sure you do obesive parameter checking and assertions to catch when something goes wrong.

This topic is closed to new replies.

Advertisement