76 lines
1.8 KiB
C++
76 lines
1.8 KiB
C++
|
|
#include <gtest/gtest.h>
|
||
|
|
#include <XCEngine/Resources/ResourcePackage.h>
|
||
|
|
#include <XCEngine/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
|