Exemple #1
0
void buildindex(void)
{
	const char *createstr = "id:i8|seak:c8|name:c30|street:a30|postal:c8|place:a30|_key:1|";
	char shcreatestr[1024];
	sprintf(shcreatestr, "../src/mdb %s c \"%s\"", db, createstr);
	shrun(shcreatestr);
	char buildstr[1024];
	sprintf(buildstr, "../src/mdb %s B", db);
	const char *buildirv = shrun(buildstr);
	CU_ASSERT_STRING_EQUAL(buildirv, "Building index 1\n");
}
Exemple #2
0
static void test_geohash_point(void)
{
	char *geohash;

	geohash = geohash_point(0, 0, 16);
	//printf("\ngeohash %s\n",geohash);
	CU_ASSERT_STRING_EQUAL(geohash, "s000000000000000");
	lwfree(geohash);

	geohash = geohash_point(90, 0, 16);
	//printf("\ngeohash %s\n",geohash);
	CU_ASSERT_STRING_EQUAL(geohash, "w000000000000000");
	lwfree(geohash);

	geohash = geohash_point(20.012345, -20.012345, 15);
	//printf("\ngeohash %s\n",geohash);
	CU_ASSERT_STRING_EQUAL(geohash, "kkqnpkue9ktbpe5");
	lwfree(geohash);

}
Exemple #3
0
/**
 * \brief for function PathCheck()
 * 
 * \note free the pointer from PathCheck()
 */
void test_PathCheck()
{
  char source_path[] = "/srv/fossology/testDbRepo12704556/%H/wget";
  char des_path[1024] = {0};
  char HostName[1024] = {0};
  char *taint_path = PathCheck(source_path);
  gethostname(HostName, sizeof(HostName));
  snprintf(des_path, sizeof(des_path), "/srv/fossology/testDbRepo12704556/%s/wget", HostName);
  CU_ASSERT_STRING_EQUAL(des_path, taint_path); /*  tainted */
  free(taint_path);
}
Exemple #4
0
void passphrase_read_prompts_to_tty()
{
	static const int read_nbyte = 11;
	int masterfd;
	char* slavedevice = NULL;
	char read_buf[read_nbyte];
	fd_set fd_set_write;

	masterfd = posix_openpt(O_RDWR|O_NOCTTY);

	if (masterfd == -1
		|| grantpt (masterfd) == -1
		|| unlockpt (masterfd) == -1
		|| (slavedevice = ptsname (masterfd)) == NULL)
		CU_FAIL_FATAL("Could not create pty");

	switch (fork())
	{
	case -1:
		CU_FAIL_FATAL("Could not fork");
	case 0:
		{
			static const int password_size = 512;
			char buffer[password_size];
			int slavefd;
			if (setsid() == (pid_t) -1)
				CU_FAIL_FATAL("Could not create new session");

			if ((slavefd = open(slavedevice, O_RDWR)) == 0)
				CU_FAIL_FATAL("Could not open slave end of pty");
			close(STDIN_FILENO);
			close(STDOUT_FILENO);
			close(STDERR_FILENO);
			close(masterfd);
			freerdp_passphrase_read("Password: "******"Master end of pty not writeable");
	if (read(masterfd, read_buf, read_nbyte) == (ssize_t) -1)
		CU_FAIL_FATAL("Nothing written to slave end of pty");
	CU_ASSERT_STRING_EQUAL(read_buf, "Password: "******"\n", (size_t) 2);
	close(masterfd);
	return;
}
static void
test_lwgeom_segmentize2d(void)
{
	LWGEOM *linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
	LWGEOM *lineout = lwgeom_segmentize2d(linein, 5);
	char *strout = lwgeom_to_ewkt(lineout);
	CU_ASSERT_STRING_EQUAL(strout, "LINESTRING(0 0,5 0,10 0)");
	lwfree(strout);
	lwgeom_free(linein);
	lwgeom_free(lineout);
}
static void test_lr(void) {
	belle_sip_uri_t *  L_uri = belle_sip_uri_parse("sip:192.168.0.1;lr");
	char* l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
	belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
	L_uri = belle_sip_uri_parse(l_raw_uri);
	belle_sip_free(l_raw_uri);
	CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "192.168.0.1");
	CU_ASSERT_EQUAL(belle_sip_uri_has_lr_param(L_uri), 1);
	belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));

}
static void test_string_n_split_when_separator_isnt_included() {
	char *line = "Hola planeta tierra";
	char ** substrings = string_n_split(line, 5, ";");

	CU_ASSERT_PTR_NOT_NULL(substrings);
	CU_ASSERT_STRING_EQUAL(substrings[0], line);
	CU_ASSERT_PTR_NULL(substrings[1]);

	string_iterate_lines(substrings, (void *) free);
	free(substrings);
}
static void test_escaped_headers(void) {
	belle_sip_uri_t *  L_uri = belle_sip_uri_parse("sip:[email protected]?User-to-User=323a313030363a3230385a48363039313941364b4342463845495936%3Bencoding%3Dhex");
	char* l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
	belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
	L_uri = belle_sip_uri_parse(l_raw_uri);
	belle_sip_free(l_raw_uri);
	CU_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_uri_get_header(L_uri,"User-to-User"));
	CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_header(L_uri,"User-to-User"), "323a313030363a3230385a48363039313941364b4342463845495936;encoding=hex");

	belle_sip_object_unref(L_uri);
}
void test_json_import(void)
{
	int ret;
	struct _rpg_hash *r;
	

	char *s = "{\"hid\":\"198\",\"name\":\"Mangatewai\",\"psm\":\"16 Oct 2012\",\"psc\":\"25 Jul 2012\",\"mapref\":\"\"}";

	ret = rpg_json_import( p, s, &r );RPG_CU_FNC_A_PTR_CHECK(r);

	{
		void *data;
		ret = rpg_hash_get(r,"hid",&data);RPG_CU_FNC_A_PTR_CHECK(data)
		CU_ASSERT_STRING_EQUAL( "198", (char *)data );
	}

	{
		void *data;
		ret = rpg_hash_get(r,"name",&data);RPG_CU_FNC_A_PTR_CHECK(data)
		CU_ASSERT_STRING_EQUAL( "Mangatewai", (char *)data );
	}

	{
		void *data;
		ret = rpg_hash_get(r,"psm",&data);RPG_CU_FNC_A_PTR_CHECK(data)
		CU_ASSERT_STRING_EQUAL( "16 Oct 2012", (char *)data );
	}

	{
		void *data;
		ret = rpg_hash_get(r,"psc",&data);RPG_CU_FNC_A_PTR_CHECK(data)
		CU_ASSERT_STRING_EQUAL( "25 Jul 2012", (char *)data );
	}

	{
		void *data;
		ret = rpg_hash_get(r,"mapref",&data);RPG_CU_FNC_A_PTR_CHECK(data)
		CU_ASSERT_STRING_EQUAL( "", (char *)data );
	}

}
Exemple #10
0
static void test_write_lon(const struct nmea_angle_t * t, const char * outcome)
{
	enum { SIZE = 128 };
	int rc;
	char buf[SIZE];

	memset(buf, 0, sizeof(buf));
	rc = nmea_write_lonitude(buf, SIZE, t);

	CU_ASSERT_EQUAL(rc, (int)strlen(outcome));
	CU_ASSERT_STRING_EQUAL(buf, outcome);
}
Exemple #11
0
static void test_nmea_fix_write(const struct nmea_fix_t * t, uint32_t ni, uint32_t nd, const char * outcome)
{
	enum { SIZE = 128 };
	int rc;
	char buf[SIZE];

	memset(buf, 0, sizeof(buf));
	rc = nmea_fix_write(buf, SIZE, t, ni, nd);

	CU_ASSERT_EQUAL(rc, (int)strlen(outcome));
	CU_ASSERT_STRING_EQUAL(buf, outcome);
}
Exemple #12
0
static void test_wkb_out_polygon(void)
{
	cu_wkb("SRID=4;POLYGON((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0))");
	CU_ASSERT_STRING_EQUAL(s,"00A000000300000004000000010000000500000000000000000000000000000000000000000000000000000000000000003FF000000000000000000000000000003FF00000000000003FF000000000000000000000000000003FF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");

	cu_wkb("SRID=14;POLYGON((0 0 0 1,0 1 0 2,1 1 0 3,1 0 0 4,0 0 0 5))");
	CU_ASSERT_STRING_EQUAL(s,"00E00000030000000E00000001000000050000000000000000000000000000000000000000000000003FF000000000000000000000000000003FF0000000000000000000000000000040000000000000003FF00000000000003FF0000000000000000000000000000040080000000000003FF00000000000000000000000000000000000000000000040100000000000000000000000000000000000000000000000000000000000004014000000000000");

	cu_wkb("SRID=4;POLYGON((0 0 0 1,0 1 0 2,1 1 0 3,1 0 0 4,0 0 0 5))");
	CU_ASSERT_STRING_EQUAL(s,"00E00000030000000400000001000000050000000000000000000000000000000000000000000000003FF000000000000000000000000000003FF0000000000000000000000000000040000000000000003FF00000000000003FF0000000000000000000000000000040080000000000003FF00000000000000000000000000000000000000000000040100000000000000000000000000000000000000000000000000000000000004014000000000000");

	cu_wkb("POLYGON EMPTY");
	CU_ASSERT_STRING_EQUAL(s,"000000000300000000");

	/*
	*  POLYGON with EMPTY shell
	*  See http://http://trac.osgeo.org/postgis/ticket/937
	*/
	cu_wkb_from_hexwkb("01030000000100000000000000");
	CU_ASSERT_STRING_EQUAL(s,"00000000030000000100000000");
}
void jobConCombiner1Archivo1BloqueYConMapEjecutado_pedirSiguienteTarea_devuelveTareaReduce()
{
	t_job *job = newJob(CON_COMBINER);
	jobAgregarArchivoMDFS(job,"/holy.txt",1);

	t_tarea *tarea1 = jobObtenerSiguienteTarea(job);
	tareaMarcarEnEjecucion(tarea1, newNodo("nodo1", "192.168.1.101", "5001"),"archivo1");
	tareaMarcarFinalizada(tarea1);

	t_tarea *tarea2 = jobObtenerSiguienteTarea(job);

	CU_ASSERT_TRUE(tareaEsReduce(tarea2));

	t_list *archivosRemotos = tareaReduceObtenerArchivosRemotos(tarea2);

	t_archivoRemoto *archivo = list_get(archivosRemotos,0);

	CU_ASSERT_EQUAL(list_size(archivosRemotos),1);
	CU_ASSERT_STRING_EQUAL(archivoRemotoObtenerNodo(archivo)->nombre,"nodo1");
	CU_ASSERT_STRING_EQUAL(archivoRemotoObtenerNombreArchivo(archivo),"archivo1");
}
static void test_info(void) {
	belle_sdp_info_t* lTmp;
	belle_sdp_info_t* l_info = belle_sdp_info_parse("i=A Seminar on the session description protocol");
	char* l_raw_info = belle_sip_object_to_string(BELLE_SIP_OBJECT(l_info));
	belle_sip_object_unref(BELLE_SIP_OBJECT(l_info));
	lTmp = belle_sdp_info_parse(l_raw_info);
	l_info = BELLE_SDP_INFO(belle_sip_object_clone(BELLE_SIP_OBJECT(lTmp)));
	belle_sip_object_unref(BELLE_SIP_OBJECT(lTmp));
	CU_ASSERT_STRING_EQUAL(belle_sdp_info_get_value(l_info), "A Seminar on the session description protocol");
	belle_sip_object_unref(BELLE_SIP_OBJECT(l_info));
	belle_sip_free(l_raw_info);
}
Exemple #15
0
static void test_wkt_in_polyhedralsurface(void)
{
	s = "POLYHEDRALSURFACE(((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,0 0 1,0 0 0)),((1 0 0,0 1 0,0 0 1,1 0 0)))";
	r = cu_wkt_in(s, WKT_EXTENDED);
	CU_ASSERT_STRING_EQUAL(r,s);
	//printf("\nIN:  %s\nOUT: %s\n",s,r);
	lwfree(r);

	s = "POLYHEDRALSURFACE Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,0 0 1,0 0 0)),((1 0 0,0 1 0,0 0 1,1 0 0)))";
	r = cu_wkt_in(s, WKT_ISO);
	CU_ASSERT_STRING_EQUAL(r,s);
	//printf("\nIN:  %s\nOUT: %s\n",s,r);
	lwfree(r);

	s = "POLYHEDRALSURFACE(((0 1 2,3 4 5,6 7,0 1 2)))";
	r = cu_wkt_in(s, WKT_ISO);
	CU_ASSERT_STRING_EQUAL(r,"can not mix dimensionality in a geometry");
	//printf("\nIN:  %s\nOUT: %s\n",s,r);
	lwfree(r);

}
void puedeEscribirRegistro()
{
	Archivo *archivoEscritura = (Archivo *) newArchivoLocal(PATH_ARCHIVO_ESCRITURA, ESCRITURA);

	escribirRegistro(archivoEscritura, NUEVO_REGISTRO_CON_SALTO_DE_LINEA);
	cerrarArchivo(archivoEscritura);

	Archivo *archivoLectura = (Archivo *) newArchivoLocal(PATH_ARCHIVO_ESCRITURA, LECTURA);
	buffer = obtenerRegistro(archivoLectura);

	CU_ASSERT_STRING_EQUAL(buffer, NUEVO_REGISTRO_CON_SALTO_DE_LINEA);
}
Exemple #17
0
static
void test_normal_bin2str()
{
    uint8_t b[] = {0x00,0x09,0x0A,0x0F};
    char* s = "00090a0f";
    char buffer[MAX_BUFFER_SIZE];
    int32_t ret;
    memset(buffer,0,sizeof(buffer));
    ret = bin2str(b,sizeof(b),buffer,sizeof(buffer));
    CU_ASSERT_EQUAL(ret,SUCCESS);
    CU_ASSERT_STRING_EQUAL(buffer,s);
}
Exemple #18
0
static void test_list_set(void)
{
	struct property_list_t list;

	CU_ASSERT_EQUAL(proplist_init(&list), 0);
	CU_ASSERT_EQUAL(list.num, 0);
	CU_ASSERT_EQUAL(proplist_set(&list, "key", "value"), 0);
	CU_ASSERT_EQUAL(list.num, 1);
	CU_ASSERT_STRING_EQUAL(proplist_value(&list, "key"), "value");
	CU_ASSERT_EQUAL(proplist_set(&list, "key", "value1"), 1);
	CU_ASSERT_EQUAL(list.num, 1);
	CU_ASSERT_STRING_EQUAL(proplist_value(&list, "key"), "value1");
	CU_ASSERT_EQUAL(proplist_set(&list, "key1", NULL), 0);
	CU_ASSERT_EQUAL(list.num, 2);
	CU_ASSERT_EQUAL(proplist_value(&list, "key1"), NULL);
	CU_ASSERT_EQUAL(proplist_set(&list, "key1", "value2"), 1);
	CU_ASSERT_EQUAL(list.num, 2);
	CU_ASSERT_STRING_EQUAL(proplist_value(&list, "key1"), "value2");
	CU_ASSERT_EQUAL(proplist_free(&list), 0);
	CU_ASSERT_EQUAL(list.num, 0);
}
Exemple #19
0
//@strcat:test_int_to_hex3 => [int_to_hex ne retourne pas "0" quand number=0]
void test_int_to_hex3(void)
{
	unsigned int i = 0;
	char* hex = malloc(sizeof(char));
	if (hex == NULL) {
        CU_FAIL("Erreur lors l'allocation de la mémoire pendant le test test_int_to_hex3.");
        return;
  }
	int_to_hex(i,hex);
	CU_ASSERT_STRING_EQUAL(hex,"0");
	free(hex);
}
static void test_headers(void) {
	belle_sip_uri_t *  L_uri = belle_sip_uri_parse("sip:192.168.0.1?toto=titi");
	char* l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
	belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
	L_uri = belle_sip_uri_parse(l_raw_uri);
	belle_sip_free(l_raw_uri);
	CU_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_uri_get_header(L_uri,"toto"));
	CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_header(L_uri,"toto"), "titi");

	CU_ASSERT_PTR_NULL(belle_sip_uri_get_header(L_uri,"bla"));
	belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
	L_uri = belle_sip_uri_parse("sip:192.168.0.1?toto=titi&header2=popo&header3=");
	l_raw_uri = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_uri));
	belle_sip_object_unref(BELLE_SIP_OBJECT(L_uri));
	L_uri = belle_sip_uri_parse(l_raw_uri);
	belle_sip_free(l_raw_uri);

	CU_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_uri_get_header(L_uri,"toto"));
	CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_header(L_uri,"header2"), "popo");
	belle_sip_object_unref(L_uri);
}
void debePoderObtenerElSiguienteRegistro()
{
	inicializar();

	buffer = obtenerRegistro(archivo);
	free(buffer);
	buffer = obtenerRegistro(archivo);

	CU_ASSERT_STRING_EQUAL(buffer, REGISTRO2);

	limpiar();
}
Exemple #22
0
/**
 * @brief test behaviour name
 */
static void testKnownBehaviours (void)
{
	uiBehaviour_t* behaviour;

	behaviour = UI_GetNodeBehaviour("button");
	CU_ASSERT_FATAL(behaviour != nullptr);
	CU_ASSERT_STRING_EQUAL(behaviour->name, "button");

	/* first one */
	behaviour = UI_GetNodeBehaviour("");
	CU_ASSERT(behaviour != nullptr);

	/* last one */
	behaviour = UI_GetNodeBehaviour("zone");
	CU_ASSERT_FATAL(behaviour != nullptr);
	CU_ASSERT_STRING_EQUAL(behaviour->name, "zone");

	/* unknown */
	behaviour = UI_GetNodeBehaviour("dahu");
	CU_ASSERT(behaviour == nullptr);
}
Exemple #23
0
static void test_wkt_in_multipolygon(void)
{
	s = "MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
	r = cu_wkt_in(s, WKT_SFSQL);
	CU_ASSERT_STRING_EQUAL(r,s);
	//printf("\nIN:  %s\nOUT: %s\n",s,r);
	lwfree(r);

	s = "MULTIPOLYGON(((0 0,0 10,10 10,0 0),(1 1,1 2,2 2,1 1)),((-10 -10,-10 -5,-5 -5,-10 -10)))";
	r = cu_wkt_in(s, WKT_SFSQL);
	CU_ASSERT_STRING_EQUAL(r,s);
	//printf("\nIN:  %s\nOUT: %s\n",s,r);
	lwfree(r);

	s = "SRID=4;MULTIPOLYGON(((0 0,0 1,1 1,0 0)))";
	r = cu_wkt_in(s, WKT_EXTENDED);
	CU_ASSERT_STRING_EQUAL(r,s);
	//printf("\nIN:  %s\nOUT: %s\n",s,r);
	lwfree(r);

}
Exemple #24
0
void test_push_strings_to_stack(void) {
    CryStack stack;

    stack = CryStack_init();

    CryStack_push(stack, CryData_string("value1"));
    CryStack_push(stack, CryData_string("value2"));
    CryStack_push(stack, CryData_string("value3"));
    CryStack_push(stack, CryData_string("value4"));
    CryStack_push(stack, CryData_string("value5"));

    CU_ASSERT_STRING_EQUAL(stack->next->data->value.string,                         "value5");
    CU_ASSERT_STRING_EQUAL(stack->next->next->data->value.string,                   "value4");
    CU_ASSERT_STRING_EQUAL(stack->next->next->next->data->value.string,             "value3");
    CU_ASSERT_STRING_EQUAL(stack->next->next->next->next->data->value.string,       "value2");
    CU_ASSERT_STRING_EQUAL(stack->next->next->next->next->next->data->value.string, "value1");
    CU_ASSERT_EQUAL(stack->next->next->next->next->next->next,                      NULL    );

    CryStack_free(stack);
    CU_ASSERT_EQUAL(data_allocated, 0);
}
static void test_email(void) {
	belle_sdp_email_t* lTmp;
	belle_sdp_email_t* l_email = belle_sdp_email_parse("e= jehan <*****@*****.**>");
	char* l_raw_email = belle_sip_object_to_string(BELLE_SIP_OBJECT(l_email));
	belle_sip_object_unref(BELLE_SIP_OBJECT(l_email));
	lTmp = belle_sdp_email_parse(l_raw_email);
	l_email = BELLE_SDP_EMAIL(belle_sip_object_clone(BELLE_SIP_OBJECT(lTmp)));
	belle_sip_object_unref(BELLE_SIP_OBJECT(lTmp));
	CU_ASSERT_STRING_EQUAL(belle_sdp_email_get_value(l_email), " jehan <*****@*****.**>");
	belle_sip_object_unref(BELLE_SIP_OBJECT(l_email));
	belle_sip_free(l_raw_email);
}
Exemple #26
0
static void
test_gen_iso8601(void)
{
    static const char DATETIME_UTC[] = "2010-11-26T03:22:02Z";
    static const time_t TIMET = 1290741722;
    char buf[30];
    int r;

    r = time_to_iso8601(TIMET, buf, sizeof(buf));
    CU_ASSERT_EQUAL(r, 20);
    CU_ASSERT_STRING_EQUAL(buf, DATETIME_UTC);
}
Exemple #27
0
static void test_ps_format(void)
{
    char       buf[128];
    prod_spec  ps;
    const char expect[] = "{HDS, \"foo\"}";
    const char nada[] = "(null)";

    ps.feedtype = HDS;
    ps.pattern = "foo";

    int status = ps_format(&ps, NULL, sizeof(buf));
    CU_ASSERT_EQUAL(status, -1);

    status = ps_format(NULL, buf, sizeof(buf));
    CU_ASSERT_EQUAL(status, strlen(nada));
    CU_ASSERT_STRING_EQUAL(buf, nada);

    status = ps_format(&ps, buf, sizeof(buf));
    CU_ASSERT_EQUAL(status, strlen(expect));
    CU_ASSERT_STRING_EQUAL(buf, expect);
}
void t_mutable_string_copy(void) {
	mutable_string_t a;
	mutable_string_t b;

	CU_ASSERT_PTR_NOT_NULL(mutable_string_init(&a));
	CU_ASSERT_PTR_NOT_NULL(mutable_string_init(&b));

	CU_ASSERT_PTR_NOT_NULL(mutable_string_assign(&a, TEST_STR_1));
	CU_ASSERT_PTR_NOT_NULL(mutable_string_assign(&b, TEST_APPEND_WHOLE));

	CU_ASSERT_STRING_EQUAL(MUTSTR(&a), TEST_STR_1);
	CU_ASSERT_STRING_EQUAL(MUTSTR(&b), TEST_APPEND_WHOLE);

	CU_ASSERT_PTR_NOT_NULL(mutable_string_copy(&b, &a));

	CU_ASSERT_STRING_EQUAL(MUTSTR(&a), TEST_STR_1);
	CU_ASSERT_STRING_EQUAL(MUTSTR(&b), TEST_STR_1);

	mutable_string_free(&a);
	mutable_string_free(&b);
}
Exemple #29
0
static void test_ptarray_append_point(void)
{
	LWLINE *line;
	char *wkt;
	POINT4D p;

	line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,1 1)"));
	p.x = 1; 
	p.y = 1;
	ptarray_append_point(line->points, &p, LW_TRUE);
	wkt = lwgeom_to_text(lwline_as_lwgeom(line));
	CU_ASSERT_STRING_EQUAL(wkt,"LINESTRING(0 0,1 1,1 1)");
	lwfree(wkt);

	ptarray_append_point(line->points, &p, LW_FALSE);
	wkt = lwgeom_to_text(lwline_as_lwgeom(line));
	CU_ASSERT_STRING_EQUAL(wkt,"LINESTRING(0 0,1 1,1 1)");
	lwfree(wkt);

	lwline_free(line);
}
Exemple #30
0
void test_rf_set_element_new_string() {
	char a[] = "a"; //Test valid element
	char mv[] = "\x94"; //Test valid element with mutated vowel
	char em[] = ""; //Test empty value

	rf_SetElement *element_a = rf_set_element_new_string(a);
	rf_SetElement *element_mv = rf_set_element_new_string(mv);
	rf_SetElement *element_em = rf_set_element_new_string(em);

	CU_ASSERT_EQUAL(element_a->type, RF_SET_ELEMENT_TYPE_STRING);
	CU_ASSERT_EQUAL(element_mv->type, RF_SET_ELEMENT_TYPE_STRING);
	CU_ASSERT_EQUAL(element_em->type, RF_SET_ELEMENT_TYPE_STRING);

	CU_ASSERT_STRING_EQUAL(element_a->value.string, a);
	CU_ASSERT_STRING_EQUAL(element_mv->value.string, mv);
	CU_ASSERT_STRING_EQUAL(element_em->value.string, em);

	rf_set_element_free(element_a);
	rf_set_element_free(element_mv);
	rf_set_element_free(element_em);
}