You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/03/24 23:02:51 UTC

[lucy-commits] svn commit: r1085159 - in /incubator/lucy/trunk/core/Lucy: Plan/FieldType.c Test/Plan/TestFieldType.c

Author: marvin
Date: Thu Mar 24 22:02:51 2011
New Revision: 1085159

URL: http://svn.apache.org/viewvc?rev=1085159&view=rev
Log:
LUCY-138 ftype_equals.patch
Have FType_Equals() return false whenever classes for "self" and "other" don't
match.

Modified:
    incubator/lucy/trunk/core/Lucy/Plan/FieldType.c
    incubator/lucy/trunk/core/Lucy/Test/Plan/TestFieldType.c

Modified: incubator/lucy/trunk/core/Lucy/Plan/FieldType.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Plan/FieldType.c?rev=1085159&r1=1085158&r2=1085159&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Plan/FieldType.c (original)
+++ incubator/lucy/trunk/core/Lucy/Plan/FieldType.c Thu Mar 24 22:02:51 2011
@@ -87,6 +87,7 @@ FType_equals(FieldType *self, Obj *other
 {
     FieldType *evil_twin = (FieldType*)other;
     if (evil_twin == self) return true;
+    if (FType_Get_VTable(self) != FType_Get_VTable(evil_twin)) return false;
     if (self->boost != evil_twin->boost) return false;
     if (!!self->indexed    != !!evil_twin->indexed)    return false;
     if (!!self->stored     != !!evil_twin->stored)     return false;

Modified: incubator/lucy/trunk/core/Lucy/Test/Plan/TestFieldType.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Plan/TestFieldType.c?rev=1085159&r1=1085158&r2=1085159&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Plan/TestFieldType.c (original)
+++ incubator/lucy/trunk/core/Lucy/Test/Plan/TestFieldType.c Thu Mar 24 22:02:51 2011
@@ -26,7 +26,16 @@ DummyFieldType*
 DummyFieldType_new()
 {
     DummyFieldType *self = (DummyFieldType*)VTable_Make_Obj(DUMMYFIELDTYPE);
-    return (DummyFieldType*)FType_init(self);
+    return (DummyFieldType*)FType_init((FieldType*)self);
+}
+
+static FieldType*
+S_alt_field_type()
+{
+    ZombieCharBuf *name = ZCB_WRAP_STR("DummyFieldType2", 15);
+    VTable *vtable = VTable_singleton((CharBuf*)name, DUMMYFIELDTYPE);
+    FieldType *self = (FieldType*)VTable_Make_Obj(vtable);
+    return FType_init(self);
 }
 
 static void
@@ -34,6 +43,7 @@ test_Dump_Load_and_Equals(TestBatch *bat
 {
     FieldType   *type          = (FieldType*)DummyFieldType_new();
     FieldType   *other         = (FieldType*)DummyFieldType_new();
+    FieldType   *class_differs = S_alt_field_type();
     FieldType   *boost_differs = (FieldType*)DummyFieldType_new();
     FieldType   *indexed       = (FieldType*)DummyFieldType_new();
     FieldType   *stored        = (FieldType*)DummyFieldType_new();
@@ -48,6 +58,10 @@ test_Dump_Load_and_Equals(TestBatch *bat
 
     TEST_TRUE(batch, FType_Equals(type, (Obj*)other),
         "Equals() true with identical stats");
+    TEST_FALSE(batch, FType_Equals(type, (Obj*)class_differs),
+        "Equals() false with subclass");
+    TEST_FALSE(batch, FType_Equals(type, (Obj*)class_differs),
+        "Equals() false with super class");
     TEST_FALSE(batch, FType_Equals(type, (Obj*)boost_differs),
         "Equals() false with different boost");
     TEST_FALSE(batch, FType_Equals(type, (Obj*)indexed),
@@ -85,7 +99,7 @@ test_Compare_Values(TestBatch *batch)
 void
 TestFType_run_tests()
 {
-    TestBatch *batch = TestBatch_new(7);
+    TestBatch *batch = TestBatch_new(9);
     TestBatch_Plan(batch);
     test_Dump_Load_and_Equals(batch);
     test_Compare_Values(batch);