Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added HexToInt function and unit tests for it.
[xestiacalendar/.git] / source / tests / xestiacalendar_commonfunctions.h
index 85ef33e..ce4fc7c 100644 (file)
@@ -197,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
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy