在VS2012单元测试中创建和测试自定义MFC CEdit时,在第21行的afxwin1.inl中断言

Assert in afxwin1.inl on line 21 when creating and testing a custom MFC CEdit in VS2012 unit test

本文关键字:21行 在第 afxwin1 断言 中断 inl CEdit 单元测试 VS2012 创建 MFC      更新时间:2023-10-16

我的老板有一个名为CInPlaceEdit的自定义CEdit类,我们目前正在Visual Studio 2012中用一个单元测试项目测试这个类。基本上,我们在单元测试中创建CEdit类,如下所示:

CDialog *dlg = new CDialog();
dlg->Create(IDD_EDIT_STRING);
CWnd *pListCtrl = dlg;
auto pParent = pListCtrl->GetParent();

auto editSpLat = new CInPlaceEdit(-1, i, pszBlank, GetEditTemplates()->m_pEdtSpLat, (void*)&m_pSP, pListCtrl, IPE_CTRL | IPE_PTRTOPTR_VAR | IPE_RIGHT_JUSTIFY, ids);
editSpLat->Create(dwStyle, CRect(0, 0, 1, 1), pListCtrl, IDC_INPLACEEDIT + i);

afxwin1.inl中第21行的assert是在调用Create(…)期间抛出的;文件afxwin1.inl中的断言是ASSERT(afxCurrentInstanceHandle != NULL)。有没有办法让我的单元测试通过这一关?

字符集不匹配可能会导致此问题。

mfc dll正在使用UNICODE。

请确保"IDD_EDIT_STRING"使用的是unicode,而不是ANSI

也许可以尝试在字符集中使用No Set

(配置属性->常规->字符集)

相关文章: