X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiacalendar_commonfunctions.h;h=ce4fc7c0301b332b78f36e8d63e5d6ef9fe8b364;hb=fb7334af110912e40389f059adcf58c4a289a881;hp=a332228d6d6410eb0f1710b133a943c88672b2e0;hpb=b143e06514c9b2080505f8057c5df52cb7525dfa;p=xestiacalendar%2F.git diff --git a/source/tests/xestiacalendar_commonfunctions.h b/source/tests/xestiacalendar_commonfunctions.h index a332228..ce4fc7c 100644 --- a/source/tests/xestiacalendar_commonfunctions.h +++ b/source/tests/xestiacalendar_commonfunctions.h @@ -1,3 +1,21 @@ +// xestiacalendar_commonfunctions.h - Xestia Calendar Common Functions Unit Tests +// +// (c) 2016 Xestia Software Development. +// +// This file is part of Xestia Calendar. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Calendar. If not, see + #include "../common/file.h" #include "../common/text.h" @@ -179,4 +197,65 @@ 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); + } \ No newline at end of file