# Updates to unit-testing system.

Premake: Changed to use PCH when compiling tests.
CxxTest: Got rid of /Wp64 warnings. Changed TS_ASSERT_STR_EQUALS to
print both strings on failure.
win_internal: Added the bits that CxxTest::Win32Gui needs (because
Win32Gui is now compiled with PCH and uses our sysdep headers).
Disabled test_cache_policies, because it took long enough for me to read
its name.

This was SVN commit r4237.
This commit is contained in:
Ykkrosh 2006-08-22 21:38:53 +00:00
parent bf95b26a80
commit e53242284f
12 changed files with 79 additions and 22 deletions

Binary file not shown.

View File

@ -603,7 +603,10 @@ function setup_tests()
package.files = hdr_files
package.rootfile = source_root .. "test_root.cpp"
if OS == "windows" then
package.rootoptions = "--gui=Win32Gui --have-eh --runner=ParenPrinter"
-- precompiled headers - the header is added to all generated .cpp files
package.pchheader = "precompiled.h"
package.rootoptions = "--gui=Win32Gui --runner=ParenPrinter --include="..package.pchheader
else
package.rootoptions = "--error-printer"
end
@ -626,6 +629,12 @@ function setup_tests()
-- from "lowlevel" static lib; must be added here to be linked in
tinsert(package.files, source_root.."lib/sysdep/win/error_dialog.rc")
-- precompiled headers
pch_dir = source_root.."pch/test/"
package.pchheader = "precompiled.h"
package.pchsource = "precompiled.cpp"
tinsert(package.files, { pch_dir.."precompiled.cpp", pch_dir.."precompiled.h" })
end
tinsert(package.buildflags, "use-library-dep-inputs")

View File

@ -391,12 +391,13 @@ static const char* listCppTargets(const char* name)
strcat(g_buffer, "$(CC) $(CFLAGS) -MF $(OBJDIR)/$(<F:%%.c=%%.d) -o $@ -c $<\n");
else if (matches(ext, ".asm"))
{
char input_dir[512];
char input_dir[512];
const char* opts;
strcpy(input_dir, path_translate(path_getdir(name) , NULL));
strcat(input_dir, "/");
const char* opts = "";
opts = "";
if (!os_is("windows"))
opts = "-dDONT_USE_UNDERLINE=1 ";

View File

@ -727,6 +727,7 @@ const char* vs_filter_links(const char* name)
void vs_list_files(const char* path, int stage)
{
int i;
const char* pchHeader = prj_get_pch_header();
const char* pchSource = prj_get_pch_source();
const char* trimPrefix = prj_get_trimprefix();
@ -807,9 +808,12 @@ void vs_list_files(const char* path, int stage)
tag_open("Tool");
tag_attr("Name=\"VCCustomBuildTool\"");
tag_attr("Description=\"Generating %s\"", targetname);
tag_attr("CommandLine=\"%s%s --part -o &quot;%s&quot; &quot;$(InputPath)&quot;\"",
tag_attr("CommandLine=\"%s%s --part %s%s -o &quot;%s&quot; &quot;$(InputPath)&quot;\"",
endsWith(prj_get_cxxtestpath(), ".pl")?"perl ":"",
path_translate(prj_get_cxxtestpath(), "windows"), targetname);
path_translate(prj_get_cxxtestpath(), "windows"),
pchHeader ? "--include=" : "",
pchHeader ? pchHeader : "",
targetname);
tag_attr("Outputs=\"%s\"", targetname);
tag_close("Tool", 0);

View File

@ -113,7 +113,7 @@ public:
TS_ASSERT_OK(tex_wrap(2, 2, 24, 0, img, &t));
TS_ASSERT_OK(tex_transform_to(&t, TEX_MIPMAPS));
const u8* const out_img = tex_get_data(&t);
TS_ASSERT_EQUALS(tex_img_size(&t), 12+3);
TS_ASSERT_EQUALS((int)tex_img_size(&t), 12+3);
TS_ASSERT_SAME_DATA(out_img, img, 12);
TS_ASSERT_SAME_DATA(out_img+12, mipmap, 3);
}
@ -124,11 +124,11 @@ public:
Tex t;
TS_ASSERT_OK(tex_wrap(100, 100, 32, TEX_ALPHA, dummy_img, &t));
TS_ASSERT_EQUALS(tex_img_size(&t), 40000);
TS_ASSERT_EQUALS((int)tex_img_size(&t), 40000);
// DXT rounds up to 4x4 blocks; DXT1a is 4bpp
Tex t2;
TS_ASSERT_OK(tex_wrap(97, 97, 4, DXT1A, dummy_img, &t2));
TS_ASSERT_EQUALS(tex_img_size(&t2), 5000);
TS_ASSERT_EQUALS((int)tex_img_size(&t2), 5000);
}
};

View File

@ -178,13 +178,15 @@ extern bool self_test_active;
// for convenience, to avoid having to include all of these manually
#include "precompiled.h"
#include "lib_errors.h"
#include "posix.h"
#define CXXTEST_HAVE_EH
#define CXXTEST_HAVE_STD
#include <cxxtest/TestSuite.h>
#define TS_ASSERT_OK(expr) TS_ASSERT_EQUALS((expr), INFO_OK)
#define TS_ASSERT_STR_EQUALS(str1, str2) TS_ASSERT(!strcmp((str1), (str2)))
#define TS_ASSERT_STR_EQUALS(str1, str2) TS_ASSERT_EQUALS(std::string(str1), std::string(str2))
#endif // #ifndef SELF_TEST_H__

View File

@ -52,9 +52,9 @@
//#define NOVIRTUALKEYCODES // VK_*
//#define NOWINMESSAGES // WM_*, EM_*, LB_*, CB_*
//#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
#define NOSYSMETRICS // SM_*
//#define NOSYSMETRICS // SM_*
#define NOMENUS // MF_*
#define NOICONS // IDI_*
//#define NOICONS // IDI_*
#define NOKEYSTATES // MK_*
//#define NOSYSCOMMANDS // SC_*
#define NORASTEROPS // Binary and Tertiary raster ops
@ -62,7 +62,7 @@
#define OEMRESOURCE // OEM Resource values
#define NOATOM // Atom Manager routines
//#define NOCLIPBOARD // Clipboard routines
#define NOCOLOR // Screen colors
//#define NOCOLOR // Screen colors
//#define NOCTLMGR // Control and Dialog routines
#define NODRAWTEXT // DrawText() and DT_*
//#define NOGDI // All GDI defines and routines
@ -80,7 +80,7 @@
//#define NOSOUND // Sound driver routines
#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines
//#define NOWH // SetWindowsHook and WH_*
#define NOWINOFFSETS // GWL_*, GCL_*, associated routines
//#define NOWINOFFSETS // GWL_*, GCL_*, associated routines
//#define NOCOMM // COMM driver routines
#define NOKANJI // Kanji support stuff.
#define NOHELP // Help engine interface.

View File

@ -62,7 +62,8 @@ public:
}
// ensures all 3 variants of Landlord<> behave the same
void test_cache_policies()
// [PT: disabled because it's far too slow]
void DISABLED_test_cache_policies()
{
Cache<int, int, Landlord_Naive > c1;
Cache<int, int, Landlord_Cached> c2;

View File

@ -0,0 +1 @@
#include "precompiled.h"

View File

@ -0,0 +1,9 @@
#include "lib/precompiled.h" // common precompiled header
// "test"-specific PCH:
#include "lib/self_test.h"
#include <cxxtest/TestListener.h>
#include <cxxtest/TestTracker.h>
#include <cxxtest/TestRunner.h>
#include <cxxtest/RealDescriptions.h>

View File

@ -33,12 +33,12 @@ public:
CParserLine Line;
TS_ASSERT(Line.ParseString(Parser, "12 34"));
TS_ASSERT_EQUALS(Line.GetArgCount(), 2);
TS_ASSERT_EQUALS((int)Line.GetArgCount(), 2);
TS_ASSERT(Line.GetArgString(0, str) && str == "12");
TS_ASSERT(Line.GetArgString(1, str) && str == "34");
TS_ASSERT(Line.ParseString(Parser, "56"));
TS_ASSERT_EQUALS(Line.GetArgCount(), 1);
TS_ASSERT_EQUALS((int)Line.GetArgCount(), 1);
TS_ASSERT(Line.GetArgString(0, str) && str == "56");
TS_ASSERT(! Line.ParseString(Parser, " "));
@ -55,22 +55,22 @@ public:
CParserLine Line;
TS_ASSERT(Line.ParseString(Parser, "12 34 56"));
TS_ASSERT_EQUALS(Line.GetArgCount(), 3);
TS_ASSERT_EQUALS((int)Line.GetArgCount(), 3);
TS_ASSERT(Line.GetArgString(0, str) && str == "12");
TS_ASSERT(Line.GetArgString(1, str) && str == "34");
TS_ASSERT(Line.GetArgString(2, str) && str == "56");
TS_ASSERT(Line.ParseString(Parser, "78 90"));
TS_ASSERT_EQUALS(Line.GetArgCount(), 2);
TS_ASSERT_EQUALS((int)Line.GetArgCount(), 2);
TS_ASSERT(Line.GetArgString(0, str) && str == "78");
TS_ASSERT(Line.GetArgString(1, str) && str == "90");
TS_ASSERT(Line.ParseString(Parser, "ab"));
TS_ASSERT_EQUALS(Line.GetArgCount(), 1);
TS_ASSERT_EQUALS((int)Line.GetArgCount(), 1);
TS_ASSERT(Line.GetArgString(0, str) && str == "ab");
TS_ASSERT(Line.ParseString(Parser, " "));
TS_ASSERT_EQUALS(Line.GetArgCount(), 0);
TS_ASSERT_EQUALS((int)Line.GetArgCount(), 0);
}

View File

@ -0,0 +1,30 @@
#include "lib/self_test.h"
class TestTest : public CxxTest::TestSuite
{
public:
void test_assert_size_t()
{
const size_t a1 = std::numeric_limits<size_t>::max();
const size_t b1 = std::numeric_limits<size_t>::max() - 1;
const size_t c1 = std::numeric_limits<size_t>::min();
size_t a2 = a1;
size_t b2 = b1;
size_t c2 = c1;
TS_ASSERT_EQUALS(a2, a2);
TS_ASSERT_DIFFERS(a2, b2);
TS_ASSERT_DIFFERS(a2, c2);
// These shouldn't cause warnings in CxxTest
TS_ASSERT_EQUALS(a1, a1);
TS_ASSERT_EQUALS(a1, a2);
TS_ASSERT_EQUALS(a2, a1);
// If TS_AS_STRING gives "{ 00 00 00 00 }", ValueTraits is failing
// to handle these types properly
TS_ASSERT_STR_EQUALS(TS_AS_STRING((size_t)0), "0");
TS_ASSERT_STR_EQUALS(TS_AS_STRING((ssize_t)0), "0");
TS_ASSERT_STR_EQUALS(TS_AS_STRING((unsigned int)0), "0");
}
};