From: <dg...@su...> - 2009-01-11 17:27:50
|
Author: dgollub Date: Sun Jan 11 18:27:09 2009 New Revision: 5111 URL: http://www.opensync.org/changeset/5111 Log: Testcase for #1021 But not reproducible on my development platform. Added: format-plugins/xmlformat/trunk/tests/data/compare/ format-plugins/xmlformat/trunk/tests/data/compare/contact1.xml format-plugins/xmlformat/trunk/tests/data/compare/contact2.xml Modified: format-plugins/xmlformat/trunk/src/xmlformat.c format-plugins/xmlformat/trunk/src/xmlformat.h format-plugins/xmlformat/trunk/tests/check_xmlformat.c Modified: format-plugins/xmlformat/trunk/src/xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.c Sun Jan 11 18:24:41 2009 (r5110) +++ format-plugins/xmlformat/trunk/src/xmlformat.c Sun Jan 11 18:27:09 2009 (r5111) @@ -125,7 +125,7 @@ } -static OSyncConvCmpResult compare_contact(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *userdata) +OSyncConvCmpResult compare_contact(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *userdata) { char* keys_content[] = {"Content", NULL}; char* keys_name[] = {"FirstName", "LastName", NULL}; Modified: format-plugins/xmlformat/trunk/src/xmlformat.h ============================================================================== --- format-plugins/xmlformat/trunk/src/xmlformat.h Sun Jan 11 18:24:41 2009 (r5110) +++ format-plugins/xmlformat/trunk/src/xmlformat.h Sun Jan 11 18:27:09 2009 (r5111) @@ -75,5 +75,7 @@ osync_bool marshal_xmlformat(const char *input, unsigned int inpsize, OSyncMarshal *marshal, void *userdata, OSyncError **error); osync_bool demarshal_xmlformat(OSyncMarshal *marshal, char **output, unsigned int *outpsize, void *userdata, OSyncError **error); +OSyncConvCmpResult compare_contact(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *userdata); + #endif /* XMLFORMAT_H_ */ Modified: format-plugins/xmlformat/trunk/tests/check_xmlformat.c ============================================================================== --- format-plugins/xmlformat/trunk/tests/check_xmlformat.c Sun Jan 11 18:24:41 2009 (r5110) +++ format-plugins/xmlformat/trunk/tests/check_xmlformat.c Sun Jan 11 18:27:09 2009 (r5111) @@ -238,6 +238,50 @@ } END_TEST +START_TEST (xmlformat_compare_ticket1021) +{ + char *testbed = setup_testbed("compare"); + + char *buffer1; + char *buffer2; + unsigned int size1; + unsigned int size2; + OSyncError *error = NULL; + OSyncConvCmpResult result; + + + fail_unless(osync_file_read( "contact1.xml", &buffer1, &size1, &error), NULL); + + OSyncXMLFormat *xmlformat1 = osync_xmlformat_parse(buffer1, size1, &error); + fail_unless(xmlformat1 != NULL, NULL); + fail_unless(error == NULL, NULL); + + fail_unless(osync_file_read( "contact2.xml", &buffer2, &size2, &error), NULL); + + OSyncXMLFormat *xmlformat2 = osync_xmlformat_parse(buffer2, size2, &error); + fail_unless(xmlformat2 != NULL, NULL); + fail_unless(error == NULL, NULL); + + g_free(buffer1); + g_free(buffer2); + + result = compare_contact((char*)xmlformat1, osync_xmlformat_size(), + (char*)xmlformat2, osync_xmlformat_size(), NULL); + fail_unless(result == OSYNC_CONV_DATA_SAME, NULL); + + result = compare_contact((char*)xmlformat2, osync_xmlformat_size(), + (char*)xmlformat1, osync_xmlformat_size(), NULL); + fail_unless(result == OSYNC_CONV_DATA_SAME, NULL); + + + osync_xmlformat_unref((OSyncXMLFormat*)xmlformat1); + osync_xmlformat_unref((OSyncXMLFormat*)xmlformat2); + + destroy_testbed(testbed); +} +END_TEST + + START_TEST (xmlformat_marshal) { char *testbed = setup_testbed("xmlformats"); @@ -309,6 +353,7 @@ create_case(s, "xmlformat_compare_test", xmlformat_compare_test); create_case(s, "xmlformat_compare_field2null", xmlformat_compare_field2null); create_case(s, "xmlformat_compare_ignore_fields", xmlformat_compare_ignore_fields); + create_case(s, "xmlformat_compare_ticket1021", xmlformat_compare_ticket1021); create_case(s, "xmlformat_marshal", xmlformat_marshal); create_case(s, "xmlformat_demarshal", xmlformat_demarshal); Added: format-plugins/xmlformat/trunk/tests/data/compare/contact1.xml ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ format-plugins/xmlformat/trunk/tests/data/compare/contact1.xml Sun Jan 11 18:27:09 2009 (r5111) @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<contact> + <FormattedName> + <Content>ffffffffff llllllllll</Content> + </FormattedName> + <Name> + <LastName>llllllllll</LastName> + <FirstName>ffffffffff</FirstName> + </Name> + <Telephone Location="Home"> + <Content>hhhhhhhhhh</Content> + </Telephone> + <Telephone Location="Work"> + <Content>wwwwwwwwww</Content> + </Telephone> +</contact> Added: format-plugins/xmlformat/trunk/tests/data/compare/contact2.xml ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ format-plugins/xmlformat/trunk/tests/data/compare/contact2.xml Sun Jan 11 18:27:09 2009 (r5111) @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<contact> + <FormattedName> + <Content>ffffffffff llllllllll</Content> + </FormattedName> + <Name> + <LastName>llllllllll</LastName> + <FirstName>ffffffffff</FirstName> + </Name> + <Telephone Location="Home"> + <Content>hhhhhhhhhh</Content> + </Telephone> + <Telephone Location="Work"> + <Content>wwwwwwwwww</Content> + </Telephone> +</contact> |