Integrate Refactor solver sources and dual MSVC CMake builds
This commit is contained in:
@@ -17,6 +17,21 @@ TEST(Ascii, LowercasesOnlyAsciiUppercaseBytes) {
|
||||
EXPECT_EQ(fesa::AsciiLower(non_ascii), non_ascii);
|
||||
}
|
||||
|
||||
TEST(Ascii, UppercaseCanonicalizationPreservesEveryOtherByteAndSourceText) {
|
||||
std::string source;
|
||||
std::string expected;
|
||||
for (unsigned int byte = 0U; byte < 256U; ++byte) {
|
||||
source.push_back(static_cast<char>(byte));
|
||||
expected.push_back(
|
||||
static_cast<char>(byte >= 97U && byte <= 122U ? byte - 32U : byte));
|
||||
}
|
||||
const std::string original = source;
|
||||
EXPECT_EQ(fesa::AsciiUppercase(source), expected);
|
||||
EXPECT_EQ(source, original);
|
||||
EXPECT_TRUE(fesa::AsciiUppercase("").empty());
|
||||
EXPECT_EQ(fesa::AsciiUppercase("Shell-01"), "SHELL-01");
|
||||
}
|
||||
|
||||
TEST(Ascii, ComparesNamesWithoutLocaleOrUnicodeFolding) {
|
||||
EXPECT_TRUE(fesa::AsciiCaseInsensitiveEquals("Beam-1", "bEaM-1"));
|
||||
EXPECT_FALSE(fesa::AsciiCaseInsensitiveEquals("Beam-1", "Beam-10"));
|
||||
|
||||
@@ -17,4 +17,12 @@ TEST(CoreDiagnostics, SourceIdentityPreservesRawIdentity) {
|
||||
EXPECT_EQ(identity.instance_name, "Beam-Instance_A");
|
||||
EXPECT_EQ(identity.source_label, 42);
|
||||
EXPECT_EQ(identity.source_label_text, "00042");
|
||||
|
||||
EXPECT_TRUE(fesa::SourceIdentityEquals(identity, identity));
|
||||
EXPECT_FALSE(fesa::SourceIdentityEquals(
|
||||
identity, {"beam-instance_a", std::int64_t{42}, "00042"}));
|
||||
EXPECT_FALSE(fesa::SourceIdentityEquals(
|
||||
identity, {"Beam-Instance_A", std::int64_t{43}, "00042"}));
|
||||
EXPECT_FALSE(fesa::SourceIdentityEquals(
|
||||
identity, {"Beam-Instance_A", std::int64_t{42}, "42"}));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -19,8 +20,68 @@ fesa::Diagnostic ModelDiagnostic() {
|
||||
"Beam length must be positive."};
|
||||
}
|
||||
|
||||
struct CopyOnlyPayload {
|
||||
explicit CopyOnlyPayload(int initial_value) : value{initial_value} {}
|
||||
CopyOnlyPayload(const CopyOnlyPayload& other)
|
||||
: value{other.value}, copies{other.copies + 1} {}
|
||||
|
||||
int value;
|
||||
int copies = 0;
|
||||
};
|
||||
|
||||
struct TransferPayload {
|
||||
explicit TransferPayload(int initial_value) : value{initial_value} {}
|
||||
TransferPayload(const TransferPayload& other)
|
||||
: value{other.value}, copies{other.copies + 1}, moves{other.moves} {}
|
||||
TransferPayload(TransferPayload&& other) noexcept
|
||||
: value{other.value}, copies{other.copies}, moves{other.moves + 1} {
|
||||
other.value = -1;
|
||||
}
|
||||
|
||||
int value;
|
||||
int copies = 0;
|
||||
int moves = 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(CoreDiagnostics, ResultOwnsCopyOnlyPayloadWithoutIntermediateCopy) {
|
||||
CopyOnlyPayload source{23};
|
||||
auto result = fesa::Result<CopyOnlyPayload>::Success(source);
|
||||
|
||||
ASSERT_TRUE(result.HasValue());
|
||||
EXPECT_TRUE(result.GetStatus().IsOk());
|
||||
EXPECT_EQ(result.Value().value, 23);
|
||||
EXPECT_EQ(result.Value().copies, 2);
|
||||
result.Value().value = 42;
|
||||
EXPECT_EQ(source.value, 23);
|
||||
EXPECT_EQ(source.copies, 0);
|
||||
}
|
||||
|
||||
TEST(CoreDiagnostics, ResultTransfersOwnedPayloadDirectlyIntoValue) {
|
||||
TransferPayload source{17};
|
||||
const auto from_lvalue = fesa::Result<TransferPayload>::Success(source);
|
||||
EXPECT_EQ(source.value, 17);
|
||||
EXPECT_EQ(source.copies, 0);
|
||||
EXPECT_EQ(source.moves, 0);
|
||||
EXPECT_EQ(from_lvalue.Value().value, 17);
|
||||
EXPECT_EQ(from_lvalue.Value().copies, 1);
|
||||
EXPECT_EQ(from_lvalue.Value().moves, 1);
|
||||
|
||||
const auto from_temporary =
|
||||
fesa::Result<TransferPayload>::Success(TransferPayload{29});
|
||||
EXPECT_EQ(from_temporary.Value().value, 29);
|
||||
EXPECT_EQ(from_temporary.Value().copies, 0);
|
||||
EXPECT_EQ(from_temporary.Value().moves, 1);
|
||||
|
||||
auto owned = std::make_unique<int>(31);
|
||||
const auto move_only =
|
||||
fesa::Result<std::unique_ptr<int>>::Success(std::move(owned));
|
||||
EXPECT_EQ(owned, nullptr);
|
||||
ASSERT_NE(move_only.Value(), nullptr);
|
||||
EXPECT_EQ(*move_only.Value(), 31);
|
||||
}
|
||||
|
||||
TEST(CoreDiagnostics, ResultEnforcesValueErrorExclusivity) {
|
||||
const fesa::Status ok = fesa::Status::Ok();
|
||||
EXPECT_TRUE(ok.IsOk());
|
||||
|
||||
Reference in New Issue
Block a user