avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mas...@apache.org
Subject svn commit: r1004849 - in /avro/trunk: CHANGES.txt lang/c/src/datum.c lang/c/tests/test_avro_data.c
Date Tue, 05 Oct 2010 22:57:18 GMT
Author: massie
Date: Tue Oct  5 22:57:17 2010
New Revision: 1004849

URL: http://svn.apache.org/viewvc?rev=1004849&view=rev
Log:
AVRO-675.  Bytes and fixed setters don't update datum size (Contributed by Douglas Creager).

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c/src/datum.c
    avro/trunk/lang/c/tests/test_avro_data.c

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1004849&r1=1004848&r2=1004849&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Oct  5 22:57:17 2010
@@ -41,6 +41,10 @@ Avro 1.4.1 (unreleased)
     AVRO-667. GenericArray fails to compare with List. SpecificRecord
     compare gets ClassCastException. (scottcarey & cutting)
 
+    AVRO-675. Bytes and fixed setters don't update datum size.
+    (Douglas Creager via massie)
+
+
 Avro 1.4.0 (31 August 2010)
 
   INCOMPATIBLE CHANGES

Modified: avro/trunk/lang/c/src/datum.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.c?rev=1004849&r1=1004848&r2=1004849&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.c (original)
+++ avro/trunk/lang/c/src/datum.c Tue Oct  5 22:57:17 2010
@@ -169,6 +169,7 @@ static int avro_bytes_set_private(avro_d
 
 	b->free = bytes_free;
 	b->bytes = (char *)bytes;
+	b->size = size;
 	return 0;
 }
 
@@ -562,6 +563,7 @@ static int avro_fixed_set_private(avro_d
 
 	fixed->free = fixed_free;
 	fixed->bytes = (char *)bytes;
+	fixed->size = size;
 	return 0;
 }
 

Modified: avro/trunk/lang/c/tests/test_avro_data.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/test_avro_data.c?rev=1004849&r1=1004848&r2=1004849&view=diff
==============================================================================
--- avro/trunk/lang/c/tests/test_avro_data.c (original)
+++ avro/trunk/lang/c/tests/test_avro_data.c Tue Oct  5 22:57:17 2010
@@ -119,11 +119,26 @@ static int test_bytes(void)
 {
 	char bytes[] = { 0xDE, 0xAD, 0xBE, 0xEF };
 	avro_schema_t writer_schema = avro_schema_bytes();
-	avro_datum_t datum = avro_wrapbytes(bytes, sizeof(bytes));
+	avro_datum_t datum;
+	avro_datum_t expected_datum;
 
+	datum = avro_wrapbytes(bytes, sizeof(bytes));
 	write_read_check(writer_schema, NULL, datum, "bytes");
 	avro_datum_decref(datum);
 	avro_schema_decref(writer_schema);
+
+	datum = avro_wrapbytes(NULL, 0);
+    avro_wrapbytes_set(datum, bytes, sizeof(bytes));
+	expected_datum = avro_wrapbytes(bytes, sizeof(bytes));
+	if (!avro_datum_equal(datum, expected_datum)) {
+		fprintf(stderr,
+		        "Expected equal bytes instances.\n");
+		exit(EXIT_FAILURE);
+	}
+	avro_datum_decref(datum);
+	avro_datum_decref(expected_datum);
+	avro_schema_decref(writer_schema);
+
 	return 0;
 }
 
@@ -313,10 +328,26 @@ static int test_fixed(void)
 {
 	char bytes[] = { 0xD, 0xA, 0xD, 0xA, 0xB, 0xA, 0xB, 0xA };
 	avro_schema_t schema = avro_schema_fixed("msg", sizeof(bytes));
-	avro_datum_t datum = avro_wrapfixed("msg", bytes, sizeof(bytes));
+	avro_datum_t datum;
+	avro_datum_t expected_datum;
+
+	datum = avro_wrapfixed("msg", bytes, sizeof(bytes));
 	write_read_check(schema, NULL, datum, "fixed");
 	avro_datum_decref(datum);
 	avro_schema_decref(schema);
+
+	datum = avro_wrapfixed("msg", NULL, 0);
+    avro_wrapfixed_set(datum, bytes, sizeof(bytes));
+	expected_datum = avro_wrapfixed("msg", bytes, sizeof(bytes));
+	if (!avro_datum_equal(datum, expected_datum)) {
+		fprintf(stderr,
+		        "Expected equal fixed instances.\n");
+		exit(EXIT_FAILURE);
+	}
+	avro_datum_decref(datum);
+	avro_datum_decref(expected_datum);
+	avro_schema_decref(schema);
+
 	return 0;
 }
 



Mime
View raw message