fixed bug #1098 so test-code works on ubuntu now

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6545 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2014-10-05 21:52:03 +00:00
parent 6fb77d0a16
commit 14fcfbe1a8
3 changed files with 16 additions and 6 deletions

View file

@ -12,6 +12,8 @@
#define EXEHEAD
#define NSIS_CONFIG_COMPRESSION_SUPPORT
#include "../Platform.h"
extern "C" {
#define NSIS_COMPRESS_USE_BZIP2
#include "../bzip2/bzlib.h"

View file

@ -1,5 +1,6 @@
// Reviewed for Unicode support by Jim Park -- 08/13/2007
#include <cppunit/extensions/HelperMacros.h>
#include "../util.h"
#include "../winchar.h"
#include <time.h>
@ -12,6 +13,8 @@
// BUGBUG: WinWStrDupFromWC is unable to test WCToUTF16LEHlpr because it is behind #ifdef MAKENSIS
// TODO write equal() for WINWCHAR -- http://subcommanderblog.wordpress.com/2009/01/10/cppunit_assert_equal-and-custom-data-types/
class WinCharTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( WinCharTest );
@ -24,8 +27,12 @@ class WinCharTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
NSISRT_Initialize();
}
void testFromTchar() {
unsigned short test[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
WINWCHAR test[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
WINWCHAR *dyn = WinWStrDupFromTChar(_T("test"));
CPPUNIT_ASSERT_EQUAL( 0, memcmp(test, dyn, 5) );
@ -44,7 +51,7 @@ public:
WINWCHAR a[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
WINWCHAR b[5];
CPPUNIT_ASSERT_EQUAL( b, WinWStrCpy(b, a) );
CPPUNIT_ASSERT( !WinWStrCmp(b, WinWStrCpy(b, a)) );
CPPUNIT_ASSERT_EQUAL( 0, memcmp(a, b, 5 * sizeof(WINWCHAR)) );
}
@ -52,15 +59,15 @@ public:
WINWCHAR a1[] = { _x('t'), _x('e'), _x('s'), _x('t'), 0 };
WINWCHAR b[5];
CPPUNIT_ASSERT_EQUAL( b, WinWStrNCpy(b, a1, 5) );
CPPUNIT_ASSERT( !WinWStrCmp(b, WinWStrNCpy(b, a1, 5)) );
CPPUNIT_ASSERT_EQUAL( 0, memcmp(a1, b, 5 * sizeof(WINWCHAR)) );
WINWCHAR a2[] = { _x('t'), _x('e'), 0, 0, 0 };
CPPUNIT_ASSERT_EQUAL( b, WinWStrNCpy(b, a2, 5) );
CPPUNIT_ASSERT( !WinWStrCmp(b, WinWStrNCpy(b, a2, 5)) );
CPPUNIT_ASSERT_EQUAL( 0, memcmp(a2, b, 5 * sizeof(WINWCHAR)) );
CPPUNIT_ASSERT_EQUAL( b, WinWStrNCpy(b, a1, 2) );
CPPUNIT_ASSERT( !WinWStrCmp(b, WinWStrNCpy(b, a1, 2)) );
CPPUNIT_ASSERT_EQUAL( 0, memcmp(a2, b, 5 * sizeof(WINWCHAR)) );
}

View file

@ -196,7 +196,7 @@ int wsprintf(TCHAR *s, const TCHAR *format, ...) {
return res;
}
static char g_nrt_iconv_narrowlocbuf[50], *g_nrt_iconv_narrowloc;
static char g_nrt_iconv_narrowlocbuf[50], *g_nrt_iconv_narrowloc = 0;
#define setlocale_ACP(cat) setlocale((cat), "")
#define iconv_ACP g_nrt_iconv_narrowloc
#define setlocale_OEM(cat) NSISRT_setlocale_wincp((cat), 1252)
@ -453,6 +453,7 @@ bool nsis_iconv_reallociconv(iconv_t CD, char**In, size_t*cbInLeft, char**Mem, s
const unsigned short CODEPAGESTR_MAXLEN = 50; // Should be plenty
void create_code_page_string(TCHAR *buf, size_t len, UINT code_page)
{
if (!g_nrt_iconv_narrowloc) NSISRT_Initialize(); // For winchar.cpp unit test
switch(code_page)
{
case CP_ACP: _sntprintf(buf, len, _T("%") NPRINs, iconv_ACP); return;