Skip to content

Commit 615d2c4

Browse files
committed
More tests added
1 parent 3cc83e8 commit 615d2c4

6 files changed

Lines changed: 28 additions & 18 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
lcov --capture \
4848
--directory build \
4949
--output-file coverage.info \
50-
--ignore-errors mismatch,source,empty,unused \
50+
--ignore-errors mismatch,source,empty,unused,negative \
5151
--rc lcov_branch_coverage=1
5252
# Strip system headers, external deps, Catch2, and test files
5353
lcov --remove coverage.info \

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ else()
3434

3535
if(ENABLE_CODE_COVERAGE)
3636
message("Code coverage instrumentation enabled")
37-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage -Og")
37+
# -fprofile-update=atomic prevents negative counter corruption when
38+
# background reader threads write to the same .gcda file concurrently.
39+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage -Og -fprofile-update=atomic")
3840
endif()
3941
endif(MSVC)
4042

tests/CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ Tests use RAII cleanup via [FileGuard](shared/file_guard.hpp) — see the **Shar
6161

6262
### Test Files
6363

64+
> **Rule**: Every `test_*.cpp` file in `tests/` **must** appear in `target_sources()` in `tests/CMakeLists.txt`.
65+
> Files not listed there are silently never compiled or run.
66+
> When adding a new test file, add it to CMakeLists.txt in the same commit.
67+
> When asked to audit this, compare `ls tests/test_*.cpp` against the `target_sources()` list.
68+
6469
- **test_error_handling.cpp**: Exception propagation from PR #282
6570
- Validates worker thread exceptions reach main thread
6671
- Tests chunk boundary corruption detection

tests/CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,26 @@ target_sources(csv_test
2323
PRIVATE
2424
${CSV_INCLUDE_DIR}/csv.hpp
2525
main.cpp
26+
test_csv_delimiter.cpp
2627
test_csv_field.cpp
2728
test_csv_field_array.cpp
2829
test_csv_format.cpp
2930
test_csv_iterator.cpp
31+
test_csv_ranges.cpp
3032
test_csv_row.cpp
3133
test_csv_row_json.cpp
3234
test_csv_stat.cpp
35+
test_data_frame.cpp
36+
test_data_type.cpp
37+
test_edge_cases_large_rows.cpp
38+
test_error_handling.cpp
3339
test_guess_csv.cpp
40+
test_raw_csv_data.cpp
3441
test_read_csv.cpp
3542
test_read_csv_file.cpp
36-
test_write_csv.cpp
37-
test_data_type.cpp
38-
test_raw_csv_data.cpp
3943
test_round_trip.cpp
40-
test_csv_delimeter.cpp
41-
test_csv_ranges.cpp
42-
test_error_handling.cpp
43-
test_data_frame.cpp
44-
test_edge_cases_large_rows.cpp
44+
test_stream_sources.cpp
45+
test_write_csv.cpp
4546
)
4647
target_link_libraries(csv_test csv)
4748
target_link_libraries(csv_test Catch2::Catch2WithMain)

tests/test_stream_sources.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,19 @@ TEST_CASE("Third-party stream compatibility", "[stream_sources][issue_259]") {
9393
REQUIRE(row_count == 2);
9494
}
9595

96-
SECTION("Non-copyable stream created in place") {
97-
// Create CSVReader directly with temporary non-copyable stream
98-
// This tests that the reference binding works correctly
99-
CSVReader reader(NonCopyableStream("ID,Value\n1,100\n2,200\n"));
100-
96+
SECTION("Non-copyable stream passed without explicit copy") {
97+
// Confirms that CSVReader stores the stream by reference (not by value),
98+
// so a non-copyable stream can be passed as a named lvalue.
99+
// Before the fix for issue #259, this would fail to compile because
100+
// the parser tried to copy the stream object internally.
101+
NonCopyableStream stream("ID,Value\n1,100\n2,200\n");
102+
CSVReader reader(stream);
103+
101104
int row_count = 0;
102105
for (auto& row : reader) {
106+
(void)row;
103107
row_count++;
104108
}
105-
// Note: With temporary stream, this may not work as expected
106-
// because the temporary goes out of scope. But the important
107-
// thing is that it compiles without "use of deleted function" error.
109+
REQUIRE(row_count == 2);
108110
}
109111
}

0 commit comments

Comments
 (0)