I am writing a dynamically growing string buffer. I have the following file .c.
#ifndef STRBUF_GROWTH_SIZE
#define STRBUF_GROWTH_SIZE 4096
#endif
My code uses this constant to redistribute the buffer. Now in the tests I need to set this value to small so that I can check the redistribution. I tried to define this in tests.cpp(all tests are in C ++ using UnitTest ++).
#define STRBUF_GROWTH_SIZE 10
TEST(StringBuffer)
{
struct strbuf *string = strbuf_init();
strbuf_add(string, "first");
CHECK_EQUAL("first", string->buffer);
CHECK_EQUAL(5, string->length);
CHECK_EQUAL(10, string->allocated);
strbuf_add(string, " second");
CHECK_EQUAL("first second", string->buffer);
CHECK_EQUAL(12, string->length);
CHECK_EQUAL(20, string->allocated);
strbuf_destroy(string);
}
I am wondering why the value has not changed to 10? How can I solve this problem?
Any thoughts?
source
share