X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiacalendar_commonfunctions.h;h=e667aa6ee7e0610e05eb1095086fac82e90fa1d3;hb=3511800e4e2c6630a24a4a4945f252f976da75c8;hp=85ef33e164ac1776d13607438e5ca3331d75684e;hpb=5de5ee07ab0f5ee617449584d65e70f83806483f;p=xestiacalendar%2F.git diff --git a/source/tests/xestiacalendar_commonfunctions.h b/source/tests/xestiacalendar_commonfunctions.h index 85ef33e..e667aa6 100644 --- a/source/tests/xestiacalendar_commonfunctions.h +++ b/source/tests/xestiacalendar_commonfunctions.h @@ -18,6 +18,7 @@ #include "../common/file.h" #include "../common/text.h" +#include "../common/colour.h" TEST(CommonFunctions, FileTests){ @@ -197,4 +198,99 @@ TEST(CommonFunctions, SplitNameValueTests){ ASSERT_EQ(PropertyName, "TEST"); ASSERT_EQ(PropertyValue, "OK"); +} + +TEST(CommonFunctions, HexToInt){ + + string Value1 = "10"; // 16 + string Value2 = "50"; // 80 + string Value3 = "4F"; // 79 + string Value4 = "FF"; // 255 + string Value5 = "FFF"; // 4095 + string Value6 = "FFFF"; // 65535 + string Value7 = "75AB"; // 30123 + string Value8 = "2AC"; // 684 + string Value9 = "!"; // Fail + string Value10 = "4BZ"; // Fail + string Value11 = "Z?!$"; // Fail + + int OutputValue = 0; + bool Result = false; + + Result = HexToInt(&Value1, &OutputValue); + + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 16); + + Result = HexToInt(&Value2, &OutputValue); + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 80); + + Result = HexToInt(&Value3, &OutputValue); + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 79); + + Result = HexToInt(&Value4, &OutputValue); + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 255); + + Result = HexToInt(&Value5, &OutputValue); + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 4095); + + Result = HexToInt(&Value6, &OutputValue); + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 65535); + + Result = HexToInt(&Value7, &OutputValue); + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 30123); + + Result = HexToInt(&Value8, &OutputValue); + ASSERT_EQ(Result, true); + ASSERT_EQ(OutputValue, 684); + + Result = HexToInt(&Value9, &OutputValue); + ASSERT_EQ(Result, false); + + Result = HexToInt(&Value10, &OutputValue); + ASSERT_EQ(Result, false); + + Result = HexToInt(&Value11, &OutputValue); + ASSERT_EQ(Result, false); + +} + +TEST(CommonFunctions, ColourStruct){ + + Colour Colour1; + Colour Colour2; + Colour Colour3; + Colour Colour4; + + Colour1.red = 0; + Colour1.green = 0; + Colour1.blue = 0; + Colour1.alpha = 0; + + Colour2.red = 512; + Colour2.green = 512; + Colour2.blue = 512; + Colour2.alpha = 512; + + Colour3.red = 16; + Colour3.green = 16; + Colour3.blue = 16; + Colour3.alpha = 16; + + Colour4.red = 80; + Colour4.green = 80; + Colour4.blue = 80; + Colour4.alpha = 80; + + ASSERT_EQ("#00000000", (string)Colour1); + ASSERT_EQ("#FFFFFFFF", (string)Colour2); + ASSERT_EQ("#10101010", (string)Colour3); + ASSERT_EQ("#50505050", (string)Colour4); + } \ No newline at end of file