示例#1
0
void test()
    {
    OilTest *test;
    OilParameter *p;
    int16_t *data;
    int n;
    int footer;
    int footer_increment = 10;
    OilFunctionClass *klass;
    OilFunctionImpl *impl;
    
    klass = oil_class_get("abs_f32_f32");
    
    if(klass != NULL)
        {
        test = (OilTest *)oil_test_new(klass); 
        
        if(test != NULL)
            {
            impl = (OilFunctionImpl*)calloc(sizeof(OilFunctionImpl), 0);
            impl->func = (void*)abs_f32_f32_test;
            impl->name = "abs_f32_f32_test";
            impl->klass = klass;
            
            oil_test_set_impl(test, impl);
            
            if(test->impl != impl)
                {
                std_log(LOG_FILENAME_LINE,"oil_test_set_impl failed. errno = %d", errno);
                assert_failed = 1;
                }
            
            p = &test->params[1];
            footer = p->test_footer;
            oil_test_set_test_footer(test, p, OIL_TEST_FOOTER+footer_increment);
            
            if(p->test_footer != footer+footer_increment)
                {
                std_log(LOG_FILENAME_LINE,"oil_test_set_test_footer failed. errno = %d", errno);
                assert_failed = 1;
                }
            
            data = (int16_t *)oil_test_get_source_data (test, OIL_ARG_SRC1);
            n = oil_test_get_arg_pre_n (test, OIL_ARG_SRC1);
            
            oil_test_cleanup(test);
            oil_test_free(test);
            }
        else
            {
            std_log(LOG_FILENAME_LINE,"oil_test_new returned NULL. errno = %d", errno);
            assert_failed = 1;
            }
        }
    else
        {
        std_log(LOG_FILENAME_LINE,"oil_class_get returned NULL. errno = %d", errno);
        assert_failed = 1;
        }
    }
示例#2
0
/*
 * Little explanation:
 *  0x00-0x7f  ASCII, one byte character
 *  0x80-0xbf  continuation byte, not a valid start byte
 *  0xc0-0xdf  2-byte character
 *  0xe0-0xef  3-byte character
 *  0xf0-0xf7  4-byte character
 *  0xf8-0xff  reserved (illegal at the present time)
 */
static void
utf8_validate_test (OilTest *test)
{
  int i;
  int n = test->n;
  uint8_t *ptr = oil_test_get_source_data (test, OIL_ARG_SRC1);
  int x;
  int extra_chars = 0;

  for (i=0;i<n;i++){
    if (i >= n-16) {
      /* if it's close to the end, we'll randomly drop in a bad
       * byte from either the 0x80-0xbf or 0xf8-0xff segments */
      x = oil_rand_u8();
      if (x < 16) {
        x = oil_rand_u8();
        if (extra_chars>0) {
          /* this might not actually be a bad char */
          ptr[i] = x;
          extra_chars--;
        } else {
          if (x & 0x80) {
            ptr[i] = 0x80 | (x&0x3f);
          } else {
            ptr[i] = 0xf8 | (x&0x07);
          }
        }
        continue;
      }
    }
    if (extra_chars > 0) {
      ptr[i] = 0x80 | (oil_rand_u8() & 0x3f);
      extra_chars--;
    } else {
      /* otherwise, we'll do a low probability of a multibyte char */
      x = oil_rand_u8() & 0xf;
      if (x == 0) {
        ptr[i] = 0xc0 | (oil_rand_u8() & 0x1f);
        extra_chars = 1;
      } else if (x == 1) {
        ptr[i] = 0xe0 | (oil_rand_u8() & 0x0f);
        extra_chars = 2;
      } else if (x == 2) {
        ptr[i] = 0xf0 | (oil_rand_u8() & 0x07);
        extra_chars = 3;
      } else {
        ptr[i] = oil_rand_u8() & 0x7f;
      }
    }
  }

}
示例#3
0
文件: idct8x8_c.c 项目: thewb/mokoiax
static void
idct8x8_test (OilTest *test)
{
  int16_t *data = oil_test_get_source_data (test, OIL_ARG_SRC1);
  int stride = oil_test_get_value (test, OIL_ARG_SSTR1);
  int i, j;

  for(j=0;j<8;j++){
    for(i=0;i<8;i++){
      OIL_GET(data, i*2 + j*stride, int16_t) = (oil_rand_s16() & 0xfff) - 2048;
    }
  }
}