changeset 119:257a1d314bcd

Bug of insert sort
author Thinker K.F. Li <thinker@branda.to>
date Sun, 14 Sep 2008 21:08:25 +0800
parents c9c6810a96c1
children 5df7403b6fbc
files src/animate.c src/redraw_man.c
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/animate.c	Sun Sep 14 18:53:17 2008 +0800
+++ b/src/animate.c	Sun Sep 14 21:08:25 2008 +0800
@@ -103,6 +103,11 @@
     mb_word_t words[1];
 };
 
+/*! \brief Create a program object.
+ *
+ * \param max_words is maximum number of words the program can hold.
+ * \param rdman is a rdman that show graphics manipulated by it.
+ */
 mb_progm_t *mb_progm_new(int max_words, redraw_man_t *rdman) {
     mb_progm_t *progm;
     int i;
--- a/src/redraw_man.c	Sun Sep 14 18:53:17 2008 +0800
+++ b/src/redraw_man.c	Sun Sep 14 21:08:25 2008 +0800
@@ -43,7 +43,7 @@
 
     for(i = 1; i < num; i++) {
 	val = *(unsigned int *)(elms[i] + off);
-	for(j = i - 1; j > 0; j--) {
+	for(j = i; j > 0; j--) {
 	    if(*(unsigned int *)(elms[j - 1] + off) <= val)
 		break;
 	    elms[j] = elms[j - 1];
@@ -984,6 +984,7 @@
     shape_t shape;
     co_aix x, y;
     co_aix w, h;
+    int trans_cnt;
     int draw_cnt;
 };
 
@@ -1000,6 +1001,7 @@
     dummy->y = y;
     dummy->w = w;
     dummy->h = h;
+    dummy->trans_cnt = 0;
     dummy->draw_cnt = 0;
 
     return (shape_t *)dummy;
@@ -1030,6 +1032,7 @@
 	if(shape->geo)
 	    geo_from_positions(shape->geo, 2, poses);
     }
+    dummy->trans_cnt++;
 }
 
 void sh_dummy_fill(shape_t *shape, cairo_t *cr) {
@@ -1134,16 +1137,20 @@
 	rdman_add_shape(rdman, shapes[i], coords[i]);
     }
     rdman_redraw_all(rdman);
+    CU_ASSERT(dummys[0]->trans_cnt == 1);
+    CU_ASSERT(dummys[1]->trans_cnt == 1);
+    CU_ASSERT(dummys[2]->trans_cnt == 1);
     CU_ASSERT(dummys[0]->draw_cnt == 1);
     CU_ASSERT(dummys[1]->draw_cnt == 1);
     CU_ASSERT(dummys[2]->draw_cnt == 1);
     
     coords[2]->matrix[2] = 100;
     coords[2]->matrix[5] = 100;
+    rdman_coord_changed(rdman, coords[0]);
     rdman_coord_changed(rdman, coords[2]);
     rdman_redraw_changed(rdman);
 
-    CU_ASSERT(dummys[0]->draw_cnt == 1);
+    CU_ASSERT(dummys[0]->draw_cnt == 2);
     CU_ASSERT(dummys[1]->draw_cnt == 2);
     CU_ASSERT(dummys[2]->draw_cnt == 2);