Fix bug in GListTruncate, extends templates tests
authorteodor <teodor>
Wed, 1 Oct 2008 09:40:35 +0000 (09:40 +0000)
committerteodor <teodor>
Wed, 1 Oct 2008 09:40:35 +0000 (09:40 +0000)
expected/tmpl
glist.c
tmpltest.c

index 7585c3b..d7dd7a7 100644 (file)
@@ -64,3 +64,53 @@ NOT DEFINED zeroID-NO
 
        
 
+================================================
+id: 23 - <i>simple</i>
+idhex: 0x00000017 - <b>HEX
+idhexdef: HEX(0x00000017) -<
+ndef: 
+ndef def: Wow
+empty 
+empty def: "EmptyId" - default
+zero 0
+zero def: 0
+
+ID-YES
+DEFINED ID-YES
+NOT ID-NO
+NOT DEFINED ID-NO
+
+ndefID-NO
+DEFINED ndefID-NO
+DEFINED ndefID-YES
+DEFINED ndefID-YES
+
+
+EmptyId-NO
+DEFINED EmptyId-NO
+DEFINED EmptyId-YES
+DEFINED EmptyId-YES
+
+zeroID-NO
+DEFINED zeroID-YES
+DEFINED zeroID-YES
+NOT DEFINED zeroID-NO
+
+
+       
+               ID!=0 && defined(zeroID) - right
+       
+
+
+
+
+       1/1. odd:true even:false 
+       
+       FIRST LAST id: 23 1234:FOO/1234
+
+       
+               <ol>
+                       <li>Again 1
+               </ol>
+       
+
diff --git a/glist.c b/glist.c
index 59213ac..9e79963 100644 (file)
--- a/glist.c
+++ b/glist.c
@@ -118,11 +118,15 @@ GListDelete(GList *l, GListCell *c) {
                l->head = c->next;
                if ( l->head ) 
                        l->head->prev = NULL;
+               else
+                       l->tail = NULL;
        } else if ( l->tail == c ) {
                tassert( c->next == NULL );
                l->tail = c->prev;
                if ( l->tail )
                        l->tail->next = NULL;
+               else
+                       l->head = NULL;
        } else {
                c->prev->next = c->next;
                c->next->prev = c->prev;
@@ -281,6 +285,7 @@ GListTruncate(GList *l, int n) {
                GListFreeCell(l, c);
        }
 
+       checkGList(l);
        return l;
 }
 
index 6b54a3d..5c3986f 100644 (file)
@@ -108,8 +108,24 @@ main(int argn, char *argv[]) {
        template.printString = outfunc;
        printTemplate( &template );
 
+       resetTemplate(&template);
+
+       setTemplateValueInt(&template, "ID", 23);
+       setTemplateValueUndefined(&template, "emptyID");
+       setTemplateValueInt(&template, "zeroid", 0);
+       addTemplateRow(&template, "outerLoop");
+       setTemplateValueString(&template, "outerLoop.data1", "ha1");
+       setTemplateValueInt(&template, "outerLoop.data1", 1234);
+       setTemplateValueString(&template, "outerLoop.data2", "FOO");
+       addTemplateRow(&template, "outerLoop.innerLoop");
+               setTemplateValueString(&template, "outerLoop.innerLoop.camenty", "Again 1");
+
+       fputs("================================================\n", stdout);
+       printTemplate( &template );
+
        resetTemplate(&template);
        freeTemplate(&template);
+
        return 0;
 }