test: reorganize core test directory structure
This commit is contained in:
@@ -17,8 +17,8 @@ RESULT_TEST_BIN := $(BUILD_DIR)/result_test
|
||||
LOGGER_TEST_BIN := $(BUILD_DIR)/logger_test
|
||||
SCOPED_FILE_TEST_BIN := $(BUILD_DIR)/scoped_file_test
|
||||
|
||||
RESULT_TEST_SRC := tests/app/core/result_test.cpp
|
||||
LOGGER_TEST_SRC := tests/app/core/logger_test.cpp
|
||||
RESULT_TEST_SRC := tests/core/result_test.cpp
|
||||
LOGGER_TEST_SRC := tests/core/logger_test.cpp
|
||||
SCOPED_FILE_TEST_SRC := tests/helpers/scoped_file_test.cpp
|
||||
|
||||
LOGGER_SRC := logger/src/logger.cpp
|
||||
|
||||
@@ -6,36 +6,38 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace core;
|
||||
|
||||
void testSuccessCreation() {
|
||||
auto result = core::Result<int>::Success(42);
|
||||
auto result = Result<int>::Success(42);
|
||||
|
||||
assert(result.isSuccess());
|
||||
assert(result.getValue() == 42);
|
||||
}
|
||||
|
||||
void testFailureCreation() {
|
||||
auto result = core::Result<int>::Failure("Invalid value");
|
||||
auto result = Result<int>::Failure("Invalid value");
|
||||
|
||||
assert(result.isFailure());
|
||||
assert(result.getError() == "Invalid value");
|
||||
}
|
||||
|
||||
void testStatusSuccess() {
|
||||
auto status = core::Status::Success(true);
|
||||
auto status = Status::Success(true);
|
||||
|
||||
assert(status.isSuccess());
|
||||
assert(status.getValue());
|
||||
}
|
||||
|
||||
void testStatusFailure() {
|
||||
auto status = core::Status::Failure("File not found");
|
||||
auto status = Status::Failure("File not found");
|
||||
|
||||
assert(status.isFailure());
|
||||
assert(status.getError() == "File not found");
|
||||
}
|
||||
|
||||
void testMoveConstruction() {
|
||||
auto source = core::Result<std::string>::Success("hello");
|
||||
auto source = Result<std::string>::Success("hello");
|
||||
|
||||
auto moved = std::move(source);
|
||||
|
||||
@@ -44,8 +46,8 @@ void testMoveConstruction() {
|
||||
}
|
||||
|
||||
void testMoveAssignment() {
|
||||
auto first = core::Result<int>::Success(10);
|
||||
auto second = core::Result<int>::Failure("error");
|
||||
auto first = Result<int>::Success(10);
|
||||
auto second = Result<int>::Failure("error");
|
||||
|
||||
second = std::move(first);
|
||||
|
||||
@@ -59,7 +61,7 @@ void testDifferentTypes() {
|
||||
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.getValue().id == 1);
|
||||
@@ -67,7 +69,7 @@ void testDifferentTypes() {
|
||||
}
|
||||
|
||||
void testValueModification() {
|
||||
auto result = core::Result<int>::Success(10);
|
||||
auto result = Result<int>::Success(10);
|
||||
|
||||
result.getValue() = 20;
|
||||
|
||||
@@ -75,7 +77,7 @@ void testValueModification() {
|
||||
}
|
||||
|
||||
void testErrorModification() {
|
||||
auto result = core::Result<int>::Failure("old error");
|
||||
auto result = Result<int>::Failure("old error");
|
||||
|
||||
result.getError() = "new error";
|
||||
|
||||
@@ -85,7 +87,7 @@ void testErrorModification() {
|
||||
void testBasicResultWithCustomError() {
|
||||
enum class ErrorCode { NotFound, PermissionDenied };
|
||||
|
||||
using CustomResult = core::BasicResult<int, ErrorCode>;
|
||||
using CustomResult = BasicResult<int, ErrorCode>;
|
||||
|
||||
auto result = CustomResult::Failure(ErrorCode::PermissionDenied);
|
||||
|
||||
Reference in New Issue
Block a user