digitalmars.D - unittest and WinMain
- ElfQT (22/22) Mar 03 2008 How can I run the unittest part in the code below?
- Robert Fraser (16/45) Mar 03 2008 Method 1:
- Robert Fraser (4/56) Mar 03 2008 Oops, spoke too soon. You do indeed need to call those, as well as
- ElfQT (1/1) Mar 03 2008 Thank You Robert, I will try that soon. ElfQT
How can I run the unittest part in the code below? I've tried several ways, but ni succes. dmd -unittest tangoUnitTest.d (I use "tango-0.99.4-bin-win32-dmd.1.024.zip".) import tango.sys.win32.UserGdi; extern (C) void rt_init( void delegate(Exception) dg = null ); extern (C) void rt_term( void delegate(Exception) dg = null ); extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { rt_init(); rt_term(); return 0; } unittest { assert(1==2); } ElfQT
Mar 03 2008
ElfQT wrote:How can I run the unittest part in the code below? I've tried several ways, but ni succes. dmd -unittest tangoUnitTest.d (I use "tango-0.99.4-bin-win32-dmd.1.024.zip".) import tango.sys.win32.UserGdi; extern (C) void rt_init( void delegate(Exception) dg = null ); extern (C) void rt_term( void delegate(Exception) dg = null ); extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { rt_init(); rt_term(); return 0; } unittest { assert(1==2); } ElfQTMethod 1: --------- extern(C) _moduleUnitTests(); BOOL WinMain(...) { _moduleUnitTests(); } Method 2: --------- http://flectioned.kuehne.cn/#unittest Or my own: http://www.dsource.org/projects/descent/browser/trunk/descent.unittest/flute/src/org/dsource/descent/unittests/flute.d These run the unit tests from within a static this() block, which hopefully runs before WinMain() (if not, you'll have to manually call _minit() and _moduleCtor(), but you'd probably need that anyway), and don't stop as soon as a test fails.
Mar 03 2008
Robert Fraser wrote:ElfQT wrote:Oops, spoke too soon. You do indeed need to call those, as well as initialize the GC: http://www.digitalmars.com/d/1.0/windows.htmlHow can I run the unittest part in the code below? I've tried several ways, but ni succes. dmd -unittest tangoUnitTest.d (I use "tango-0.99.4-bin-win32-dmd.1.024.zip".) import tango.sys.win32.UserGdi; extern (C) void rt_init( void delegate(Exception) dg = null ); extern (C) void rt_term( void delegate(Exception) dg = null ); extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { rt_init(); rt_term(); return 0; } unittest { assert(1==2); } ElfQTMethod 1: --------- extern(C) _moduleUnitTests(); BOOL WinMain(...) { _moduleUnitTests(); } Method 2: --------- http://flectioned.kuehne.cn/#unittest Or my own: http://www.dsource.org/projects/descent/browser/trunk/descent.unittest/flute/src/org/dsource/desce t/unittests/flute.d These run the unit tests from within a static this() block, which hopefully runs before WinMain() (if not, you'll have to manually call _minit() and _moduleCtor(), but you'd probably need that anyway), and don't stop as soon as a test fails.
Mar 03 2008
Thank You Robert, I will try that soon. ElfQT
Mar 03 2008