Revision: 14667
Author: adrian.chadd
Date: Sun May 16 06:52:14 2010
Log: Add a test case for the insertion logic. This handles the
case of inserting in the middle of an already filled out array;
it doesn't test the behaviour of inserting -past- the last
member of the array.


http://code.google.com/p/lusca-cache/source/detail?r=14667

Modified:
 /branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c

=======================================
--- /branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c Sun May 16 03:29:20 2010 +++ /branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c Sun May 16 06:52:14 2010
@@ -90,10 +90,41 @@
        vector_done(&v);
 }

+/* ** */
+ATF_TC(Vector_insert_1);
+ATF_TC_HEAD(Vector_insert_1, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Vector insert checks");
+}
+ATF_TC_BODY(Vector_insert_1, tc)
+{
+       Vector v;
+       int i, *n;
+
+       vector_init(&v, sizeof(int), 128);
+       for (i = 0; i < 16; i++) {
+               n = (int *) vector_append(&v);
+               ATF_REQUIRE(n != NULL);
+               (*n) = i;
+               //printf("%d: %p; used %d\n", i, n, v.used_count);
+       }
+
+       for (i = 0; i < 32; i += 2) {
+               n = (int *) vector_insert(&v, i);
+       }
+       for (i = 0; i < v.used_count; i++) {
+               n = (int *) vector_get_real(&v, i);
+               ATF_REQUIRE(n != NULL);
+               //printf("%d: %d (%d)\n", i, (*n), i / 2);
+               ATF_REQUIRE_EQ( (*n), i / 2);
+       }
+}
+

 ATF_TP_ADD_TCS(tp)
 {
         ATF_TP_ADD_TC(tp, Vector_test_1);
         ATF_TP_ADD_TC(tp, Vector_test_2);
         ATF_TP_ADD_TC(tp, Vector_test_3);
-}
+        ATF_TP_ADD_TC(tp, Vector_insert_1);
+}

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to