From 9210ac57ceca00d95ad3a0fd8974f26affdc1516 Mon Sep 17 00:00:00 2001 From: berryplus Date: Sat, 4 Apr 2020 14:55:27 +0900 Subject: [PATCH 1/4] =?UTF-8?q?CNative=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E3=81=AE=E6=9C=9F=E5=BE=85=E5=80=A4=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LE(=less than or Equal)とすべきところをLT(=less than)としていた。 コメントに書いてある通り、期待値は「より大きい」で「以上」ではないので修正しておく。 --- tests/unittests/test-cnative.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/unittests/test-cnative.cpp b/tests/unittests/test-cnative.cpp index b13664bf13..0ed1352914 100644 --- a/tests/unittests/test-cnative.cpp +++ b/tests/unittests/test-cnative.cpp @@ -54,7 +54,7 @@ TEST(CNativeW, ConstructWithStringWithLength) CNativeW value(sz, cch); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_LE(cch + 1, value.capacity()); } /*! @@ -70,7 +70,7 @@ TEST(CNativeW, ConstructWithString) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_LE(cch + 1, value.capacity()); } /*! @@ -83,7 +83,7 @@ TEST(CNativeW, ConstructWithStringEmpty) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_LT(1, value.capacity()); + EXPECT_LE(1, value.capacity()); } /*! @@ -133,7 +133,7 @@ TEST(CNativeW, ConstructFromOtherByMove) CNativeW value(std::move(other)); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_LE(cch + 1, value.capacity()); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -157,7 +157,7 @@ TEST(CNativeW, CopyFromOther) value = other; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_LE(cch + 1, value.capacity()); // コピー元バッファとは別に新しいバッファが確保される ASSERT_NE(other.GetStringPtr(), value.GetStringPtr()); @@ -179,7 +179,7 @@ TEST(CNativeW, MoveFromOther) value = std::move(other); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_LE(cch + 1, value.capacity()); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -220,7 +220,7 @@ TEST(CNativeW, AssignString) value = sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_LE(cch + 1, value.capacity()); } /*! @@ -263,7 +263,7 @@ TEST(CNativeW, AppendChar) value += sz[0]; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(1, value.GetStringLength()); - EXPECT_LT(1 + 1, value.capacity()); + EXPECT_LE(1 + 1, value.capacity()); } /*! @@ -280,7 +280,7 @@ TEST(CNativeW, AppendString) value += sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_LE(cch + 1, value.capacity()); } /*! @@ -548,7 +548,7 @@ TEST(CNativeW, ReplaceOfNullString) value.Replace(L"置換前", L"置換後"); ASSERT_STREQ(L"", value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_LT(1, value.capacity()); + EXPECT_LE(1, value.capacity()); } /*! From 4338501af3615d60e3ba535328aba3f5f7268a78 Mon Sep 17 00:00:00 2001 From: berryplus Date: Wed, 22 Apr 2020 00:19:01 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Revert=20"CNative=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=B1=E3=83=BC=E3=82=B9=E3=81=AE=E6=9C=9F=E5=BE=85?= =?UTF-8?q?=E5=80=A4=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=99=E3=82=8B"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 05fec6894fbf8fe42abd875504c863cd1b06ea51. --- tests/unittests/test-cnative.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/unittests/test-cnative.cpp b/tests/unittests/test-cnative.cpp index 0ed1352914..b13664bf13 100644 --- a/tests/unittests/test-cnative.cpp +++ b/tests/unittests/test-cnative.cpp @@ -54,7 +54,7 @@ TEST(CNativeW, ConstructWithStringWithLength) CNativeW value(sz, cch); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LE(cch + 1, value.capacity()); + EXPECT_LT(cch + 1, value.capacity()); } /*! @@ -70,7 +70,7 @@ TEST(CNativeW, ConstructWithString) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LE(cch + 1, value.capacity()); + EXPECT_LT(cch + 1, value.capacity()); } /*! @@ -83,7 +83,7 @@ TEST(CNativeW, ConstructWithStringEmpty) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_LE(1, value.capacity()); + EXPECT_LT(1, value.capacity()); } /*! @@ -133,7 +133,7 @@ TEST(CNativeW, ConstructFromOtherByMove) CNativeW value(std::move(other)); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LE(cch + 1, value.capacity()); + EXPECT_LT(cch + 1, value.capacity()); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -157,7 +157,7 @@ TEST(CNativeW, CopyFromOther) value = other; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LE(cch + 1, value.capacity()); + EXPECT_LT(cch + 1, value.capacity()); // コピー元バッファとは別に新しいバッファが確保される ASSERT_NE(other.GetStringPtr(), value.GetStringPtr()); @@ -179,7 +179,7 @@ TEST(CNativeW, MoveFromOther) value = std::move(other); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LE(cch + 1, value.capacity()); + EXPECT_LT(cch + 1, value.capacity()); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -220,7 +220,7 @@ TEST(CNativeW, AssignString) value = sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LE(cch + 1, value.capacity()); + EXPECT_LT(cch + 1, value.capacity()); } /*! @@ -263,7 +263,7 @@ TEST(CNativeW, AppendChar) value += sz[0]; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(1, value.GetStringLength()); - EXPECT_LE(1 + 1, value.capacity()); + EXPECT_LT(1 + 1, value.capacity()); } /*! @@ -280,7 +280,7 @@ TEST(CNativeW, AppendString) value += sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LE(cch + 1, value.capacity()); + EXPECT_LT(cch + 1, value.capacity()); } /*! @@ -548,7 +548,7 @@ TEST(CNativeW, ReplaceOfNullString) value.Replace(L"置換前", L"置換後"); ASSERT_STREQ(L"", value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_LE(1, value.capacity()); + EXPECT_LT(1, value.capacity()); } /*! From 03f7c797904ce021076908bf083ccd29421259d4 Mon Sep 17 00:00:00 2001 From: berryplus Date: Wed, 22 Apr 2020 00:37:47 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=A2?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E6=9D=A1=E4=BB=B6=E3=81=AB=E5=90=88=E3=82=8F?= =?UTF-8?q?=E3=81=9B=E3=81=A6=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 期待結果「Nより大きい」に対して「N+1より小さい」になっていた。 「Nより大きい」の左右を反転すると「N以下」なので間違いではないが混乱のもとになるので修正する。 --- tests/unittests/test-cnative.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/unittests/test-cnative.cpp b/tests/unittests/test-cnative.cpp index b13664bf13..03bacbb28e 100644 --- a/tests/unittests/test-cnative.cpp +++ b/tests/unittests/test-cnative.cpp @@ -54,7 +54,7 @@ TEST(CNativeW, ConstructWithStringWithLength) CNativeW value(sz, cch); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_GT(value.capacity(), cch); } /*! @@ -70,7 +70,7 @@ TEST(CNativeW, ConstructWithString) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_GT(value.capacity(), cch); } /*! @@ -83,7 +83,7 @@ TEST(CNativeW, ConstructWithStringEmpty) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_LT(1, value.capacity()); + EXPECT_GT(value.capacity(), 0); } /*! @@ -133,7 +133,7 @@ TEST(CNativeW, ConstructFromOtherByMove) CNativeW value(std::move(other)); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_GT(value.capacity(), cch); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -157,7 +157,7 @@ TEST(CNativeW, CopyFromOther) value = other; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_GT(value.capacity(), cch); // コピー元バッファとは別に新しいバッファが確保される ASSERT_NE(other.GetStringPtr(), value.GetStringPtr()); @@ -179,7 +179,7 @@ TEST(CNativeW, MoveFromOther) value = std::move(other); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_GT(value.capacity(), cch); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -220,7 +220,7 @@ TEST(CNativeW, AssignString) value = sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_GT(value.capacity(), cch); } /*! @@ -263,7 +263,7 @@ TEST(CNativeW, AppendChar) value += sz[0]; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(1, value.GetStringLength()); - EXPECT_LT(1 + 1, value.capacity()); + EXPECT_GT(value.capacity(), 1); } /*! @@ -280,7 +280,7 @@ TEST(CNativeW, AppendString) value += sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_LT(cch + 1, value.capacity()); + EXPECT_GT(value.capacity(), cch); } /*! @@ -548,7 +548,7 @@ TEST(CNativeW, ReplaceOfNullString) value.Replace(L"置換前", L"置換後"); ASSERT_STREQ(L"", value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_LT(1, value.capacity()); + EXPECT_GT(value.capacity(), 0); } /*! From 01e070bd9d4156d888e1e22f685779dd0b8ac730 Mon Sep 17 00:00:00 2001 From: berryplus Date: Thu, 23 Apr 2020 12:51:18 +0900 Subject: [PATCH 4/4] =?UTF-8?q?EXPECT=5FGT=E3=81=A0=E3=81=A8=E8=A6=8B?= =?UTF-8?q?=E8=BE=9B=E3=81=84=E3=81=AE=E3=81=A7=E5=8F=8D=E8=BB=A2=E3=81=95?= =?UTF-8?q?=E3=81=9B=E3=81=A6LE=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit コメントで混乱しないように「~より大きくなる」の表現を書き替える。 --- tests/unittests/test-cnative.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/unittests/test-cnative.cpp b/tests/unittests/test-cnative.cpp index 03bacbb28e..3468df26fb 100644 --- a/tests/unittests/test-cnative.cpp +++ b/tests/unittests/test-cnative.cpp @@ -45,7 +45,7 @@ TEST(CNativeW, ConstructWithoutParam) * @brief コンストラクタ(文字列と文字列長指定)の仕様 * @remark バッファが確保される * @remark 文字列長は指定した文字列長になる - * @remark バッファサイズは指定した文字列長より大きくなる + * @remark バッファサイズは指定した文字列を格納できるサイズになる */ TEST(CNativeW, ConstructWithStringWithLength) { @@ -54,7 +54,7 @@ TEST(CNativeW, ConstructWithStringWithLength) CNativeW value(sz, cch); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_GT(value.capacity(), cch); + EXPECT_LE(cch, value.capacity()); } /*! @@ -70,7 +70,7 @@ TEST(CNativeW, ConstructWithString) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_GT(value.capacity(), cch); + EXPECT_LE(cch, value.capacity()); } /*! @@ -83,7 +83,7 @@ TEST(CNativeW, ConstructWithStringEmpty) CNativeW value(sz); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_GT(value.capacity(), 0); + EXPECT_LE(0, value.capacity()); } /*! @@ -133,7 +133,7 @@ TEST(CNativeW, ConstructFromOtherByMove) CNativeW value(std::move(other)); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_GT(value.capacity(), cch); + EXPECT_LE(cch, value.capacity()); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -157,7 +157,7 @@ TEST(CNativeW, CopyFromOther) value = other; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_GT(value.capacity(), cch); + EXPECT_LE(cch, value.capacity()); // コピー元バッファとは別に新しいバッファが確保される ASSERT_NE(other.GetStringPtr(), value.GetStringPtr()); @@ -179,7 +179,7 @@ TEST(CNativeW, MoveFromOther) value = std::move(other); ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_GT(value.capacity(), cch); + EXPECT_LE(cch, value.capacity()); // ムーブ元は抜け殻になる ASSERT_EQ(NULL, other.GetStringPtr()); @@ -220,7 +220,7 @@ TEST(CNativeW, AssignString) value = sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_GT(value.capacity(), cch); + EXPECT_LE(cch, value.capacity()); } /*! @@ -253,7 +253,7 @@ TEST(CNativeW, AssignStringNullLiteral) * @brief 加算代入演算子(文字指定)の仕様 * @remark バッファが確保される * @remark 文字列長は演算子呼出前の文字列長+1になる - * @remark バッファサイズは2以上になる + * @remark バッファサイズは連結された文字列を格納できるサイズになる */ TEST(CNativeW, AppendChar) { @@ -263,7 +263,7 @@ TEST(CNativeW, AppendChar) value += sz[0]; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(1, value.GetStringLength()); - EXPECT_GT(value.capacity(), 1); + EXPECT_LE(1, value.capacity()); } /*! @@ -280,7 +280,7 @@ TEST(CNativeW, AppendString) value += sz; ASSERT_STREQ(sz, value.GetStringPtr()); EXPECT_EQ(cch, value.GetStringLength()); - EXPECT_GT(value.capacity(), cch); + EXPECT_LE(cch, value.capacity()); } /*! @@ -540,7 +540,7 @@ TEST(CNativeW, operatorNotEqualStringNull) * @brief 独自関数Replaceの仕様 * @remark バッファが確保される * @remark 文字列長は0になる - * @remark バッファサイズは1以上になる + * @remark バッファサイズは空文字列を格納できるサイズになる */ TEST(CNativeW, ReplaceOfNullString) { @@ -548,7 +548,7 @@ TEST(CNativeW, ReplaceOfNullString) value.Replace(L"置換前", L"置換後"); ASSERT_STREQ(L"", value.GetStringPtr()); EXPECT_EQ(0, value.GetStringLength()); - EXPECT_GT(value.capacity(), 0); + EXPECT_LE(0, value.capacity()); } /*! @@ -600,7 +600,7 @@ TEST(CNativeW, Clear) // 1-3. バッファの状態をチェックする - EXPECT_GT(orgCapacity, 0); // データ追加後のバッファサイズを確認する + EXPECT_LE(0, orgCapacity); // データ追加後のバッファサイズを確認する EXPECT_EQ(orgLength, fixedPatternLen); // データ追加後のデータサイズを確認する // 2-1. CNativeW をクリアする