Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

条件判定(KEYCODE)が常にfalseになる警告修正 #2023

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gorogoro123
Copy link
Contributor

PR対象

  • アプリ(サクラエディタ本体)

カテゴリ

  • 改善

PR の背景

Clang/LLVM でbuild時に "-Wtautological-constant-out-of-range-compare" のwarningが出力される。
CDataProfile.h(229,39): warning : result of comparison of constant 128 with expression of type 'KEYCODE' (aka 'char') is always false [-Wtautological-constant-out-of-range-compare]
KEYCODE型(char) の変数の範囲は -128~127、128は範囲外。

仕様・動作説明

  1. コンパイル時にチェックします。
  2. unit test を追加します。

PR の影響範囲

影響なし。

テスト内容

変更前後で unit test が PASS することを確認します。

関連 issue, PR

#1548

参考資料

https://cpprefjp.github.io/reference/limits/numeric_limits.html

@AppVeyorBot
Copy link

Copy link
Contributor

@berryzplus berryzplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対応ありがとうございます。

str = profile_data::ToString(code);
ASSERT_STREQ(L"\x01", str.c_str());

code = 0x61;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
code = 0x61;
code = 'a';

/*!
* @brief ToString(KEYCODE)のテスト
*/
TEST(profile_data, ToString_KEYCODE)
Copy link
Contributor

@berryzplus berryzplus Mar 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

219行目の TryParse_WCHAR と構成を合わせるとよりよいかもです。

やってることは

  1. 妥当な値を渡して parse できることの確認。
  2. 不正な値を渡して parse できないことの確認。(値が変わらない)
  3. 妥当な値を渡して parse できることの確認。

です。

書いてくれたものほうがより細かい確認をできていますが、上記2の確認ができてないです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants