void TestBoundedBuffer::TestConstruction()
{
	unsigned char buf [300];
	ZeroMemory(buf, 300);
	buf[0] = 1;
	BoundedBuffer boundedBuf(buf, 300);

	assertMessage(boundedBuf.m_iMaxSize == 300, _T("Buffer bounds not being set"));
	assertMessage(boundedBuf.m_pBuf != NULL, _T("Failed to allocated the local (I work on this) buffer"));
	assertMessage(boundedBuf.m_pBuf[0] == 1, _T("Didn't copy buffer from source to temporary copy"));
	assertMessage((void*)(boundedBuf.m_pBuf) != (void*)(&buf), _T("Buffer internal pointer not set"));

	BoundedBuffer null_buf(NULL, 100);
	assertMessage(null_buf.m_iMaxSize == 100, _T("Buffer bounds not being set"));
	assertMessage(null_buf.m_pBuf != NULL, _T("Failed to allocated the local (I work on this) buffer"));
	assertMessage(null_buf.m_pBuf[0] == 0, _T("Didn't null out the desired buffer space."));

	BoundedBuffer empty_buf(NULL, 0);
	assertMessage(empty_buf.m_iMaxSize == 0, _T("Buffer bounds not being set"));
	assertMessage(empty_buf.m_pBuf == NULL, _T("Failed to allocated the local (I work on this) buffer"));
}
Beispiel #2
0
char		*main_menu(t_term *term)
{
  char		buf[3];
  t_menu	*menu;
  int		nb_read;
  int		xmenu;
  int		nb_key;
  char		*str;

  xmenu = 0;
  menu = xmalloc(sizeof(*menu) * 4);
  xtputs(xtgetstr("vi", &term->area), 1, my_outc);
  xtputs(term->clstr, 1, my_outc);
  init_menu(menu);
  while (1)
    {
      show_menu(menu, xmenu, 9, term);
      empty_buf(buf, 3);
      nb_read = xread(0, buf, 3);
      if (nb_read == 1 && (buf[0] == 27))
	break;
      else if ((nb_read == 3) && (nb_key = test_key(term, buf[2])))
	xmenu = move_mkey(nb_key, xmenu);
      else if ((nb_read == 1) && (buf[0] == 32))
	{
	  if ((str = main_smenu(term, xmenu, menu)))
	    {
	      xtputs(xtgetstr("ve", &term->area), 1, my_outc);
	      free_menu(menu);
	      return (str);
	    }
	}
    }
  xtputs(xtgetstr("ve", &term->area), 1, my_outc);
  free_menu(menu);
  return (0);
}