return (0);
}
+/* Verify that a block of memory is filled with the specified byte. */
+int
+assertion_memory_filled_with(const char *file, int line,
+ const void *_v1, const char *vd,
+ size_t l, const char *ld,
+ char b, const char *bd, void *extra)
+{
+ const char *v1 = (const char *)_v1;
+ size_t c = 0;
+ size_t i;
+ (void)ld; /* UNUSED */
+
+ assertion_count(file, line);
+
+ for (i = 0; i < l; ++i) {
+ if (v1[i] == b) {
+ ++c;
+ }
+ }
+ if (c == l)
+ return (1);
+
+ failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd);
+ logprintf(" Only %d bytes were correct\n", (int)c);
+ failure_finish(extra);
+ return (0);
+}
+
/* Verify that the named file exists and is empty. */
int
assertion_empty_file(const char *filename, int line, const char *f1)
/* Not a lot of error checking here; the input better be right. */
out = fopen(name, "wb");
while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) {
- fwrite(buff, 1, rbytes, out);
+ if (fwrite(buff, 1, rbytes, out) != rbytes) {
+ logprintf("Error: fwrite\n");
+ break;
+ }
}
fclose(out);
fclose(in);
return (0);
}
+/* Verify that a block of memory is filled with the specified byte. */
+int
+assertion_memory_filled_with(const char *file, int line,
+ const void *_v1, const char *vd,
+ size_t l, const char *ld,
+ char b, const char *bd, void *extra)
+{
+ const char *v1 = (const char *)_v1;
+ size_t c = 0;
+ size_t i;
+ (void)ld; /* UNUSED */
+
+ assertion_count(file, line);
+
+ for (i = 0; i < l; ++i) {
+ if (v1[i] == b) {
+ ++c;
+ }
+ }
+ if (c == l)
+ return (1);
+
+ failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd);
+ logprintf(" Only %d bytes were correct\n", (int)c);
+ failure_finish(extra);
+ return (0);
+}
+
/* Verify that the named file exists and is empty. */
int
assertion_empty_file(const char *filename, int line, const char *f1)
/* Not a lot of error checking here; the input better be right. */
out = fopen(name, "wb");
while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) {
- fwrite(buff, 1, rbytes, out);
+ if (fwrite(buff, 1, rbytes, out) != rbytes) {
+ logprintf("Error: fwrite\n");
+ break;
+ }
}
fclose(out);
fclose(in);
/* Not a lot of error checking here; the input better be right. */
out = fopen(name, "wb");
while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) {
- fwrite(buff, 1, rbytes, out);
+ if (fwrite(buff, 1, rbytes, out) != rbytes) {
+ logprintf("Error: fwrite\n");
+ break;
+ }
}
fclose(out);
fclose(in);
return (0);
}
+/* Verify that a block of memory is filled with the specified byte. */
+int
+assertion_memory_filled_with(const char *file, int line,
+ const void *_v1, const char *vd,
+ size_t l, const char *ld,
+ char b, const char *bd, void *extra)
+{
+ const char *v1 = (const char *)_v1;
+ size_t c = 0;
+ size_t i;
+ (void)ld; /* UNUSED */
+
+ assertion_count(file, line);
+
+ for (i = 0; i < l; ++i) {
+ if (v1[i] == b) {
+ ++c;
+ }
+ }
+ if (c == l)
+ return (1);
+
+ failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd);
+ logprintf(" Only %d bytes were correct\n", (int)c);
+ failure_finish(extra);
+ return (0);
+}
+
/* Verify that the named file exists and is empty. */
int
assertion_empty_file(const char *filename, int line, const char *f1)
/* Not a lot of error checking here; the input better be right. */
out = fopen(name, "wb");
while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) {
- fwrite(buff, 1, rbytes, out);
+ if (fwrite(buff, 1, rbytes, out) != rbytes) {
+ logprintf("Error: fwrite\n");
+ break;
+ }
}
fclose(out);
fclose(in);