forked from 0ad/0ad
Ykkrosh
a265a441fd
* vsnprintf2: Made compatible between GCC and MSVC - it now always null-terminates the buffer, and returns -1 on overflow. Fixes #158. Added tests. * MeshManager: Use shared_ptr.expired() instead of checking for bad_weak_ptr exception. * Xeromyces: Added tests for GetXMBPath, because it does unusual things in sscanf which MSVC's /analyze complains about. * ConfigDB, ScriptGlue: Replaced some asserts with return-on-failure, to avoid invalid array accesses when continuing after the assert (as complained about by /analyze). * CStr: Removed "using namespace std". Added tests for handling of invalid UTF-8. This was SVN commit r4625.
33 lines
755 B
C++
33 lines
755 B
C++
#include "lib/self_test.h"
|
|
|
|
#include "ps/XML/Xeromyces.h"
|
|
#include "lib/res/file/vfs.h"
|
|
#include "lib/res/file/path.h"
|
|
#include "lib/res/file/trace.h"
|
|
|
|
class TestXeromyces : public CxxTest::TestSuite
|
|
{
|
|
public:
|
|
void test_paths()
|
|
{
|
|
file_init();
|
|
path_init();
|
|
file_set_root_dir(0, "../data");
|
|
vfs_init();
|
|
|
|
vfs_mount("", "mods/_tests", VFS_MOUNT_RECURSIVE);
|
|
vfs_set_write_target("mods/_tests");
|
|
|
|
char xmbPath[PATH_MAX];
|
|
|
|
CXeromyces::GetXMBPath("test1.xml", "test1.xmb", xmbPath);
|
|
TS_ASSERT_STR_EQUALS(xmbPath, "cache/mods/_tests/xmb/test1.xmb");
|
|
|
|
CXeromyces::GetXMBPath("a/b/test1.xml", "a/b/test1.xmb", xmbPath);
|
|
TS_ASSERT_STR_EQUALS(xmbPath, "cache/mods/_tests/xmb/a/b/test1.xmb");
|
|
|
|
vfs_shutdown();
|
|
path_reset_root_dir();
|
|
}
|
|
};
|