Revision: 14673
Author: adrian.chadd
Date: Sun May 16 16:08:51 2010
Log: Add some bounds check testing to the Vector unit tests.
This tests:
* valid entry;
* out of bounds entry, but within the pre-allocated area;
* out of bounds entry, and outside the pre-allocated area.
http://code.google.com/p/lusca-cache/source/detail?r=14673
Modified:
/branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c
=======================================
--- /branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c Sun May 16 06:52:14
2010
+++ /branches/LUSCA_HEAD/test-suite/atf/lib_Vector.c Sun May 16 16:08:51
2010
@@ -120,11 +120,32 @@
}
}
+ATF_TC(Vector_bounds_1);
+ATF_TC_HEAD(Vector_bounds_1, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test out-of-bounds access fails");
+}
+
+ATF_TC_BODY(Vector_bounds_1, tc)
+{
+ Vector v;
+ int *n;
+
+ vector_init(&v, sizeof(int), 128);
+ (void) vector_append(&v);
+ ATF_REQUIRE(vector_get_real(&v, 0) != NULL);
+ ATF_REQUIRE(vector_get_real(&v, 1) == NULL);
+ ATF_REQUIRE(vector_get_real(&v, 2) == NULL);
+ ATF_REQUIRE(vector_get_real(&v, 129) == NULL);
+ vector_done(&v);
+}
+
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_bounds_1);
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.