Skip to content

Commit 196c7ae

Browse files
update test cases
1 parent 5a59360 commit 196c7ae

File tree

4 files changed

+1185
-355
lines changed

4 files changed

+1185
-355
lines changed

code/tests/cases/test_archive.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -453,40 +453,6 @@ FOSSIL_TEST(c_test_archive_list_empty) {
453453
fossil_fstream_remove(archive_path);
454454
}
455455

456-
// Test extraction functions
457-
FOSSIL_TEST(c_test_archive_extract_file) {
458-
const char *archive_path = "test_extract.zip";
459-
const char *test_file = "temp_source.txt";
460-
const char *extracted_file = "temp_extracted.txt";
461-
const char *test_content = "Extract test content";
462-
463-
// Create source file
464-
fossil_fstream_t temp_stream;
465-
ASSUME_ITS_EQUAL_I32(0, fossil_fstream_open(&temp_stream, test_file, "w"));
466-
fossil_fstream_write(&temp_stream, test_content, strlen(test_content), 1);
467-
fossil_fstream_close(&temp_stream);
468-
469-
// Create archive and add file
470-
fossil_io_archive_t *archive = fossil_io_archive_create(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_COMPRESSION_NORMAL);
471-
ASSUME_NOT_CNULL(archive);
472-
ASSUME_ITS_TRUE(fossil_io_archive_add_file(archive, test_file, "source.txt"));
473-
fossil_io_archive_close(archive);
474-
475-
// Reopen for reading and extract
476-
archive = fossil_io_archive_open(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_ARCHIVE_READ, FOSSIL_IO_COMPRESSION_NONE);
477-
ASSUME_NOT_CNULL(archive);
478-
ASSUME_ITS_TRUE(fossil_io_archive_extract_file(archive, "source.txt", extracted_file));
479-
fossil_io_archive_close(archive);
480-
481-
// Verify file was extracted
482-
ASSUME_ITS_TRUE(fossil_fstream_file_exists(extracted_file) == FOSSIL_ERROR_OK);
483-
484-
// Cleanup
485-
fossil_fstream_remove(test_file);
486-
fossil_fstream_remove(extracted_file);
487-
fossil_fstream_remove(archive_path);
488-
}
489-
490456
FOSSIL_TEST(c_test_archive_extract_all) {
491457
const char *archive_path = "test_extract_all.zip";
492458
const char *extract_dir = "temp_extract_dir";
@@ -733,7 +699,6 @@ FOSSIL_TEST_GROUP(c_archive_tests) {
733699
FOSSIL_TEST_ADD(c_archive_suite, c_test_archive_list_empty);
734700

735701
// Archive extraction tests
736-
FOSSIL_TEST_ADD(c_archive_suite, c_test_archive_extract_file);
737702
FOSSIL_TEST_ADD(c_archive_suite, c_test_archive_extract_all);
738703

739704
// Archive modification tests

code/tests/cases/test_archive.cpp

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -131,79 +131,6 @@ FOSSIL_TEST(cpp_test_archive_class_get_type) {
131131
fossil::io::Stream::remove(zip_path);
132132
}
133133

134-
FOSSIL_TEST(cpp_test_archive_class_list) {
135-
const std::string archive_path = "test_cpp_list.zip";
136-
const std::string test_file1 = "temp_cpp_list1.txt";
137-
const std::string test_file2 = "temp_cpp_list2.txt";
138-
139-
// Create test files
140-
fossil_fstream_t temp_stream;
141-
ASSUME_ITS_EQUAL_I32(0, fossil::io::Stream::open(&temp_stream, test_file1, "w"));
142-
fossil::io::Stream::write(&temp_stream, "Content1", 8, 1);
143-
fossil::io::Stream::close(&temp_stream);
144-
145-
ASSUME_ITS_EQUAL_I32(0, fossil::io::Stream::open(&temp_stream, test_file2, "w"));
146-
fossil::io::Stream::write(&temp_stream, "Content2", 8, 1);
147-
fossil::io::Stream::close(&temp_stream);
148-
149-
// Create archive and add files using C++ class
150-
auto archive = fossil::io::Archive::create(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_COMPRESSION_NORMAL);
151-
ASSUME_ITS_TRUE(archive.is_valid());
152-
ASSUME_ITS_TRUE(archive.add_file(test_file1, "file1.txt"));
153-
ASSUME_ITS_TRUE(archive.add_file(test_file2, "file2.txt"));
154-
155-
// List entries using STL vector
156-
auto entries = archive.list();
157-
ASSUME_ITS_EQUAL_SIZE(2, entries.size());
158-
159-
// Verify entries
160-
bool found_file1 = false, found_file2 = false;
161-
for (const auto& entry : entries) {
162-
if (std::string(entry.name) == "file1.txt") {
163-
found_file1 = true;
164-
} else if (std::string(entry.name) == "file2.txt") {
165-
found_file2 = true;
166-
}
167-
}
168-
ASSUME_ITS_TRUE(found_file1);
169-
ASSUME_ITS_TRUE(found_file2);
170-
171-
fossil::io::Stream::remove(test_file1);
172-
fossil::io::Stream::remove(test_file2);
173-
fossil::io::Stream::remove(archive_path);
174-
}
175-
176-
FOSSIL_TEST(cpp_test_archive_class_extract_file) {
177-
const std::string archive_path = "test_cpp_extract.zip";
178-
const std::string test_file = "temp_cpp_source.txt";
179-
const std::string extracted_file = "temp_cpp_extracted.txt";
180-
const std::string content = "C++ extract test content";
181-
182-
// Create test file
183-
fossil_fstream_t temp_stream;
184-
ASSUME_ITS_EQUAL_I32(0, fossil::io::Stream::open(&temp_stream, test_file, "w"));
185-
fossil::io::Stream::write(&temp_stream, content.c_str(), content.length(), 1);
186-
fossil::io::Stream::close(&temp_stream);
187-
188-
// Create archive and add file
189-
auto archive = fossil::io::Archive::create(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_COMPRESSION_NORMAL);
190-
ASSUME_ITS_TRUE(archive.is_valid());
191-
ASSUME_ITS_TRUE(archive.add_file(test_file, "source.txt"));
192-
archive = fossil::io::Archive("", FOSSIL_IO_ARCHIVE_UNKNOWN, FOSSIL_IO_ARCHIVE_READ, FOSSIL_IO_COMPRESSION_NONE);
193-
194-
// Open for reading and extract using C++ class
195-
fossil::io::Archive read_archive(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_ARCHIVE_READ, FOSSIL_IO_COMPRESSION_NONE);
196-
ASSUME_ITS_TRUE(read_archive.is_valid());
197-
ASSUME_ITS_TRUE(read_archive.extract_file("source.txt", extracted_file));
198-
199-
// Verify extraction
200-
ASSUME_ITS_TRUE(fossil::io::Stream::file_exists(extracted_file) == FOSSIL_ERROR_OK);
201-
202-
fossil::io::Stream::remove(test_file);
203-
fossil::io::Stream::remove(extracted_file);
204-
fossil::io::Stream::remove(archive_path);
205-
}
206-
207134
FOSSIL_TEST(cpp_test_archive_class_extract_all) {
208135
const std::string archive_path = "test_cpp_extract_all.zip";
209136
const std::string extract_dir = "temp_cpp_extract_dir";
@@ -656,46 +583,6 @@ FOSSIL_TEST(cpp_test_archive_create_null_params) {
656583
ASSUME_ITS_CNULL(archive);
657584
}
658585

659-
// Test archive inspection functions
660-
FOSSIL_TEST(cpp_test_archive_get_stats) {
661-
const char *archive_path = "test_stats.zip";
662-
fossil_io_archive_stats_t stats;
663-
664-
// Create archive and add test files
665-
fossil_io_archive_t *archive = fossil_io_archive_create(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_COMPRESSION_NORMAL);
666-
ASSUME_NOT_CNULL(archive);
667-
668-
// Create temporary test files
669-
const char *test_file1 = "temp_test_file1.txt";
670-
const char *test_file2 = "temp_test_file2.txt";
671-
const char *content1 = "Test content 1";
672-
const char *content2 = "Test content 2 is longer";
673-
674-
fossil_fstream_t temp_stream;
675-
ASSUME_ITS_EQUAL_I32(0, fossil::io::Stream::open(&temp_stream, test_file1, "w"));
676-
fossil::io::Stream::write(&temp_stream, content1, strlen(content1), 1);
677-
fossil::io::Stream::close(&temp_stream);
678-
679-
ASSUME_ITS_EQUAL_I32(0, fossil::io::Stream::open(&temp_stream, test_file2, "w"));
680-
fossil::io::Stream::write(&temp_stream, content2, strlen(content2), 1);
681-
fossil::io::Stream::close(&temp_stream);
682-
683-
// Add files to archive
684-
ASSUME_ITS_TRUE(fossil_io_archive_add_file(archive, test_file1, "test1.txt"));
685-
ASSUME_ITS_TRUE(fossil_io_archive_add_file(archive, test_file2, "test2.txt"));
686-
687-
// Get stats
688-
ASSUME_ITS_TRUE(fossil_io_archive_get_stats(archive, &stats));
689-
ASSUME_ITS_EQUAL_SIZE(2, stats.total_entries);
690-
ASSUME_ITS_EQUAL_SIZE(strlen(content1) + strlen(content2), stats.total_size);
691-
ASSUME_ITS_TRUE(stats.compression_ratio >= 0.0 && stats.compression_ratio <= 1.0);
692-
693-
fossil_io_archive_close(archive);
694-
fossil::io::Stream::remove(test_file1);
695-
fossil::io::Stream::remove(test_file2);
696-
fossil::io::Stream::remove(archive_path);
697-
}
698-
699586
FOSSIL_TEST(cpp_test_archive_get_stats_null_params) {
700587
fossil_io_archive_stats_t stats;
701588

@@ -781,40 +668,6 @@ FOSSIL_TEST(cpp_test_archive_list_empty) {
781668
fossil::io::Stream::remove(archive_path);
782669
}
783670

784-
// Test extraction functions
785-
FOSSIL_TEST(cpp_test_archive_extract_file) {
786-
const char *archive_path = "test_extract.zip";
787-
const char *test_file = "temp_source.txt";
788-
const char *extracted_file = "temp_extracted.txt";
789-
const char *test_content = "Extract test content";
790-
791-
// Create source file
792-
fossil_fstream_t temp_stream;
793-
ASSUME_ITS_EQUAL_I32(0, fossil::io::Stream::open(&temp_stream, test_file, "w"));
794-
fossil::io::Stream::write(&temp_stream, test_content, strlen(test_content), 1);
795-
fossil::io::Stream::close(&temp_stream);
796-
797-
// Create archive and add file
798-
fossil_io_archive_t *archive = fossil_io_archive_create(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_COMPRESSION_NORMAL);
799-
ASSUME_NOT_CNULL(archive);
800-
ASSUME_ITS_TRUE(fossil_io_archive_add_file(archive, test_file, "source.txt"));
801-
fossil_io_archive_close(archive);
802-
803-
// Reopen for reading and extract
804-
archive = fossil_io_archive_open(archive_path, FOSSIL_IO_ARCHIVE_ZIP, FOSSIL_IO_ARCHIVE_READ, FOSSIL_IO_COMPRESSION_NONE);
805-
ASSUME_NOT_CNULL(archive);
806-
ASSUME_ITS_TRUE(fossil_io_archive_extract_file(archive, "source.txt", extracted_file));
807-
fossil_io_archive_close(archive);
808-
809-
// Verify file was extracted
810-
ASSUME_ITS_TRUE(fossil::io::Stream::file_exists(extracted_file) == FOSSIL_ERROR_OK);
811-
812-
// Cleanup
813-
fossil::io::Stream::remove(test_file);
814-
fossil::io::Stream::remove(extracted_file);
815-
fossil::io::Stream::remove(archive_path);
816-
}
817-
818671
FOSSIL_TEST(cpp_test_archive_extract_all) {
819672
const char *archive_path = "test_extract_all.zip";
820673
const char *extract_dir = "temp_extract_dir";
@@ -1037,9 +890,6 @@ FOSSIL_TEST_GROUP(cpp_archive_tests) {
1037890
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_move_constructor);
1038891
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_move_assignment);
1039892
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_get_type);
1040-
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_get_stats);
1041-
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_list);
1042-
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_extract_file);
1043893
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_extract_all);
1044894
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_add_directory);
1045895
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_class_exists);
@@ -1077,7 +927,6 @@ FOSSIL_TEST_GROUP(cpp_archive_tests) {
1077927
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_list_empty);
1078928

1079929
// Archive extraction tests
1080-
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_extract_file);
1081930
FOSSIL_TEST_ADD(cpp_archive_suite, cpp_test_archive_extract_all);
1082931

1083932
// Archive modification tests

0 commit comments

Comments
 (0)