diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2023-09-07 11:37:00 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2023-09-07 11:37:00 +0200 |
commit | 00e80c21d99d4945e81f2a91bed1deea0be00ab4 (patch) | |
tree | ddb5a9f07d80161194054f77515bd8d1e3527cd0 /source/tests | |
parent | a62c2be660777137d23ee17f21affaca2802f44b (diff) | |
download | kit-00e80c21d99d4945e81f2a91bed1deea0be00ab4.zip |
input stream: wrap FILE
Diffstat (limited to 'source/tests')
-rw-r--r-- | source/tests/input_stream.test.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/tests/input_stream.test.c b/source/tests/input_stream.test.c index 46ee0dd..467c227 100644 --- a/source/tests/input_stream.test.c +++ b/source/tests/input_stream.test.c @@ -1,4 +1,5 @@ #include "../kit/input_stream.h" +#include "../kit/file.h" #define KIT_TEST_FILE input_stream #include "../kit_test/test.h" @@ -15,9 +16,29 @@ TEST("input stream wrap string") { char buf[4]; str_t buf_ref = { .size = sizeof(buf), .values = buf }; - REQUIRE(IS_READ(in, buf_ref) == buf_ref.size); + REQUIRE_EQ(IS_READ(in, buf_ref), buf_ref.size); REQUIRE(AR_EQUAL(foo_ref, bar_ref)); REQUIRE(AR_EQUAL(buf_ref, bar_ref)); is_destroy(in); } + +TEST("input stream wrap file") { + char foo[] = "test"; + char bar[] = "test"; + + FILE *f = fopen("_kit_temp", "wb"); + fwrite(foo, 1, 4, f); + fclose(f); + + f = fopen("_kit_temp", "rb"); + + is_handle_t in = IS_WRAP_FILE(f); + + REQUIRE_EQ(IS_READ(in, SZ(bar)), SZ(bar).size); + REQUIRE(AR_EQUAL(SZ(foo), SZ(bar))); + + is_destroy(in); + fclose(f); + file_remove(SZ("_kit_temp")); +} |