提交 c42a0037 编写于 作者: R Rémi Arnaud 提交者: GitHub

Merge pull request #516 from fl4re/misc/daevalidator-tests

DAEValidator tests
set(name DAEValidator)
project(${name})
project(DAEValidator)
set(libDAEValidator_include_dirs
${CMAKE_CURRENT_SOURCE_DIR}/include
)
set(libDAEValidator_include_dirs ${libDAEValidator_include_dirs} PARENT_SCOPE) # adding include dirs to a parent scope
set(SRC
src/ArgumentParser.cpp
src/Dae.cpp
src/DaeValidator.cpp
src/Log.cpp
src/main.cpp
src/PathUtil.cpp
src/Strings.cpp
src/StringUtil.cpp
src/Uri.cpp
src/XmlAttribute.cpp
src/XmlDoc.cpp
src/XmlNamespace.cpp
src/XmlNode.cpp
src/XmlNodes.cpp
src/XmlNodeSet.cpp
src/XmlSchema.cpp
# DAEValidatorLibrary
set(DAEValidatorLibrarySources
library/src/ArgumentParser.cpp
library/src/Dae.cpp
library/src/DaeValidator.cpp
library/src/Log.cpp
library/src/DAEValidatorLibrary.cpp
library/src/PathUtil.cpp
library/src/Strings.cpp
library/src/StringUtil.cpp
library/src/Uri.cpp
library/src/XmlAttribute.cpp
library/src/XmlDoc.cpp
library/src/XmlNamespace.cpp
library/src/XmlNode.cpp
library/src/XmlNodes.cpp
library/src/XmlNodeSet.cpp
library/src/XmlSchema.cpp
include/ArgumentParser.h
include/Dae.h
include/DaeValidator.h
include/Log.h
include/Macros.h
include/no_warning_array
include/no_warning_functional
include/no_warning_iostream
include/no_warning_list
include/no_warning_map
include/no_warning_string
include/no_warning_vector
include/no_warning_Windows.h
include/PathUtil.h
include/Strings.h
include/StringUtil.h
include/Uri.h
include/Xml.h
include/XmlCommon.h
include/XmlAttribute.h
include/XmlDoc.h
include/XmlNamespace.h
include/XmlNode.h
include/XmlNodes.h
include/XmlNodeSet.h
include/XmlSchema.h
include/win/dirent.h
library/include/ArgumentParser.h
library/include/Dae.h
library/include/DaeValidator.h
library/include/Log.h
library/include/Macros.h
library/include/DAEValidatorLibrary.h
library/include/no_warning_algorithm
library/include/no_warning_array
library/include/no_warning_begin
library/include/no_warning_chrono
library/include/no_warning_end
library/include/no_warning_fstream
library/include/no_warning_functional
library/include/no_warning_iomanip
library/include/no_warning_iostream
library/include/no_warning_list
library/include/no_warning_map
library/include/no_warning_memory
library/include/no_warning_regex
library/include/no_warning_sstream
library/include/no_warning_string
library/include/no_warning_vector
library/include/no_warning_Windows.h
library/include/PathUtil.h
library/include/Strings.h
library/include/StringUtil.h
library/include/Uri.h
library/include/Xml.h
library/include/XmlCommon.h
library/include/XmlAttribute.h
library/include/XmlDoc.h
library/include/XmlNamespace.h
library/include/XmlNode.h
library/include/XmlNodes.h
library/include/XmlNodeSet.h
library/include/XmlSchema.h
library/include/win/dirent.h
)
add_library(DAEValidatorLibrary ${DAEValidatorLibrarySources})
include_directories("library/include")
set(libDAEValidator_libs
${LIBXML2_LIBRARIES}
zlib
# DAEValidatorExecutable
set(DAEValidatorExecutableSources
executable/src/Main.cpp
)
add_executable(DAEValidatorExecutable ${DAEValidatorExecutableSources})
add_dependencies(DAEValidatorExecutable DAEValidatorLibrary)
set(Libraries DAEValidatorLibrary)
if (NOT LIBXML2_FOUND)
if (USE_STATIC)
list(APPEND Libraries xml_static)
else ()
list(APPEND Libraries xml_shared)
endif ()
else ()
list(APPEND Libraries ${LIBXML2_LIBRARIES})
endif ()
if (USE_STATIC)
list(APPEND Libraries zlib_static)
else ()
list(APPEND Libraries zlib_shared)
endif ()
if (WIN32)
list(APPEND Libraries ws2_32.lib)
endif ()
target_link_libraries(DAEValidatorExecutable ${Libraries})
set_target_properties(DAEValidatorExecutable PROPERTIES OUTPUT_NAME DAEValidator)
if (WIN32)
set(libDAEValidator_libs ${libDAEValidator_libs}
ws2_32.lib
)
# C4505: 'function' : unreferenced local function has been removed
# C4514: 'function' : unreferenced inline function has been removed
# C4592: symbol will be dynamically initialized (implementation limitation)
# C4710: 'function' : function not inlined
# C4711: function 'function' selected for inline expansion
# C4820: 'bytes' bytes padding added after construct 'member_name'
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Wall /WX /wd4505 /wd4514 /wd4592 /wd4710 /wd4711 /wd4820")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
endif ()
include_directories(
${libDAEValidator_include_dirs}
${LIBXML2_INCLUDE_DIR}
${zlib_include_dirs}
)
add_custom_command(
TARGET DAEValidatorExecutable POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/xsd $<TARGET_FILE_DIR:DAEValidatorExecutable>
)
# DAEValidatorTests
macro(configure_files srcDir destDir)
message(STATUS "Configuring directory ${srcDir} -> ${destDir}")
make_directory(${destDir})
file(GLOB_RECURSE templateFiles RELATIVE ${srcDir} ${srcDir}/*)
foreach(templateFile ${templateFiles})
set(srcTemplatePath ${srcDir}/${templateFile})
if(NOT IS_DIRECTORY ${srcTemplatePath})
message(STATUS "Configuring file ${templateFile}")
configure_file(
${srcTemplatePath}
${destDir}/${templateFile}
COPYONLY)
endif(NOT IS_DIRECTORY ${srcTemplatePath})
endforeach(templateFile)
endmacro(configure_files)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
if (WIN32 AND ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 3.0.1)
set(DAEValidatorTestsSources
tests/src/ArgumentParserTests.cpp
tests/src/Common.cpp
tests/src/DaeTests.cpp
tests/src/DaeValidatorTests.cpp
tests/src/DaeValidatorLibraryTests.cpp
tests/src/LogTests.cpp
tests/src/PathUtilTests.cpp
tests/src/StringUtilTests.cpp
tests/src/UriTests.cpp
tests/src/XmlAttributeTests.cpp
tests/src/XmlDocTests.cpp
tests/src/XmlNamespaceTests.cpp
tests/src/XmlNodeSetTests.cpp
tests/src/XmlNodesTests.cpp
tests/src/XmlNodeTests.cpp
tests/src/XmlSchemaTests.cpp
tests/include/Common.h
)
string(REGEX REPLACE "/Common7/IDE/devenv.com" "/VC" VCINSTALLDIR ${CMAKE_VS_DEVENV_COMMAND})
link_directories(${VCINSTALLDIR}/UnitTest/lib)
add_library(DAEValidatorTests SHARED ${DAEValidatorTestsSources})
add_dependencies(DAEValidatorTests DAEValidatorLibrary)
target_include_directories(DAEValidatorTests PRIVATE ${VCINSTALLDIR}/UnitTest/include tests/include)
set(Libraries DAEValidatorLibrary)
if (USE_STATIC)
list(APPEND Libraries xml_static zlib_static)
else ()
list(APPEND Libraries xml_shared zlib_shared)
endif ()
if (WIN32)
list(APPEND Libraries ws2_32.lib)
endif ()
target_link_libraries(DAEValidatorTests ${Libraries})
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/tests/data ${CMAKE_CURRENT_BINARY_DIR}/tests/data)
set_target_properties(DAEValidatorTests
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/bin
)
add_custom_command(
TARGET DAEValidatorTests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/xsd ${CMAKE_CURRENT_BINARY_DIR}/tests/bin/Debug
)
add_custom_command(
TARGET DAEValidatorTests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/xsd ${CMAKE_CURRENT_BINARY_DIR}/tests/bin/Release
)
endif ()
link_directories(${LIBRARY_OUTPUT_PATH})
add_executable(${name} ${SRC})
target_link_libraries(${name} ${libDAEValidator_libs})
# Externals
# libxml
if (NOT LIBXML2_FOUND)
add_definitions(
-DLIBXML_AUTOMATA_ENABLED
......@@ -89,32 +198,20 @@ if (NOT LIBXML2_FOUND)
-DLIBXML_TREE_ENABLED
)
if (USE_STATIC)
add_dependencies(${name} xml_static)
add_dependencies(DAEValidatorExecutable xml_static)
endif ()
if (USE_SHARED)
add_dependencies(${name} xml_shared)
add_dependencies(DAEValidatorExecutable xml_shared)
endif ()
endif ()
if (USE_STATIC)
add_dependencies(${name} zlib_static)
include_directories("../Externals/LibXML/include")
else ()
add_dependencies(${name} zlib_shared)
include_directories(${LIBXML2_INCLUDE_DIR})
endif ()
if (WIN32)
# C4505: 'function' : unreferenced local function has been removed
# C4514: 'function' : unreferenced inline function has been removed
# C4710: 'function' : function not inlined
# C4711: function 'function' selected for inline expansion
# C4820: 'bytes' bytes padding added after construct 'member_name'
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Wall /WX /wd4505 /wd4514 /wd4710 /wd4711 /wd4820")
# zlib
if (USE_STATIC)
add_dependencies(DAEValidatorExecutable zlib_static)
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
add_dependencies(DAEValidatorExecutable zlib_shared)
endif ()
add_custom_command(
TARGET ${name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/xsd $<TARGET_FILE_DIR:${name}>
)
include_directories("../Externals/zlib/include")
#include "DAEValidatorLibrary.h"
int main(int argc, char* argv[])
{
return opencollada::main(argc, argv);
}
\ No newline at end of file
#include "Macros.h"
#pragma warning(push)
#pragma warning(disable:4668)
#include "Windows.h"
#pragma warning(pop)
\ No newline at end of file
#include "Macros.h"
#if defined(_WIN32)
#pragma warning(push)
#if IS_MSVC_AND_MSVC_VERSION_LT(1900)
#pragma warning(disable:4350)
#endif
#endif
#include <array>
#if defined(_WIN32)
#pragma warning(pop)
#endif
\ No newline at end of file
#include "Macros.h"
#if defined(_WIN32)
#pragma warning(push)
#if IS_MSVC_AND_MSVC_VERSION_LT(1900)
#pragma warning(disable:4350)
#endif
#endif
#include <functional>
#if defined(_WIN32)
#pragma warning(pop)
#endif
\ No newline at end of file
#if defined(_WIN32)
#pragma warning(push)
#if defined(_MSC_VER)
# if defined(_DEBUG)
# pragma warning(disable:4548)
# endif
# if _MSC_VER < 1900
# pragma warning(disable:4350)
# endif
#endif
#endif
#include <iostream>
#if defined(_WIN32)
#pragma warning(pop)
#endif
\ No newline at end of file
#include "Macros.h"
#if defined(_WIN32)
#pragma warning(push)
#if IS_MSVC_AND_MSVC_VERSION_LT(1900)
#pragma warning(disable:4350)
#endif
#endif
#include <list>
#if defined(_WIN32)
#pragma warning(pop)
#endif
\ No newline at end of file
#include "Macros.h"
#if defined(_WIN32)
#pragma warning(push)
#if IS_MSVC_AND_MSVC_VERSION_LT(1900)
#pragma warning(disable:4350)
#endif
#endif
#include <map>
#if defined(_WIN32)
#pragma warning(pop)
#endif
\ No newline at end of file
#include "Macros.h"
#if defined(_WIN32)
#pragma warning(push)
#if IS_MSVC_AND_MSVC_VERSION_LT(1900)
#pragma warning(disable:4350)
#endif
#endif
#include <string>
#if defined(_WIN32)
#pragma warning(pop)
#endif
\ No newline at end of file
#include "Macros.h"
#if defined(_WIN32)
#pragma warning(push)
#if IS_MSVC_AND_MSVC_VERSION_LT(1900)
#pragma warning(disable:4350)
#endif
#endif
#include <vector>
#if defined(_WIN32)
#pragma warning(pop)
#endif
\ No newline at end of file
......@@ -2,7 +2,7 @@
#include "no_warning_functional"
#include "no_warning_map"
#include <sstream>
#include "no_warning_sstream"
#include "no_warning_string"
#include "no_warning_vector"
......@@ -21,9 +21,9 @@ namespace opencollada
size_t getNumParameters() const;
bool isSet() const;
bool isRequired() const;
std::string getHint() const;
std::string getHint(size_t index) const;
std::string getHelp() const;
const std::string & getHint() const;
const std::string & getHint(size_t index) const;
const std::string & getHelp() const;
template<typename T>
T getValue(size_t index = 0) const
......
#pragma once
namespace opencollada
{
int main(int argc, char* argv[]);
}
\ No newline at end of file
......@@ -15,11 +15,27 @@ namespace opencollada
using Super = XmlDoc;
public:
enum class Version
{
Unknown,
COLLADA14,
COLLADA15
};
Dae() = default;
Dae(Dae && other);
const Dae & operator = (Dae && other);
static const XmlSchema & GetColladaSchema141();
//static const XmlSchema & GetColladaSchema15();
static const std::string & GetColladaNamespace141();
static const std::string & GetColladaNamespace15();
virtual void readFile(const std::string & path) override;
Version getVersion() const;
const Uri & getURI() const { return mUri; }
......@@ -45,5 +61,13 @@ namespace opencollada
mutable std::set<std::string> mIdCache;
mutable bool mCacheInitialized = false;
static std::string mColladaNamespace141;
static std::string mColladaSchemaFileName141;
static XmlSchema mColladaSchema141;
static std::string mColladaNamespace15;
static std::string mColladaSchemaFileName15;
static XmlSchema mColladaSchema15;
};
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
#include "no_warning_functional"
#include "no_warning_iostream"
#include <memory>
#include "no_warning_memory"
#include "no_warning_string"
namespace opencollada
......@@ -40,10 +40,13 @@ namespace opencollada
class Log
{
public:
static void Setup(bool quiet);
Log(bool quiet);
private:
static std::unique_ptr<streamhook> mCoutHook;
static std::unique_ptr<streamhook> mCerrHook;
Log(const Log &) = delete;
const Log & operator = (const Log &) = delete;
std::unique_ptr<streamhook> mCoutHook;
std::unique_ptr<streamhook> mCerrHook;
};
}
\ No newline at end of file
......@@ -8,6 +8,8 @@
#if defined(_MSC_VER)
#define IS_MSVC_AND_MSVC_VERSION_LT(version) (_MSC_VER < version)
#define IS_MSVC_AND_MSVC_VERSION_GTE(version) (_MSC_VER >= version)
#else
#define IS_MSVC_AND_MSVC_VERSION_LT(version) 0
#define IS_MSVC_AND_MSVC_VERSION_GTE(version) 0
#endif
\ No newline at end of file
......@@ -53,8 +53,6 @@ namespace opencollada
static std::string MergePaths(const Uri & baseUri, const std::string & ref_path);
// Rebuild mUri from mScheme, mAuthority, mPath, mQuery and mFragment
void rebuild();
// Rebuild mUri from mScheme, mAuthority, mPath, mQuery and mFragment but don't validate
void rebuild_fast();
private:
......
......@@ -30,6 +30,7 @@ namespace opencollada
operator bool() const;
void reset();
XmlNode root() const;
std::string getRootNamespace() const;
class TempRootMod
{
......
......@@ -18,6 +18,8 @@ namespace opencollada
public:
XmlNode() = default;
operator bool() const;
bool operator == (const XmlNode & other) const;
bool operator != (const XmlNode & other) const;
XmlDoc & doc() const;
XmlNode child(const std::string & name) const;
......@@ -41,5 +43,4 @@ namespace opencollada
};
}
bool operator == (const std::string & s, const unsigned char* c);
//bool operator != (const std::string & s, const unsigned char* c);
\ No newline at end of file
bool operator == (const std::string & s, const unsigned char* c);
\ No newline at end of file
......@@ -33,6 +33,7 @@ namespace opencollada
int mIndex = 0;
};
bool empty() const;