Revision: 14684
Author: adrian.chadd
Date: Thu May 20 03:21:33 2010
Log: Add in test cases for vector_shrink().
http://code.google.com/p/lusca-cache/source/detail?r=14684
Modified:
/branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c
=======================================
--- /branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c Sun May 16 16:08:51
2010
+++ /branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c Thu May 20 03:21:33
2010
@@ -140,6 +140,46 @@
vector_done(&v);
}
+ATF_TC(Vector_shrink_1);
+ATF_TC_HEAD(Vector_shrink_1, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test vector_shrink() works as
advertised");
+}
+ATF_TC_BODY(Vector_shrink_1, tc)
+{
+ Vector v;
+ int *n;
+ int i;
+
+ vector_init(&v, sizeof(int), 128);
+
+ /* Allocate */
+ for (i = 0; i < 10; i++) {
+ n = (int *) vector_append(&v);
+ (*n) = i;
+ }
+
+ /* Shrinking the array past the array bounds should be a no-op */
+ vector_shrink(&v, 12);
+ ATF_REQUIRE(vector_numentries(&v) == 10);
+ vector_shrink(&v, 11);
+ ATF_REQUIRE(vector_numentries(&v) == 10);
+
+ /* Shrinking the array on the array bounds should be a no-op */
+ vector_shrink(&v, 10);
+ ATF_REQUIRE(vector_numentries(&v) == 10);
+
+ /* Shrinking the array before should shrink */
+ vector_shrink(&v, 9);
+ ATF_REQUIRE(vector_numentries(&v) == 9);
+
+ vector_shrink(&v, 2);
+ ATF_REQUIRE(vector_numentries(&v) == 2);
+
+ vector_shrink(&v, 0);
+ ATF_REQUIRE(vector_numentries(&v) == 0);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -148,4 +188,5 @@
ATF_TP_ADD_TC(tp, Vector_test_3);
ATF_TP_ADD_TC(tp, Vector_bounds_1);
ATF_TP_ADD_TC(tp, Vector_insert_1);
-}
+ ATF_TP_ADD_TC(tp, Vector_shrink_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.