Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
static void testAppendChar()
{
  MemoryPool pool = newMemoryPool();

  StringBuffer s = newStringBuffer(&pool, "A test string");
  s.appendChar(&s, '!');
  assertEquals(string, "A test string!", s.str);
  s.appendChar(&s, '-');
  assertEquals(string, "A test string!-", s.str);

  pool.drain(&pool);
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
static void testAppendString()
{
  MemoryPool pool = newMemoryPool();

  StringBuffer s = newStringBuffer(&pool, "A test string");
  s.append(&s, " - appended value");
  assertEquals(string, "A test string - appended value", s.str);
  s.append(&s, " & another value");
  assertEquals(string, "A test string - appended value & another value", s.str);
  assertTrue(s.size > strlen("A test string - appended value & another value"));

  pool.drain(&pool);
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
static void testToString()
{
  MemoryPool pool = newMemoryPool();

  StringBuffer sb = newStringBuffer(&pool, "A test strin");
  sb.appendChar(&sb, 'g');
  assertEquals(string, "A test string", sb.str);

  string s = sb.toString(&sb, &pool);
  assertEquals(string, "A test string", s);
  assertEquals(unsigned_int, 13, strlen(s));

  pool.drain(&pool);
}