gmockのマッチャーをプリコンパイル済みヘッダーでまとめてusingする#2101
Merged
berryzplus merged 2 commits intoJul 13, 2025
Merged
Conversation
Member
|
変更後の書き方 の場合何がメリットあるんですか? |
Contributor
Author
EXPECT_THATは「actual が expected である」をチェックします。 次のような、必ず失敗するテストケースがあるとします。 EXPECT_STREQ( L"expected", L"actuial" );
EXPECT_THAT( L"actuial", ::testing::StrEq(L"expected") );実行結果はこんな感じになります。 従来の書き方「EXPECT_EQ」だと与えた2つの引数が意味付けされません。(どちらが結果でどちらが期待値かわからない。) 後者のほうが分かりやすいと思いますが、いかがでしょうか。 |
|
Contributor
Author
|
レビューありがとうございます。 マージは2approveされた時点、または、最初のapproveから1週間経過後でやっているのでしばらくお待ちください。。 |
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.




PR対象
カテゴリ
PR の背景
プロジェクトのテストアサーションの書き方に微妙に統一感がない。
従来の書き方例
GMockの定義済みマッチャー群をまとめて using することにより、統一感および書きやすさの向上を図ります。
仕様・動作説明
変更後の書き方例
EXPECT_THAT(actuial, StrEq(expected));PR の影響範囲
テスト内容
関連 issue, PR
このPull Requestの変更を含んでいます。
「既存テストの拡充に必要な変更」の位置づけになります。
参考資料