Exemplo n.º 1
0
Arquivo: info.c Projeto: 111X/radare
static GObject * radare_gui_radget_information_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	RadareGUIRadgetInformationClass * klass;
	GObjectClass * parent_class;
	RadareGUIRadgetInformation * self;
	klass = RADARE_GUI_RADGET_INFORMATION_CLASS (g_type_class_peek (RADARE_GUI_TYPE_RADGET_INFORMATION));
	parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = RADARE_GUI_RADGET_INFORMATION (obj);
	{
		GtkVBox* _tmp0;
		Line* _tmp2;
		Line* _tmp1;
		Line* _tmp4;
		Line* _tmp3;
		_tmp0 = NULL;
#line 14 "info.vala"
		self->priv->vb = (_tmp0 = g_object_ref_sink (((GtkVBox*) (gtk_vbox_new (FALSE, 2)))), (self->priv->vb == NULL ? NULL : (self->priv->vb = (g_object_unref (self->priv->vb), NULL))), _tmp0);
		_tmp2 = NULL;
		_tmp1 = NULL;
#line 15 "info.vala"
		self->priv->file = (_tmp2 = line_name ((_tmp1 = g_object_ref_sink (line_new ())), "File", "/bin/ls"), (self->priv->file == NULL ? NULL : (self->priv->file = (g_object_unref (self->priv->file), NULL))), _tmp2);
		(_tmp1 == NULL ? NULL : (_tmp1 = (g_object_unref (_tmp1), NULL)));
#line 16 "info.vala"
		gtk_container_add (((GtkContainer*) (self->priv->vb)), ((GtkWidget*) (self->priv->file)));
		_tmp4 = NULL;
		_tmp3 = NULL;
#line 17 "info.vala"
		self->priv->size = (_tmp4 = line_numeric ((_tmp3 = g_object_ref_sink (line_new ())), "Size", 38432), (self->priv->size == NULL ? NULL : (self->priv->size = (g_object_unref (self->priv->size), NULL))), _tmp4);
		(_tmp3 == NULL ? NULL : (_tmp3 = (g_object_unref (_tmp3), NULL)));
#line 18 "info.vala"
		gtk_container_add (((GtkContainer*) (self->priv->vb)), ((GtkWidget*) (self->priv->size)));
#line 19 "info.vala"
		radare_gui_radget_refresh (((RadareGUIRadget*) (self)));
	}
	return obj;
}
Exemplo n.º 2
0
TEST(FileIO, XmlGmlWriterReaderTest)
{
	// Writer test
	std::string test_data_file(BaseLib::BuildInfo::source_path + "/Tests/FileIO/xmlgmltestdata.gml");

	GeoLib::GEOObjects geo_objects;

	//setup test data
	std::string geo_name("TestData");

	{   // Create points.
		auto points = std::unique_ptr<std::vector<GeoLib::Point*>>(
		    new std::vector<GeoLib::Point*>(10));

		(*points)[0] = new GeoLib::Point(1, 1, 0);
		(*points)[1] = new GeoLib::Point(1, 1, 0);
		(*points)[2] = new GeoLib::Point(1, 2, 0);
		(*points)[3] = new GeoLib::Point(1, 3, 0);
		(*points)[4] = new GeoLib::Point(2, 1, 0);
		(*points)[5] = new GeoLib::Point(2, 2, 0);
		(*points)[6] = new GeoLib::Point(2, 3, 0);
		(*points)[7] = new GeoLib::Point(3, 1, 0);
		(*points)[8] = new GeoLib::Point(3, 2, 0);
		(*points)[9] = new GeoLib::Point(3, 3, 0);
		geo_objects.addPointVec(std::move(points), geo_name);
	}
	auto const points = geo_objects.getPointVec(geo_name);

	const std::vector<std::size_t> pnt_id_map (geo_objects.getPointVecObj(geo_name)->getIDMap());

	{   // Create polylines.
		auto lines = std::unique_ptr<std::vector<GeoLib::Polyline*>>(
		    new std::vector<GeoLib::Polyline*>(5));
		std::map<std::string, std::size_t>* ply_names =
		    new std::map<std::string, std::size_t>;
		(*lines)[0] = new GeoLib::Polyline(*points);
		(*lines)[0]->addPoint(pnt_id_map[0]);
		(*lines)[0]->addPoint(pnt_id_map[2]);
		(*lines)[0]->addPoint(pnt_id_map[3]);
		ply_names->insert(std::pair<std::string, std::size_t>("left", 0));
		(*lines)[1] = new GeoLib::Polyline(*points);
		(*lines)[1]->addPoint(pnt_id_map[4]);
		(*lines)[1]->addPoint(pnt_id_map[5]);
		(*lines)[1]->addPoint(pnt_id_map[6]);
		ply_names->insert(std::pair<std::string, std::size_t>("center", 1));
		(*lines)[2] = new GeoLib::Polyline(*points);
		(*lines)[2]->addPoint(pnt_id_map[1]);
		(*lines)[2]->addPoint(pnt_id_map[4]);
		(*lines)[3] = new GeoLib::Polyline(*points);
		(*lines)[3]->addPoint(pnt_id_map[4]);
		(*lines)[3]->addPoint(pnt_id_map[7]);
		(*lines)[4] = new GeoLib::Polyline(*points);
		(*lines)[4]->addPoint(pnt_id_map[7]);
		(*lines)[4]->addPoint(pnt_id_map[8]);
		(*lines)[4]->addPoint(pnt_id_map[9]);
		ply_names->insert(std::pair<std::string, std::size_t>("right", 4));
		geo_objects.addPolylineVec(std::move(lines), geo_name, ply_names);
	}

	{   // Create surfaces.
		auto sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>(
		    new std::vector<GeoLib::Surface*>(2));
		(*sfcs)[0] = new GeoLib::Surface(*points);
		(*sfcs)[0]->addTriangle(pnt_id_map[1], pnt_id_map[4], pnt_id_map[2]);
		(*sfcs)[0]->addTriangle(pnt_id_map[2], pnt_id_map[4], pnt_id_map[5]);
		(*sfcs)[0]->addTriangle(pnt_id_map[2], pnt_id_map[5], pnt_id_map[3]);
		(*sfcs)[0]->addTriangle(pnt_id_map[3], pnt_id_map[5], pnt_id_map[6]);
		(*sfcs)[1] = new GeoLib::Surface(*points);
		(*sfcs)[1]->addTriangle(pnt_id_map[4], pnt_id_map[7], pnt_id_map[9]);
		(*sfcs)[1]->addTriangle(pnt_id_map[4], pnt_id_map[9], pnt_id_map[6]);
		geo_objects.addSurfaceVec(std::move(sfcs), geo_name);
	}

	FileIO::XmlGmlInterface xml(geo_objects);
	xml.setNameForExport(geo_name);
	int result = xml.writeToFile(test_data_file);
	ASSERT_EQ(result, 1);

	// Reader test
	result = xml.readFile(QString::fromStdString(test_data_file));
	ASSERT_EQ(result, 1);

	const std::vector<GeoLib::Point*> *readerPoints = geo_objects.getPointVec(geo_name);
	const GeoLib::PolylineVec *line_vec = geo_objects.getPolylineVecObj(geo_name);
	const std::vector<GeoLib::Polyline*> *readerLines = geo_objects.getPolylineVec(geo_name);
	const std::vector<GeoLib::Surface*> *readerSfcs = geo_objects.getSurfaceVec(geo_name);
	ASSERT_EQ(9u, readerPoints->size());
	ASSERT_EQ(5u, readerLines->size());
	ASSERT_EQ(2u, readerSfcs->size());

	GeoLib::Point* pnt = (*readerPoints)[7];
	ASSERT_EQ(3.0, (*pnt)[0]);
	ASSERT_EQ(2.0, (*pnt)[1]);
	ASSERT_EQ(0.0, (*pnt)[2]);

	GeoLib::Polyline* line = (*readerLines)[4];
	ASSERT_EQ(3u, line->getNumberOfPoints());
	ASSERT_EQ(6u, line->getPointID(0));
	ASSERT_EQ(7u, line->getPointID(1));
	ASSERT_EQ(8u, line->getPointID(2));
	std::string line_name("");
	line_vec->getNameOfElementByID(4, line_name);
	ASSERT_EQ("right", line_name);

	GeoLib::Surface* sfc = (*readerSfcs)[1];
	ASSERT_EQ(2u, sfc->getNTriangles());
	const GeoLib::Triangle* tri = (*sfc)[1];
	ASSERT_EQ(3u, (*tri)[0]);
	ASSERT_EQ(8u, (*tri)[1]);
	ASSERT_EQ(5u, (*tri)[2]);

	boost::filesystem::remove(test_data_file);
	test_data_file += ".md5";
	boost::filesystem::remove(test_data_file);
}