docs: update TEST_SPEC.md and README.md to reflect new directory structure
- TEST_SPEC.md: Updated test directory structure to reflect Core/Asset, Core/IO, and Resources/<Type> subdirectories - TEST_SPEC.md: Updated module names and test counts (852 total) - TEST_SPEC.md: Updated build commands for new Resources subdirectories - README.md: Updated engine structure with Core/Asset/ and Core/IO/ - README.md: Updated Resources section with layered architecture - README.md: Updated test coverage table with accurate counts
This commit is contained in:
35
tests/Core/Asset/CMakeLists.txt
Normal file
35
tests/Core/Asset/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
# ============================================================
|
||||
# Core/Asset Tests
|
||||
# ============================================================
|
||||
|
||||
set(ASSET_TEST_SOURCES
|
||||
test_iresource.cpp
|
||||
test_resource_types.cpp
|
||||
test_resource_guid.cpp
|
||||
test_resource_handle.cpp
|
||||
test_resource_cache.cpp
|
||||
test_resource_dependency.cpp
|
||||
)
|
||||
|
||||
add_executable(asset_tests ${ASSET_TEST_SOURCES})
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(asset_tests PROPERTIES
|
||||
LINK_FLAGS "/NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:libcmt.lib"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(asset_tests
|
||||
PRIVATE
|
||||
XCEngine
|
||||
GTest::gtest
|
||||
GTest::gtest_main
|
||||
)
|
||||
|
||||
target_include_directories(asset_tests PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
${CMAKE_SOURCE_DIR}/tests/fixtures
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(asset_tests)
|
||||
34
tests/Core/IO/CMakeLists.txt
Normal file
34
tests/Core/IO/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
# ============================================================
|
||||
# Core/IO Tests
|
||||
# ============================================================
|
||||
|
||||
set(IO_TEST_SOURCES
|
||||
test_iresource_loader.cpp
|
||||
test_resource_path.cpp
|
||||
test_resource_filesystem.cpp
|
||||
test_file_archive.cpp
|
||||
test_resource_package.cpp
|
||||
)
|
||||
|
||||
add_executable(io_tests ${IO_TEST_SOURCES})
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(io_tests PROPERTIES
|
||||
LINK_FLAGS "/NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:libcmt.lib"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(io_tests
|
||||
PRIVATE
|
||||
XCEngine
|
||||
GTest::gtest
|
||||
GTest::gtest_main
|
||||
)
|
||||
|
||||
target_include_directories(io_tests PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
${CMAKE_SOURCE_DIR}/tests/fixtures
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(io_tests)
|
||||
51
tests/Core/IO/test_file_archive.cpp
Normal file
51
tests/Core/IO/test_file_archive.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <XCEngine/Core/IO/FileArchive.h>
|
||||
#include <XCEngine/Core/Containers/String.h>
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
using namespace XCEngine::Containers;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(FileArchive, DefaultConstructor) {
|
||||
FileArchive archive;
|
||||
EXPECT_FALSE(archive.IsValid());
|
||||
}
|
||||
|
||||
TEST(FileArchive, OpenInvalidPath) {
|
||||
FileArchive archive;
|
||||
bool result = archive.Open("invalid/path/to/archive.zip");
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_TRUE(archive.IsValid());
|
||||
}
|
||||
|
||||
TEST(FileArchive, GetPath) {
|
||||
FileArchive archive;
|
||||
EXPECT_EQ(archive.GetPath(), "");
|
||||
}
|
||||
|
||||
TEST(FileArchive, Exists) {
|
||||
FileArchive archive;
|
||||
EXPECT_FALSE(archive.Exists("test.txt"));
|
||||
}
|
||||
|
||||
TEST(FileArchive, GetSize) {
|
||||
FileArchive archive;
|
||||
EXPECT_EQ(archive.GetSize("test.txt"), 0u);
|
||||
}
|
||||
|
||||
TEST(FileArchive, Read) {
|
||||
FileArchive archive;
|
||||
char buffer[100] = {0};
|
||||
bool result = archive.Read("test.txt", buffer, 100, 0);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST(FileArchive, Enumerate) {
|
||||
FileArchive archive;
|
||||
Array<String> files(10);
|
||||
archive.Enumerate("*.txt", files);
|
||||
EXPECT_EQ(files.Size(), 0u);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
39
tests/Core/IO/test_iresource_loader.cpp
Normal file
39
tests/Core/IO/test_iresource_loader.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <XCEngine/Core/IO/IResourceLoader.h>
|
||||
#include <XCEngine/Core/Asset/ResourceTypes.h>
|
||||
#include <XCEngine/Core/Asset/ResourceManager.h>
|
||||
#include <XCEngine/Core/Containers/String.h>
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
using namespace XCEngine::Containers;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(LoadResult, DefaultConstructor) {
|
||||
LoadResult result;
|
||||
EXPECT_FALSE(result.success);
|
||||
EXPECT_EQ(result.resource, nullptr);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST(LoadResult, FromBool) {
|
||||
LoadResult result(true);
|
||||
EXPECT_TRUE(result.success);
|
||||
}
|
||||
|
||||
TEST(LoadResult, FromErrorString) {
|
||||
XCEngine::Containers::String errorMsg = "Error loading file";
|
||||
LoadResult result(errorMsg);
|
||||
EXPECT_FALSE(result.success);
|
||||
EXPECT_STREQ(result.errorMessage.CStr(), "Error loading file");
|
||||
}
|
||||
|
||||
TEST(LoadResult, BoolOperator) {
|
||||
LoadResult emptyResult;
|
||||
EXPECT_FALSE(emptyResult);
|
||||
|
||||
LoadResult errorResult("error");
|
||||
EXPECT_FALSE(errorResult);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
41
tests/Core/IO/test_resource_filesystem.cpp
Normal file
41
tests/Core/IO/test_resource_filesystem.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <XCEngine/Core/IO/ResourceFileSystem.h>
|
||||
#include <XCEngine/Core/Containers/String.h>
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
using namespace XCEngine::Containers;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(ResourceFileSystem, GetSingleton) {
|
||||
ResourceFileSystem& fs = ResourceFileSystem::Get();
|
||||
EXPECT_EQ(&fs, &ResourceFileSystem::Get());
|
||||
}
|
||||
|
||||
TEST(ResourceFileSystem, Initialize) {
|
||||
ResourceFileSystem fs;
|
||||
fs.Initialize("test/path");
|
||||
fs.Shutdown();
|
||||
}
|
||||
|
||||
TEST(ResourceFileSystem, AddDirectory) {
|
||||
ResourceFileSystem fs;
|
||||
fs.Initialize("test/path");
|
||||
|
||||
bool result = fs.AddDirectory("textures");
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
fs.Shutdown();
|
||||
}
|
||||
|
||||
TEST(ResourceFileSystem, Exists) {
|
||||
ResourceFileSystem fs;
|
||||
fs.Initialize("test/path");
|
||||
|
||||
bool exists = fs.Exists("test.txt");
|
||||
EXPECT_TRUE(exists);
|
||||
|
||||
fs.Shutdown();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
75
tests/Core/IO/test_resource_package.cpp
Normal file
75
tests/Core/IO/test_resource_package.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <XCEngine/Core/IO/ResourcePackage.h>
|
||||
#include <XCEngine/Core/Containers/Array.h>
|
||||
#include <XCEngine/Core/Types.h>
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
using namespace XCEngine::Containers;
|
||||
using namespace XCEngine::Core;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(ResourcePackageBuilder, DefaultConstructor) {
|
||||
ResourcePackageBuilder builder;
|
||||
EXPECT_TRUE(builder.GetOutputPath().Empty());
|
||||
EXPECT_EQ(builder.GetProgress(), 0.0f);
|
||||
}
|
||||
|
||||
TEST(ResourcePackageBuilder, SetOutputPath) {
|
||||
ResourcePackageBuilder builder;
|
||||
builder.SetOutputPath("test.pkg");
|
||||
EXPECT_EQ(builder.GetOutputPath(), "test.pkg");
|
||||
}
|
||||
|
||||
TEST(ResourcePackageBuilder, AddFile) {
|
||||
ResourcePackageBuilder builder;
|
||||
builder.SetOutputPath("test.pkg");
|
||||
|
||||
bool result = builder.AddFile("nonexistent.txt", "test.txt");
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST(ResourcePackageBuilder, BuildWithoutFiles) {
|
||||
ResourcePackageBuilder builder;
|
||||
builder.SetOutputPath("test.pkg");
|
||||
|
||||
bool result = builder.Build();
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST(ResourcePackage, DefaultConstructor) {
|
||||
ResourcePackage pkg;
|
||||
EXPECT_FALSE(pkg.IsValid());
|
||||
}
|
||||
|
||||
TEST(ResourcePackage, OpenInvalidPath) {
|
||||
ResourcePackage pkg;
|
||||
bool result = pkg.Open("invalid/path/package.pkg");
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_FALSE(pkg.IsValid());
|
||||
}
|
||||
|
||||
TEST(ResourcePackage, Exists) {
|
||||
ResourcePackage pkg;
|
||||
EXPECT_FALSE(pkg.Exists("test.txt"));
|
||||
}
|
||||
|
||||
TEST(ResourcePackage, GetSize) {
|
||||
ResourcePackage pkg;
|
||||
EXPECT_EQ(pkg.GetSize("test.txt"), 0u);
|
||||
}
|
||||
|
||||
TEST(ResourcePackage, Read) {
|
||||
ResourcePackage pkg;
|
||||
Array<XCEngine::Core::uint8> data = pkg.Read("test.txt");
|
||||
EXPECT_EQ(data.Size(), 0u);
|
||||
}
|
||||
|
||||
TEST(ResourcePackage, Enumerate) {
|
||||
ResourcePackage pkg;
|
||||
Array<String> files(10);
|
||||
pkg.Enumerate("*.txt", files);
|
||||
EXPECT_EQ(files.Size(), 0u);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
110
tests/Core/IO/test_resource_path.cpp
Normal file
110
tests/Core/IO/test_resource_path.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <XCEngine/Core/IO/ResourcePath.h>
|
||||
#include <XCEngine/Core/Asset/ResourceTypes.h>
|
||||
#include <XCEngine/Core/Containers/String.h>
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
using namespace XCEngine::Containers;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(ResourcePath, DefaultConstructor) {
|
||||
ResourcePath path;
|
||||
EXPECT_FALSE(path.IsValid());
|
||||
}
|
||||
|
||||
TEST(ResourcePath, ConstructorWithCString) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_TRUE(path.IsValid());
|
||||
EXPECT_EQ(path.GetPath(), "textures/player.png");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, ConstructorWithString) {
|
||||
String str = "models/player.fbx";
|
||||
ResourcePath path(str);
|
||||
EXPECT_TRUE(path.IsValid());
|
||||
EXPECT_EQ(path.GetPath(), str);
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetExtension) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_EQ(path.GetExtension(), ".png");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetExtensionNoExtension) {
|
||||
ResourcePath path("textures/player");
|
||||
EXPECT_TRUE(path.GetExtension().Empty());
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetStem) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_EQ(path.GetStem(), "player");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetStemNoExtension) {
|
||||
ResourcePath path("textures/player");
|
||||
EXPECT_EQ(path.GetStem(), "player");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetFileName) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_EQ(path.GetFileName(), "player.png");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetDirectory) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_EQ(path.GetDirectory(), "textures");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetDirectoryWithBackslash) {
|
||||
ResourcePath path("textures\\player.png");
|
||||
EXPECT_EQ(path.GetDirectory(), "textures");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetFullPath) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_EQ(path.GetFullPath(), "textures/player.png");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, HasExtension) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_TRUE(path.HasExtension(".png"));
|
||||
EXPECT_FALSE(path.HasExtension(".jpg"));
|
||||
}
|
||||
|
||||
TEST(ResourcePath, HasExtensionNoExtension) {
|
||||
ResourcePath path("textures/player");
|
||||
EXPECT_FALSE(path.HasExtension(".png"));
|
||||
}
|
||||
|
||||
TEST(ResourcePath, HasAnyExtension) {
|
||||
ResourcePath path("textures/player.png");
|
||||
const char* extensions[] = { ".jpg", ".png", ".tga" };
|
||||
EXPECT_TRUE(path.HasAnyExtension(extensions, 3));
|
||||
}
|
||||
|
||||
TEST(ResourcePath, HasAnyExtensionNoMatch) {
|
||||
ResourcePath path("textures/player.png");
|
||||
const char* extensions[] = { ".jpg", ".tga", ".bmp" };
|
||||
EXPECT_FALSE(path.HasAnyExtension(extensions, 3));
|
||||
}
|
||||
|
||||
TEST(ResourcePath, ToGUID) {
|
||||
ResourcePath path("textures/player.png");
|
||||
ResourceGUID guid = path.ToGUID();
|
||||
EXPECT_TRUE(guid.IsValid());
|
||||
}
|
||||
|
||||
TEST(ResourcePath, SetPath) {
|
||||
ResourcePath path;
|
||||
path.SetPath("textures/player.png");
|
||||
EXPECT_TRUE(path.IsValid());
|
||||
EXPECT_EQ(path.GetPath(), "textures/player.png");
|
||||
}
|
||||
|
||||
TEST(ResourcePath, GetRelativePath) {
|
||||
ResourcePath path("textures/player.png");
|
||||
EXPECT_EQ(path.GetRelativePath(), "textures/player.png");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user