cpp-testing

cpp-testing is a skill for Claude Code from loulanyue/awesome-claude-notes. It costs 55 tokens per session (3,130 once invoked), scanned A, original, MIT.

A guide for testing C++17/20 code with GoogleTest, GoogleMock, CMake, and CTest. It covers unit and integration tests, test discovery, coverage, and sanitizers.

In plain words
What is it for?
Use it to create or update C++ tests, organize test files, configure CTest, add CI test checks, and enable coverage or sanitizer diagnostics.
Why use it?
It provides a repeatable way to find regressions, investigate failed or flaky tests, and diagnose memory or race problems. TDD means writing a failing test first, making it pass, then cleaning up the code.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the awesome-claude-notes plugin — 106 skills, 61 commands, 29 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/loulanyue/awesome-claude-notes/cpp-testing
Any agent
npx skills add loulanyue/awesome-claude-notes --skill cpp-testing
Clone the repo
git clone --depth 1 https://github.com/loulanyue/awesome-claude-notes

Made for: Claude Code.

Or install awesome-claude-notes, the plugin that ships this one along with the rest of its 106 skills, 61 commands, 29 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cpp-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/loulanyue/awesome-claude-notes/cpp-testing.svg)](https://agentmods.dev/skills/loulanyue/awesome-claude-notes/cpp-testing)
Your own site
<a href="https://agentmods.dev/skills/loulanyue/awesome-claude-notes/cpp-testing"><img src="https://agentmods.dev/badge/skills/loulanyue/awesome-claude-notes/cpp-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,130 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00055 $0.03130
Opus 5 $0.00028 $0.01565
Sonnet 5 $0.00011 $0.00626
Haiku 4.5 $0.00006 $0.00313

Measured 2d ago against content hash daaf61a088c2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

cpp-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/ja-JP/skills/cpp-testing/SKILL.md · 332 lines

How it starts

The opening of the file, as written. The whole thing — 332 lines — stays where its author put it; the contents beside it link to each section on GitHub.

C++ Testing(エージェントスキル)

CMake/CTest を使用した GoogleTest/GoogleMock による最新の C++(C++17/20)向けのエージェント重視のテストワークフローです。

使用タイミング

  • 新しい C++ テストの作成または既存のテストの修正
  • C++ コンポーネントのユニット/統合テストカバレッジの設計
  • テストカバレッジ、CI ゲーティング、リグレッション保護の追加
  • 一貫した実行のための CMake/CTest ワークフローの設定
  • テスト失敗またはフレーキーな動作の調査
  • メモリ/レース診断のためのサニタイザーの有効化

使用すべきでない場合

  • テスト変更を伴わない新しい製品機能の実装
  • テストカバレッジや失敗に関連しない大規模なリファクタリング
  • 検証するテストリグレッションのないパフォーマンスチューニング
  • C++ 以外のプロジェクトまたはテスト以外のタスク

コア概念

  • TDD ループ: red → green → refactor(テスト優先、最小限の修正、その後クリーンアップ)
  • 分離: グローバル状態よりも依存性注入とフェイクを優先
  • テストレイアウト: tests/unittests/integrationtests/testdata
  • モック vs フェイク: 相互作用にはモック、ステートフルな動作にはフェイク
  • CTest ディスカバリー: 安定したテストディスカバリーのために gtest_discover_tests() を使用
  • CI シグナル: 最初にサブセットを実行し、次に --output-on-failure でフルスイートを実行

TDD ワークフロー

RED → GREEN → REFACTOR ループに従います:

  1. RED: 新しい動作をキャプチャする失敗するテストを書く
  2. GREEN: 合格する最小限の変更を実装する
  3. REFACTOR: テストがグリーンのままクリーンアップする
// tests/add_test.cpp
#include <gtest/gtest.h>

int Add(int a, int b); // プロダクションコードによって提供されます。

TEST(AddTest, AddsTwoNumbers) { // RED
  EXPECT_EQ(Add(2, 3), 5);
}

// src/add.cpp
int Add(int a, int b) { // GREEN
  return a + b;
}

// REFACTOR: テストが合格したら簡素化/名前変更

コード例

基本的なユニットテスト(gtest)

// tests/calculator_test.cpp
#include <gtest/gtest.h>

int Add(int a, int b); // プロダクションコードによって提供されます。

TEST(CalculatorTest, AddsTwoNumbers) {
    EXPECT_EQ(Add(2, 3), 5);
}

フィクスチャ(gtest)

// tests/user_store_test.cpp
// 擬似コードスタブ: UserStore/User をプロジェクトの型に置き換えてください。
#include <gtest/gtest.h>
#include <memory>
#include <optional>
#include <string>

struct User { std::string name; };
class UserStore {
public:
    explicit UserStore(std::string /*path*/) {}
    void Seed(std::initializer_list<User> /*users*/) {}
    std::optional<User> Find(const std::string &/*name*/) { return User{"alice"}; }
};

class UserStoreTest : public ::testing::Test {
protected:
    void SetUp() override {
        store = std::make_unique<UserStore>(":memory:");
        store->Seed({{"alice"}, {"bob"}});
    }

    std::unique_ptr<UserStore> store;
};

TEST_F(UserStoreTest, FindsExistingUser) {
    auto user = store->Find("alice");
    ASSERT_TRUE(user.has_value());
    EXPECT_EQ(user->name, "alice");
}

Read the full file on GitHub · 332 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 332 lines · 55 tokens per session scan A daaf61a088c2

Subscribe to this mod's changes

cpp-testing is a skill published in the GitHub repository loulanyue/awesome-claude-notes (270 stars, last pushed 2d ago), licensed MIT. It adds 55 tokens to every session and 3,130 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.