|
| 1 | +namespace Platform::Data::Tests |
| 2 | +{ |
| 3 | + TEST_CLASS(LinksConstantsTests) |
| 4 | + { |
| 5 | + public: TEST_METHOD(ConstructorTest) |
| 6 | + { |
| 7 | + auto constants = LinksConstants<std::uint64_t>(enableExternalReferencesSupport: true); |
| 8 | + Assert::AreEqual(Hybrid<std::uint64_t>.ExternalZero, constants.ExternalReferencesRange.Value.Minimum); |
| 9 | + Assert::AreEqual(std::numeric_limits<std::uint64_t>::max(), constants.ExternalReferencesRange.Value.Maximum); |
| 10 | + } |
| 11 | + |
| 12 | + public: TEST_METHOD(ExternalReferencesTest) |
| 13 | + { |
| 14 | + TestExternalReferences<std::uint64_t, std::int64_t>(); |
| 15 | + TestExternalReferences<std::uint32_t, std::int32_t>(); |
| 16 | + TestExternalReferences<std::uint16_t, std::int16_t>(); |
| 17 | + TestExternalReferences<std::uint8_t, std::int8_t>(); |
| 18 | + } |
| 19 | + |
| 20 | + private: static void TestExternalReferences<TUnsigned, TSigned>() |
| 21 | + { |
| 22 | + auto unsingedOne = 0(TUnsigned) + 1; |
| 23 | + auto converter = UncheckedConverter<TSigned, TUnsigned>.Default; |
| 24 | + auto half = converter.Convert(NumericType<TSigned>.MaxValue); |
| 25 | + LinksConstants<TUnsigned> constants = LinksConstants<TUnsigned>({unsingedOne, half}, {half + unsingedOne, NumericType<TUnsigned>.MaxValue}); |
| 26 | + |
| 27 | + auto minimum = Hybrid<TUnsigned>(0, isExternal: true); |
| 28 | + auto maximum = Hybrid<TUnsigned>(half, isExternal: true); |
| 29 | + |
| 30 | + Assert::IsTrue(constants.IsExternalReference(minimum)); |
| 31 | + Assert::IsTrue(minimum.IsExternal); |
| 32 | + Assert::IsFalse(minimum.IsInternal); |
| 33 | + Assert::IsTrue(constants.IsExternalReference(maximum)); |
| 34 | + Assert::IsTrue(maximum.IsExternal); |
| 35 | + Assert::IsFalse(maximum.IsInternal); |
| 36 | + } |
| 37 | + }; |
| 38 | +} |
0 commit comments