-
Notifications
You must be signed in to change notification settings - Fork 165
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
CNativeW::SetString に NULL を指定した場合に wcslen に NULL を渡して落ちてしまう不具合を修正 #1087
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,15 +86,19 @@ TEST(CNativeW, ConstructWithStringEmpty) | |
} | ||
|
||
/*! | ||
* @brief コンストラクタ(nullptr指定)の仕様 | ||
* @remark 構築できない(実行時エラーになる) | ||
* @note バグですね(^^; | ||
* @brief コンストラクタ(NULL指定)の仕様 | ||
* @remark バッファは確保されない | ||
* @remark 文字列長はゼロになる | ||
*/ | ||
TEST(CNativeW, ConstructWithStringNull) | ||
{ | ||
volatile int ret = 0; | ||
ASSERT_DEATH({ CNativeW value(NULL); ret = value.capacity(); }, ".*"); | ||
(void)ret; | ||
CNativeW value(NULL); | ||
EXPECT_EQ(0, value.GetStringLength()); | ||
EXPECT_EQ(nullptr, value.GetStringPtr()); | ||
|
||
CNativeW value2(nullptr); | ||
EXPECT_EQ(0, value2.GetStringLength()); | ||
EXPECT_EQ(nullptr, value2.GetStringPtr()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. キャパがゼロになるのも仕様な認識です。 これも後追いでいいです。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2d5a94a でコメントを追加しました。 |
||
|
||
/*! | ||
|
@@ -236,14 +240,15 @@ TEST(CNativeW, AssignString) | |
|
||
/*! | ||
* @brief 代入演算子(nullptr指定)の仕様 | ||
* @remark 代入できない(実行時エラーになる) | ||
* @note バグですね(^^; | ||
* @remark バッファを確保している場合は解放される | ||
* @remark 文字列長はゼロになる | ||
*/ | ||
TEST(CNativeW, AssignStringNullPointer) | ||
{ | ||
volatile int ret = 0; | ||
ASSERT_DEATH({ CNativeW value; value = nullptr; ret = value.capacity(); }, ".*"); | ||
(void)ret; | ||
CNativeW value(L"test"); | ||
value = nullptr; | ||
EXPECT_EQ(0, value.GetStringLength()); | ||
EXPECT_EQ(nullptr, value.GetStringPtr()); | ||
} | ||
|
||
/*! | ||
|
@@ -303,14 +308,15 @@ TEST(CNativeW, AppendString) | |
|
||
/*! | ||
* @brief 加算代入演算子(nullptr指定)の仕様 | ||
* @remark 加算代入できない(実行時エラーになる) | ||
* @note バグですね(^^; | ||
* @remark 加算代入しても内容に変化無し | ||
*/ | ||
TEST(CNativeW, AppendStringNullPointer) | ||
{ | ||
volatile int ret = 0; | ||
ASSERT_DEATH({ CNativeW value; value += nullptr; ret = value.capacity(); }, ".*"); | ||
(void)ret; | ||
CNativeW org(L"orz"); | ||
CNativeW value(org); | ||
value += nullptr; | ||
EXPECT_EQ(value.GetStringLength(), org.GetStringLength()); | ||
EXPECT_TRUE(CNativeW::IsEqual(value, org)); | ||
} | ||
|
||
/*! | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このクラスに関して、テストを整備する目的は挙動を仕様化することなので、想定結果をコメントで入れたいっす。
まあ、後で自分でPR出しますんで対応不要ですが。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2d5a94a でコメントを追加しました。