On Mon, May 23, 2011 at 2:56 PM, <astokes(a)fedoraproject.org> wrote:
+ void testGetNetworkIP(void)
+ {
+ unsigned int i;
+ const char *ip = NULL;
+ for(i=0; i<iface_names.size(); i++) {
+ ip = mh_network_get_ip_address(iface_names[i]);
+ TS_TRACE(ip);
+ TS_ASSERT((is_match("^\\d+\\.\\d+\\.\\d+\\.\\d+",
+ ip)) >= 0);
+ }
+ }
+
You should use a C++ style iterator here and in other similar loops:
for(std::vector<char *>::iterator it = iface_names.begin(); it !=
iface_names.end(); ++it) {
....
}
+#define OVECCOUNT 30
+
+int
+is_match(const char *pattern, const char *subject)
+{
+ int erroroffset;
+ int ovector[OVECCOUNT];
+ const char *error;
+ pcre *re;
+ int rc;
+
+ re = pcre_compile(pattern,
+ 0,
+ &error,
+ &erroroffset,
+ NULL);
+ if (re == NULL) {
+ return PCRE_ERROR_NULL;
+ }
+
+ rc = pcre_exec(
+ re,
+ NULL,
+ subject,
+ strlen(subject),
+ 0,
+ 0,
+ ovector,
+ OVECCOUNT);
+
I know it comes out to the same thing, but to be more explicit about
it, you could use DIMOF(ovector) instead of OVECOUNT.
+#ifndef __MH_TEST_UTILITIES_H
+#define __MH_TEST_UTILITIES_H
+
+extern int is_match(const char *pattern, const char *subject);
Perhaps to more follow a common naming convention, mh_test_is_match() ?
--
Russell Bryant