test: reorganize core test directory structure

This commit is contained in:
user
2026-07-19 16:41:22 +04:00
parent f3b0f449b1
commit 6247442253
2 changed files with 15 additions and 13 deletions
+2 -2
View File
@@ -17,8 +17,8 @@ RESULT_TEST_BIN := $(BUILD_DIR)/result_test
LOGGER_TEST_BIN := $(BUILD_DIR)/logger_test LOGGER_TEST_BIN := $(BUILD_DIR)/logger_test
SCOPED_FILE_TEST_BIN := $(BUILD_DIR)/scoped_file_test SCOPED_FILE_TEST_BIN := $(BUILD_DIR)/scoped_file_test
RESULT_TEST_SRC := tests/app/core/result_test.cpp RESULT_TEST_SRC := tests/core/result_test.cpp
LOGGER_TEST_SRC := tests/app/core/logger_test.cpp LOGGER_TEST_SRC := tests/core/logger_test.cpp
SCOPED_FILE_TEST_SRC := tests/helpers/scoped_file_test.cpp SCOPED_FILE_TEST_SRC := tests/helpers/scoped_file_test.cpp
LOGGER_SRC := logger/src/logger.cpp LOGGER_SRC := logger/src/logger.cpp
@@ -6,36 +6,38 @@
namespace { namespace {
using namespace core;
void testSuccessCreation() { void testSuccessCreation() {
auto result = core::Result<int>::Success(42); auto result = Result<int>::Success(42);
assert(result.isSuccess()); assert(result.isSuccess());
assert(result.getValue() == 42); assert(result.getValue() == 42);
} }
void testFailureCreation() { void testFailureCreation() {
auto result = core::Result<int>::Failure("Invalid value"); auto result = Result<int>::Failure("Invalid value");
assert(result.isFailure()); assert(result.isFailure());
assert(result.getError() == "Invalid value"); assert(result.getError() == "Invalid value");
} }
void testStatusSuccess() { void testStatusSuccess() {
auto status = core::Status::Success(true); auto status = Status::Success(true);
assert(status.isSuccess()); assert(status.isSuccess());
assert(status.getValue()); assert(status.getValue());
} }
void testStatusFailure() { void testStatusFailure() {
auto status = core::Status::Failure("File not found"); auto status = Status::Failure("File not found");
assert(status.isFailure()); assert(status.isFailure());
assert(status.getError() == "File not found"); assert(status.getError() == "File not found");
} }
void testMoveConstruction() { void testMoveConstruction() {
auto source = core::Result<std::string>::Success("hello"); auto source = Result<std::string>::Success("hello");
auto moved = std::move(source); auto moved = std::move(source);
@@ -44,8 +46,8 @@ void testMoveConstruction() {
} }
void testMoveAssignment() { void testMoveAssignment() {
auto first = core::Result<int>::Success(10); auto first = Result<int>::Success(10);
auto second = core::Result<int>::Failure("error"); auto second = Result<int>::Failure("error");
second = std::move(first); second = std::move(first);
@@ -59,7 +61,7 @@ void testDifferentTypes() {
std::string name; std::string name;
}; };
auto result = core::Result<User>::Success(User{1, "Alex"}); auto result = Result<User>::Success(User{1, "Alex"});
assert(result.isSuccess()); assert(result.isSuccess());
assert(result.getValue().id == 1); assert(result.getValue().id == 1);
@@ -67,7 +69,7 @@ void testDifferentTypes() {
} }
void testValueModification() { void testValueModification() {
auto result = core::Result<int>::Success(10); auto result = Result<int>::Success(10);
result.getValue() = 20; result.getValue() = 20;
@@ -75,7 +77,7 @@ void testValueModification() {
} }
void testErrorModification() { void testErrorModification() {
auto result = core::Result<int>::Failure("old error"); auto result = Result<int>::Failure("old error");
result.getError() = "new error"; result.getError() = "new error";
@@ -85,7 +87,7 @@ void testErrorModification() {
void testBasicResultWithCustomError() { void testBasicResultWithCustomError() {
enum class ErrorCode { NotFound, PermissionDenied }; enum class ErrorCode { NotFound, PermissionDenied };
using CustomResult = core::BasicResult<int, ErrorCode>; using CustomResult = BasicResult<int, ErrorCode>;
auto result = CustomResult::Failure(ErrorCode::PermissionDenied); auto result = CustomResult::Failure(ErrorCode::PermissionDenied);