Skip to content

Commit 027275f

Browse files
test for new getc
1 parent 9f12961 commit 027275f

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

code/tests/cases/test_input.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,15 @@ FOSSIL_TEST_CASE(c_test_io_validate_is_length_invalid) {
208208
ASSUME_ITS_FALSE(result);
209209
}
210210

211-
FOSSIL_TEST_CASE(c_test_io_show_progress) {
212-
// This test assumes the progress bar function doesn't return anything.
213-
// We'll just check that the progress is shown correctly.
211+
FOSSIL_TEST_CASE(c_test_io_getc) {
212+
const char *input_data = "test input\n";
213+
FILE *input_stream = tmpfile();
214+
fwrite(input_data, 1, strlen(input_data), input_stream);
215+
rewind(input_stream);
214216

215-
// Test with various progress values (0%, 50%, 100%)
216-
fossil_io_show_progress(0);
217-
fossil_io_show_progress(50);
218-
fossil_io_show_progress(100);
217+
int ch = fossil_io_getc(input_stream);
218+
ASSUME_ITS_EQUAL_I32('t', ch);
219+
fclose(input_stream);
219220
}
220221

221222
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -240,7 +241,7 @@ FOSSIL_TEST_GROUP(c_input_tests) {
240241
FOSSIL_TEST_ADD(c_input_suite, c_test_io_validate_is_email_invalid);
241242
FOSSIL_TEST_ADD(c_input_suite, c_test_io_validate_is_length_valid);
242243
FOSSIL_TEST_ADD(c_input_suite, c_test_io_validate_is_length_invalid);
243-
FOSSIL_TEST_ADD(c_input_suite, c_test_io_show_progress);
244+
FOSSIL_TEST_ADD(c_input_suite, c_test_io_getc);
244245

245246
FOSSIL_TEST_REGISTER(c_input_suite);
246247
}

code/tests/cases/test_input.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,17 @@ FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream_whitespace_only) {
335335
fclose(input_stream);
336336
}
337337

338+
FOSSIL_TEST_CASE(cpp_test_io_getc) {
339+
const char *input_data = "test input\n";
340+
FILE *input_stream = tmpfile();
341+
fwrite(input_data, 1, strlen(input_data), input_stream);
342+
rewind(input_stream);
343+
344+
int ch = fossil::io::Input::getc(input_stream);
345+
ASSUME_ITS_EQUAL_I32('t', ch);
346+
fclose(input_stream);
347+
}
348+
338349
// * * * * * * * * * * * * * * * * * * * * * * * *
339350
// * Fossil Logic Test Pool
340351
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -369,6 +380,7 @@ FOSSIL_TEST_GROUP(cpp_input_tests) {
369380
FOSSIL_TEST_ADD(cpp_input_suite, cpp_test_io_input_class_gets_utf8_valid);
370381
FOSSIL_TEST_ADD(cpp_input_suite, cpp_test_io_input_class_gets_from_stream_empty);
371382
FOSSIL_TEST_ADD(cpp_input_suite, cpp_test_io_input_class_gets_from_stream_whitespace_only);
383+
FOSSIL_TEST_ADD(cpp_input_suite, cpp_test_io_getc);
372384

373385
FOSSIL_TEST_REGISTER(cpp_input_suite);
374386
}

0 commit comments

Comments
 (0)