コード例 #1
0
ファイル: test_once.cpp プロジェクト: LancelotGHX/Simula
void call_once_with_functor()
{
    unsigned const loop_count=100;
    int my_once_value=0;
    static boost::once_flag functor_flag=BOOST_ONCE_INIT;
    for(unsigned i=0;i<loop_count;++i)
    {
        boost::call_once(functor_flag, increment_value(&var_to_init_with_functor));
        my_once_value=var_to_init_with_functor;
        if(my_once_value!=1)
        {
            break;
        }
    }
    boost::unique_lock<boost::mutex> lock(m);
    BOOST_CHECK_EQUAL(my_once_value, 1);
}
コード例 #2
0
// This test case succeeds since increment_value() asserts on the NULL pointer.
void increment_value_assert(void **state) {
    expect_assert_failure(increment_value(NULL));
}
コード例 #3
0
/* This test case will fail but the assert is caught by run_tests() and the
 * next test is executed. */
void increment_value_fail(void **state) {
    increment_value(NULL);
}
コード例 #4
0
ファイル: spin_edit.c プロジェクト: olegyurchenko/dda-control
/*----------------------------------------------------------------------------*/
static int spin_handler(void *data, event_t evt, int param1, void *param2)
{
  (void) data; //Prevent unused warning
  (void) param1;
  (void) param2;
  switch(evt)
  {
  case IDLE_EVENT:
    if(timeout_riched(&spin_data.timeout, sys_tick_count()))
    {
      timeout_set(&spin_data.timeout, CURSOR_TIME, sys_tick_count());
      spin_data.cursor_active = !spin_data.cursor_active;
      draw_cursor();
    }

    if(spin_data.active_key == KEY_UP && timeout_riched(&spin_data.key_timeout, sys_tick_count()))
    {
      if(!increment_value())
        spin_data.active_key = 0;
      else
        timeout_set(&spin_data.key_timeout, KEY_REPEAT_TIME, sys_tick_count());
    }

    if(spin_data.active_key == KEY_DOWN && timeout_riched(&spin_data.key_timeout, sys_tick_count()))
    {
      if(!decrement_value())
        spin_data.active_key = 0;
      else
        timeout_set(&spin_data.key_timeout, KEY_REPEAT_TIME, sys_tick_count());
    }
    break;

  case MODE_SET_EVENT:
    if(!param1) //Mode exit
      return 0;
    display();
    break;

  case KEY_PRESS_EVENT:
    if(param1 == KEY_UP)
    {
      if(increment_value())
      {
        spin_data.active_key = KEY_UP;
        timeout_set(&spin_data.key_timeout, KEY_DELAY_TIME, sys_tick_count());
      }
    }

    if(param1 == KEY_DOWN)
    {
      if(decrement_value())
      {
        spin_data.active_key = KEY_DOWN;
        timeout_set(&spin_data.key_timeout, KEY_DELAY_TIME, sys_tick_count());
      }
    }

    if(param1 == KEY_STOP || param1 == KEY_MENU)
    {
      start_work_menu();
    }

    if(param1 == KEY_OK)
    {
      *spin_data.value = value;
      pop_event_handler();
    }
    break;

  case KEY_RELEASE_EVENT:
    spin_data.active_key = 0;
    break;

  default:
    break;
  }
  return 0;
}