feat: 資料結構練習場 src/ds (doctest + ctest)#1
Open
GenYuLi wants to merge 1 commit into
Open
Conversation
對應 rust playground 的 src/ds:header-only 資料結構練習場, 每個結構一個資料夾,旁邊放 doctest 測試,ctest 一鍵全跑 (≈ cargo test)。 - ds.hpp umbrella header(≈ ds/mod.rs)+ ds_test_main.cpp - tree/ 以 BinarySearchTree 作為已實作 + 已測試的範例 - graph/ trie/ list/ 為骨架:class 外形 + 預期 API 的 TODO, 測試以 doctest::skip() 跳過,留給之後填實作 - CMake: FetchContent 接 doctest(SOURCE_SUBDIR 跳過其過舊 CMakeLists, 自建 interface target),GLOB_RECURSE 收 *_test.cpp 進 ds_tests,掛上 ctest - src/ds/README.md 說明用法 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
對應 rust playground 的
src/ds/,建一個 header-only 的資料結構練習場:每個結構一個資料夾,旁邊放 doctest 測試,ctest一鍵全跑(≈cargo test)。內容
ds.hppumbrella header(≈ rust 的ds/mod.rs)+ds_test_main.cpp(唯一的 doctest main TU)tree/——BinarySearchTree作為已實作 + 已測試的範例(3 個 TEST_CASE 通過)graph/trie/list/—— 骨架:class 外形 + 預期 API 的 TODO 註解,測試以doctest::skip()跳過,實作與測試內容留白待補CMakeLists.txt:SOURCE_SUBDIR跳過其過舊的 CMakeLists,自建 interface target)GLOB_RECURSE ... CONFIGURE_DEPENDS自動收src/ds/**/*_test.cpp進單一ds_tests,掛上ctestsrc/ds/README.md說明用法與如何新增結構怎麼跑
cmake -S . -B build cmake --build build --target ds_tests ctest --test-dir build --output-on-failure驗證
乾淨 build 目錄下 configure / build /
ctest全綠:BST 三個測試跑、三個骨架 skip,100% tests passed。備註
xxx/xxx.hpp+xxx/xxx_test.cpp,不用改 CMake(GLOB 自動收)。build/內 CMakeCache 存的是舊 gcc 路徑(先前就存在),重建一次即可:rm -rf build && direnv exec . cmake -S . -B build。🤖 Generated with Claude Code