Skip to content

Commit

Permalink
ApiWrap::List_GetText()のテストを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohki Akikaze committed Jan 2, 2022
1 parent c899648 commit 978a9a5
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unittests/test-StdControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,35 @@ TEST(StdControl, Wnd_GetText2)
DestroyWindow(hwnd);
ASSERT_STREQ(s.c_str(), text);
}

TEST(StdControl, List_GetText) {
std::wstring text = L"0123456789abcdef";
HWND list = ::CreateWindow(L"LISTBOX", nullptr, 0, 1, 1, 1, 1, nullptr, nullptr, nullptr, nullptr);
ApiWrap::List_AddString(list, text.c_str());
ApiWrap::List_AddString(list, L"");

std::wstring result1;
ASSERT_TRUE(ApiWrap::List_GetText(list, 0, result1));
ASSERT_EQ(result1, text);

result1.clear();
ASSERT_TRUE(ApiWrap::List_GetText(list, 1, result1));
ASSERT_TRUE(result1.empty());

ASSERT_FALSE(ApiWrap::List_GetText(list, 2, result1));

wchar_t result2[15]{};
ASSERT_EQ(ApiWrap::List_GetText(list, 0, result2), LB_ERRSPACE);

wchar_t result3[16]{};
ASSERT_EQ(ApiWrap::List_GetText(list, 0, result3), LB_ERRSPACE);

wchar_t result4[17]{};
ASSERT_EQ(ApiWrap::List_GetText(list, 0, result4), text.length());
ASSERT_STREQ(result4, text.c_str());

result4[0] = L'\0';
ASSERT_EQ(ApiWrap::List_GetText(list, 2, result4), LB_ERR);

::DestroyWindow(list);
}

0 comments on commit 978a9a5

Please sign in to comment.