Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $(static_lib_name): $(objects)
src/%.o: src/%.c templates
$(cc) -c $(flags) -fPIC $< -o $@

test/%.o: test/%.c templates
test/%.o: test/%.c templates prism
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I needed to add prism as a dependency of the test target, otherwise make test could not complete after a make clean due to a missing Prism header.

$(cc) -c $(test_cflags) $(test_flags) $(prism_flags) $< -o $@

.PHONY: test
Expand Down
7 changes: 7 additions & 0 deletions test/c/test_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ void create_test_file(const char* filename, const char* content) {
fclose(fp);
}

// Test that reading a non-existent file correctly exits
// Note: Check verifies the exit code via tcase_add_exit_test, so no assertions.
TEST(test_herb_read_file_nonexistent_exits)
herb_read_file("non_existent_file.txt");
END

// Test reading from a file
TEST(test_herb_read_file)
const char* filename = "test_herb_read_file.txt";
Expand All @@ -31,6 +37,7 @@ TCase* io_tests(void) {
TCase* io = tcase_create("IO");

tcase_add_test(io, test_herb_read_file);
tcase_add_exit_test(io, test_herb_read_file_nonexistent_exits, 1);

return io;
}
Loading