added winchar_strdup
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4936 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
82ab983cbd
commit
0b19a3fa29
3 changed files with 19 additions and 0 deletions
|
@ -13,6 +13,7 @@ class WinCharTest : public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST( testStrNCpy );
|
CPPUNIT_TEST( testStrNCpy );
|
||||||
CPPUNIT_TEST( testStrLen );
|
CPPUNIT_TEST( testStrLen );
|
||||||
CPPUNIT_TEST( testStrCmp );
|
CPPUNIT_TEST( testStrCmp );
|
||||||
|
CPPUNIT_TEST( testStrDup );
|
||||||
CPPUNIT_TEST( testStoi );
|
CPPUNIT_TEST( testStoi );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
@ -96,6 +97,16 @@ public:
|
||||||
TEST_STR_CMP(empty, empty);
|
TEST_STR_CMP(empty, empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testStrDup() {
|
||||||
|
WCHAR a[] = { 'a', 'b', 'c', 0 };
|
||||||
|
|
||||||
|
WCHAR *b = winchar_strdup(a);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL( 0, winchar_strcmp(a, b) );
|
||||||
|
|
||||||
|
delete [] b;
|
||||||
|
}
|
||||||
|
|
||||||
void testStoi() {
|
void testStoi() {
|
||||||
srand(time(0));
|
srand(time(0));
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,13 @@ size_t winchar_strlen(WCHAR *ws)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WCHAR *winchar_strdup(WCHAR *ws)
|
||||||
|
{
|
||||||
|
WCHAR *dup = new WCHAR[winchar_strlen(ws) + 1];
|
||||||
|
winchar_strcpy(dup, ws);
|
||||||
|
return dup;
|
||||||
|
}
|
||||||
|
|
||||||
int winchar_strcmp(const WCHAR *ws1, const WCHAR *ws2)
|
int winchar_strcmp(const WCHAR *ws1, const WCHAR *ws2)
|
||||||
{
|
{
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
|
|
|
@ -5,5 +5,6 @@ char *winchar_toansi(const WCHAR* ws, unsigned int codepage = CP_ACP);
|
||||||
WCHAR *winchar_strcpy(WCHAR *ws1, const WCHAR *ws2);
|
WCHAR *winchar_strcpy(WCHAR *ws1, const WCHAR *ws2);
|
||||||
WCHAR *winchar_strncpy(WCHAR *ws1, const WCHAR *ws2, size_t n);
|
WCHAR *winchar_strncpy(WCHAR *ws1, const WCHAR *ws2, size_t n);
|
||||||
size_t winchar_strlen(WCHAR *ws);
|
size_t winchar_strlen(WCHAR *ws);
|
||||||
|
WCHAR *winchar_strdup(WCHAR *ws);
|
||||||
int winchar_strcmp(const WCHAR *ws1, const WCHAR *ws2);
|
int winchar_strcmp(const WCHAR *ws1, const WCHAR *ws2);
|
||||||
int winchar_stoi(const WCHAR *ws);
|
int winchar_stoi(const WCHAR *ws);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue