Commit 7aee9c3
committed
feat(solutions): 参考答案自己成为一个 mcpp 工程,
在此之前 solutions/ 只是一堆躺在磁盘上的 .cpp:不是工作区成员,mcpp 从头到
尾不认识它。想验证答案对不对,唯一的办法是把 52 个文件覆盖到 src/*/tests/
上、跑一遍、再 git 还原 —— 一套带副作用、要求工作树干净、只有 CI 脚本会用
的流程。学习者或贡献者想确认「答案是好的」,没有一条命令可以跑。
现在 solutions/ 是一个正经工程:
solutions/mcpp.toml name=solutions, c++23, 依赖 d2x
solutions/tests/<std>/... 52 份答案,就是它的测试
于是:
mcpp test -p solutions # 52 passed; 0 failed
mcpp test -p solutions cpp11 # 按子串筛
零副作用、不碰练习目录、任何人随手可跑。布局与练习一一对应,测试名
(intro/hello-mcpp、cpp11/00-auto-and-decltype/0) 直接对回练习文件。
配置刻意与练习工程一致(c++23 + d2x),否则「答案能过」推不出「答案放进
练习里也能过」。
覆盖-还原那套 e2e 保留 —— 它验的是另一件事:答案放到练习的位置上也成立,
且练习在未完成时确实不通过。两条互补:新的这条挂了说明答案本身是错的,
旧的那条挂了说明答案与练习对不上。
- e2e.sh 新增 solutions_selftest(),并核对测试条数 == 答案文件数:测试发现
是按 tests/**/*.cpp 自动扫的,布局一改就可能一个都没扫到,而「0 个测试」
在 mcpp 眼里同样是 "test result ok"
- CI 每档平台新增独立一段 `mcpp test -p solutions`,排在覆盖-还原之前,
失败定位最短
- e2e.sh / checker-e2e.sh / 文件名核对 job 的路径映射跟随改为 solutions/tests/mcpp test -p solutions 直接跑1 parent eb5ce5e commit 7aee9c3
57 files changed
Lines changed: 78 additions & 6 deletions
File tree
- .github/workflows
- d2x/buildtools/tests
- solutions
- tests
- cpp11
- 00-auto-and-decltype
- 01-default-and-delete
- 02-final-and-override
- 03-trailing-return-type
- 04-rvalue-references
- 05-move-semantics
- 06-scoped-enums
- 07-constexpr
- 08-literal-type
- 09-list-initialization
- 10-delegating-constructors
- 11-inherited-constructors
- 12-nullptr
- 13-long-long
- 14-type-alias
- 15-variadic-templates
- 16-generalized-unions
- 17-pod-type
- cpp14/00-generic-lambdas
- intro
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
184 | 190 | | |
| 191 | + | |
| 192 | + | |
185 | 193 | | |
186 | 194 | | |
187 | 195 | | |
| |||
209 | 217 | | |
210 | 218 | | |
211 | 219 | | |
212 | | - | |
213 | | - | |
| 220 | + | |
| 221 | + | |
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
57 | | - | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
67 | | - | |
| 70 | + | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| |||
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
95 | 131 | | |
96 | 132 | | |
97 | 133 | | |
| |||
110 | 146 | | |
111 | 147 | | |
112 | 148 | | |
| 149 | + | |
113 | 150 | | |
114 | 151 | | |
115 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| 13 | + | |
9 | 14 | | |
10 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
0 commit comments