msvc unittests for dlangui

This commit is contained in:
Vadim Lopatin 2015-12-24 08:38:21 +03:00
parent a2c6d38970
commit 7982e7e3fe
5 changed files with 316 additions and 71 deletions

View File

@ -51,6 +51,8 @@ Global
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Unittest|Win32 = Unittest|Win32
Unittest|x64 = Unittest|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Debug|Win32.ActiveCfg = Debug|Win32
@ -61,6 +63,10 @@ Global
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Release|Win32.Build.0 = Release|Win32
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Release|x64.ActiveCfg = Release|x64
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Release|x64.Build.0 = Release|x64
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Unittest|Win32.ActiveCfg = Unittest|Win32
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Unittest|Win32.Build.0 = Unittest|Win32
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Unittest|x64.ActiveCfg = Unittest|x64
{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}.Unittest|x64.Build.0 = Unittest|x64
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Debug|Win32.ActiveCfg = Debug|Win32
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Debug|Win32.Build.0 = Debug|Win32
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Debug|x64.ActiveCfg = Debug|x64
@ -69,6 +75,10 @@ Global
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Release|Win32.Build.0 = Release|Win32
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Release|x64.ActiveCfg = Release|x64
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Release|x64.Build.0 = Release|x64
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Unittest|Win32.ActiveCfg = Release|Win32
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Unittest|Win32.Build.0 = Release|Win32
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Unittest|x64.ActiveCfg = Release|x64
{1C8C4726-B356-4533-90C7-88BDA875BF30}.Unittest|x64.Build.0 = Release|x64
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Debug|Win32.ActiveCfg = Debug|Win32
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Debug|Win32.Build.0 = Debug|Win32
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Debug|x64.ActiveCfg = Debug|x64
@ -77,6 +87,10 @@ Global
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Release|Win32.Build.0 = Release|Win32
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Release|x64.ActiveCfg = Release|x64
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Release|x64.Build.0 = Release|x64
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Unittest|Win32.ActiveCfg = Release|Win32
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Unittest|Win32.Build.0 = Release|Win32
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Unittest|x64.ActiveCfg = Release|x64
{79EA1B6E-D87E-4C45-A12D-7AD00C398F1F}.Unittest|x64.Build.0 = Release|x64
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Debug|Win32.ActiveCfg = Debug|Win32
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Debug|Win32.Build.0 = Debug|Win32
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Debug|x64.ActiveCfg = Debug|x64
@ -85,6 +99,10 @@ Global
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Release|Win32.Build.0 = Release|Win32
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Release|x64.ActiveCfg = Release|x64
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Release|x64.Build.0 = Release|x64
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Unittest|Win32.ActiveCfg = Release|Win32
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Unittest|Win32.Build.0 = Release|Win32
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Unittest|x64.ActiveCfg = Release|x64
{B1CA031C-C195-4938-8F3E-8BFF7DA68933}.Unittest|x64.Build.0 = Release|x64
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Debug|Win32.ActiveCfg = Debug|Win32
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Debug|Win32.Build.0 = Debug|Win32
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Debug|x64.ActiveCfg = Debug|x64
@ -93,6 +111,10 @@ Global
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Release|Win32.Build.0 = Release|Win32
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Release|x64.ActiveCfg = Release|x64
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Release|x64.Build.0 = Release|x64
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Unittest|Win32.ActiveCfg = Release|Win32
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Unittest|Win32.Build.0 = Release|Win32
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Unittest|x64.ActiveCfg = Release|x64
{9F5147FF-DB71-4CEC-BF2F-803143E42BCD}.Unittest|x64.Build.0 = Release|x64
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Debug|Win32.ActiveCfg = Debug|Win32
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Debug|Win32.Build.0 = Debug|Win32
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Debug|x64.ActiveCfg = Debug|x64
@ -101,12 +123,20 @@ Global
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Release|Win32.Build.0 = Release|Win32
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Release|x64.ActiveCfg = Release|x64
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Release|x64.Build.0 = Release|x64
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Unittest|Win32.ActiveCfg = Release|Win32
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Unittest|Win32.Build.0 = Release|Win32
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Unittest|x64.ActiveCfg = Release|x64
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Unittest|x64.Build.0 = Release|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Debug|Win32.ActiveCfg = Debug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Debug|Win32.Build.0 = Debug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Debug|x64.ActiveCfg = Debug|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Release|Win32.ActiveCfg = Release|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Release|Win32.Build.0 = Release|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Release|x64.ActiveCfg = Release|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Unittest|Win32.ActiveCfg = Release|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Unittest|Win32.Build.0 = Release|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Unittest|x64.ActiveCfg = Release|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Unittest|x64.Build.0 = Release|x64
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Debug|Win32.ActiveCfg = Debug|Win32
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Debug|Win32.Build.0 = Debug|Win32
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Debug|x64.ActiveCfg = Debug|x64
@ -114,12 +144,20 @@ Global
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Release|Win32.ActiveCfg = Release|Win32
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Release|Win32.Build.0 = Release|Win32
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Release|x64.ActiveCfg = Release|x64
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Unittest|Win32.ActiveCfg = Release|Win32
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Unittest|Win32.Build.0 = Release|Win32
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Unittest|x64.ActiveCfg = Release|x64
{533AF38D-98E7-446F-9689-805BDFF3CE84}.Unittest|x64.Build.0 = Release|x64
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Debug|Win32.ActiveCfg = Debug|Win32
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Debug|Win32.Build.0 = Debug|Win32
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Debug|x64.ActiveCfg = Debug|x64
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Release|Win32.ActiveCfg = Release|Win32
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Release|Win32.Build.0 = Release|Win32
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Release|x64.ActiveCfg = Release|x64
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Unittest|Win32.ActiveCfg = Release|Win32
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Unittest|Win32.Build.0 = Release|Win32
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Unittest|x64.ActiveCfg = Release|x64
{29CF2CAC-2C0C-4F17-9292-E1706AC7EBBF}.Unittest|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -33,7 +33,7 @@
<useArrayBounds>0</useArrayBounds>
<noboundscheck>0</noboundscheck>
<useSwitchError>0</useSwitchError>
<useUnitTests>1</useUnitTests>
<useUnitTests>0</useUnitTests>
<useInline>0</useInline>
<release>0</release>
<preservePaths>0</preservePaths>
@ -44,7 +44,7 @@
<pic>0</pic>
<cov>0</cov>
<nofloat>0</nofloat>
<Dversion>2.043</Dversion>
<Dversion>2</Dversion>
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
<allinst>0</allinst>
<stackStomp>0</stackStomp>
@ -102,6 +102,108 @@
<postBuildCommand />
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
</Config>
<Config name="Unittest" platform="Win32">
<obj>0</obj>
<link>0</link>
<lib>0</lib>
<subsystem>1</subsystem>
<multiobj>0</multiobj>
<singleFileCompilation>0</singleFileCompilation>
<oneobj>0</oneobj>
<mscoff>0</mscoff>
<trace>0</trace>
<quiet>0</quiet>
<verbose>0</verbose>
<vtls>0</vtls>
<vgc>0</vgc>
<symdebug>1</symdebug>
<optimize>0</optimize>
<cpu>0</cpu>
<isX86_64>0</isX86_64>
<isLinux>0</isLinux>
<isOSX>0</isOSX>
<isWindows>0</isWindows>
<isFreeBSD>0</isFreeBSD>
<isSolaris>0</isSolaris>
<scheduler>0</scheduler>
<useDeprecated>0</useDeprecated>
<errDeprecated>1</errDeprecated>
<useAssert>0</useAssert>
<useInvariants>0</useInvariants>
<useIn>0</useIn>
<useOut>0</useOut>
<useArrayBounds>0</useArrayBounds>
<noboundscheck>0</noboundscheck>
<useSwitchError>0</useSwitchError>
<useUnitTests>1</useUnitTests>
<useInline>0</useInline>
<release>0</release>
<preservePaths>0</preservePaths>
<warnings>1</warnings>
<infowarnings>0</infowarnings>
<checkProperty>0</checkProperty>
<genStackFrame>0</genStackFrame>
<pic>0</pic>
<cov>0</cov>
<nofloat>0</nofloat>
<Dversion>2</Dversion>
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
<allinst>0</allinst>
<stackStomp>0</stackStomp>
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath />
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>
<objname />
<libname />
<doDocComments>0</doDocComments>
<docdir />
<docname />
<modules_ddoc />
<ddocfiles />
<doHdrGeneration>0</doHdrGeneration>
<hdrdir />
<hdrname />
<doXGeneration>1</doXGeneration>
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
<debuglevel>0</debuglevel>
<debugids />
<versionlevel>0</versionlevel>
<versionids>EmbedStandardResources ForceLogs</versionids>
<dump_source>0</dump_source>
<mapverbosity>0</mapverbosity>
<createImplib>0</createImplib>
<defaultlibname />
<debuglibname />
<moduleDepsFile />
<run>0</run>
<runargs />
<runCv2pdb>1</runCv2pdb>
<pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
<cv2pdbPre2043>0</cv2pdbPre2043>
<cv2pdbNoDemangle>0</cv2pdbNoDemangle>
<cv2pdbEnumType>0</cv2pdbEnumType>
<cv2pdbOptions />
<objfiles />
<linkswitches />
<libfiles />
<libpaths />
<deffile />
<resfile />
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
<useStdLibPath>1</useStdLibPath>
<cRuntime>2</cRuntime>
<privatePhobos>0</privatePhobos>
<additionalOptions />
<preBuildCommand />
<postBuildCommand />
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
</Config>
<Config name="Release" platform="Win32">
<obj>0</obj>
<link>0</link>
@ -306,6 +408,108 @@
<postBuildCommand />
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
</Config>
<Config name="Unittest" platform="x64">
<obj>0</obj>
<link>0</link>
<lib>1</lib>
<subsystem>0</subsystem>
<multiobj>0</multiobj>
<singleFileCompilation>0</singleFileCompilation>
<oneobj>0</oneobj>
<mscoff>0</mscoff>
<trace>0</trace>
<quiet>0</quiet>
<verbose>0</verbose>
<vtls>0</vtls>
<vgc>0</vgc>
<symdebug>1</symdebug>
<optimize>0</optimize>
<cpu>0</cpu>
<isX86_64>1</isX86_64>
<isLinux>0</isLinux>
<isOSX>0</isOSX>
<isWindows>0</isWindows>
<isFreeBSD>0</isFreeBSD>
<isSolaris>0</isSolaris>
<scheduler>0</scheduler>
<useDeprecated>0</useDeprecated>
<errDeprecated>1</errDeprecated>
<useAssert>0</useAssert>
<useInvariants>0</useInvariants>
<useIn>0</useIn>
<useOut>0</useOut>
<useArrayBounds>0</useArrayBounds>
<noboundscheck>0</noboundscheck>
<useSwitchError>0</useSwitchError>
<useUnitTests>1</useUnitTests>
<useInline>0</useInline>
<release>0</release>
<preservePaths>0</preservePaths>
<warnings>1</warnings>
<infowarnings>0</infowarnings>
<checkProperty>0</checkProperty>
<genStackFrame>0</genStackFrame>
<pic>0</pic>
<cov>0</cov>
<nofloat>0</nofloat>
<Dversion>2</Dversion>
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
<allinst>0</allinst>
<stackStomp>0</stackStomp>
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath />
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>
<objname />
<libname />
<doDocComments>0</doDocComments>
<docdir />
<docname />
<modules_ddoc />
<ddocfiles />
<doHdrGeneration>0</doHdrGeneration>
<hdrdir />
<hdrname />
<doXGeneration>1</doXGeneration>
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
<debuglevel>0</debuglevel>
<debugids />
<versionlevel>0</versionlevel>
<versionids>EmbedStandardResources ForceLogs</versionids>
<dump_source>0</dump_source>
<mapverbosity>0</mapverbosity>
<createImplib>0</createImplib>
<defaultlibname />
<debuglibname />
<moduleDepsFile />
<run>0</run>
<runargs />
<runCv2pdb>1</runCv2pdb>
<pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
<cv2pdbPre2043>0</cv2pdbPre2043>
<cv2pdbNoDemangle>0</cv2pdbNoDemangle>
<cv2pdbEnumType>0</cv2pdbEnumType>
<cv2pdbOptions />
<objfiles />
<linkswitches />
<libfiles />
<libpaths />
<deffile />
<resfile />
<exefile>$(OutDir)\$(ProjectName).lib</exefile>
<useStdLibPath>1</useStdLibPath>
<cRuntime>2</cRuntime>
<privatePhobos>0</privatePhobos>
<additionalOptions />
<preBuildCommand />
<postBuildCommand />
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
</Config>
<Config name="Release" platform="x64">
<obj>0</obj>
<link>0</link>
@ -467,15 +671,6 @@
<File path="3rdparty\fontconfig\package.d" />
<File path="3rdparty\fontconfig\types.d" />
</Folder>
<Folder name="gl3n">
<File path="deps\gl3n\gl3n\aabb.d" />
<File path="deps\gl3n\gl3n\frustum.d" />
<File path="deps\gl3n\gl3n\interpolate.d" />
<File path="deps\gl3n\gl3n\linalg.d" />
<File path="deps\gl3n\gl3n\math.d" />
<File path="deps\gl3n\gl3n\plane.d" />
<File path="deps\gl3n\gl3n\util.d" />
</Folder>
<Folder name="win32">
<File path="3rdparty\win32\basetsd.d" />
<File path="3rdparty\win32\basetyps.d" />

View File

@ -609,29 +609,27 @@ private bool parseColor(ref string src, ref CssLength value)
}
version(unittest) {
void testCSS() {
CssStyle style = new CssStyle();
CssDeclaration decl = new CssDeclaration();
CssWhiteSpace whiteSpace = CssWhiteSpace.inherit;
CssTextAlign textAlign = CssTextAlign.inherit;
CssTextAlign textAlignLast = CssTextAlign.inherit;
CssTextDecoration textDecoration = CssTextDecoration.inherit;
CssHyphenate hyphenate = CssHyphenate.inherit;
string src = "{ display: inline; text-decoration: underline; white-space: pre; text-align: right; text-align-last: left; hyphenate: auto }";
assert(decl.parse(src, true));
assert(style.display == CssDisplay.block);
assert(style.textDecoration == CssTextDecoration.inherit);
assert(style.whiteSpace == CssWhiteSpace.inherit);
assert(style.textAlign == CssTextAlign.inherit);
assert(style.textAlignLast == CssTextAlign.inherit);
assert(style.hyphenate == CssHyphenate.inherit);
decl.apply(style);
assert(style.display == CssDisplay.inline);
assert(style.textDecoration == CssTextDecoration.underline);
assert(style.whiteSpace == CssWhiteSpace.pre);
assert(style.textAlign == CssTextAlign.right);
assert(style.textAlignLast == CssTextAlign.left);
assert(style.hyphenate == CssHyphenate.auto_);
}
unittest {
CssStyle style = new CssStyle();
CssDeclaration decl = new CssDeclaration();
CssWhiteSpace whiteSpace = CssWhiteSpace.inherit;
CssTextAlign textAlign = CssTextAlign.inherit;
CssTextAlign textAlignLast = CssTextAlign.inherit;
CssTextDecoration textDecoration = CssTextDecoration.inherit;
CssHyphenate hyphenate = CssHyphenate.inherit;
string src = "{ display: inline; text-decoration: underline; white-space: pre; text-align: right; text-align-last: left; hyphenate: auto }";
assert(decl.parse(src, true));
assert(style.display == CssDisplay.block);
assert(style.textDecoration == CssTextDecoration.inherit);
assert(style.whiteSpace == CssWhiteSpace.inherit);
assert(style.textAlign == CssTextAlign.inherit);
assert(style.textAlignLast == CssTextAlign.inherit);
assert(style.hyphenate == CssHyphenate.inherit);
decl.apply(style);
assert(style.display == CssDisplay.inline);
assert(style.textDecoration == CssTextDecoration.underline);
assert(style.whiteSpace == CssWhiteSpace.pre);
assert(style.textAlign == CssTextAlign.right);
assert(style.textAlignLast == CssTextAlign.left);
assert(style.hyphenate == CssHyphenate.auto_);
}

View File

@ -403,40 +403,35 @@ enum Ns : ns_id {
xsi
}
version(unittest) {
void testDOM() {
import std.algorithm : equal;
//import std.stdio;
IdentMap!(elem_id) map;
map.init!Tag();
//writeln("running DOM unit test");
assert(map["pre"] == Tag.pre);
assert(map["body"] == Tag.body_);
assert(map[Tag.div].equal("div"));
Document doc = new Document();
auto body_ = doc.appendElement(null, "body");
assert(body_.id == Tag.body_);
assert(body_.name.equal("body"));
auto div = body_.appendElement(null, "div");
assert(body_.childCount == 1);
assert(div.id == Tag.div);
assert(div.name.equal("div"));
auto t1 = div.appendText("Some text"d);
assert(div.childCount == 1);
assert(div.child(0).text.equal("Some text"d));
auto t2 = div.appendText("Some more text"d);
assert(div.childCount == 2);
assert(div.childIndex(t1) == 0);
assert(div.childIndex(t2) == 1);
div.setAttr(Ns.none, Attr.id, "div_id");
assert(div.attrValue(Ns.none, Attr.id).equal("div_id"));
destroy(doc);
}
}
unittest {
testDOM();
import std.algorithm : equal;
//import std.stdio;
IdentMap!(elem_id) map;
map.init!Tag();
//writeln("running DOM unit test");
assert(map["pre"] == Tag.pre);
assert(map["body"] == Tag.body_);
assert(map[Tag.div].equal("div"));
Document doc = new Document();
auto body_ = doc.appendElement(null, "body");
assert(body_.id == Tag.body_);
assert(body_.name.equal("body"));
auto div = body_.appendElement(null, "div");
assert(body_.childCount == 1);
assert(div.id == Tag.div);
assert(div.name.equal("div"));
auto t1 = div.appendText("Some text"d);
assert(div.childCount == 1);
assert(div.child(0).text.equal("Some text"d));
auto t2 = div.appendText("Some more text"d);
assert(div.childCount == 2);
assert(div.childIndex(t1) == 0);
assert(div.childIndex(t2) == 1);
div.setAttr(Ns.none, Attr.id, "div_id");
assert(div.attrValue(Ns.none, Attr.id).equal("div_id"));
destroy(doc);
}

View File

@ -252,3 +252,22 @@ extern (C) void releaseResourcesOnAppExit() {
}
}
}
version(unittest) {
version (Windows) {
mixin APP_ENTRY_POINT;
/// entry point for dlangui based application
extern (C) int UIAppMain(string[] args) {
// just to enable running unit tests
import core.runtime;
import std.stdio;
if (!runModuleUnitTests()) {
writeln("Error occured in unit tests. Press enter.");
readln();
return 1;
}
return 0;
}
}
}