diff --git a/openVulkanoCpp/Base/Version.hpp b/openVulkanoCpp/Base/Version.hpp index 89783e5..5570f59 100644 --- a/openVulkanoCpp/Base/Version.hpp +++ b/openVulkanoCpp/Base/Version.hpp @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2025. MadVoxel AG + * All rights reserved. + */ + /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -76,7 +81,7 @@ namespace OpenVulkano o.m_leadComponents = { 0, 0 }; } - VersionDataExtended(VersionDataExtendedData&& data) : + [[maybe_unused]] VersionDataExtended(VersionDataExtendedData&& data) : m_leadComponents({ UINT32_MAX, UINT32_MAX }), m_data(std::make_unique(std::move(data))) {} @@ -119,16 +124,16 @@ namespace OpenVulkano else compact = o.compact; } - VersionData(const VersionDataCompact& other) { new (&compact)VersionDataCompact(other); } + [[maybe_unused]] VersionData(const VersionDataCompact& other) { new (&compact)VersionDataCompact(other); } VersionData(VersionDataCompact&& other) { new (&compact) VersionDataCompact(std::move(other)); } - VersionData(const VersionDataExtended& other) + [[maybe_unused]] VersionData(const VersionDataExtended& other) { new (&extended)VersionDataExtended(other); } - VersionData(VersionDataExtended&& other) { new (&extended) VersionDataExtended(std::move(other)); } + [[maybe_unused]] VersionData(VersionDataExtended&& other) { new (&extended) VersionDataExtended(std::move(other)); } ~VersionData() { @@ -252,12 +257,11 @@ namespace OpenVulkano //[[nodiscard]] bool IsPreRelease() const { return m_preRelease; } - [[nodiscard]] const std::vector& GetTags() const + [[nodiscard]] std::span GetTags() const { - static std::vector fallbackTags; if (IsExtendedData()) return m_data.extended.m_data->m_tagComponents; - return fallbackTags; + return {}; } [[nodiscard]] std::span GetVersionComponents() const @@ -290,8 +294,10 @@ namespace OpenVulkano [[nodiscard]] int CompareComponents(const Version& other) const; }; - static Version operator""_v(const char* str) { return { str }; } - static Version operator""_version(const char* str) { return { str }; } - static Version operator""_v(const long double val) { return Version(static_cast(val)); } - static Version operator""_version(const long double val) { return Version(static_cast(val)); } + [[nodiscard]] [[maybe_unused]] static Version operator""_v(const char* str) { return { str }; } + [[nodiscard]] [[maybe_unused]] static Version operator""_v(const char* str, size_t c) { return { std::string_view(str, c) }; } + [[nodiscard]] [[maybe_unused]] static Version operator""_version(const char* str) { return { str }; } + [[nodiscard]] [[maybe_unused]] static Version operator""_version(const char* str, size_t c) { return { std::string_view(str, c) }; } + [[nodiscard]] [[maybe_unused]] static Version operator""_v(const long double val) { return Version(static_cast(val)); } + [[nodiscard]] [[maybe_unused]] static Version operator""_version(const long double val) { return Version(static_cast(val)); } } diff --git a/tests/Base/VersionTest.cpp b/tests/Base/VersionTest.cpp index 2618f6b..271f9bd 100644 --- a/tests/Base/VersionTest.cpp +++ b/tests/Base/VersionTest.cpp @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2025. MadVoxel AG + * All rights reserved. + */ + /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -550,6 +555,17 @@ TEST_CASE("testToString", "[Version]") REQUIRE_FALSE(VERSION_1_0 == static_cast(version_1)); REQUIRE_FALSE(VERSION_1_0 == static_cast(version_1_2)); REQUIRE_FALSE("2.0" == static_cast(version_v2_0)); + REQUIRE("v2.0" == version_v2_0.String()); +} + +TEST_CASE("testTags", "[Version]") +{ + const Version taged("v1.2.3-ALPHA-B99"); + REQUIRE(taged.Build() == 99); + REQUIRE(taged.GetTags().size() == 2); + REQUIRE(taged.GetTags()[0] == "ALPHA"); + REQUIRE(taged.GetTags()[1] == "B99"); + REQUIRE(Version("1.90").GetTags().empty()); } TEST_CASE("testUnimportantVersionParts", "[Version]") @@ -603,3 +619,12 @@ TEST_CASE("testMoveConstructorAndAssignment", "[Version]") REQUIRE(extended3 != extended); REQUIRE(extended3 != mvConstructedExtended); } + +TEST_CASE("testLiterals", "[Version]") +{ + REQUIRE(version_1 == 1_v); + REQUIRE(version_1 == 1.0_v); + REQUIRE(version_1_2 == 1.2_v); + REQUIRE(version_1_2 == 1.2_version); + REQUIRE(Version(1, 2, 3) == "1.2.3"_version); +} \ No newline at end of file