END_TEST START_TEST (test_image) { uint32_t rs = run_kernel(image_source, ImageKind); const char *errstr = 0; switch (rs) { case 1: errstr = "Image1 must have width of 4"; break; case 2: errstr = "Image1 must have width of 4"; break; case 3: errstr = "Image2 must have type SIGNED_FLOAT16"; break; case 4: errstr = "Image2 must have channel order RGBA"; break; case 5: errstr = "The value read from the image is not good"; break; default: errstr = default_error(rs); } fail_if( errstr != 0, errstr ); }
static void i_append_widget( GtkWidget *gtk_panel, enum mrpanel_tipo_disposicion_t tipo_disposicion, unsigned long ind_fila, unsigned long ind_columna, bool expand, bool fill, GtkWidget *gtk_hijo) { switch(tipo_disposicion) { case MRPANEL_HORIZONTAL: case MRPANEL_VERTICAL: i_append_hijos(gtk_panel, gtk_hijo, expand, fill); break; case MRPANEL_GRID: assert(ind_fila != USHRT_MAX); assert(ind_columna != USHRT_MAX); i_append_grid(gtk_panel, ind_fila, ind_columna, gtk_hijo, expand, fill); break; default_error(); } }
//------------------------------------------------------------------------------ // void *CFileBas::openBin(const char *nameFile, enum TypeOpen_t typeOpen) { FILE *file; const char *modeFile; if (s_filesOpened == NULL) { s_filesOpened = new CArray<PrvFileOpened>; atexit(prv_deleteArrayOpened); } switch(typeOpen) { case CFileBas::READ: modeFile = "rb"; break; case CFileBas::WRITE: modeFile = "wb"; break; default_error(); } file = fopen(nameFile, modeFile); assert_no_null(file); prv_registerFile(s_filesOpened, nameFile, file); return file; }
END_TEST START_TEST (test_builtins) { uint32_t rs = run_kernel(builtins_source, NormalKind); const char *errstr = 0; switch (rs) { case 1: errstr = "float2 cos(float2) doesn't behave correctly"; break; case 2: errstr = "float cos(float) doesn't behave correctly"; break; case 3: errstr = "float copysign(float) doesn't behave correctly"; break; case 4: errstr = "float2 copysign(float2) doesn't behave correctly"; break; case 5: errstr = "exp2() doesn't behave correctly"; break; default: errstr = default_error(rs); } fail_if( errstr != 0, errstr ); }
//------------------------------------------------------------------------------ // static void prv_setPixelRGB( IplImage *cvImage, unsigned long x, unsigned long y, unsigned char r, unsigned char g, unsigned char b) { unsigned char *ptrPixel; ptrPixel = prv_getPixel(cvImage, x, y); switch(cvImage->nChannels) { case 3: *(ptrPixel+2) = r; *(ptrPixel+1) = g; *ptrPixel = b; break; case 1: assert(r == g); assert(g == b); *ptrPixel = r; break; default_error(); } }
//------------------------------------------------------------------------------ // static void prv_getPixelRGB( IplImage *cvimg, unsigned long x, unsigned long y, unsigned char *r, unsigned char *g, unsigned char *b) { unsigned char *ptrPixel; assert_no_null(r); assert_no_null(g); assert_no_null(b); ptrPixel = prv_getPixel(cvimg, x, y); switch(cvimg->nChannels) { case 4: case 3: *r = *(ptrPixel+2); *g = *(ptrPixel+1); *b = *ptrPixel; break; case 1: *r = *ptrPixel; *g = *ptrPixel; *b = *ptrPixel; break; default_error(); } }
static void i_hacer(struct marco_t *marco, struct i_datos_aplicacion_t *datos_aplicacion, const char *parametro) { enum tipo_compilacion_t tipo_compilacion; char *mensaje_error; assert_no_null(datos_aplicacion); if (i_es_version_compilacion(parametro, &tipo_compilacion, &mensaje_error) == true) { struct cfgproy_t *cfg_proyectos; cfg_proyectos = i_genera_proyectos(datos_aplicacion->directorio_base); switch(datos_aplicacion->tipo_hacer) { case i_HACER_NORMAL: case i_HACER_ALL: //TODO: De momento no hacemos nada con el ALL sólo por compatibilidad con Eclipse. cfgproy_hacer_ejecutables(cfg_proyectos, tipo_compilacion, marco); break; case i_HACER_CLEAN: cfgproy_clean_segun_compilacion(cfg_proyectos, tipo_compilacion, marco); break; default_error(); } cfgproy_destruye(&cfg_proyectos); } else { marco_lanza_mensaje(marco, MARCO_MENSAJE_ERROR, mensaje_error); strbas_destroy(&mensaje_error); } }
END_TEST START_TEST (test_barrier) { uint32_t rs = run_kernel(barrier_source, BarrierKind); fail_if( rs != 0x40, default_error(rs) ); }
static int lketama_roll(lua_State *L){ size_t fsiz; char *filename = (char *)luaL_checklstring(L, 1, &fsiz); if( fsiz > 255 ) return luaL_argerror(L, 1, "filename must not be longer than 255 bytes"); contdata *data = lua_newuserdata(L, sizeof(*data)); if(!data) return default_error(L); if(ketama_roll((ketama_continuum*)&data->cont, filename) == 0) return nil_error(L, 0, "continuum fail"); luaL_getmetatable(L, MT_NAME); lua_setmetatable(L, -2); return 1; }
static int rdb_open(lua_State *L){ const char *host = luaL_optstring(L, 1, "localhost"); int port = luaL_optint(L, 2, 1978); RDBDATA *data = lua_newuserdata(L, sizeof(*data)); if(!data) return default_error(L); data->rdb = tcrdbnew(); if(!tcrdbopen(data->rdb, host, port)) return rdb_error(L, data->rdb); data->is_open = true; luaL_getmetatable(L, MT_NAME); lua_setmetatable(L, -2); return 1; }
static bool prv_existId( const class CArrayString *ids_primitives, const class CArrayString *ids_transforms, const class CArrayString *ids_actors, enum prv_typeElementWorld_t typeElement, const char *idStr, unsigned long line, class ILog *log) { bool existId; const class CArrayString *ids; const char *typeElementStr; switch(typeElement) { case prv_PRIMITIVE: ids = ids_primitives; typeElementStr = "Primitive"; break; case prv_TRANSFORM: ids = ids_transforms; typeElementStr = "Transform"; break; case prv_ACTOR: ids = ids_actors; typeElementStr = "Actor"; break; default_error(); } existId = ids->searchString(idStr, NULL); if (existId == false) { char *messageError; messageError = strbas_printf(PRV_ELEMENT_NOT_EXIST, typeElementStr, idStr, typeElementStr); log->errorWithLine(line, messageError); strbas_destroy(&messageError); } return existId; }
struct item_implementacion_t *gtkpanel_crea_panel( enum mrpanel_tipo_disposicion_t tipo_disposicion, unsigned long num_filas, unsigned long num_columnas, bool homogeneus, unsigned long pixelsSpacing) { GtkWidget *box; switch(tipo_disposicion) { case MRPANEL_HORIZONTAL: assert(num_filas == 1); assert(num_columnas > 0); box = gtk_hbox_new(homogeneus, pixelsSpacing); break; case MRPANEL_VERTICAL: assert(num_filas > 0); assert(num_columnas == 1); box = gtk_vbox_new(homogeneus, pixelsSpacing); break; case MRPANEL_GRID: assert(num_filas != USHRT_MAX); assert(num_columnas != USHRT_MAX); box = gtk_table_new(num_filas, num_columnas, pixelsSpacing); break; default_error(); } gtk_widget_show(box); return (struct item_implementacion_t *)box; }
void CPrvProcessElements::processNode(const class CNodeXML *node) { assert_no_null(node); if (node->isTag(PRV_ID_ELEMENT_SCENE) == true) { char *idStr, *idClass; enum prv_typeElementWorld_t typeElement; struct CPrivateElementWorld *elementWorld; bool isElementOk, hasClass, hasId; idClass = NULL; hasClass = node->getClass(&idClass); idStr = NULL; hasId = node->getId(&idStr); if (hasClass == true) { isElementOk = prv_typeElement(idClass, &typeElement); if (isElementOk == false) m_dataProcess->log->warningWithLine(node->getLine(), PRV_ERROR_TYPE_CLASS); } else { isElementOk = false; prv_warningNotAttribute(m_dataProcess->log, node->getLine(), "class"); } if (hasId == false) { isElementOk = false; prv_warningNotAttribute(m_dataProcess->log, node->getLine(), "id"); } if (isElementOk == true) { isElementOk = prv_existId( m_dataProcess->ids_primitives, m_dataProcess->ids_transforms, m_dataProcess->ids_actors, typeElement, idStr, node->getLine(), m_dataProcess->log); } if (isElementOk == true) { class CArray<CPrivateElementWorld> *elementsTransform; elementsTransform = new CArray<CPrivateElementWorld>; switch(typeElement) { case prv_PRIMITIVE: case prv_ACTOR: break; case prv_TRANSFORM: { class CPrvProcessElements *process; struct prv_dataProcessElements_t *dataProcessTransform; dataProcessTransform = prv_createDataProcessElement( m_dataProcess->ids_primitives, m_dataProcess->ids_transforms, m_dataProcess->ids_actors, elementsTransform, m_dataProcess->log); process = new CPrvProcessElements(m_recursiveLevel, &dataProcessTransform); node->processAllChildren(process); delete process; break; } default_error(); } if (isElementOk == true) { elementWorld = new CPrivateElementWorld(typeElement, idStr, &elementsTransform); m_dataProcess->elementsWorld->add(elementWorld); } else delete elementsTransform; } if (hasId == true) strbas_destroy(&idStr); if (hasClass == true) strbas_destroy(&idClass); } else { m_dataProcess->log->warningWithLine(node->getLine(), PRV_ELEMENT_NOT_GMV); } }