Skip to content

Commit a27f1f8

Browse files
committed
Add unit tests for FileCollector, CommandBase filters, and StatsAnalyser
- test_file_collector.cpp: 11 tests for file/directory collection - test_command_base.cpp: 28 tests for filtering logic (date, value, errors) - test_stats_analyser.cpp: 32 tests for statistical functions (isNumeric, median, stddev, percentile) - Fix test_error_detector.cpp Windows compatibility (mkdir/rmdir) - Update Makefile with all new unit test targets
1 parent f3b7880 commit a27f1f8

File tree

5 files changed

+1000
-4
lines changed

5 files changed

+1000
-4
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ endif
1919
# Source files
2020
SOURCES = src/sensor-data.cpp
2121
LIB_SOURCES = src/csv_parser.cpp src/json_parser.cpp src/error_detector.cpp src/file_utils.cpp src/sensor_data_transformer.cpp src/data_counter.cpp src/error_lister.cpp src/error_summarizer.cpp src/stats_analyser.cpp src/latest_finder.cpp
22-
TEST_SOURCES = tests/test_csv_parser.cpp tests/test_json_parser.cpp tests/test_error_detector.cpp tests/test_file_utils.cpp tests/test_date_utils.cpp tests/test_common_arg_parser.cpp tests/test_data_reader.cpp
22+
TEST_SOURCES = tests/test_csv_parser.cpp tests/test_json_parser.cpp tests/test_error_detector.cpp tests/test_file_utils.cpp tests/test_date_utils.cpp tests/test_common_arg_parser.cpp tests/test_data_reader.cpp tests/test_file_collector.cpp tests/test_command_base.cpp tests/test_stats_analyser.cpp
2323

2424
# Object files
2525
LIB_OBJECTS = $(LIB_SOURCES:.cpp=.o)
26-
TEST_EXECUTABLES = test_csv_parser test_json_parser test_error_detector test_file_utils test_date_utils test_common_arg_parser test_data_reader
26+
TEST_EXECUTABLES = test_csv_parser test_json_parser test_error_detector test_file_utils test_date_utils test_common_arg_parser test_data_reader test_file_collector test_command_base test_stats_analyser
2727

2828
TARGET = sensor-data
2929

@@ -47,6 +47,9 @@ test: $(LIB_OBJECTS)
4747
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_date_utils.cpp -o test_date_utils $(LDFLAGS) && ./test_date_utils
4848
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_common_arg_parser.cpp src/file_utils.o -o test_common_arg_parser $(LDFLAGS) && ./test_common_arg_parser
4949
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_data_reader.cpp src/csv_parser.o src/json_parser.o src/file_utils.o -o test_data_reader $(LDFLAGS) && ./test_data_reader
50+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_file_collector.cpp src/file_utils.o -o test_file_collector $(LDFLAGS) && ./test_file_collector
51+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_command_base.cpp src/error_detector.o -o test_command_base $(LDFLAGS) && ./test_command_base
52+
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) tests/test_stats_analyser.cpp -o test_stats_analyser $(LDFLAGS) && ./test_stats_analyser
5053
@echo "All unit tests passed!"
5154

5255
# Run integration tests (requires bash)

0 commit comments

Comments
 (0)