zig-testing
Zig 测试与调试技能。涉及 std.testing 的断言、测试组织、内存泄漏检测、以及 std.debug 的日志、堆栈回溯。在需要编写测试、调试代码、诊断问题时调用。
Skill by Yabuku-xD
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/yabuku-xd-zig-testing-6c6fa8
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/zig-testing
What's inside
- Skill name
zig-testing- Description
- Zig 测试与调试技能。涉及 std.testing 的断言、测试组织、内存泄漏检测、以及 std.debug 的日志、堆栈回溯。在需要编写测试、调试代码、诊断问题时调用。
- License
- MIT
- Instructions
- 272 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Zig 测试与调试
> 基于 std.testing 和 std.debug 的质量保障工具(Zig 0.16.0)。
## Capability Boundaries
### ✅ 强项
1. 单元测试编写与断言
2. 测试组织(test 声明、doctest、测试过滤器)
3. 内存泄漏检测
4. 日志输出(std.log)
5. 调试工具(panic、断言、堆栈回溯、hex dump)
### ⚠️ 前置要求
1. 确认 Zig 版本(`zig version`)
### ❌ 不适用范围
1. 构建系统测试配置 → 使用 `zig-build-system` 技能
2. 集成测试框架 → 使用 `zig-0.16` 技能
3. 性能基准测试 → 暂不涉及(Zig 尚未内置 benchmark)
## 何时使用
- "帮我写单元测试"
- "调试这个函数的输出"
- "检查内存泄漏"
## Data Privacy
本技能不收集、存储或传输任何用户数据。
## Workflow — 测试
步骤 1. **声明测试** — `test "name" { ... }`
步骤 2. **使用断言** — `expect`, `expectEqual`, `expectEqualStrings`
步骤 3. **运行测试** — `zig test src/main.zig` 或 `zig build test`
步骤 4. **检查结果** — 通过/失败/泄漏
## 断言速查
| 断言 | 用途 |
|------|------|
| `expect(bool)` | 条件为真 |
| `expectEqual(expected, actual)` | 浅相等(peer type) |
| `expectEqualDeep(expected, actual)` | 深相等(递归比较) |
| `expectEqualStrings(expected, actual)` | 字符串相等(带 diff) |
| `expectEqualSlices(T, expected, actual)` | 切片相等 |
| `expectError(error, result)` | 返回特定错误 |
| `expectApproxEqAbs(expected, actual, eps)` | 浮点近似(绝对误差) |
| `expectApproxEqRel(expected, actual, eps)` | 浮点近似(相对误差) |
| `expectFmt(expected, template, args)` | 格式化输出匹配 |
| `expectStringStartsWith(actual, prefix)` | 字符串前缀 |
| `expectStringEndsWith(actual, suffix)` | 字符串后缀 |
## 基本断言
```zig
test "basic assertions" {
try std.testing.expect(true);
try std.testing.expectEqual(@as(u32, 42), @as(u32, 42));
try std.testing.expectEqualStrings("hello", "hello");
try std.testing.expectEqualSlices(u8, &[_]u8{ 1, 2 }, &[_]u8{ 1, 2 });
try std.testing.expectEqualDeep(
struct{ x: i32, y: i32 }{ .x = 1, .y = 2 },
struct{ x: i32, y: i32 }{ .x = 1, .y = 2 },
);
}
```
### 浮点比较
```zig
test "float comparison" {
try std.testing.expectApproxEqAbs(@as(f32, 1.0), 1.0001, 0.001);
try std.testing.expectApproxEqRel(@as(f64, 100.0), 99.5, 0.01);
}
```
### 错误检查
```zig
test "error handling" {
const result: anyerror!i32 = error.SomeError;
try std.testing.expectError(error.SomeError, result);
}
```
## 测试组织
### 内联测试
```zig
const std = @import("std");
const expect = std.testing.expect;
test "inline test" {
try expect(1 + 1 == 2);
}
```
### doctest(文档中的测试)
```zig
/// Adds two numbers.
///
/// ```
/// const result = add(2, 3);
/// try std.testing.expectEqual(@as(i32, 5), result);
/// ```
fn add(a: i32, b: i32) i32 {
return a + b;
}
```
### 测试过滤器
```bash
# 运行名称包含 "http" 的测试
zig test src/main.zig --test-filter "http"From Yabuku-xD/omfx, MIT.
More from Yabuku-xD/omfx
- 0.529score
zig-memory-management
Yabuku-xD
Memory management in Zig including allocators, pointers, slices, alignment, and ownership patterns.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-tiger-style
Yabuku-xD
TigerStyle Zig coding guidelines — distilled from TigerBeetle's production codebase.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-comptime
Yabuku-xD
Zig comptime skill for compile-time evaluation and metaprogramming.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-testing
Yabuku-xD
Zig testing skill for writing and running tests.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-code-review
Yabuku-xD
Review Zig project code for style, correctness, and logic.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-debugging
Yabuku-xD
Zig debugging skill.
SkillBFreshness: BClaude Code +9 - 0.518score
code-audit
Yabuku-xD
Conducts an exhaustive, multi-pass, line-by-line technical audit and verification of local files or directories.
SkillBFreshness: BClaude Code +9 - 0.518score
zig-build-system
Yabuku-xD
Zig 构建系统专项技能。涉及 build.zig 和 build.zig.zon 的编写、模块管理、依赖配置、交叉编译、C/C++ 集成、自定义构建步骤和测试配置。在需要配置或调试项目构建时调用。
SkillBFreshness: BClaude Code +9 - 0.518score
zig-concurrency
Yabuku-xD
Zig 并发编程技能。涉及 std.Thread 的线程创建、同步原语(Mutex、RwLock、Condition、Semaphore、WaitGroup)、线程池和原子操作。在需要多线程或并行计算时调用。
SkillBFreshness: BClaude Code +9 - 0.518score
zig-project-structure
Yabuku-xD
Zig 项目结构全生命周期管理。创建项目骨架(exe/lib/多模块/带依赖)或检查已有项目的目录结构、文件命名、构建配置合规性,输出结构化报告。
SkillBFreshness: BClaude Code +9 - 0.516score
zig-build-system
Yabuku-xD
Zig build system skill for multi-file Zig projects.
SkillBFreshness: BClaude Code +9 - 0.515score
hello-omfx
Yabuku-xD
Example skill.
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 24, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Yabuku-xD/omfx
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Yabuku-xD
- 0.529score
zig-memory-management
Yabuku-xD
Memory management in Zig including allocators, pointers, slices, alignment, and ownership patterns.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-comptime
Yabuku-xD
Zig comptime skill for compile-time evaluation and metaprogramming.
SkillBFreshness: BClaude Code +9 - 0.524score
zig-tiger-style
Yabuku-xD
TigerStyle Zig coding guidelines — distilled from TigerBeetle's production codebase.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-debugging
Yabuku-xD
Zig debugging skill.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-testing
Yabuku-xD
Zig testing skill for writing and running tests.
SkillBFreshness: BClaude Code +9 - 0.520score
zig-code-review
Yabuku-xD
Review Zig project code for style, correctness, and logic.
SkillBFreshness: BClaude Code +9
Cite this page
zig-testing skill. Agent Mart. https://agentmart.dev/skills/yabuku-xd-zig-testing-6c6fa8 (last updated 2026-10-24)