| 1 | #include <cgreen/cgreen.h> |
| 2 | #include <cgreen/mocks.h> |
| 3 | |
| 4 | char *read_paragraph(int (*read)(void *), void *stream); |
| 5 | |
| 6 | static int stream_stub(void *stream) { |
| 7 | return (int)mock(stream); |
| 8 | } |
| 9 | |
| 10 | Describe(ParagraphReader); |
| 11 | BeforeEach(ParagraphReader) {} |
| 12 | AfterEach(ParagraphReader) {} |
| 13 | |
| 14 | Ensure(ParagraphReader, gives_null_when_reading_empty_stream) { |
| 15 | always_expect(stream_stub, will_return(EOF)); // <1> |
| 16 | assert_that(read_paragraph(&stream_stub, NULL), is_null); |
| 17 | } |