Fix the bug with EET_T_UNKNOW/EET_G_UNKNOWN that did break the CVS.

Add a test to detect this bug and caught another one, not yet solved
with dump/undump of EET_T_UNKNOW/EET_G_UNKNOWN.


SVN revision: 34925
This commit is contained in:
Cedric BAIL 2008-06-27 15:26:53 +00:00
parent 0db98a4d3f
commit d16456e061
2 changed files with 58 additions and 4 deletions

View File

@ -1745,7 +1745,7 @@ _eet_data_dump_encode(Eet_Dictionary *ed,
break;
}
if ((node->type > EET_G_UNKNOWN) && (node->type < EET_G_LAST))
if ((node->type >= EET_G_UNKNOWN) && (node->type < EET_G_LAST))
chnk = eet_data_chunk_new(ds->data, ds->pos, node->name, EET_T_UNKNOW, node->type);
else
chnk = eet_data_chunk_new(ds->data, ds->pos, node->name, node->type, EET_G_UNKNOWN);
@ -2314,7 +2314,7 @@ _eet_data_descriptor_decode(const Eet_Dictionary *ed,
memset(&echnk, 0, sizeof(Eet_Data_Chunk));
eet_data_chunk_get(ed, &echnk, p, size);
if (!echnk.name) return 0;
if (!echnk.name) goto error;
/* get the data */
data_ret = _eet_data_descriptor_decode(ed,
NULL,
@ -2712,14 +2712,14 @@ eet_data_put_array(Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Elemen
static void
eet_data_put_unknown(Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Stream *ds, void *data_in)
{
void *data = NULL;
int size;
void *data;
if (IS_SIMPLE_TYPE(ede->type))
data = eet_data_put_type(ed, ede->type, data_in, &size);
else if (ede->subtype)
{
if (*((char **)(((char *)data_in))))
if (*((char **)data_in))
data = _eet_data_descriptor_encode(ed,
ede->subtype,
*((char **)((char *)(data_in))),

View File

@ -35,6 +35,8 @@ struct _Eet_Test_Basic_Type
unsigned short us;
unsigned int ui;
unsigned long long ul;
Eet_Test_Basic_Type *empty;
Eet_Test_Basic_Type *with;
};
#define EET_TEST_CHAR 0x42
@ -108,6 +110,33 @@ _eet_test_basic_set(Eet_Test_Basic_Type *res, int i)
res->us = EET_TEST_SHORT;
res->ui = EET_TEST_INT;
res->ul = EET_TEST_LONG_LONG;
res->empty = NULL;
res->with = NULL;
if (i == 0)
{
Eet_Test_Basic_Type *tmp;
tmp = malloc(sizeof (Eet_Test_Basic_Type));
fail_if(!tmp);
res->with = tmp;
tmp->c = EET_TEST_CHAR;
tmp->s = EET_TEST_SHORT;
tmp->i = EET_TEST_INT + i + 1;
tmp->l = EET_TEST_LONG_LONG;
tmp->str = EET_TEST_STRING;
tmp->istr = EET_TEST_STRING;
tmp->f1 = - EET_TEST_FLOAT;
tmp->d = - EET_TEST_DOUBLE;
tmp->f2 = EET_TEST_FLOAT4;
tmp->uc = EET_TEST_CHAR;
tmp->us = EET_TEST_SHORT;
tmp->ui = EET_TEST_INT;
tmp->ul = EET_TEST_LONG_LONG;
tmp->empty = NULL;
tmp->with = NULL;
}
}
static void
@ -137,6 +166,28 @@ _eet_test_basic_check(Eet_Test_Basic_Type *result, int i)
tmp = (result->d + EET_TEST_DOUBLE);
if (tmp < 0) tmp = -tmp;
fail_if(tmp > 0.00005);
fail_if(result->empty != NULL);
if (i == 0)
{
Eet_Test_Basic_Type *tmp;
tmp = result->with;
fail_if(tmp == NULL);
fail_if(tmp->c != EET_TEST_CHAR);
fail_if(tmp->s != EET_TEST_SHORT);
fail_if(tmp->i != EET_TEST_INT + i + 1);
fail_if(tmp->l != EET_TEST_LONG_LONG);
fail_if(strcmp(tmp->str, EET_TEST_STRING) != 0);
fail_if(strcmp(tmp->istr, EET_TEST_STRING) != 0);
fail_if(tmp->uc != EET_TEST_CHAR);
fail_if(tmp->us != EET_TEST_SHORT);
fail_if(tmp->ui != EET_TEST_INT);
fail_if(tmp->ul != EET_TEST_LONG_LONG);
}
else
fail_if(result->with != NULL);
}
static void
@ -155,6 +206,9 @@ _eet_build_basic_descriptor(Eet_Data_Descriptor *edd)
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Eet_Test_Basic_Type, "us", us, EET_T_USHORT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Eet_Test_Basic_Type, "ui", ui, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Eet_Test_Basic_Type, "ul", ul, EET_T_ULONG_LONG);
EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "empty", empty, edd);
EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "with", with, edd);
}
START_TEST(eet_test_basic_data_type_encoding_decoding)